diff options
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.cpp | 111 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.h | 2 | ||||
-rw-r--r-- | WebKit/android/AndroidLog.h | 1 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 1 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 5 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 11 |
6 files changed, 131 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index 52a457d..ac3e306 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -348,6 +348,117 @@ bool LayerAndroid::prepareContext(bool force) return m_recordingPicture; } +// Debug tools : dump the layers tree in a file. +// The format is simple: +// properties have the form: key = value; +// all statements are finished with a semi-colon. +// value can be: +// - int +// - float +// - array of elements +// - composed type +// a composed type enclose properties in { and } +// an array enclose composed types in { }, separated with a comma. +// exemple: +// { +// x = 3; +// y = 4; +// value = { +// x = 3; +// y = 4; +// }; +// anarray = [ +// { x = 3; }, +// { y = 4; } +// ]; +// } + +void lwrite(FILE* file, const char* str) +{ + fwrite(str, sizeof(char), strlen(str), file); +} + +void writeIndent(FILE* file, int indentLevel) +{ + if (indentLevel) + fprintf(file, "%*s", indentLevel*2, " "); +} + +void writeln(FILE* file, int indentLevel, const char* str) +{ + writeIndent(file, indentLevel); + lwrite(file, str); + lwrite(file, "\n"); +} + +void writeIntVal(FILE* file, int indentLevel, const char* str, int value) +{ + writeIndent(file, indentLevel); + fprintf(file, "%s = %d;\n", str, value); +} + +void writeFloatVal(FILE* file, int indentLevel, const char* str, float value) +{ + writeIndent(file, indentLevel); + fprintf(file, "%s = %.3f;\n", str, value); +} + +void writePoint(FILE* file, int indentLevel, const char* str, SkPoint point) +{ + writeIndent(file, indentLevel); + fprintf(file, "%s = { x = %.3f; y = %.3f; };\n", str, point.fX, point.fY); +} + +void writeSize(FILE* file, int indentLevel, const char* str, SkSize size) +{ + writeIndent(file, indentLevel); + fprintf(file, "%s = { w = %.3f; h = %.3f; };\n", str, size.width(), size.height()); +} + +void writeLength(FILE* file, int indentLevel, const char* str, SkLength length) +{ + if (!length.defined()) return; + fprintf(file, "%s = { type = %d; value = %.2f; };\n", str, length.type, length.value); +} + +void LayerAndroid::dumpLayers(FILE* file, int indentLevel) +{ + writeln(file, indentLevel, "{"); + + writeIntVal(file, indentLevel + 1, "haveContents", m_haveContents); + writeIntVal(file, indentLevel + 1, "drawsContent", m_drawsContent); + writeIntVal(file, indentLevel + 1, "haveImage", m_haveImage); + writeIntVal(file, indentLevel + 1, "clipRect", m_haveClip); + + writeFloatVal(file, indentLevel + 1, "opacity", m_opacity); + writeSize(file, indentLevel + 1, "size", m_size); + writePoint(file, indentLevel + 1, "position", m_position); + writePoint(file, indentLevel + 1, "translation", m_translation); + writePoint(file, indentLevel + 1, "anchor", m_anchorPoint); + writePoint(file, indentLevel + 1, "scale", m_scale); + + if (m_doRotation) + writeFloatVal(file, indentLevel + 1, "angle", m_angleTransform); + + writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft); + writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop); + writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight); + writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom); + + if (countChildren()) { + writeln(file, indentLevel + 1, "children = ["); + for (unsigned int i = 0; i < countChildren(); i++) { + if (i > 0) + writeln(file, indentLevel + 1, ", "); + LayerAndroid* layer = static_cast<LayerAndroid*>(getChild(i)); + if (layer) + layer->dumpLayers(file, indentLevel + 1); + } + writeln(file, indentLevel + 1, "];"); + } + writeln(file, indentLevel, "}"); +} + } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index e6dbfb9..8050356 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -75,6 +75,8 @@ public: SkPicture* picture() const { return m_recordingPicture; } + void dumpLayers(FILE*, int indentLevel); + private: void paintChildren(int scrollX, int scrollY, diff --git a/WebKit/android/AndroidLog.h b/WebKit/android/AndroidLog.h index b5d63e8..a69dce6 100644 --- a/WebKit/android/AndroidLog.h +++ b/WebKit/android/AndroidLog.h @@ -43,5 +43,6 @@ extern FILE* gRenderTreeFile; #endif /* ANDROID_DOM_LOGGING */ #define DISPLAY_TREE_LOG_FILE "/sdcard/displayTree.txt" +#define LAYERS_TREE_LOG_FILE "/sdcard/layersTree.plist" #endif /* ANDROIDLOG_H_ */ diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 4385f4d..d04ac30 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -900,6 +900,7 @@ void WebViewCore::setRootLayer(int layer) env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_setRootLayer, layer); + mRootLayer = layer; checkException(env); } diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 3085a49..a32ba0c 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -129,6 +129,7 @@ namespace android { #if USE(ACCELERATED_COMPOSITING) void immediateRepaint(); void setRootLayer(int layer); + int rootLayer() { return mRootLayer; } #endif /** Invalidate the view/screen, NOT the content/DOM, but expressed in @@ -544,6 +545,10 @@ namespace android { uint32_t m_now; #endif +#if USE(ACCELERATED_COMPOSITING) + int mRootLayer; +#endif + private: // called from constructor, to add this to a global list static void addInstance(WebViewCore*); diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 4a80210..193a86e 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -2042,6 +2042,17 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl) fwrite("\n", 1, 1, file); fclose(file); } +#if USE(ACCELERATED_COMPOSITING) + int pRootLayer = view->getWebViewCore()->rootLayer(); + if (pRootLayer) { + LayerAndroid* rootLayer = reinterpret_cast<LayerAndroid*>(pRootLayer); + FILE* file = fopen(LAYERS_TREE_LOG_FILE,"w"); + if (file) { + rootLayer->dumpLayers(file, 0); + fclose(file); + } + } +#endif } #endif } |