Added toString to SkMaskFilter-derived classes
https://codereview.appspot.com/7889043/ git-svn-id: http://skia.googlecode.com/svn/trunk@8194 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
cd9caa8017
commit
0bd80fa01b
@ -93,6 +93,8 @@ public:
|
||||
*/
|
||||
virtual void computeFastBounds(const SkRect& src, SkRect* dest) const;
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const = 0;)
|
||||
|
||||
protected:
|
||||
// empty for now, but lets get our subclass to remember to init us for the future
|
||||
SkMaskFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
|
||||
SkIPoint* margin) const SK_OVERRIDE;
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
|
||||
|
||||
protected:
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&,
|
||||
SkIPoint*) const SK_OVERRIDE;
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
|
||||
|
||||
protected:
|
||||
SkKernel33ProcMaskFilter(SkFlattenableReadBuffer& rb);
|
||||
virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
|
||||
@ -44,6 +46,7 @@ public:
|
||||
// override from SkKernel33ProcMaskFilter
|
||||
virtual uint8_t computeValue(uint8_t* const* srcRows) const SK_OVERRIDE;
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkKernel33MaskFilter)
|
||||
|
||||
private:
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
return SkMask::kA8_Format;
|
||||
}
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter);
|
||||
|
||||
protected:
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&,
|
||||
SkIPoint*) const SK_OVERRIDE;
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter)
|
||||
|
||||
protected:
|
||||
|
@ -48,10 +48,21 @@ public:
|
||||
// if (c < min) c = min;
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
virtual void toString(SkString* str) const SK_OVERRIDE {
|
||||
str->append("ReduceNoise: (");
|
||||
this->INHERITED::toString(str);
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(ReduceNoise)
|
||||
|
||||
private:
|
||||
ReduceNoise(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {}
|
||||
|
||||
typedef SkKernel33ProcMaskFilter INHERITED;
|
||||
};
|
||||
|
||||
class Darken : public SkKernel33ProcMaskFilter {
|
||||
@ -69,10 +80,21 @@ public:
|
||||
SkASSERT(f >= 0 && f <= 1);
|
||||
return (int)(f * 255);
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
virtual void toString(SkString* str) const SK_OVERRIDE {
|
||||
str->append("Darken: (");
|
||||
this->INHERITED::toString(str);
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Darken)
|
||||
|
||||
private:
|
||||
Darken(SkFlattenableReadBuffer& rb) : SkKernel33ProcMaskFilter(rb) {}
|
||||
|
||||
typedef SkKernel33ProcMaskFilter INHERITED;
|
||||
};
|
||||
|
||||
static SkMaskFilter* makemf() { return new Darken(0x30); }
|
||||
|
@ -2295,6 +2295,7 @@ void SkPaint::toString(SkString* str) const {
|
||||
SkMaskFilter* maskFilter = this->getMaskFilter();
|
||||
if (NULL != maskFilter) {
|
||||
str->append("<dt>MaskFilter:</dt><dd>");
|
||||
SkDEVCODE(maskFilter->toString(str);)
|
||||
str->append("</dd>");
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "SkBounder.h"
|
||||
#include "SkRasterClip.h"
|
||||
#include "SkRTConf.h"
|
||||
#include "SkStringUtils.h"
|
||||
|
||||
class SkBlurMaskFilterImpl : public SkMaskFilter {
|
||||
public:
|
||||
@ -27,6 +28,7 @@ public:
|
||||
virtual BlurType asABlur(BlurInfo*) const SK_OVERRIDE;
|
||||
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
|
||||
|
||||
SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
|
||||
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl)
|
||||
|
||||
protected:
|
||||
@ -339,6 +341,35 @@ SkMaskFilter::BlurType SkBlurMaskFilterImpl::asABlur(BlurInfo* info) const {
|
||||
return gBlurStyle2BlurType[fBlurStyle];
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkBlurMaskFilterImpl::toString(SkString* str) const {
|
||||
str->append("SkBlurMaskFilterImpl: (");
|
||||
|
||||
str->append("radius: ");
|
||||
str->appendScalar(fRadius);
|
||||
str->append(" ");
|
||||
|
||||
static const char* gStyleName[SkBlurMaskFilter::kBlurStyleCount] = {
|
||||
"normal", "solid", "outer", "inner"
|
||||
};
|
||||
|
||||
str->appendf("style: %s ", gStyleName[fBlurStyle]);
|
||||
str->append("flags: (");
|
||||
if (fBlurFlags) {
|
||||
bool needSeparator = false;
|
||||
SkAddFlagToString(str,
|
||||
SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransform_BlurFlag),
|
||||
"IgnoreXform", &needSeparator);
|
||||
SkAddFlagToString(str,
|
||||
SkToBool(fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag),
|
||||
"HighQuality", &needSeparator);
|
||||
} else {
|
||||
str->append("None");
|
||||
}
|
||||
str->append("))");
|
||||
}
|
||||
#endif
|
||||
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
|
||||
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkEmbossMask.h"
|
||||
#include "SkFlattenableBuffers.h"
|
||||
#include "SkString.h"
|
||||
|
||||
static inline int pin2byte(int n) {
|
||||
if (n < 0) {
|
||||
@ -131,3 +132,24 @@ void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
|
||||
buffer.writeByteArray(&tmpLight, sizeof(tmpLight));
|
||||
buffer.writeScalar(fBlurRadius);
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkEmbossMaskFilter::toString(SkString* str) const {
|
||||
str->append("SkEmbossMaskFilter: (");
|
||||
|
||||
str->append("direction: (");
|
||||
str->appendScalar(fLight.fDirection[0]);
|
||||
str->append(", ");
|
||||
str->appendScalar(fLight.fDirection[1]);
|
||||
str->append(", ");
|
||||
str->appendScalar(fLight.fDirection[2]);
|
||||
str->append(") ");
|
||||
|
||||
str->appendf("ambient: %d specular: %d ",
|
||||
fLight.fAmbient, fLight.fSpecular);
|
||||
|
||||
str->append("blurRadius: ");
|
||||
str->appendScalar(fBlurRadius);
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "SkKernel33MaskFilter.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkFlattenableBuffers.h"
|
||||
#include "SkString.h"
|
||||
|
||||
SkMask::Format SkKernel33ProcMaskFilter::getFormat() const {
|
||||
return SkMask::kA8_Format;
|
||||
@ -84,6 +85,12 @@ SkKernel33ProcMaskFilter::SkKernel33ProcMaskFilter(SkFlattenableReadBuffer& rb)
|
||||
fPercent256 = rb.readInt();
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkKernel33ProcMaskFilter::toString(SkString* str) const {
|
||||
str->appendf("percent256: %d, ", fPercent256);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint8_t SkKernel33MaskFilter::computeValue(uint8_t* const* srcRows) const {
|
||||
@ -117,3 +124,19 @@ SkKernel33MaskFilter::SkKernel33MaskFilter(SkFlattenableReadBuffer& rb)
|
||||
SkASSERT(9 == count);
|
||||
fShift = rb.readInt();
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkKernel33MaskFilter::toString(SkString* str) const {
|
||||
str->append("SkKernel33MaskFilter: (");
|
||||
|
||||
str->appendf("kernel: (%d, %d, %d, %d, %d, %d, %d, %d, %d), ",
|
||||
fKernel[0][0], fKernel[0][1], fKernel[0][2],
|
||||
fKernel[1][0], fKernel[1][1], fKernel[1][2],
|
||||
fKernel[2][0], fKernel[2][1], fKernel[2][2]);
|
||||
str->appendf("shift: %d, ", fShift);
|
||||
|
||||
this->INHERITED::toString(str);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "SkStippleMaskFilter.h"
|
||||
|
||||
#include "SkString.h"
|
||||
|
||||
bool SkStippleMaskFilter::filterMask(SkMask* dst,
|
||||
const SkMask& src,
|
||||
@ -44,3 +44,9 @@ bool SkStippleMaskFilter::filterMask(SkMask* dst,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkStippleMaskFilter::toString(SkString* str) const {
|
||||
str->append("SkStippleMaskFilter: ()");
|
||||
}
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "SkTableMaskFilter.h"
|
||||
#include "SkFlattenableBuffers.h"
|
||||
#include "SkString.h"
|
||||
|
||||
SkTableMaskFilter::SkTableMaskFilter() {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
@ -126,3 +127,17 @@ void SkTableMaskFilter::MakeClipTable(uint8_t table[256], uint8_t min,
|
||||
SkDebugf("\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
void SkTableMaskFilter::toString(SkString* str) const {
|
||||
str->append("SkTableMaskFilter: (");
|
||||
|
||||
str->append("table: ");
|
||||
for (int i = 0; i < 255; ++i) {
|
||||
str->appendf("%d, ", fTable[i]);
|
||||
}
|
||||
str->appendf("%d", fTable[255]);
|
||||
|
||||
str->append(")");
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user