diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-28 20:21:59 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-01-28 20:21:59 +0000 |
commit | 4991b8f23482afc1494fd17647421ce68de53331 (patch) | |
tree | cab68b2aa8bc017b30a904c6be057d33694c5bcb /src/effects | |
parent | 85ec74ca543b13739db1ad55dedd7bdfae4ab1a6 (diff) |
Added toString to SkDrawLooper-derived classes
https://codereview.appspot.com/7195054/
git-svn-id: http://skia.googlecode.com/svn/trunk@7422 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkBlurDrawLooper.cpp | 38 | ||||
-rw-r--r-- | src/effects/SkLayerDrawLooper.cpp | 98 |
2 files changed, 134 insertions, 2 deletions
diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp index e6e2ffdd8c..dda20638a3 100644 --- a/src/effects/SkBlurDrawLooper.cpp +++ b/src/effects/SkBlurDrawLooper.cpp @@ -8,10 +8,12 @@ #include "SkBlurDrawLooper.h" #include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkColorFilter.h" #include "SkFlattenableBuffers.h" -#include "SkPaint.h" #include "SkMaskFilter.h" -#include "SkColorFilter.h" +#include "SkPaint.h" +#include "SkString.h" +#include "SkStringUtils.h" SkBlurDrawLooper::SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color, uint32_t flags) @@ -115,3 +117,35 @@ bool SkBlurDrawLooper::next(SkCanvas* canvas, SkPaint* paint) { return false; } } + +#ifdef SK_DEVELOPER +void SkBlurDrawLooper::toString(SkString* str) const { + str->append("SkBlurDrawLooper: "); + + str->append("dx: "); + str->appendScalar(fDx); + + str->append(" dy: "); + str->appendScalar(fDy); + + str->append(" color: "); + str->appendHex(fBlurColor); + + str->append(" flags: ("); + if (kNone_BlurFlag == fBlurFlags) { + str->append("None"); + } else { + bool needsSeparator = false; + SkAddFlagToString(str, SkToBool(kIgnoreTransform_BlurFlag & fBlurFlags), "IgnoreTransform", + &needsSeparator); + SkAddFlagToString(str, SkToBool(kOverrideColor_BlurFlag & fBlurFlags), "OverrideColor", + &needsSeparator); + SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "HighQuality", + &needsSeparator); + } + str->append(")"); + + // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toString is added + // alternatively we could cache the radius in SkBlurDrawLooper and just add it here +} +#endif diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index c27908f250..6d03eae84d 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -10,6 +10,8 @@ #include "SkFlattenableBuffers.h" #include "SkLayerDrawLooper.h" #include "SkPaint.h" +#include "SkString.h" +#include "SkStringUtils.h" #include "SkUnPreMultiply.h" SK_DEFINE_INST_COUNT(SkLayerDrawLooper) @@ -245,3 +247,99 @@ SkLayerDrawLooper::SkLayerDrawLooper(SkFlattenableReadBuffer& buffer) } #endif } + +#ifdef SK_DEVELOPER +void SkLayerDrawLooper::toString(SkString* str) const { + str->appendf("SkLayerDrawLooper (%d): ", fCount); + + Rec* rec = fRecs; + for (int i = 0; i < fCount; i++) { + str->appendf("%d: ", i); + + str->append("flagsMask: ("); + if (0 == rec->fInfo.fFlagsMask) { + str->append("None"); + } else { + bool needSeparator = false; + SkAddFlagToString(str, SkToBool(SkPaint::kAntiAlias_Flag & rec->fInfo.fFlagsMask), + "AntiAlias", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kFilterBitmap_Flag & rec->fInfo.fFlagsMask), + "FilterBitmap", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kDither_Flag & rec->fInfo.fFlagsMask), + "Dither", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kUnderlineText_Flag & rec->fInfo.fFlagsMask), + "UnderlineText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kStrikeThruText_Flag & rec->fInfo.fFlagsMask), + "StrikeThruText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kFakeBoldText_Flag & rec->fInfo.fFlagsMask), + "FakeBoldText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kLinearText_Flag & rec->fInfo.fFlagsMask), + "LinearText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kSubpixelText_Flag & rec->fInfo.fFlagsMask), + "SubpixelText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kDevKernText_Flag & rec->fInfo.fFlagsMask), + "DevKernText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kLCDRenderText_Flag & rec->fInfo.fFlagsMask), + "LCDRenderText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kEmbeddedBitmapText_Flag & rec->fInfo.fFlagsMask), + "EmbeddedBitmapText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kAutoHinting_Flag & rec->fInfo.fFlagsMask), + "Autohinted", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kVerticalText_Flag & rec->fInfo.fFlagsMask), + "VerticalText", &needSeparator); + SkAddFlagToString(str, SkToBool(SkPaint::kGenA8FromLCD_Flag & rec->fInfo.fFlagsMask), + "GenA8FromLCD", &needSeparator); + } + str->append(") "); + + str->append("paintBits: ("); + if (0 == rec->fInfo.fPaintBits) { + str->append("None"); + } else if (kEntirePaint_Bits == rec->fInfo.fPaintBits) { + str->append("EntirePaint"); + } else { + bool needSeparator = false; + SkAddFlagToString(str, SkToBool(kStyle_Bit & rec->fInfo.fPaintBits), "Style", + &needSeparator); + SkAddFlagToString(str, SkToBool(kTextSkewX_Bit & rec->fInfo.fPaintBits), "TextSkewX", + &needSeparator); + SkAddFlagToString(str, SkToBool(kPathEffect_Bit & rec->fInfo.fPaintBits), "PathEffect", + &needSeparator); + SkAddFlagToString(str, SkToBool(kMaskFilter_Bit & rec->fInfo.fPaintBits), "MaskFilter", + &needSeparator); + SkAddFlagToString(str, SkToBool(kShader_Bit & rec->fInfo.fPaintBits), "Shader", + &needSeparator); + SkAddFlagToString(str, SkToBool(kColorFilter_Bit & rec->fInfo.fPaintBits), "ColorFilter", + &needSeparator); + SkAddFlagToString(str, SkToBool(kXfermode_Bit & rec->fInfo.fPaintBits), "Xfermode", + &needSeparator); + } + str->append(") "); + + static const char* gModeStrings[SkXfermode::kLastMode+1] = { + "kClear", "kSrc", "kDst", "kSrcOver", "kDstOver", "kSrcIn", "kDstIn", + "kSrcOut", "kDstOut", "kSrcATop", "kDstATop", "kXor", "kPlus", + "kMultiply", "kScreen", "kOverlay", "kDarken", "kLighten", "kColorDodge", + "kColorBurn", "kHardLight", "kSoftLight", "kDifference", "kExclusion" + }; + + str->appendf("mode: %s ", gModeStrings[rec->fInfo.fColorMode]); + + str->append("offset: ("); + str->appendScalar(rec->fInfo.fOffset.fX); + str->append(", "); + str->appendScalar(rec->fInfo.fOffset.fY); + str->append(") "); + + str->append("postTranslate: "); + if (rec->fInfo.fPostTranslate) { + str->append("true "); + } else { + str->append("false "); + } + + // TODO: add "rec->fPaint.toString(str);" when SkPaint::toString is added + rec = rec->fNext; + } +} +#endif |