summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/layers/DumpLayer.cpp88
-rw-r--r--Source/WebCore/platform/graphics/android/layers/DumpLayer.h66
-rw-r--r--Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp28
-rw-r--r--Source/WebCore/platform/graphics/android/layers/FixedPositioning.h2
-rw-r--r--Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.h2
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp64
-rw-r--r--Source/WebCore/platform/graphics/android/layers/LayerAndroid.h8
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/Surface.cpp4
-rw-r--r--Source/WebKit/android/jni/ViewStateSerializer.cpp65
-rw-r--r--Source/WebKit/android/nav/WebView.cpp28
11 files changed, 239 insertions, 122 deletions
diff --git a/Source/WebCore/platform/graphics/android/layers/DumpLayer.cpp b/Source/WebCore/platform/graphics/android/layers/DumpLayer.cpp
index 5551965..d827c44 100644
--- a/Source/WebCore/platform/graphics/android/layers/DumpLayer.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/DumpLayer.cpp
@@ -3,79 +3,87 @@
#if USE(ACCELERATED_COMPOSITING)
+#define WRITE_VAL(format, ...) (snprintf(m_valueBuffer, BUF_SIZE, format, __VA_ARGS__), writeEntry(label, m_valueBuffer))
+
namespace WebCore {
-void lwrite(FILE* file, const char* str)
+void LayerDumper::writeIntVal(const char* label, int value)
{
- fwrite(str, sizeof(char), strlen(str), file);
+ WRITE_VAL("%d", value);
}
-void writeIndent(FILE* file, int indentLevel)
+void LayerDumper::writeHexVal(const char* label, int value)
{
- if (indentLevel)
- fprintf(file, "%*s", indentLevel*2, " ");
+ WRITE_VAL("%x", value);
}
-void writeln(FILE* file, int indentLevel, const char* str)
+void LayerDumper::writeFloatVal(const char* label, float value)
{
- writeIndent(file, indentLevel);
- lwrite(file, str);
- lwrite(file, "\n");
+ WRITE_VAL("%.3f", value);
}
-void writeIntVal(FILE* file, int indentLevel, const char* str, int value)
+void LayerDumper::writePoint(const char* label, SkPoint point)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = %d;\n", str, value);
+ WRITE_VAL("{ x = %.3f; y = %.3f; }", point.fX, point.fY);
}
-void writeHexVal(FILE* file, int indentLevel, const char* str, int value)
+void LayerDumper::writeIntPoint(const char* label, IntPoint point)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = %x;\n", str, value);
+ WRITE_VAL("{ x = %d; y = %d; }", point.x(), point.y());
}
-void writeFloatVal(FILE* file, int indentLevel, const char* str, float value)
+void LayerDumper::writeSize(const char* label, SkSize size)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = %.3f;\n", str, value);
+ WRITE_VAL("{ w = %.3f; h = %.3f; }", size.width(), size.height());
}
-void writePoint(FILE* file, int indentLevel, const char* str, SkPoint point)
+void LayerDumper::writeRect(const char* label, SkRect rect)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = { x = %.3f; y = %.3f; };\n", str, point.fX, point.fY);
+ WRITE_VAL("{ x = %.3f; y = %.3f; w = %.3f; h = %.3f; }",
+ rect.fLeft, rect.fTop, rect.width(), rect.height());
}
-void writeIntPoint(FILE* file, int indentLevel, const char* str, IntPoint point)
+void LayerDumper::writeMatrix(const char* label, const TransformationMatrix& matrix)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = { x = %d; y = %d; };\n", str, point.x(), point.y());
+ WRITE_VAL("{ (%.2f,%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f,%.2f),"
+ "(%.2f,%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f,%.2f) }",
+ matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
+ matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
+ matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(),
+ matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44());
}
-void writeSize(FILE* file, int indentLevel, const char* str, SkSize size)
+void LayerDumper::writeLength(const char* label, SkLength value)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = { w = %.3f; h = %.3f; };\n", str, size.width(), size.height());
+ if (value.defined())
+ WRITE_VAL("{ type = %d; value = %.2f; }", value.type, value.value);
+ else
+ writeEntry(label, "<undefined>");
}
-void writeRect(FILE* file, int indentLevel, const char* str, SkRect rect)
+void FileLayerDumper::beginLayer(const char* className, const LayerAndroid* layerPtr)
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = { x = %.3f; y = %.3f; w = %.3f; h = %.3f; };\n",
- str, rect.fLeft, rect.fTop, rect.width(), rect.height());
+ LayerDumper::beginLayer(className, layerPtr);
+ writeLine("{");
+ writeHexVal("layer", (int)layerPtr);
}
-void writeMatrix(FILE* file, int indentLevel, const char* str, const TransformationMatrix& matrix)
+void FileLayerDumper::endLayer()
{
- writeIndent(file, indentLevel);
- fprintf(file, "%s = { (%.2f,%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f,%.2f),"
- "(%.2f,%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f,%.2f) };\n",
- str,
- matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
- matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
- matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(),
- matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44());
+ writeLine("}");
+ LayerDumper::endLayer();
+}
+
+void FileLayerDumper::writeEntry(const char* label, const char* value)
+{
+ fprintf(m_file, "%*s%s = %s\n", (m_indentLevel + 1) * 2, " ", label, value);
+}
+
+void FileLayerDumper::writeLine(const char* str)
+{
+ if (m_indentLevel)
+ fprintf(m_file, "%*s", m_indentLevel * 2, " ");
+ fprintf(m_file, "%s\n", str);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/layers/DumpLayer.h b/Source/WebCore/platform/graphics/android/layers/DumpLayer.h
index 5b30952..9fd3365 100644
--- a/Source/WebCore/platform/graphics/android/layers/DumpLayer.h
+++ b/Source/WebCore/platform/graphics/android/layers/DumpLayer.h
@@ -17,7 +17,9 @@
#ifndef DumpLayer_h
#define DumpLayer_h
+#include "FixedPositioning.h"
#include "IntPoint.h"
+#include "LayerAndroid.h"
#include "SkPoint.h"
#include "SkRect.h"
#include "SkSize.h"
@@ -50,17 +52,59 @@
namespace WebCore {
-void lwrite(FILE* file, const char* str);
-void writeIndent(FILE* file, int indentLevel);
-void writeln(FILE* file, int indentLevel, const char* str);
-void writeIntVal(FILE* file, int indentLevel, const char* str, int value);
-void writeHexVal(FILE* file, int indentLevel, const char* str, int value);
-void writeFloatVal(FILE* file, int indentLevel, const char* str, float value);
-void writePoint(FILE* file, int indentLevel, const char* str, SkPoint point);
-void writeIntPoint(FILE* file, int indentLevel, const char* str, IntPoint point);
-void writeSize(FILE* file, int indentLevel, const char* str, SkSize size);
-void writeRect(FILE* file, int indentLevel, const char* str, SkRect rect);
-void writeMatrix(FILE* file, int indentLevel, const char* str, const TransformationMatrix& matrix);
+class LayerDumper {
+public:
+ LayerDumper(int initialIndentLevel = 0)
+ : m_indentLevel(initialIndentLevel)
+ {}
+ virtual ~LayerDumper() {}
+
+ virtual void beginLayer(const char* className, const LayerAndroid* layerPtr) {}
+
+ virtual void endLayer() {}
+
+ virtual void beginChildren(int childCount) {
+ m_indentLevel++;
+ }
+ virtual void endChildren() {
+ m_indentLevel--;
+ }
+
+ void writeIntVal(const char* label, int value);
+ void writeHexVal(const char* label, int value);
+ void writeFloatVal(const char* label, float value);
+ void writePoint(const char* label, SkPoint value);
+ void writeIntPoint(const char* label, IntPoint value);
+ void writeSize(const char* label, SkSize value);
+ void writeRect(const char* label, SkRect value);
+ void writeMatrix(const char* label, const TransformationMatrix& value);
+ void writeLength(const char* label, SkLength value);
+
+protected:
+ virtual void writeEntry(const char* label, const char* value) = 0;
+
+ int m_indentLevel;
+
+private:
+ static const int BUF_SIZE = 4096;
+ char m_valueBuffer[BUF_SIZE];
+};
+
+class FileLayerDumper : public LayerDumper {
+public:
+ FileLayerDumper(FILE* file)
+ : m_file(file)
+ {}
+
+ virtual void beginLayer(const char* className, const LayerAndroid* layerPtr);
+ virtual void endLayer();
+protected:
+ virtual void writeEntry(const char* label, const char* value);
+
+private:
+ void writeLine(const char* str);
+ FILE* m_file;
+};
}
diff --git a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp
index 82afe8f..aa204f8 100644
--- a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp
@@ -86,25 +86,17 @@ void FixedPositioning::contentDraw(SkCanvas* canvas, Layer::PaintStyle style)
}
}
-void writeLength(FILE* file, int indentLevel, const char* str, SkLength length)
+void FixedPositioning::dumpLayer(LayerDumper* dumper) const
{
- if (!length.defined())
- return;
- writeIndent(file, indentLevel);
- fprintf(file, "%s = { type = %d; value = %.2f; };\n", str, length.type, length.value);
-}
-
-void FixedPositioning::dumpLayer(FILE* file, int indentLevel) const
-{
- 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);
- writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft);
- writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop);
- writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight);
- writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom);
- writeRect(file, indentLevel + 1, "fixedRect", m_fixedRect);
+ dumper->writeLength("fixedLeft", m_fixedLeft);
+ dumper->writeLength("fixedTop", m_fixedTop);
+ dumper->writeLength("fixedRight", m_fixedRight);
+ dumper->writeLength("fixedBottom", m_fixedBottom);
+ dumper->writeLength("fixedMarginLeft", m_fixedMarginLeft);
+ dumper->writeLength("fixedMarginTop", m_fixedMarginTop);
+ dumper->writeLength("fixedMarginRight", m_fixedMarginRight);
+ dumper->writeLength("fixedMarginBottom", m_fixedMarginBottom);
+ dumper->writeRect("fixedRect", m_fixedRect);
}
BackgroundImagePositioning::BackgroundImagePositioning(LayerAndroid* layer, const BackgroundImagePositioning& position)
diff --git a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h
index e273a25..ac838c8 100644
--- a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h
+++ b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h
@@ -130,7 +130,7 @@ public:
void contentDraw(SkCanvas* canvas, Layer::PaintStyle style);
- void dumpLayer(FILE*, int indentLevel) const;
+ void dumpLayer(LayerDumper*) const;
// ViewStateSerializer friends
friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream);
diff --git a/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.cpp
index 3532542..4481f55 100644
--- a/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.cpp
@@ -29,10 +29,10 @@ IFrameLayerAndroid* IFrameLayerAndroid::updatePosition(SkRect viewport,
return this;
}
-void IFrameLayerAndroid::dumpLayer(FILE* file, int indentLevel) const
+void IFrameLayerAndroid::dumpLayer(LayerDumper* dumper) const
{
- writeIntVal(file, indentLevel + 1, "m_isIframe", true);
- writeIntPoint(file, indentLevel + 1, "m_iframeOffset", m_iframeOffset);
+ LayerAndroid::dumpLayer(dumper);
+ dumper->writeIntPoint("m_iframeOffset", m_iframeOffset);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.h
index f2fbf49..08e7212 100644
--- a/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/IFrameLayerAndroid.h
@@ -53,7 +53,7 @@ public:
virtual IFrameLayerAndroid* updatePosition(SkRect viewport,
IFrameLayerAndroid* parentIframeLayer);
- virtual void dumpLayer(FILE*, int indentLevel) const;
+ virtual void dumpLayer(LayerDumper*) const;
const IntPoint& iframeOffset() const { return m_iframeOffset; }
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index d709a9c..dde7e9b 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -598,7 +598,7 @@ void LayerAndroid::showLayer(int indent)
m_clippingRect.width(), m_clippingRect.height());
ALOGD("%s s:%x %s %s (%d) [%d:%x - 0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) "
"clip (%d, %d, %d, %d) %s %s m_content(%x), pic w: %d h: %d originalLayer: %x %d",
- spaces, m_surface, m_haveClip ? "CLIP LAYER" : "", subclassName().ascii().data(),
+ spaces, m_surface, m_haveClip ? "CLIP LAYER" : "", subclassName(),
subclassType(), uniqueId(), this, m_owningLayer,
needsTexture() ? "needsTexture" : "",
m_imageCRC ? "hasImage" : "",
@@ -951,60 +951,42 @@ void LayerAndroid::setFixedPosition(FixedPositioning* position) {
m_fixedPosition = position;
}
-void LayerAndroid::dumpLayer(FILE* file, int indentLevel) const
+void LayerAndroid::dumpLayer(LayerDumper* dumper) const
{
- writeHexVal(file, indentLevel + 1, "layer", (int)this);
- writeIntVal(file, indentLevel + 1, "layerId", m_uniqueId);
- writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip);
- writeIntVal(file, indentLevel + 1, "isFixed", isPositionFixed());
+ dumper->writeIntVal("layerId", m_uniqueId);
+ dumper->writeIntVal("haveClip", m_haveClip);
+ dumper->writeIntVal("isFixed", isPositionFixed());
- writeFloatVal(file, indentLevel + 1, "opacity", getOpacity());
- writeSize(file, indentLevel + 1, "size", getSize());
- writePoint(file, indentLevel + 1, "position", getPosition());
- writePoint(file, indentLevel + 1, "anchor", getAnchorPoint());
+ dumper->writeFloatVal("opacity", getOpacity());
+ dumper->writeSize("size", getSize());
+ dumper->writePoint("position", getPosition());
+ dumper->writePoint("anchor", getAnchorPoint());
- writeMatrix(file, indentLevel + 1, "drawMatrix", m_drawTransform);
- writeMatrix(file, indentLevel + 1, "transformMatrix", m_transform);
- writeRect(file, indentLevel + 1, "clippingRect", SkRect(m_clippingRect));
+ dumper->writeMatrix("drawMatrix", m_drawTransform);
+ dumper->writeMatrix("transformMatrix", m_transform);
+ dumper->writeRect("clippingRect", SkRect(m_clippingRect));
if (m_content) {
- writeIntVal(file, indentLevel + 1, "m_content.width", m_content->width());
- writeIntVal(file, indentLevel + 1, "m_content.height", m_content->height());
+ dumper->writeIntVal("m_content.width", m_content->width());
+ dumper->writeIntVal("m_content.height", m_content->height());
}
if (m_fixedPosition)
- return m_fixedPosition->dumpLayer(file, indentLevel);
+ m_fixedPosition->dumpLayer(dumper);
}
-void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const
+void LayerAndroid::dumpLayers(LayerDumper* dumper) const
{
- writeln(file, indentLevel, "{");
-
- dumpLayer(file, indentLevel);
+ dumper->beginLayer(subclassName(), this);
+ dumpLayer(dumper);
+ dumper->beginChildren(countChildren());
if (countChildren()) {
- writeln(file, indentLevel + 1, "children = [");
- for (int i = 0; i < countChildren(); i++) {
- if (i > 0)
- writeln(file, indentLevel + 1, ", ");
- getChild(i)->dumpLayers(file, indentLevel + 1);
- }
- writeln(file, indentLevel + 1, "];");
+ for (int i = 0; i < countChildren(); i++)
+ getChild(i)->dumpLayers(dumper);
}
- writeln(file, indentLevel, "}");
-}
-
-void LayerAndroid::dumpToLog() const
-{
- FILE* file = fopen("/data/data/com.android.browser/layertmp", "w");
- dumpLayers(file, 0);
- fclose(file);
- file = fopen("/data/data/com.android.browser/layertmp", "r");
- char buffer[512];
- bzero(buffer, sizeof(buffer));
- while (fgets(buffer, sizeof(buffer), file))
- SkDebugf("%s", buffer);
- fclose(file);
+ dumper->endChildren();
+ dumper->endLayer();
}
LayerAndroid* LayerAndroid::findById(int match)
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index 79c84b4..312ad7b 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -73,6 +73,7 @@ class IFrameLayerAndroid;
class LayerMergeState;
class RenderLayer;
class PaintedSurface;
+class LayerDumper;
class TexturesResult {
public:
@@ -100,7 +101,7 @@ public:
CanvasLayer, BaseLayer } SubclassType;
typedef enum { InvalidateNone = 0, InvalidateLayers } InvalidateFlags;
- String subclassName()
+ const char* subclassName() const
{
switch (subclassType()) {
case LayerAndroid::StandardLayer:
@@ -195,9 +196,7 @@ public:
bool hasAnimations() const;
void addDirtyArea();
- virtual void dumpLayer(FILE*, int indentLevel) const;
- void dumpLayers(FILE*, int indentLevel) const;
- void dumpToLog() const;
+ void dumpLayers(LayerDumper*) const;
virtual IFrameLayerAndroid* updatePosition(SkRect viewport,
IFrameLayerAndroid* parentIframeLayer);
@@ -290,6 +289,7 @@ public:
}
protected:
+ virtual void dumpLayer(LayerDumper*) const;
/** Call this with the current viewport (scrolling, zoom) to update
the position of the fixed layers.
diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
index 1898910..96a4a16 100644
--- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp
@@ -218,7 +218,7 @@ void Surface::prepareGL(bool layerTilesDisabled, bool updateWithBlit)
ALOGV("prepareGL on Surf %p with SurfBack %p, %d layers, first layer %s (%d) "
"prepareArea(%d, %d - %d x %d) fullArea(%d, %d - %d x %d)",
this, m_surfaceBacking, m_layers.size(),
- getFirstLayer()->subclassName().ascii().data(),
+ getFirstLayer()->subclassName(),
getFirstLayer()->uniqueId(),
prepareArea.x(), prepareArea.y(), prepareArea.width(), prepareArea.height(),
fullArea.x(), fullArea.y(), fullArea.width(), fullArea.height());
@@ -253,7 +253,7 @@ bool Surface::drawGL(bool layerTilesDisabled)
bool askRedraw = false;
if (m_surfaceBacking && !tilesDisabled) {
ALOGV("drawGL on Surf %p with SurfBack %p, first layer %s (%d)", this, m_surfaceBacking,
- getFirstLayer()->subclassName().ascii().data(), getFirstLayer()->uniqueId());
+ getFirstLayer()->subclassName(), getFirstLayer()->uniqueId());
bool force3dContentVisible = true;
IntRect drawArea = visibleContentArea(force3dContentVisible);
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index 02ddca6..8963837 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -30,6 +30,7 @@
#include "BaseLayerAndroid.h"
#include "CreateJavaOutputStreamAdaptor.h"
+#include "DumpLayer.h"
#include "FixedPositioning.h"
#include "ImagesManager.h"
#include "IFrameContentLayerAndroid.h"
@@ -56,6 +57,68 @@ enum LayerTypes {
LTFixedLayerAndroid = 3
};
+#define ID "mID"
+#define LEFT "layout:mLeft"
+#define TOP "layout:mTop"
+#define WIDTH "layout:getWidth()"
+#define HEIGHT "layout:getHeight()"
+
+class HierarchyLayerDumper : public LayerDumper {
+public:
+ HierarchyLayerDumper(SkWStream* stream, int level)
+ : LayerDumper(level)
+ , m_stream(stream)
+ {}
+
+ virtual void beginLayer(const char* className, const LayerAndroid* layerPtr) {
+ LayerDumper::beginLayer(className, layerPtr);
+ for (int i = 0; i < m_indentLevel; i++) {
+ m_stream->writeText(" ");
+ }
+ m_stream->writeText(className);
+ m_stream->writeText("@");
+ m_stream->writeHexAsText(layerPtr->uniqueId());
+ m_stream->writeText(" ");
+
+ writeHexVal(ID, (int) layerPtr);
+ writeIntVal(LEFT, layerPtr->getPosition().fX);
+ writeIntVal(TOP, layerPtr->getPosition().fY);
+ writeIntVal(WIDTH, layerPtr->getWidth());
+ writeIntVal(HEIGHT, layerPtr->getHeight());
+ }
+
+ virtual void beginChildren(int childCount) {
+ m_stream->writeText("\n");
+ LayerDumper::beginChildren(childCount);
+ }
+
+protected:
+ virtual void writeEntry(const char* label, const char* value) {
+ m_stream->writeText(label);
+ m_stream->writeText("=");
+ int len = strlen(value);
+ m_stream->writeDecAsText(len);
+ m_stream->writeText(",");
+ m_stream->writeText(value);
+ m_stream->writeText(" ");
+ }
+
+private:
+ SkWStream* m_stream;
+};
+
+static void nativeDumpLayerHierarchy(JNIEnv* env, jobject, jint jbaseLayer, jint level,
+ jobject jstream, jbyteArray jstorage)
+{
+ SkWStream *stream = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
+ BaseLayerAndroid* baseLayer = reinterpret_cast<BaseLayerAndroid*>(jbaseLayer);
+ SkSafeRef(baseLayer);
+ HierarchyLayerDumper dumper(stream, level);
+ baseLayer->dumpLayers(&dumper);
+ SkSafeUnref(baseLayer);
+ delete stream;
+}
+
static bool nativeSerializeViewState(JNIEnv* env, jobject, jint jbaseLayer,
jobject jstream, jbyteArray jstorage)
{
@@ -478,6 +541,8 @@ LayerAndroid* deserializeLayer(int version, SkStream* stream)
* JNI registration
*/
static JNINativeMethod gSerializerMethods[] = {
+ { "nativeDumpLayerHierarchy", "(IILjava/io/OutputStream;[B)V",
+ (void*) nativeDumpLayerHierarchy },
{ "nativeSerializeViewState", "(ILjava/io/OutputStream;[B)Z",
(void*) nativeSerializeViewState },
{ "nativeDeserializeViewState", "(ILjava/io/InputStream;[B)I",
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 8e88131..c708c25 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -32,6 +32,7 @@
#include "BaseLayerAndroid.h"
#include "BaseRenderer.h"
#include "DrawExtra.h"
+#include "DumpLayer.h"
#include "Frame.h"
#include "GLWebViewState.h"
#include "GraphicsJNI.h"
@@ -995,6 +996,28 @@ static void nativeCopyBaseContentToPicture(JNIEnv *env, jobject obj, jobject pic
GET_NATIVE_VIEW(env, obj)->copyBaseContentToPicture(picture);
}
+static jboolean nativeDumpLayerContentToPicture(JNIEnv *env, jobject obj, jint instance,
+ jstring jclassName, jint layerId, jobject pict)
+{
+ bool success = false;
+ SkPicture* picture = GraphicsJNI::getNativePicture(env, pict);
+ std::string classname = jstringToStdString(env, jclassName);
+ BaseLayerAndroid* baseLayer = reinterpret_cast<WebView*>(instance)->getBaseLayer();
+ LayerAndroid* layer = baseLayer->findById(layerId);
+ SkSafeRef(layer);
+ if (layer && layer->subclassName() == classname) {
+ LayerContent* content = layer->content();
+ if (content) {
+ SkCanvas* canvas = picture->beginRecording(content->width(), content->height());
+ content->draw(canvas);
+ picture->endRecording();
+ success = true;
+ }
+ }
+ SkSafeUnref(layer);
+ return success;
+}
+
static bool nativeHasContent(JNIEnv *env, jobject obj)
{
return GET_NATIVE_VIEW(env, obj)->hasContent();
@@ -1187,7 +1210,8 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
if (baseLayer) {
FILE* file = fopen(LAYERS_TREE_LOG_FILE,"w");
if (file) {
- baseLayer->dumpLayers(file, 0);
+ WebCore::FileLayerDumper dumper(file);
+ baseLayer->dumpLayers(&dumper);
fclose(file);
}
}
@@ -1355,6 +1379,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeGetBaseLayer },
{ "nativeCopyBaseContentToPicture", "(Landroid/graphics/Picture;)V",
(void*) nativeCopyBaseContentToPicture },
+ { "nativeDumpLayerContentToPicture", "(ILjava/lang/String;ILandroid/graphics/Picture;)Z",
+ (void*) nativeDumpLayerContentToPicture },
{ "nativeHasContent", "()Z",
(void*) nativeHasContent },
{ "nativeDiscardAllTextures", "()V",