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
This commit is contained in:
parent
06b8a19b56
commit
76f9e938df
@ -8,6 +8,7 @@
|
||||
|
||||
#include "SkObjectParser.h"
|
||||
#include "SkRRect.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkData.h"
|
||||
@ -154,6 +155,7 @@ SkString* SkObjectParser::PaintToString(const SkPaint& paint) {
|
||||
SkShader* shader = paint.getShader();
|
||||
if (NULL != shader) {
|
||||
mPaint->append("<dt>Shader:</dt><dd>");
|
||||
SkDEVCODE(shader->toString(mPaint);)
|
||||
mPaint->append("</dd>");
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkOSMenu.h"
|
||||
|
||||
@ -271,3 +274,5 @@ bool is_debugger(SkView* view) {
|
||||
SkEvent isDebugger(gIsDebuggerQuery);
|
||||
return view->doQuery(&isDebugger);
|
||||
}
|
||||
|
||||
#endif
|
@ -6,6 +6,9 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SkDebugDumper.h"
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
|
||||
#include "SkString.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkShader.h"
|
||||
@ -146,3 +149,5 @@ void SkDebugDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -7,6 +7,9 @@
|
||||
*/
|
||||
#ifndef SkDebugDumper_DEFINED
|
||||
#define SkDebugDumper_DEFINED
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
|
||||
#include "SkDumpCanvas.h"
|
||||
#include "SkEvent.h"
|
||||
|
||||
@ -35,4 +38,7 @@ private:
|
||||
|
||||
typedef SkDumpCanvas::Dumper INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@ struct SkRect;
|
||||
class SkPaint;
|
||||
class SkPixelRef;
|
||||
class SkRegion;
|
||||
class SkString;
|
||||
|
||||
// This is an opaque class, not interpreted by skia
|
||||
class SkGpuTexture;
|
||||
@ -625,6 +626,8 @@ public:
|
||||
int fHeight;
|
||||
};
|
||||
|
||||
SkDEVCODE(void toString(SkString* str) const;)
|
||||
|
||||
private:
|
||||
struct MipMap;
|
||||
mutable MipMap* fMipMap;
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
|
||||
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader)
|
||||
|
||||
protected:
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
virtual void endContext() SK_OVERRIDE;
|
||||
virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
|
||||
|
||||
protected:
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
|
||||
virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
|
||||
|
||||
protected:
|
||||
|
@ -527,8 +527,8 @@ public:
|
||||
// return the number of bytes read
|
||||
uint32_t readFromMemory(const void* buffer);
|
||||
|
||||
void dump() const;
|
||||
void toDumpString(SkString*) const;
|
||||
SkDEVCODE(void dump() const;)
|
||||
SkDEVCODE(void toString(SkString*) const;)
|
||||
|
||||
/**
|
||||
* Calculates the maximum stretching factor of the matrix. If the matrix has
|
||||
|
@ -341,6 +341,8 @@ public:
|
||||
static SkShader* CreateBitmapShader(const SkBitmap& src,
|
||||
TileMode tmx, TileMode tmy);
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const;)
|
||||
|
||||
protected:
|
||||
enum MatrixClass {
|
||||
kLinear_MatrixClass, // no perspective
|
||||
|
@ -112,6 +112,16 @@ inline void operator delete(void* p) {
|
||||
#define SkAssertResult(cond) cond
|
||||
#endif
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
#define SkDEVCODE(code) code
|
||||
// the 'toString' helper functions convert Sk* objects to human-readable
|
||||
// form in developer mode
|
||||
#define SK_DEVELOPER_TO_STRING() virtual void toString(SkString* str) const SK_OVERRIDE;
|
||||
#else
|
||||
#define SkDEVCODE(code)
|
||||
#define SK_DEVELOPER_TO_STRING()
|
||||
#endif
|
||||
|
||||
template <bool>
|
||||
struct SkCompileAssert {
|
||||
};
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
|
||||
virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTransparentShader)
|
||||
|
||||
private:
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "SkCanvas.h"
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
|
||||
/** This class overrides all the draw methods on SkCanvas, and formats them
|
||||
as text, and then sends that to a Dumper helper object.
|
||||
|
||||
@ -155,3 +157,5 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -153,11 +153,13 @@ protected:
|
||||
canvas->drawPicture(*pict);
|
||||
canvas->restore();
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
if (false) {
|
||||
SkDebugfDumper dumper;
|
||||
SkDumpCanvas dumpCanvas(&dumper);
|
||||
dumpCanvas.drawPicture(*pict);
|
||||
}
|
||||
#endif
|
||||
|
||||
// test that we can re-record a subpicture, and see the results
|
||||
|
||||
|
@ -56,7 +56,7 @@ static void test_33(const SkMatrix44& mat,
|
||||
if (dst[0] != x0 || dst[1] != x1 || dst[2] != x2 ||
|
||||
dst[3] != y0 || dst[4] != y1 || dst[5] != y2) {
|
||||
SkString str;
|
||||
dst.toDumpString(&str);
|
||||
dst.toString(&str);
|
||||
SkDebugf("3x3: expected 3x3 [%g %g %g] [%g %g %g] bug got %s\n",
|
||||
x0, x1, x2, y0, y1, y2, str.c_str());
|
||||
}
|
||||
@ -116,7 +116,7 @@ static void dump_layers(const SkLayer* layer, int tab = 0) {
|
||||
SkString matrixStr;
|
||||
|
||||
layer->getLocalTransform(&matrix);
|
||||
matrix.toDumpString(&matrixStr);
|
||||
matrix.toString(&matrixStr);
|
||||
|
||||
for (int j = 0; j < tab; j++) {
|
||||
SkDebugf(" ");
|
||||
|
@ -1638,3 +1638,44 @@ void SkBitmap::validate() const {
|
||||
#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
|
||||
|
||||
|
@ -127,7 +127,7 @@ bool SkBitmapProcShader::setContext(const SkBitmap& device,
|
||||
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 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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
|
||||
|
@ -19,18 +19,17 @@ public:
|
||||
|
||||
// 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
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "SkTLazy.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkXfermode.h"
|
||||
#include "SkString.h"
|
||||
|
||||
SkBlitter::~SkBlitter() {}
|
||||
|
||||
@ -663,6 +664,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#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:
|
||||
|
@ -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 @@ void SkFilterShader::shadeSpan16(int x, int y, uint16_t result[], int count) {
|
||||
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
|
@ -13,6 +13,7 @@
|
||||
#include "SkColorShader.h"
|
||||
#include "SkFlattenableBuffers.h"
|
||||
#include "SkXfermode.h"
|
||||
#include "SkString.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -172,3 +173,20 @@ void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count) {
|
||||
} 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
|
||||
|
@ -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 @@ public:
|
||||
|
||||
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 @@ void SkTriColorShader::shadeSpan(int x, int y, SkPMColor dstC[], int count) {
|
||||
}
|
||||
}
|
||||
|
||||
#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,
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
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:
|
||||
|
@ -1820,14 +1820,15 @@ uint32_t SkMatrix::readFromMemory(const void* buffer) {
|
||||
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 @@ void SkMatrix::toDumpString(SkString* str) const {
|
||||
SkFractToFloat(fMat[6]), SkFractToFloat(fMat[7]), SkFractToFloat(fMat[8]));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -182,6 +182,15 @@ SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
|
||||
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 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const {
|
||||
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::shadeSpan16(int x, int y, uint16_t span[], int count) {
|
||||
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
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "SkTransparentShader.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkString.h"
|
||||
|
||||
bool SkTransparentShader::setContext(const SkBitmap& device,
|
||||
const SkPaint& paint,
|
||||
@ -125,3 +126,13 @@ void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count)
|
||||
memcpy(span, src, count << 1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkTransparentShader::toString(SkString* str) const {
|
||||
str->append("SkTransparentShader: (");
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -546,16 +546,16 @@ void SkGradientShaderBase::commonAsAGradient(GradientInfo* info) const {
|
||||
if (info) {
|
||||
if (info->fColorCount >= fColorCount) {
|
||||
if (info->fColors) {
|
||||
memcpy(info->fColors, fOrigColors,
|
||||
fColorCount * sizeof(SkColor));
|
||||
memcpy(info->fColors, fOrigColors, fColorCount * sizeof(SkColor));
|
||||
}
|
||||
if (info->fColorOffsets) {
|
||||
if (fColorCount == 2) {
|
||||
info->fColorOffsets[0] = 0;
|
||||
info->fColorOffsets[1] = SK_Scalar1;
|
||||
} else if (fColorCount > 2) {
|
||||
for (int i = 0; i < fColorCount; i++)
|
||||
for (int i = 0; i < fColorCount; ++i) {
|
||||
info->fColorOffsets[i] = SkFixedToScalar(fRecs[i].fPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -564,6 +564,42 @@ void SkGradientShaderBase::commonAsAGradient(GradientInfo* info) const {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkGradientShaderBase::toString(SkString* str) const {
|
||||
|
||||
str->appendf("%d colors: ", fColorCount);
|
||||
|
||||
for (int i = 0; i < fColorCount; ++i) {
|
||||
str->appendHex(fOrigColors[i]);
|
||||
if (i < fColorCount-1) {
|
||||
str->append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
if (fColorCount > 2) {
|
||||
str->append(" points: (");
|
||||
for (int i = 0; i < fColorCount; ++i) {
|
||||
str->appendScalar(SkFixedToScalar(fRecs[i].fPos));
|
||||
if (i < fColorCount-1) {
|
||||
str->append(", ");
|
||||
}
|
||||
}
|
||||
str->append(")");
|
||||
}
|
||||
|
||||
static const char* gTileModeName[SkShader::kTileModeCount] = {
|
||||
"clamp", "repeat", "mirror"
|
||||
};
|
||||
|
||||
str->append(" ");
|
||||
str->append(gTileModeName[fTileMode]);
|
||||
|
||||
// TODO: add "fMapper->toString(str);" when SkUnitMapper::toString is added
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -139,6 +139,7 @@ public:
|
||||
protected:
|
||||
SkGradientShaderBase(SkFlattenableReadBuffer& );
|
||||
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
|
||||
SkUnitMapper* fMapper;
|
||||
SkMatrix fPtsToUnit; // set by subclass
|
||||
|
@ -564,3 +564,16 @@ GrEffect* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) cons
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkLinearGradient::toString(SkString* str) const {
|
||||
str->append("SkLinearGradient (");
|
||||
|
||||
str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
|
||||
str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
|
||||
virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
|
||||
|
||||
protected:
|
||||
|
@ -588,3 +588,21 @@ GrEffect* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) cons
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkRadialGradient::toString(SkString* str) const {
|
||||
str->append("SkRadialGradient: (");
|
||||
|
||||
str->append("center: (");
|
||||
str->appendScalar(fCenter.fX);
|
||||
str->append(", ");
|
||||
str->appendScalar(fCenter.fY);
|
||||
str->append(") radius: ");
|
||||
str->appendScalar(fRadius);
|
||||
str->append(" ");
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
|
||||
virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
|
||||
|
||||
protected:
|
||||
|
@ -489,3 +489,19 @@ GrEffect* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&) const
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkSweepGradient::toString(SkString* str) const {
|
||||
str->append("SkSweepGradient: (");
|
||||
|
||||
str->append("center: (");
|
||||
str->appendScalar(fCenter.fX);
|
||||
str->append(", ");
|
||||
str->appendScalar(fCenter.fY);
|
||||
str->append(") ");
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
|
||||
virtual GrEffect* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSweepGradient)
|
||||
|
||||
protected:
|
||||
|
@ -715,3 +715,29 @@ GrEffect* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPai
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkTwoPointConicalGradient::toString(SkString* str) const {
|
||||
str->append("SkTwoPointConicalGradient: (");
|
||||
|
||||
str->append("center1: (");
|
||||
str->appendScalar(fCenter1.fX);
|
||||
str->append(", ");
|
||||
str->appendScalar(fCenter1.fY);
|
||||
str->append(") radius1: ");
|
||||
str->appendScalar(fRadius1);
|
||||
str->append(" ");
|
||||
|
||||
str->append("center2: (");
|
||||
str->appendScalar(fCenter2.fX);
|
||||
str->append(", ");
|
||||
str->appendScalar(fCenter2.fY);
|
||||
str->append(") radius2: ");
|
||||
str->appendScalar(fRadius2);
|
||||
str->append(" ");
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
SkScalar getStartRadius() const { return fRadius1; }
|
||||
SkScalar getDiffRadius() const { return fRadius2 - fRadius1; }
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointConicalGradient)
|
||||
|
||||
protected:
|
||||
|
@ -309,6 +309,32 @@ bool SkTwoPointRadialGradient::setContext( const SkBitmap& device,
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkTwoPointRadialGradient::toString(SkString* str) const {
|
||||
str->append("SkTwoPointRadialGradient: (");
|
||||
|
||||
str->append("center1: (");
|
||||
str->appendScalar(fCenter1.fX);
|
||||
str->append(", ");
|
||||
str->appendScalar(fCenter1.fY);
|
||||
str->append(") radius1: ");
|
||||
str->appendScalar(fRadius1);
|
||||
str->append(" ");
|
||||
|
||||
str->append("center2: (");
|
||||
str->appendScalar(fCenter2.fX);
|
||||
str->append(", ");
|
||||
str->appendScalar(fCenter2.fY);
|
||||
str->append(") radius2: ");
|
||||
str->appendScalar(fRadius2);
|
||||
str->append(" ");
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
||||
SkTwoPointRadialGradient::SkTwoPointRadialGradient(
|
||||
SkFlattenableReadBuffer& buffer)
|
||||
: INHERITED(buffer),
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
SkScalar getStartRadius() const { return fStartRadius; }
|
||||
SkScalar getDiffRadius() const { return fDiffRadius; }
|
||||
|
||||
SK_DEVELOPER_TO_STRING()
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient)
|
||||
|
||||
protected:
|
||||
|
@ -5,7 +5,10 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkDumpCanvas.h"
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
#include "SkPicture.h"
|
||||
#include "SkPixelRef.h"
|
||||
#include "SkRRect.h"
|
||||
@ -130,31 +133,6 @@ static const char* toString(SkCanvas::PointMode pm) {
|
||||
return gPMNames[pm];
|
||||
}
|
||||
|
||||
static const char* toString(SkBitmap::Config config) {
|
||||
static const char* gConfigNames[] = {
|
||||
"NONE", "A1", "A8", "INDEX8", "565", "4444", "8888", "RLE"
|
||||
};
|
||||
return gConfigNames[config];
|
||||
}
|
||||
|
||||
static void toString(const SkBitmap& bm, SkString* str) {
|
||||
str->appendf("bitmap:[%d %d] %s", bm.width(), bm.height(),
|
||||
toString(bm.config()));
|
||||
|
||||
SkPixelRef* pr = bm.pixelRef();
|
||||
if (NULL == pr) {
|
||||
// show null or the explicit pixel address (rare)
|
||||
str->appendf(" pixels:%p", bm.getPixels());
|
||||
} else {
|
||||
const char* uri = pr->getURI();
|
||||
if (uri) {
|
||||
str->appendf(" uri:\"%s\"", uri);
|
||||
} else {
|
||||
str->appendf(" pixelref:%p", pr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc,
|
||||
SkString* str) {
|
||||
// FIXME: this code appears to be untested - and probably unused - and probably wrong
|
||||
@ -273,14 +251,14 @@ bool SkDumpCanvas::skew(SkScalar sx, SkScalar sy) {
|
||||
|
||||
bool SkDumpCanvas::concat(const SkMatrix& matrix) {
|
||||
SkString str;
|
||||
matrix.toDumpString(&str);
|
||||
matrix.toString(&str);
|
||||
this->dump(kMatrix_Verb, NULL, "concat(%s)", str.c_str());
|
||||
return this->INHERITED::concat(matrix);
|
||||
}
|
||||
|
||||
void SkDumpCanvas::setMatrix(const SkMatrix& matrix) {
|
||||
SkString str;
|
||||
matrix.toDumpString(&str);
|
||||
matrix.toString(&str);
|
||||
this->dump(kMatrix_Verb, NULL, "setMatrix(%s)", str.c_str());
|
||||
this->INHERITED::setMatrix(matrix);
|
||||
}
|
||||
@ -362,7 +340,7 @@ void SkDumpCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
|
||||
void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
|
||||
const SkPaint* paint) {
|
||||
SkString str;
|
||||
toString(bitmap, &str);
|
||||
bitmap.toString(&str);
|
||||
this->dump(kDrawBitmap_Verb, paint, "drawBitmap(%s %g %g)", str.c_str(),
|
||||
SkScalarToFloat(x), SkScalarToFloat(y));
|
||||
}
|
||||
@ -370,7 +348,7 @@ void SkDumpCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
|
||||
void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
|
||||
const SkRect& dst, const SkPaint* paint) {
|
||||
SkString bs, rs;
|
||||
toString(bitmap, &bs);
|
||||
bitmap.toString(&bs);
|
||||
toString(dst, &rs);
|
||||
// show the src-rect only if its not everything
|
||||
if (src && (src->fLeft > 0 || src->fTop > 0 ||
|
||||
@ -388,8 +366,8 @@ void SkDumpCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* sr
|
||||
void SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
|
||||
const SkPaint* paint) {
|
||||
SkString bs, ms;
|
||||
toString(bitmap, &bs);
|
||||
m.toDumpString(&ms);
|
||||
bitmap.toString(&bs);
|
||||
m.toString(&ms);
|
||||
this->dump(kDrawBitmap_Verb, paint, "drawBitmapMatrix(%s %s)",
|
||||
bs.c_str(), ms.c_str());
|
||||
}
|
||||
@ -397,7 +375,7 @@ void SkDumpCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
|
||||
void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
|
||||
const SkPaint* paint) {
|
||||
SkString str;
|
||||
toString(bitmap, &str);
|
||||
bitmap.toString(&str);
|
||||
this->dump(kDrawBitmap_Verb, paint, "drawSprite(%s %d %d)", str.c_str(),
|
||||
x, y);
|
||||
}
|
||||
@ -525,4 +503,4 @@ static void dumpToDebugf(const char text[], void*) {
|
||||
|
||||
SkDebugfDumper::SkDebugfDumper() : INHERITED(dumpToDebugf, NULL) {}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -39,9 +39,13 @@ static SkPicture* inspect(const char path[]) {
|
||||
}
|
||||
|
||||
static void dumpOps(SkPicture* pic) {
|
||||
#ifdef SK_DEVELOPER
|
||||
SkDebugfDumper dumper;
|
||||
SkDumpCanvas canvas(&dumper);
|
||||
canvas.drawPicture(*pic);
|
||||
#else
|
||||
printf("SK_DEVELOPER mode not enabled\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
int tool_main(int argc, char** argv);
|
||||
|
Loading…
Reference in New Issue
Block a user