summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/layers
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-06-14 14:42:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-06-14 14:42:40 -0700
commit462daef330d6d963124ce4d5535b80ba9acea2b6 (patch)
tree05e405519accdd4395e83ffa7393202727d3bfd8 /Source/WebCore/platform/graphics/android/layers
parent736e83761cd309092370bb9f7842826186c32722 (diff)
parentcc6ffa0710f304fbcaa43953b0dc89e1d9b931a2 (diff)
downloadexternal_webkit-462daef330d6d963124ce4d5535b80ba9acea2b6.zip
external_webkit-462daef330d6d963124ce4d5535b80ba9acea2b6.tar.gz
external_webkit-462daef330d6d963124ce4d5535b80ba9acea2b6.tar.bz2
Merge "Show layer tree in hierarchyviewer"
Diffstat (limited to 'Source/WebCore/platform/graphics/android/layers')
-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
8 files changed, 145 insertions, 119 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.