Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleanup code related to SkFlattenable::flatten()

The following changes were made by this CL:

1. Make flatten() a protected method as callers should use
   SkFlattenableWriteBuffer to flatten an object
2. Make flatten a const method (including subclasses)
3. Mark subclass implementation of flatten with SK_OVERRIDE
4. Ensure overridden flatten impls call their parent
5. Remove no-op implementations of flatten from subclasses

Additionally, if necessary the unflattening constructor was
also moved to the protected section of the subclasses
header if it was not already there.

git-svn-id: http://skia.googlecode.com/svn/trunk/src@3540 2bbb7eff-a529-9590-31e7-b0007b416f81
  • Loading branch information...
commit cd2e444e946f5cfec4723f5bc46e9487d82e8e54 1 parent 0637218
djsollen@google.com authored
Showing with 109 additions and 125 deletions.
  1. +0 −2  animator/SkDrawExtraPathEffect.cpp
  2. +1 −1  core/SkBitmapProcShader.cpp
  3. +1 −1  core/SkBitmapProcShader.h
  4. +2 −3 core/SkBlitter.cpp
  5. +1 −1  core/SkColorFilter.cpp
  6. +1 −1  core/SkComposeShader.cpp
  7. +1 −1  core/SkFlattenable.cpp
  8. +1 −1  core/SkMallocPixelRef.cpp
  9. +4 −2 core/SkPathEffect.cpp
  10. +1 −1  core/SkPixelRef.cpp
  11. +0 −3  core/SkRasterizer.cpp
  12. +2 −8 core/SkShader.cpp
  13. +0 −4 core/SkShape.cpp
  14. +8 −8 core/SkXfermode.cpp
  15. +2 −1  effects/Sk1DPathEffect.cpp
  16. +3 −2 effects/Sk2DPathEffect.cpp
  17. +1 −1  effects/SkAvoidXfermode.cpp
  18. +2 −1  effects/SkBlurDrawLooper.cpp
  19. +1 −1  effects/SkBlurImageFilter.cpp
  20. +2 −4 effects/SkBlurMaskFilter.cpp
  21. +4 −4 effects/SkColorFilters.cpp
  22. +1 −1  effects/SkColorMatrixFilter.cpp
  23. +2 −1  effects/SkCornerPathEffect.cpp
  24. +2 −1  effects/SkDashPathEffect.cpp
  25. +2 −1  effects/SkDiscretePathEffect.cpp
  26. +4 −3 effects/SkEmbossMaskFilter.cpp
  27. +35 −37 effects/SkGradientShader.cpp
  28. +1 −1  effects/SkGroupShape.cpp
  29. +2 −2 effects/SkKernel33MaskFilter.cpp
  30. +1 −1  effects/SkLayerDrawLooper.cpp
  31. +1 −1  effects/SkLayerRasterizer.cpp
  32. +1 −1  effects/SkMorphologyImageFilter.cpp
  33. +2 −2 effects/SkPixelXorXfermode.cpp
  34. +2 −2 effects/SkRectShape.cpp
  35. +2 −2 effects/SkTableColorFilter.cpp
  36. +1 −1  effects/SkTableMaskFilter.cpp
  37. +5 −5 effects/SkTestImageFilters.cpp
  38. +0 −5 effects/SkTransparentShader.cpp
  39. +1 −1  images/SkFlipPixelRef.cpp
  40. +1 −1  images/SkImageRef.cpp
  41. +1 −1  ports/SkImageRef_ashmem.cpp
  42. +3 −3 ports/SkImageRef_ashmem.h
  43. +1 −1  utils/SkUnitMappers.cpp
View
2  animator/SkDrawExtraPathEffect.cpp
@@ -140,8 +140,6 @@ class SkShape1DPathEffect : public Sk1DPathEffect {
}
private:
- virtual void flatten(SkFlattenableWriteBuffer& ) {}
-
static bool GetContourLength(const char* token, size_t len, void* clen, SkScriptValue* value) {
if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) {
value->fOperand.fScalar = *(SkScalar*) clen;
View
2  core/SkBitmapProcShader.cpp
@@ -68,7 +68,7 @@ SkShader::BitmapType SkBitmapProcShader::asABitmap(SkBitmap* texture,
return kDefault_BitmapType;
}
-void SkBitmapProcShader::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkBitmapProcShader::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
fRawBitmap.flatten(buffer);
View
2  core/SkBitmapProcShader.h
@@ -36,7 +36,7 @@ class SkBitmapProcShader : public SkShader {
protected:
SkBitmapProcShader(SkFlattenableReadBuffer& );
- virtual void flatten(SkFlattenableWriteBuffer& );
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
SkBitmap fRawBitmap; // experimental for RLE encoding
SkBitmapProcState fState;
View
5 core/SkBlitter.cpp
@@ -659,14 +659,13 @@ class Sk3DShader : public SkShader {
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk3DShader)
protected:
- Sk3DShader(SkFlattenableReadBuffer& buffer) :
- INHERITED(buffer) {
+ Sk3DShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
fProxy = static_cast<SkShader*>(buffer.readFlattenable());
fPMColor = buffer.readU32();
fMask = NULL;
}
- virtual void flatten(SkFlattenableWriteBuffer& buffer) {
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fProxy);
buffer.write32(fPMColor);
View
2  core/SkColorFilter.cpp
@@ -66,7 +66,7 @@ void SkFilterShader::endSession() {
this->INHERITED::endSession();
}
-void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkFilterShader::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fShader);
buffer.writeFlattenable(fFilter);
View
2  core/SkComposeShader.cpp
@@ -70,7 +70,7 @@ class SkAutoAlphaRestore {
uint8_t fAlpha;
};
-void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkComposeShader::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fShaderA);
buffer.writeFlattenable(fShaderB);
View
2  core/SkFlattenable.cpp
@@ -37,7 +37,7 @@ void SkWriteRegion(SkWriter32* writer, const SkRegion& rgn) {
///////////////////////////////////////////////////////////////////////////////
-void SkFlattenable::flatten(SkFlattenableWriteBuffer&)
+void SkFlattenable::flatten(SkFlattenableWriteBuffer&) const
{
/* we don't write anything at the moment, but this allows our subclasses
to not know that, since we want them to always call INHERITED::flatten()
View
2  core/SkMallocPixelRef.cpp
@@ -34,7 +34,7 @@ void SkMallocPixelRef::onUnlockPixels() {
// nothing to do
}
-void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.write32(fSize);
View
6 core/SkPathEffect.cpp
@@ -29,7 +29,8 @@ SkPairPathEffect::~SkPairPathEffect() {
/*
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
*/
-void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkPairPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fPE0);
buffer.writeFlattenable(fPE1);
}
@@ -108,7 +109,8 @@ bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src,
return true;
}
-void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkStrokePathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
buffer.writeScalar(fWidth);
buffer.writeScalar(fMiter);
buffer.write8(fStyle);
View
2  core/SkPixelRef.cpp
@@ -49,7 +49,7 @@ SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
fIsImmutable = buffer.readBool();
}
-void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeBool(fIsImmutable);
}
View
3  core/SkRasterizer.cpp
@@ -12,9 +12,6 @@
#include "SkMaskFilter.h"
#include "SkPath.h"
-// do nothing for now, since we don't store anything at flatten time
-SkRasterizer::SkRasterizer(SkFlattenableReadBuffer&) {}
-
bool SkRasterizer::rasterize(const SkPath& fillPath, const SkMatrix& matrix,
const SkIRect* clipBounds, SkMaskFilter* filter,
SkMask* mask, SkMask::CreateMode mode) {
View
10 core/SkShader.cpp
@@ -41,7 +41,7 @@ void SkShader::endSession() {
SkDEBUGCODE(fInSession = false;)
}
-void SkShader::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkShader::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeBool(fLocalMatrix != NULL);
if (fLocalMatrix) {
@@ -238,7 +238,7 @@ SkColorShader::SkColorShader(SkFlattenableReadBuffer& b) : INHERITED(b) {
fColor = b.readU32();
}
-void SkColorShader::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkColorShader::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.write8(fInheritColor);
if (fInheritColor) {
@@ -331,8 +331,6 @@ SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorShader)
#include "SkEmptyShader.h"
-SkEmptyShader::SkEmptyShader(SkFlattenableReadBuffer& b) : INHERITED(b) {}
-
uint32_t SkEmptyShader::getFlags() { return 0; }
uint8_t SkEmptyShader::getSpan16Alpha() const { return 0; }
@@ -351,8 +349,4 @@ void SkEmptyShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
SkDEBUGFAIL("should never get called, since setContext() returned false");
}
-void SkEmptyShader::flatten(SkFlattenableWriteBuffer& buffer) {
- this->INHERITED::flatten(buffer);
-}
-
SK_DEFINE_FLATTENABLE_REGISTRAR(SkEmptyShader)
View
4 core/SkShape.cpp
@@ -60,10 +60,6 @@ SkShape::SkShape(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
inc_shape(this);
}
-void SkShape::flatten(SkFlattenableWriteBuffer& buffer) {
- this->INHERITED::flatten(buffer);
-}
-
void SkShape::onDraw(SkCanvas*) {}
SK_DEFINE_FLATTENABLE_REGISTRAR(SkShape)
View
16 core/SkXfermode.cpp
@@ -685,7 +685,8 @@ SkProcXfermode::SkProcXfermode(SkFlattenableReadBuffer& buffer)
fProc = (SkXfermodeProc)buffer.readFunctionPtr();
}
-void SkProcXfermode::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkProcXfermode::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
if (buffer.isCrossProcess()) {
// function pointer is only valid in the current process. Write a NULL
// so it can't be accidentally used
@@ -729,16 +730,10 @@ class SkProcCoeffXfermode : public SkProcXfermode {
return true;
}
- virtual void flatten(SkFlattenableWriteBuffer& buffer) {
- this->INHERITED::flatten(buffer);
- buffer.write32(fMode);
- }
-
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
protected:
- SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer)
- : INHERITED(buffer) {
+ SkProcCoeffXfermode(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
fMode = (SkXfermode::Mode)buffer.readU32();
const ProcCoeff& rec = gProcCoeffs[fMode];
@@ -749,6 +744,11 @@ class SkProcCoeffXfermode : public SkProcXfermode {
this->INHERITED::setProc(rec.fProc);
}
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
+ this->INHERITED::flatten(buffer);
+ buffer.write32(fMode);
+ }
+
private:
Mode fMode;
Coeff fSrcCoeff, fDstCoeff;
View
3  effects/Sk1DPathEffect.cpp
@@ -156,7 +156,8 @@ SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) {
return fInitialOffset;
}
-void SkPath1DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkPath1DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
buffer.writeScalar(fAdvance);
if (fAdvance > 0) {
fPath.flatten(buffer);
View
5 effects/Sk2DPathEffect.cpp
@@ -64,7 +64,8 @@ void Sk2DPathEffect::end(SkPath* dst) {}
///////////////////////////////////////////////////////////////////////////////
-void Sk2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void Sk2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
char storage[SkMatrix::kMaxFlattenSize];
uint32_t size = fMatrix.flatten(storage);
buffer.write32(size);
@@ -92,7 +93,7 @@ SkPath2DPathEffect::SkPath2DPathEffect(SkFlattenableReadBuffer& buffer)
fPath.unflatten(buffer);
}
-void SkPath2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkPath2DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
fPath.flatten(buffer);
}
View
2  effects/SkAvoidXfermode.cpp
@@ -29,7 +29,7 @@ SkAvoidXfermode::SkAvoidXfermode(SkFlattenableReadBuffer& buffer)
fMode = (Mode)buffer.readU8();
}
-void SkAvoidXfermode::flatten(SkFlattenableWriteBuffer& buffer)
+void SkAvoidXfermode::flatten(SkFlattenableWriteBuffer& buffer) const
{
this->INHERITED::flatten(buffer);
View
3  effects/SkBlurDrawLooper.cpp
@@ -61,7 +61,8 @@ SkBlurDrawLooper::~SkBlurDrawLooper() {
SkSafeUnref(fColorFilter);
}
-void SkBlurDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkBlurDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
buffer.writeScalar(fDx);
buffer.writeScalar(fDy);
buffer.write32(fBlurColor);
View
2  effects/SkBlurImageFilter.cpp
@@ -24,7 +24,7 @@ bool SkBlurImageFilter::asABlur(SkSize* sigma) const {
return true;
}
-void SkBlurImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkBlurImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fSigma.fWidth);
buffer.writeScalar(fSigma.fHeight);
View
6 effects/SkBlurMaskFilter.cpp
@@ -24,9 +24,6 @@ class SkBlurMaskFilterImpl : public SkMaskFilter {
virtual BlurType asABlur(BlurInfo*) const SK_OVERRIDE;
virtual void computeFastBounds(const SkRect& src, SkRect* dst) SK_OVERRIDE;
- // overrides from SkFlattenable
- virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
-
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurMaskFilterImpl)
private:
@@ -35,6 +32,7 @@ class SkBlurMaskFilterImpl : public SkMaskFilter {
uint32_t fBlurFlags;
SkBlurMaskFilterImpl(SkFlattenableReadBuffer&);
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
typedef SkMaskFilter INHERITED;
};
@@ -112,7 +110,7 @@ SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkFlattenableReadBuffer& buffer)
SkASSERT((unsigned)fBlurStyle < SkBlurMaskFilter::kBlurStyleCount);
}
-void SkBlurMaskFilterImpl::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkBlurMaskFilterImpl::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fRadius);
buffer.write32(fBlurStyle);
View
8 effects/SkColorFilters.cpp
@@ -50,7 +50,7 @@ class SkModeColorFilter : public SkColorFilter {
bool isModeValid() const { return ILLEGAL_XFERMODE_MODE != fMode; }
protected:
- virtual void flatten(SkFlattenableWriteBuffer& buffer) {
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer);
buffer.write32(fColor);
buffer.write32(fMode);
@@ -193,7 +193,7 @@ class Proc_SkModeColorFilter : public SkModeColorFilter {
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Proc_SkModeColorFilter)
protected:
- virtual void flatten(SkFlattenableWriteBuffer& buffer) {
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer);
buffer.writeFunctionPtr((void*)fProc);
buffer.writeFunctionPtr((void*)fProc16);
@@ -312,7 +312,7 @@ class SkLightingColorFilter : public SkColorFilter {
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLightingColorFilter)
protected:
- virtual void flatten(SkFlattenableWriteBuffer& buffer) {
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
this->INHERITED::flatten(buffer);
buffer.write32(fMul);
buffer.write32(fAdd);
@@ -489,7 +489,7 @@ class SkSimpleColorFilter : public SkColorFilter {
}
}
- virtual void flatten(SkFlattenableWriteBuffer& buffer) {}
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {}
virtual Factory getFactory() {
return CreateProc;
View
2  effects/SkColorMatrixFilter.cpp
@@ -310,7 +310,7 @@ void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count,
///////////////////////////////////////////////////////////////////////////////
-void SkColorMatrixFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkColorMatrixFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFunctionPtr((void*)fProc);
View
3  effects/SkCornerPathEffect.cpp
@@ -129,7 +129,8 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src,
return true;
}
-void SkCornerPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkCornerPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
buffer.writeScalar(fRadius);
}
View
3  effects/SkDashPathEffect.cpp
@@ -140,9 +140,10 @@ SkFlattenable::Factory SkDashPathEffect::getFactory() {
return fInitialDashLength < 0 ? NULL : CreateProc;
}
-void SkDashPathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkDashPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
SkASSERT(fInitialDashLength >= 0);
+ this->INHERITED::flatten(buffer);
buffer.write32(fCount);
buffer.write32(fInitialDashIndex);
buffer.writeScalar(fInitialDashLength);
View
3  effects/SkDiscretePathEffect.cpp
@@ -67,7 +67,8 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
return true;
}
-void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer) const {
+ this->INHERITED::flatten(buffer);
buffer.writeScalar(fSegLength);
buffer.writeScalar(fPerterb);
}
View
7 effects/SkEmbossMaskFilter.cpp
@@ -122,11 +122,12 @@ SkEmbossMaskFilter::SkEmbossMaskFilter(SkFlattenableReadBuffer& buffer)
fBlurRadius = buffer.readScalar();
}
-void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkEmbossMaskFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
- fLight.fPad = 0; // for the font-cache lookup to be clean
- buffer.writeMul4(&fLight, sizeof(fLight));
+ Light tmpLight = fLight;
+ tmpLight.fPad = 0; // for the font-cache lookup to be clean
+ buffer.writeMul4(&tmpLight, sizeof(tmpLight));
buffer.writeScalar(fBlurRadius);
}
View
72 effects/SkGradientShader.cpp
@@ -174,6 +174,8 @@ class Gradient_Shader : public SkShader {
protected:
Gradient_Shader(SkFlattenableReadBuffer& );
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
+
SkUnitMapper* fMapper;
SkMatrix fPtsToUnit; // set by subclass
SkMatrix fDstToIndex;
@@ -190,7 +192,6 @@ class Gradient_Shader : public SkShader {
};
Rec* fRecs;
- virtual void flatten(SkFlattenableWriteBuffer& );
const uint16_t* getCache16() const;
const SkPMColor* getCache32() const;
@@ -404,7 +405,7 @@ void Gradient_Shader::initCommon() {
fColorsAreOpaque = colorAlpha == 0xFF;
}
-void Gradient_Shader::flatten(SkFlattenableWriteBuffer& buffer) {
+void Gradient_Shader::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fMapper);
buffer.write32(fColorCount);
@@ -849,22 +850,21 @@ class Linear_Gradient : public Gradient_Shader {
SkScalar* twoPointRadialParams) const SK_OVERRIDE;
virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
- virtual void flatten(SkFlattenableWriteBuffer& buffer) SK_OVERRIDE {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fStart.fX);
- buffer.writeScalar(fStart.fY);
- buffer.writeScalar(fEnd.fX);
- buffer.writeScalar(fEnd.fY);
- }
-
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Linear_Gradient)
protected:
Linear_Gradient(SkFlattenableReadBuffer& buffer)
- : Gradient_Shader(buffer),
+ : INHERITED(buffer),
fStart(unflatten_point(buffer)),
fEnd(unflatten_point(buffer)) {
}
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
+ this->INHERITED::flatten(buffer);
+ buffer.writeScalar(fStart.fX);
+ buffer.writeScalar(fStart.fY);
+ buffer.writeScalar(fEnd.fX);
+ buffer.writeScalar(fEnd.fY);
+ }
private:
typedef Gradient_Shader INHERITED;
@@ -1507,21 +1507,20 @@ class Radial_Gradient : public Gradient_Shader {
return kRadial_GradientType;
}
- virtual void flatten(SkFlattenableWriteBuffer& buffer) SK_OVERRIDE {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fCenter.fX);
- buffer.writeScalar(fCenter.fY);
- buffer.writeScalar(fRadius);
- }
-
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Radial_Gradient)
protected:
Radial_Gradient(SkFlattenableReadBuffer& buffer)
- : Gradient_Shader(buffer),
+ : INHERITED(buffer),
fCenter(unflatten_point(buffer)),
fRadius(buffer.readScalar()) {
}
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
+ this->INHERITED::flatten(buffer);
+ buffer.writeScalar(fCenter.fX);
+ buffer.writeScalar(fCenter.fY);
+ buffer.writeScalar(fRadius);
+ }
private:
typedef Gradient_Shader INHERITED;
@@ -2039,21 +2038,11 @@ class Two_Point_Radial_Gradient : public Gradient_Shader {
return true;
}
- virtual void flatten(SkFlattenableWriteBuffer& buffer) SK_OVERRIDE {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fCenter1.fX);
- buffer.writeScalar(fCenter1.fY);
- buffer.writeScalar(fCenter2.fX);
- buffer.writeScalar(fCenter2.fY);
- buffer.writeScalar(fRadius1);
- buffer.writeScalar(fRadius2);
- }
-
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Two_Point_Radial_Gradient)
protected:
Two_Point_Radial_Gradient(SkFlattenableReadBuffer& buffer)
- : Gradient_Shader(buffer),
+ : INHERITED(buffer),
fCenter1(unflatten_point(buffer)),
fCenter2(unflatten_point(buffer)),
fRadius1(buffer.readScalar()),
@@ -2061,6 +2050,16 @@ class Two_Point_Radial_Gradient : public Gradient_Shader {
init();
};
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
+ this->INHERITED::flatten(buffer);
+ buffer.writeScalar(fCenter1.fX);
+ buffer.writeScalar(fCenter1.fY);
+ buffer.writeScalar(fCenter2.fX);
+ buffer.writeScalar(fCenter2.fY);
+ buffer.writeScalar(fRadius1);
+ buffer.writeScalar(fRadius2);
+ }
+
private:
typedef Gradient_Shader INHERITED;
const SkPoint fCenter1;
@@ -2125,19 +2124,18 @@ class Sweep_Gradient : public Gradient_Shader {
return kSweep_GradientType;
}
- virtual void flatten(SkFlattenableWriteBuffer& buffer) SK_OVERRIDE {
- this->INHERITED::flatten(buffer);
- buffer.writeScalar(fCenter.fX);
- buffer.writeScalar(fCenter.fY);
- }
-
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sweep_Gradient)
protected:
Sweep_Gradient(SkFlattenableReadBuffer& buffer)
- : Gradient_Shader(buffer),
+ : INHERITED(buffer),
fCenter(unflatten_point(buffer)) {
}
+ virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE {
+ this->INHERITED::flatten(buffer);
+ buffer.writeScalar(fCenter.fX);
+ buffer.writeScalar(fCenter.fY);
+ }
private:
typedef Gradient_Shader INHERITED;
View
2  effects/SkGroupShape.cpp
@@ -83,7 +83,7 @@ void SkGroupShape::onDraw(SkCanvas* canvas) {
}
}
-void SkGroupShape::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkGroupShape::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
int count = fList.count();
View
4 effects/SkKernel33MaskFilter.cpp
@@ -73,7 +73,7 @@ bool SkKernel33ProcMaskFilter::filterMask(SkMask* dst, const SkMask& src,
return true;
}
-void SkKernel33ProcMaskFilter::flatten(SkFlattenableWriteBuffer& wb) {
+void SkKernel33ProcMaskFilter::flatten(SkFlattenableWriteBuffer& wb) const {
this->INHERITED::flatten(wb);
wb.write32(fPercent256);
}
@@ -104,7 +104,7 @@ uint8_t SkKernel33MaskFilter::computeValue(uint8_t* const* srcRows) {
return (uint8_t)value;
}
-void SkKernel33MaskFilter::flatten(SkFlattenableWriteBuffer& wb) {
+void SkKernel33MaskFilter::flatten(SkFlattenableWriteBuffer& wb) const {
this->INHERITED::flatten(wb);
wb.writeMul4(fKernel, 9 * sizeof(int));
wb.write32(fShift);
View
2  effects/SkLayerDrawLooper.cpp
@@ -180,7 +180,7 @@ SkLayerDrawLooper::Rec* SkLayerDrawLooper::Rec::Reverse(Rec* head) {
///////////////////////////////////////////////////////////////////////////////
-void SkLayerDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkLayerDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
#ifdef SK_DEBUG
View
2  effects/SkLayerRasterizer.cpp
@@ -197,7 +197,7 @@ SkLayerRasterizer::SkLayerRasterizer(SkFlattenableReadBuffer& buffer)
}
}
-void SkLayerRasterizer::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkLayerRasterizer::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.write32(fLayers.count());
View
2  effects/SkMorphologyImageFilter.cpp
@@ -19,7 +19,7 @@ SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX, int radiusY)
}
-void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkMorphologyImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fRadius.fWidth);
buffer.writeScalar(fRadius.fHeight);
View
4 effects/SkPixelXorXfermode.cpp
@@ -18,13 +18,13 @@ SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) {
return res;
}
-void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb) {
+void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb) const {
this->INHERITED::flatten(wb);
wb.write32(fOpColor);
}
SkPixelXorXfermode::SkPixelXorXfermode(SkFlattenableReadBuffer& rb)
- : SkXfermode(rb) {
+ : INHERITED(rb) {
fOpColor = rb.readU32();
}
View
4 effects/SkRectShape.cpp
@@ -60,7 +60,7 @@ void SkRectShape::onDraw(SkCanvas* canvas) {
}
}
-void SkRectShape::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkRectShape::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeRect(fBounds);
@@ -74,7 +74,7 @@ SkRectShape::SkRectShape(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
///////////////////////////////////////////////////////////////////////////////
-void SkPaintShape::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkPaintShape::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
fPaint.flatten(buffer);
View
4 effects/SkTableColorFilter.cpp
@@ -35,12 +35,12 @@ class SkTable_ColorFilter : public SkColorFilter {
virtual void filterSpan(const SkPMColor src[], int count,
SkPMColor dst[]) SK_OVERRIDE;
- virtual void flatten(SkFlattenableWriteBuffer&) SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter)
protected:
SkTable_ColorFilter(SkFlattenableReadBuffer& buffer);
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
private:
SkBitmap* fBitmap;
@@ -145,7 +145,7 @@ static const uint8_t gCountNibBits[] = {
#include "SkPackBits.h"
-void SkTable_ColorFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkTable_ColorFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
uint8_t storage[5*256];
View
2  effects/SkTableMaskFilter.cpp
@@ -71,7 +71,7 @@ SkMask::Format SkTableMaskFilter::getFormat() {
return SkMask::kA8_Format;
}
-void SkTableMaskFilter::flatten(SkFlattenableWriteBuffer& wb) {
+void SkTableMaskFilter::flatten(SkFlattenableWriteBuffer& wb) const {
this->INHERITED::flatten(wb);
wb.writePad(fTable, 256);
}
View
10 effects/SkTestImageFilters.cpp
@@ -32,7 +32,7 @@ bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm
return true;
}
-void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fOffset.x());
buffer.writeScalar(fOffset.y());
@@ -84,7 +84,7 @@ bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
fOuter->filterBounds(tmp, ctm, dst);
}
-void SkComposeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkComposeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fOuter);
@@ -238,7 +238,7 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
return true;
}
-void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
int storedCount = fCount;
@@ -307,7 +307,7 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
return true;
}
-void SkColorFilterImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkColorFilterImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeFlattenable(fColorFilter);
@@ -369,7 +369,7 @@ bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
return true;
}
-void SkDownSampleImageFilter::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkDownSampleImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fScale);
View
5 effects/SkTransparentShader.cpp
@@ -125,8 +125,3 @@ void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count)
memcpy(span, src, count << 1);
}
}
-
-void SkTransparentShader::flatten(SkFlattenableWriteBuffer& buffer) {
- this->INHERITED::flatten(buffer);
-}
-
View
2  images/SkFlipPixelRef.cpp
@@ -60,7 +60,7 @@ void SkFlipPixelRef::swapPages() {
fMutex.release();
}
-void SkFlipPixelRef::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkFlipPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.write32(fSize);
View
2  images/SkImageRef.cpp
@@ -189,7 +189,7 @@ SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer)
fFactory = NULL;
}
-void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.write8(fConfig);
View
2  ports/SkImageRef_ashmem.cpp
@@ -210,7 +210,7 @@ void SkImageRef_ashmem::onUnlockPixels() {
fBitmap.setPixels(NULL, NULL);
}
-void SkImageRef_ashmem::flatten(SkFlattenableWriteBuffer& buffer) {
+void SkImageRef_ashmem::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
const char* uri = getURI();
if (uri) {
View
6 ports/SkImageRef_ashmem.h
@@ -22,11 +22,12 @@ class SkImageRef_ashmem : public SkImageRef {
SkImageRef_ashmem(SkStream*, SkBitmap::Config, int sampleSize = 1);
virtual ~SkImageRef_ashmem();
- // overrides
- virtual void flatten(SkFlattenableWriteBuffer&);
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageRef_ashmem)
protected:
+ SkImageRef_ashmem(SkFlattenableReadBuffer&);
+ virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
+
virtual bool onDecode(SkImageDecoder* codec, SkStream* stream,
SkBitmap* bitmap, SkBitmap::Config config,
SkImageDecoder::Mode mode);
@@ -35,7 +36,6 @@ class SkImageRef_ashmem : public SkImageRef {
virtual void onUnlockPixels();
private:
- SkImageRef_ashmem(SkFlattenableReadBuffer&);
void closeFD();
SkColorTable* fCT;
View
2  utils/SkUnitMappers.cpp
@@ -33,7 +33,7 @@ SkDiscreteMapper::SkDiscreteMapper(SkFlattenableReadBuffer& rb)
fScale = rb.readU32();
}
-void SkDiscreteMapper::flatten(SkFlattenableWriteBuffer& wb) {
+void SkDiscreteMapper::flatten(SkFlattenableWriteBuffer& wb) const {
this->INHERITED::flatten(wb);
wb.write32(fSegments);
Please sign in to comment.
Something went wrong with that request. Please try again.