Added print out of SkShader information to debugger
https://codereview.appspot.com/7105045/
git-svn-id: http://skia.googlecode.com/svn/trunk@7201 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index f0dafc1..9692a71 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1638,3 +1638,44 @@
#endif
}
#endif
+
+#ifdef SK_DEVELOPER
+void SkBitmap::toString(SkString* str) const {
+
+ static const char* gConfigNames[kConfigCount] = {
+ "NONE", "A1", "A8", "INDEX8", "565", "4444", "8888", "RLE"
+ };
+
+ str->appendf("bitmap: ((%d, %d) %s", this->width(), this->height(),
+ gConfigNames[this->config()]);
+
+ str->append(" (");
+ if (this->isOpaque()) {
+ str->append("opaque");
+ } else {
+ str->append("transparent");
+ }
+ if (this->isImmutable()) {
+ str->append(", immutable");
+ } else {
+ str->append(", not-immutable");
+ }
+ str->append(")");
+
+ SkPixelRef* pr = this->pixelRef();
+ if (NULL == pr) {
+ // show null or the explicit pixel address (rare)
+ str->appendf(" pixels:%p", this->getPixels());
+ } else {
+ const char* uri = pr->getURI();
+ if (NULL != uri) {
+ str->appendf(" uri:\"%s\"", uri);
+ } else {
+ str->appendf(" pixelref:%p", pr);
+ }
+ }
+
+ str->append(")");
+}
+#endif
+
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index c3b9b26..aa79071 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -127,7 +127,7 @@
flags &= ~kHasSpan16_Flag;
}
- // if we're only 1-pixel heigh, and we don't rotate, then we can claim this
+ // if we're only 1-pixel high, and we don't rotate, then we can claim this
if (1 == bitmap.height() &&
only_scale_and_translate(this->getTotalInverse())) {
flags |= kConstInY32_Flag;
@@ -306,38 +306,27 @@
///////////////////////////////////////////////////////////////////////////////
-static const char* gTileModeName[] = {
- "clamp", "repeat", "mirror"
-};
+#ifdef SK_DEVELOPER
+void SkBitmapProcShader::toString(SkString* str) const {
+ static const char* gTileModeName[SkShader::kTileModeCount] = {
+ "clamp", "repeat", "mirror"
+ };
-bool SkBitmapProcShader::toDumpString(SkString* str) const {
- str->printf("BitmapShader: [%d %d %d",
- fRawBitmap.width(), fRawBitmap.height(),
- fRawBitmap.bytesPerPixel());
+ str->append("BitmapShader: (");
- // add the pixelref
- SkPixelRef* pr = fRawBitmap.pixelRef();
- if (pr) {
- const char* uri = pr->getURI();
- if (uri) {
- str->appendf(" \"%s\"", uri);
- }
- }
-
- // add the (optional) matrix
- {
- if (this->hasLocalMatrix()) {
- SkString info;
- this->getLocalMatrix().toDumpString(&info);
- str->appendf(" %s", info.c_str());
- }
- }
-
- str->appendf(" [%s %s]]",
+ str->appendf("(%s, %s)",
gTileModeName[fState.fTileModeX],
gTileModeName[fState.fTileModeY]);
- return true;
+
+ str->append(" ");
+ fRawBitmap.toString(str);
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
}
+#endif
+
///////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU
diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h
index fb7ff0b..e5f7b91 100644
--- a/src/core/SkBitmapProcShader.h
+++ b/src/core/SkBitmapProcShader.h
@@ -19,18 +19,17 @@
// overrides from SkShader
virtual bool isOpaque() const SK_OVERRIDE;
- virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&);
- virtual void endContext();
- virtual uint32_t getFlags() { return fFlags; }
- virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
+ virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE;
+ virtual void endContext() SK_OVERRIDE;
+ virtual uint32_t getFlags() SK_OVERRIDE { return fFlags; }
+ virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE;
virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count);
- virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const;
+ virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
+ virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
-
- // override from flattenable
- virtual bool toDumpString(SkString* str) const;
+
+ SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
#if SK_SUPPORT_GPU
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index efe9d11..e3b3c34 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -19,6 +19,7 @@
#include "SkTLazy.h"
#include "SkUtils.h"
#include "SkXfermode.h"
+#include "SkString.h"
SkBlitter::~SkBlitter() {}
@@ -663,6 +664,21 @@
}
}
+#ifdef SK_DEVELOPER
+ virtual void toString(SkString* str) const SK_OVERRIDE {
+ str->append("Sk3DShader: (");
+
+ if (NULL != fProxy) {
+ str->append("Proxy: ");
+ fProxy->toString(str);
+ }
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
+ }
+#endif
+
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
protected:
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp
index 747b2ff..5bfca46 100644
--- a/src/core/SkColorFilter.cpp
+++ b/src/core/SkColorFilter.cpp
@@ -10,6 +10,7 @@
#include "SkFlattenableBuffers.h"
#include "SkShader.h"
#include "SkUnPreMultiply.h"
+#include "SkString.h"
SK_DEFINE_INST_COUNT(SkColorFilter)
@@ -117,3 +118,17 @@
fFilter->filterSpan16(result, count, result);
}
+#ifdef SK_DEVELOPER
+void SkFilterShader::toString(SkString* str) const {
+ str->append("SkFilterShader: (");
+
+ str->append("Shader: ");
+ fShader->toString(str);
+ str->append(" Filter: ");
+ // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
+}
+#endif
\ No newline at end of file
diff --git a/src/core/SkComposeShader.cpp b/src/core/SkComposeShader.cpp
index 92ffaf7..fd3b21e 100644
--- a/src/core/SkComposeShader.cpp
+++ b/src/core/SkComposeShader.cpp
@@ -13,6 +13,7 @@
#include "SkColorShader.h"
#include "SkFlattenableBuffers.h"
#include "SkXfermode.h"
+#include "SkString.h"
///////////////////////////////////////////////////////////////////////////////
@@ -172,3 +173,20 @@
} while (count > 0);
}
}
+
+#ifdef SK_DEVELOPER
+void SkComposeShader::toString(SkString* str) const {
+ str->append("SkComposeShader: (");
+
+ str->append("ShaderA: ");
+ fShaderA->toString(str);
+ str->append(" ShaderB: ");
+ fShaderB->toString(str);
+ str->append(" Xfermode: ");
+ // TODO: add "fMode->toString(str);" once SkXfermode::toString is added
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
+}
+#endif
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index d6ee66f..cf638e9 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -20,6 +20,7 @@
#include "SkRasterizer.h"
#include "SkScan.h"
#include "SkShader.h"
+#include "SkString.h"
#include "SkStroke.h"
#include "SkTemplatesPriv.h"
#include "SkTLazy.h"
@@ -2331,6 +2332,7 @@
virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE;
+ SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTriColorShader)
protected:
@@ -2403,6 +2405,16 @@
}
}
+#ifdef SK_DEVELOPER
+void SkTriColorShader::toString(SkString* str) const {
+ str->append("SkTriColorShader: (");
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
+}
+#endif
+
void SkDraw::drawVertices(SkCanvas::VertexMode vmode, int count,
const SkPoint vertices[], const SkPoint textures[],
const SkColor colors[], SkXfermode* xmode,
diff --git a/src/core/SkFilterShader.h b/src/core/SkFilterShader.h
index ded3125..be19640 100644
--- a/src/core/SkFilterShader.h
+++ b/src/core/SkFilterShader.h
@@ -24,6 +24,7 @@
virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
virtual void shadeSpan16(int x, int y, uint16_t[], int count) SK_OVERRIDE;
+ SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader)
protected:
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index d7b2ff6..532a534 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1820,14 +1820,15 @@
return 9 * sizeof(SkScalar);
}
+#ifdef SK_DEVELOPER
void SkMatrix::dump() const {
SkString str;
- this->toDumpString(&str);
+ this->toString(&str);
SkDebugf("%s\n", str.c_str());
}
-void SkMatrix::toDumpString(SkString* str) const {
- str->printf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]",
+void SkMatrix::toString(SkString* str) const {
+ str->appendf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]",
#ifdef SK_SCALAR_IS_FLOAT
fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
fMat[6], fMat[7], fMat[8]);
@@ -1837,6 +1838,7 @@
SkFractToFloat(fMat[6]), SkFractToFloat(fMat[7]), SkFractToFloat(fMat[8]));
#endif
}
+#endif
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 41de802..d895801 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -182,6 +182,15 @@
return SkShader::CreateBitmapShader(src, tmx, tmy, NULL, 0);
}
+#ifdef SK_DEVELOPER
+void SkShader::toString(SkString* str) const {
+ if (this->hasLocalMatrix()) {
+ str->append(" ");
+ this->getLocalMatrix().toString(str);
+ }
+}
+#endif
+
//////////////////////////////////////////////////////////////////////////////
#include "SkColorShader.h"
@@ -303,6 +312,23 @@
return kColor_GradientType;
}
+#ifdef SK_DEVELOPER
+void SkColorShader::toString(SkString* str) const {
+ str->append("SkColorShader: (");
+
+ if (fInheritColor) {
+ str->append("Color: inherited from paint");
+ } else {
+ str->append("Color: ");
+ str->appendHex(fColor);
+ }
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
+}
+#endif
+
///////////////////////////////////////////////////////////////////////////////
#include "SkEmptyShader.h"
@@ -324,3 +350,13 @@
void SkEmptyShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
SkDEBUGFAIL("should never get called, since setContext() returned false");
}
+
+#ifdef SK_DEVELOPER
+void SkEmptyShader::toString(SkString* str) const {
+ str->append("SkEmptyShader: (");
+
+ this->INHERITED::toString(str);
+
+ str->append(")");
+}
+#endif