• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "config.h"
2 #include "DumpLayer.h"
3 
4 #if USE(ACCELERATED_COMPOSITING)
5 
6 #define WRITE_VAL(format, ...) (snprintf(m_valueBuffer, BUF_SIZE, format, __VA_ARGS__), writeEntry(label, m_valueBuffer))
7 
8 namespace WebCore {
9 
writeIntVal(const char * label,int value)10 void LayerDumper::writeIntVal(const char* label, int value)
11 {
12     WRITE_VAL("%d", value);
13 }
14 
writeHexVal(const char * label,int value)15 void LayerDumper::writeHexVal(const char* label, int value)
16 {
17     WRITE_VAL("%x", value);
18 }
19 
writeFloatVal(const char * label,float value)20 void LayerDumper::writeFloatVal(const char* label, float value)
21 {
22     WRITE_VAL("%.3f", value);
23 }
24 
writePoint(const char * label,SkPoint point)25 void LayerDumper::writePoint(const char* label, SkPoint point)
26 {
27     WRITE_VAL("{ x = %.3f; y = %.3f; }", point.fX, point.fY);
28 }
29 
writeIntPoint(const char * label,IntPoint point)30 void LayerDumper::writeIntPoint(const char* label, IntPoint point)
31 {
32     WRITE_VAL("{ x = %d; y = %d; }", point.x(), point.y());
33 }
34 
writeSize(const char * label,SkSize size)35 void LayerDumper::writeSize(const char* label, SkSize size)
36 {
37     WRITE_VAL("{ w = %.3f; h = %.3f; }", size.width(), size.height());
38 }
39 
writeRect(const char * label,SkRect rect)40 void LayerDumper::writeRect(const char* label, SkRect rect)
41 {
42     WRITE_VAL("{ x = %.3f; y = %.3f; w = %.3f; h = %.3f; }",
43             rect.fLeft, rect.fTop, rect.width(), rect.height());
44 }
45 
writeMatrix(const char * label,const TransformationMatrix & matrix)46 void LayerDumper::writeMatrix(const char* label, const TransformationMatrix& matrix)
47 {
48     WRITE_VAL("{ (%.2f,%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f,%.2f),"
49             "(%.2f,%.2f,%.2f,%.2f),(%.2f,%.2f,%.2f,%.2f) }",
50             matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
51             matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
52             matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(),
53             matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44());
54 }
55 
writeLength(const char * label,SkLength value)56 void LayerDumper::writeLength(const char* label, SkLength value)
57 {
58     if (value.defined())
59         WRITE_VAL("{ type = %d; value = %.2f; }", value.type, value.value);
60     else
61         writeEntry(label, "<undefined>");
62 }
63 
beginLayer(const char * className,const LayerAndroid * layerPtr)64 void FileLayerDumper::beginLayer(const char* className, const LayerAndroid* layerPtr)
65 {
66     LayerDumper::beginLayer(className, layerPtr);
67     writeLine("{");
68     writeHexVal("layer", (int)layerPtr);
69 }
70 
endLayer()71 void FileLayerDumper::endLayer()
72 {
73     writeLine("}");
74     LayerDumper::endLayer();
75 }
76 
writeEntry(const char * label,const char * value)77 void FileLayerDumper::writeEntry(const char* label, const char* value)
78 {
79     fprintf(m_file, "%*s%s = %s\n", (m_indentLevel + 1) * 2, " ", label, value);
80 }
81 
writeLine(const char * str)82 void FileLayerDumper::writeLine(const char* str)
83 {
84     if (m_indentLevel)
85         fprintf(m_file, "%*s", m_indentLevel * 2, " ");
86     fprintf(m_file, "%s\n", str);
87 }
88 
89 } // namespace WebCore
90 
91 #endif // USE(ACCELERATED_COMPOSITING)
92