From a2ca41e3afdd8fad5e0e924dec029f33918e0a67 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Fri, 23 Mar 2012 19:00:34 +0000 Subject: [PATCH] Cleanup Macros arround static initializers for SkFlattenable. This CL also removes an unused debugging function from the class Review URL: https://codereview.appspot.com/5890043 git-svn-id: http://skia.googlecode.com/svn/trunk@3483 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/Debugger/SkDebugDumper.cpp | 7 +- gm/gmmain.cpp | 3 +- gyp/effects.gyp | 2 - include/core/SkColorFilter.h | 2 +- include/core/SkColorShader.h | 3 +- include/core/SkEmptyShader.h | 4 ++ include/core/SkFlattenable.h | 36 ++++------ include/core/SkPathEffect.h | 1 - include/core/SkShape.h | 2 - include/core/SkXfermode.h | 2 +- include/effects/Sk1DPathEffect.h | 2 - include/effects/Sk2DPathEffect.h | 4 -- include/effects/SkAvoidXfermode.h | 2 - include/effects/SkBlurDrawLooper.h | 2 - include/effects/SkBlurImageFilter.h | 2 - include/effects/SkBlurMaskFilter.h | 3 +- include/effects/SkColorMatrixFilter.h | 2 - include/effects/SkCornerPathEffect.h | 2 - include/effects/SkDashPathEffect.h | 2 - include/effects/SkDiscretePathEffect.h | 2 - include/effects/SkEffects.h | 16 ----- include/effects/SkEmbossMaskFilter.h | 2 - include/effects/SkGradientShader.h | 2 +- include/effects/SkGroupShape.h | 2 - include/effects/SkLayerDrawLooper.h | 2 - include/effects/SkLayerRasterizer.h | 2 - include/effects/SkMorphologyImageFilter.h | 2 - include/effects/SkPixelXorXfermode.h | 2 - include/effects/SkRectShape.h | 2 - include/effects/SkTableColorFilter.h | 2 + src/core/SkBitmapProcShader.h | 1 - src/core/SkFlattenable.cpp | 4 -- src/core/SkPathEffect.cpp | 8 +-- src/core/SkShader.cpp | 3 + src/effects/Sk2DPathEffect.cpp | 3 +- src/effects/SkEffects.cpp | 53 -------------- src/effects/SkGradientShader.cpp | 4 -- src/effects/SkTableColorFilter.cpp | 4 ++ src/effects/SkTestImageFilters.cpp | 5 ++ src/ports/SkGlobalInitialization_chromium.cpp | 20 +++--- src/ports/SkGlobalInitialization_default.cpp | 69 +++++++++++++++++-- src/utils/SkDumpCanvas.cpp | 7 +- 42 files changed, 120 insertions(+), 180 deletions(-) delete mode 100644 include/effects/SkEffects.h delete mode 100644 src/effects/SkEffects.cpp diff --git a/experimental/Debugger/SkDebugDumper.cpp b/experimental/Debugger/SkDebugDumper.cpp index 8ecbec1005..64ac2eb459 100644 --- a/experimental/Debugger/SkDebugDumper.cpp +++ b/experimental/Debugger/SkDebugDumper.cpp @@ -35,12 +35,7 @@ static void appendPtr(SkString* str, const void* ptr, const char name[]) { static void appendFlattenable(SkString* str, const SkFlattenable* ptr, const char name[]) { if (ptr) { - SkString info; - if (ptr->toDumpString(&info)) { - str->appendf("%s\n", info.c_str()); - } else { - str->appendf("%s: %p\n", name, ptr); - } + str->appendf("%s: %p\n", name, ptr); } } diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index bcceb727c2..a8aa49cb9f 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -877,7 +877,8 @@ int main(int argc, char * const argv[]) { readPath, diffPath); } - if ((ERROR_NONE == testErrors) && doSerialize) { + if ((ERROR_NONE == testErrors) && doSerialize && + !(gmFlags & GM::kSkipPicture_Flag)) { testErrors |= test_picture_serialization(gm, gRec[i], forwardRenderedBitmap, readPath, diffPath); diff --git a/gyp/effects.gyp b/gyp/effects.gyp index d23d7efc80..397596551e 100644 --- a/gyp/effects.gyp +++ b/gyp/effects.gyp @@ -22,7 +22,6 @@ '../include/effects/SkDashPathEffect.h', '../include/effects/SkDiscretePathEffect.h', '../include/effects/SkDrawExtraPathEffect.h', - '../include/effects/SkEffects.h', '../include/effects/SkEmbossMaskFilter.h', '../include/effects/SkGradientShader.h', '../include/effects/SkGroupShape.h', @@ -56,7 +55,6 @@ '../src/effects/SkCornerPathEffect.cpp', '../src/effects/SkDashPathEffect.cpp', '../src/effects/SkDiscretePathEffect.cpp', - '../src/effects/SkEffects.cpp', '../src/effects/SkEmbossMask.cpp', '../src/effects/SkEmbossMask.h', '../src/effects/SkEmbossMask_Table.h', diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h index 97db5cc546..2151106859 100644 --- a/include/core/SkColorFilter.h +++ b/include/core/SkColorFilter.h @@ -118,7 +118,7 @@ public: */ static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add); - SK_DECLARE_FLATTENABLE_REGISTRAR() + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() protected: SkColorFilter() {} SkColorFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {} diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h index 9b1fed3d72..6c6e11d767 100644 --- a/include/core/SkColorShader.h +++ b/include/core/SkColorShader.h @@ -49,6 +49,8 @@ public: virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; + static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); + protected: SkColorShader(SkFlattenableReadBuffer&); @@ -56,7 +58,6 @@ protected: virtual Factory getFactory() SK_OVERRIDE; private: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); SkColor fColor; // ignored if fInheritColor is true SkPMColor fPMColor; // cached after setContext() diff --git a/include/core/SkEmptyShader.h b/include/core/SkEmptyShader.h index bf270bf642..1541c89611 100644 --- a/include/core/SkEmptyShader.h +++ b/include/core/SkEmptyShader.h @@ -30,6 +30,10 @@ 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; + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(SkEmptyShader, (buffer)); + } + protected: SkEmptyShader(SkFlattenableReadBuffer&); diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h index a66638eb4e..4170e260bb 100644 --- a/include/core/SkFlattenable.h +++ b/include/core/SkFlattenable.h @@ -22,33 +22,28 @@ class SkString; #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS -#define SK_DECLARE_FLATTENABLE_REGISTRAR() - #define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable) \ static SkFlattenable::Registrar g##flattenable##Reg(#flattenable, \ - flattenable::CreateProc); - -#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) + flattenable::CreateProc); #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ static SkFlattenable::Registrar g##flattenable##Reg(#flattenable, \ - flattenable::CreateProc); + flattenable::CreateProc); + +#define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() +#define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END #else -#define SK_DECLARE_FLATTENABLE_REGISTRAR() static void Init(); +#define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable) +#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ + SkFlattenable::Registrar(#flattenable, flattenable::CreateProc); -#define SK_DEFINE_FLATTENABLE_REGISTRAR(flattenable) \ - void flattenable::Init() { \ - SkFlattenable::Registrar(#flattenable, CreateProc); \ - } +#define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables(); #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(flattenable) \ - void flattenable::Init() { - -#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \ - SkFlattenable::Registrar(#flattenable, flattenable::CreateProc); - + void flattenable::InitializeFlattenables() { + #define SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END \ } @@ -77,22 +72,17 @@ public: */ virtual void flatten(SkFlattenableWriteBuffer&); - /** Set the string to describe the sublass and return true. If this is not - overridden, ignore the string param and return false. - */ - virtual bool toDumpString(SkString*) const; - static Factory NameToFactory(const char name[]); static const char* FactoryToName(Factory); static void Register(const char name[], Factory); - + class Registrar { public: Registrar(const char name[], Factory factory) { SkFlattenable::Register(name, factory); } }; - + protected: SkFlattenable(SkFlattenableReadBuffer&) {} diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index 1b4cd5f522..880219fead 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -34,7 +34,6 @@ public: */ virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width) = 0; - SK_DECLARE_FLATTENABLE_REGISTRAR() private: // illegal SkPathEffect(const SkPathEffect&); diff --git a/include/core/SkShape.h b/include/core/SkShape.h index c7cf9ec3cf..b40d886083 100644 --- a/include/core/SkShape.h +++ b/include/core/SkShape.h @@ -38,8 +38,6 @@ public: // public for Registrar static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: virtual void onDraw(SkCanvas*); diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h index 0d1c207b68..4f28bb2f50 100644 --- a/include/core/SkXfermode.h +++ b/include/core/SkXfermode.h @@ -172,7 +172,7 @@ public: return AsMode(xfer, mode); } - SK_DECLARE_FLATTENABLE_REGISTRAR() + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() protected: SkXfermode(SkFlattenableReadBuffer& rb) : SkFlattenable(rb) {} diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h index 814e547153..51a5a78686 100644 --- a/include/effects/Sk1DPathEffect.h +++ b/include/effects/Sk1DPathEffect.h @@ -63,8 +63,6 @@ public: return SkNEW_ARGS(SkPath1DPathEffect, (buffer)); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkPath1DPathEffect(SkFlattenableReadBuffer& buffer); diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h index b5d7fbb1b8..f0d60ca578 100644 --- a/include/effects/Sk2DPathEffect.h +++ b/include/effects/Sk2DPathEffect.h @@ -47,8 +47,6 @@ protected: // protected so that subclasses can call this during unflattening Sk2DPathEffect(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - private: SkMatrix fMatrix, fInverse; // illegal @@ -71,8 +69,6 @@ public: static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkPath2DPathEffect(SkFlattenableReadBuffer& buffer); diff --git a/include/effects/SkAvoidXfermode.h b/include/effects/SkAvoidXfermode.h index 398eaeaf29..8497265ded 100644 --- a/include/effects/SkAvoidXfermode.h +++ b/include/effects/SkAvoidXfermode.h @@ -59,8 +59,6 @@ public: return SkNEW_ARGS(SkAvoidXfermode, (buffer)); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkAvoidXfermode(SkFlattenableReadBuffer&); diff --git a/include/effects/SkBlurDrawLooper.h b/include/effects/SkBlurDrawLooper.h index be1a78edd5..46f72b9594 100644 --- a/include/effects/SkBlurDrawLooper.h +++ b/include/effects/SkBlurDrawLooper.h @@ -48,8 +48,6 @@ public: return SkNEW_ARGS(SkBlurDrawLooper, (buffer)); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkBlurDrawLooper(SkFlattenableReadBuffer&); // overrides from SkFlattenable diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h index 4c9798b1f4..2af31e86d1 100644 --- a/include/effects/SkBlurImageFilter.h +++ b/include/effects/SkBlurImageFilter.h @@ -21,8 +21,6 @@ public: return SkNEW_ARGS(SkBlurImageFilter, (buffer)); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: explicit SkBlurImageFilter(SkFlattenableReadBuffer& buffer); diff --git a/include/effects/SkBlurMaskFilter.h b/include/effects/SkBlurMaskFilter.h index 9e85d877a5..9a1c9cecff 100644 --- a/include/effects/SkBlurMaskFilter.h +++ b/include/effects/SkBlurMaskFilter.h @@ -55,8 +55,7 @@ public: SkScalar ambient, SkScalar specular, SkScalar blurRadius); - SK_DECLARE_FLATTENABLE_REGISTRAR() - + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() private: SkBlurMaskFilter(); // can't be instantiated }; diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h index 1475258055..62e8d3d267 100644 --- a/include/effects/SkColorMatrixFilter.h +++ b/include/effects/SkColorMatrixFilter.h @@ -39,8 +39,6 @@ public: static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: // overrides for SkFlattenable virtual Factory getFactory(); diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h index 990bad0ee3..b4d7f860f5 100644 --- a/include/effects/SkCornerPathEffect.h +++ b/include/effects/SkCornerPathEffect.h @@ -37,8 +37,6 @@ public: static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkCornerPathEffect(SkFlattenableReadBuffer&); diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h index 6d34910b8b..29a6d1b59a 100644 --- a/include/effects/SkDashPathEffect.h +++ b/include/effects/SkDashPathEffect.h @@ -39,8 +39,6 @@ public: static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkDashPathEffect(SkFlattenableReadBuffer&); diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h index 5369ddbe33..02ef391086 100644 --- a/include/effects/SkDiscretePathEffect.h +++ b/include/effects/SkDiscretePathEffect.h @@ -36,8 +36,6 @@ public: static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkDiscretePathEffect(SkFlattenableReadBuffer&); diff --git a/include/effects/SkEffects.h b/include/effects/SkEffects.h deleted file mode 100644 index 04091de85b..0000000000 --- a/include/effects/SkEffects.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkEffects_DEFINED -#define SkEffects_DEFINED - -class SkEffects { -public: - static void Init(); -}; - -#endif diff --git a/include/effects/SkEmbossMaskFilter.h b/include/effects/SkEmbossMaskFilter.h index 257e19ac78..c0e6b7e1a1 100644 --- a/include/effects/SkEmbossMaskFilter.h +++ b/include/effects/SkEmbossMaskFilter.h @@ -41,8 +41,6 @@ public: // This method is not exported to java. virtual void flatten(SkFlattenableWriteBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkEmbossMaskFilter(SkFlattenableReadBuffer&); diff --git a/include/effects/SkGradientShader.h b/include/effects/SkGradientShader.h index 3232703c92..427b3da35c 100644 --- a/include/effects/SkGradientShader.h +++ b/include/effects/SkGradientShader.h @@ -113,7 +113,7 @@ public: const SkColor colors[], const SkScalar pos[], int count, SkUnitMapper* mapper = NULL); - SK_DECLARE_FLATTENABLE_REGISTRAR() + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() }; #endif diff --git a/include/effects/SkGroupShape.h b/include/effects/SkGroupShape.h index 7764003c87..76dd13d696 100644 --- a/include/effects/SkGroupShape.h +++ b/include/effects/SkGroupShape.h @@ -138,8 +138,6 @@ public: // public for Registrar static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: // overrides virtual void onDraw(SkCanvas*); diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index 697d7b2f56..b9b080232d 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -106,8 +106,6 @@ public: return SkNEW_ARGS(SkLayerDrawLooper, (buffer)); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkLayerDrawLooper(SkFlattenableReadBuffer&); diff --git a/include/effects/SkLayerRasterizer.h b/include/effects/SkLayerRasterizer.h index 91deb61ff6..50758b16dc 100644 --- a/include/effects/SkLayerRasterizer.h +++ b/include/effects/SkLayerRasterizer.h @@ -38,8 +38,6 @@ public: static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkLayerRasterizer(SkFlattenableReadBuffer&); diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h index 2297938cef..8d9f453478 100644 --- a/include/effects/SkMorphologyImageFilter.h +++ b/include/effects/SkMorphologyImageFilter.h @@ -37,7 +37,6 @@ public: return SkNEW_ARGS(SkDilateImageFilter, (buffer)); } virtual Factory getFactory() SK_OVERRIDE { return CreateProc; } - SK_DECLARE_FLATTENABLE_REGISTRAR() typedef SkMorphologyImageFilter INHERITED; }; @@ -55,7 +54,6 @@ public: return SkNEW_ARGS(SkErodeImageFilter, (buffer)); } virtual Factory getFactory() SK_OVERRIDE { return CreateProc; } - SK_DECLARE_FLATTENABLE_REGISTRAR() private: typedef SkMorphologyImageFilter INHERITED; diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h index a7197abe9a..b9975cffa5 100644 --- a/include/effects/SkPixelXorXfermode.h +++ b/include/effects/SkPixelXorXfermode.h @@ -29,8 +29,6 @@ public: return SkNEW_ARGS(SkPixelXorXfermode, (buffer)); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: // override from SkXfermode virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst); diff --git a/include/effects/SkRectShape.h b/include/effects/SkRectShape.h index 519398c460..b521846ad5 100644 --- a/include/effects/SkRectShape.h +++ b/include/effects/SkRectShape.h @@ -47,8 +47,6 @@ public: // public for Registrar static SkFlattenable* CreateProc(SkFlattenableReadBuffer&); - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: SkRectShape(SkFlattenableReadBuffer&); diff --git a/include/effects/SkTableColorFilter.h b/include/effects/SkTableColorFilter.h index b442197bda..9fec68c25e 100644 --- a/include/effects/SkTableColorFilter.h +++ b/include/effects/SkTableColorFilter.h @@ -29,6 +29,8 @@ public: const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256]); + + SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() }; #endif diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index 4f8d0c5667..cd702793d1 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -37,7 +37,6 @@ public: // override from flattenable virtual bool toDumpString(SkString* str) const; - SK_DECLARE_FLATTENABLE_REGISTRAR() protected: SkBitmapProcShader(SkFlattenableReadBuffer& ); virtual void flatten(SkFlattenableWriteBuffer& ); diff --git a/src/core/SkFlattenable.cpp b/src/core/SkFlattenable.cpp index 59a262ada9..9d8c215a8c 100644 --- a/src/core/SkFlattenable.cpp +++ b/src/core/SkFlattenable.cpp @@ -383,7 +383,3 @@ const char* SkFlattenable::FactoryToName(Factory fact) { } return NULL; } - -bool SkFlattenable::toDumpString(SkString* str) const { - return false; -} diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index d81ac9ff3d..852c25f9da 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -134,9 +134,7 @@ SkStrokePathEffect::SkStrokePathEffect(SkFlattenableReadBuffer& buffer) { /////////////////////////////////////////////////////////////////////////////// -SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkPathEffect) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposePathEffect) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkStrokePathEffect) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect) -SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END +SK_DEFINE_FLATTENABLE_REGISTRAR(SkComposePathEffect) +SK_DEFINE_FLATTENABLE_REGISTRAR(SkStrokePathEffect) +SK_DEFINE_FLATTENABLE_REGISTRAR(SkSumPathEffect) diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index ce7ff9ef66..618b8d2745 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -333,6 +333,8 @@ SkShader::GradientType SkColorShader::asAGradient(GradientInfo* info) const { return kColor_GradientType; } +SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorShader) + /////////////////////////////////////////////////////////////////////////////// #include "SkEmptyShader.h" @@ -363,3 +365,4 @@ void SkEmptyShader::flatten(SkFlattenableWriteBuffer& buffer) { this->INHERITED::flatten(buffer); } +SK_DEFINE_FLATTENABLE_REGISTRAR(SkEmptyShader) diff --git a/src/effects/Sk2DPathEffect.cpp b/src/effects/Sk2DPathEffect.cpp index 37296108cb..23037f7abc 100644 --- a/src/effects/Sk2DPathEffect.cpp +++ b/src/effects/Sk2DPathEffect.cpp @@ -117,5 +117,6 @@ void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) { dst->addPath(fPath, loc.fX, loc.fY); } -SK_DEFINE_FLATTENABLE_REGISTRAR(SkPath2DPathEffect) +/////////////////////////////////////////////////////////////////////////////// +SK_DEFINE_FLATTENABLE_REGISTRAR(SkPath2DPathEffect) diff --git a/src/effects/SkEffects.cpp b/src/effects/SkEffects.cpp deleted file mode 100644 index d4ccac0600..0000000000 --- a/src/effects/SkEffects.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkTypes.h" - -#if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS - -#include "Sk1DPathEffect.h" -#include "Sk2DPathEffect.h" -#include "SkAvoidXfermode.h" -#include "SkBlurDrawLooper.h" -#include "SkBlurImageFilter.h" -#include "SkBlurMaskFilter.h" -#include "SkColorFilter.h" -#include "SkColorMatrixFilter.h" -#include "SkCornerPathEffect.h" -#include "SkDashPathEffect.h" -#include "SkDiscretePathEffect.h" -#include "SkEffects.h" -#include "SkFlattenable.h" -#include "SkGradientShader.h" -#include "SkGroupShape.h" -#include "SkLayerDrawLooper.h" -#include "SkLayerRasterizer.h" -#include "SkPathEffect.h" -#include "SkPixelXorXfermode.h" -#include "SkRectShape.h" - -void SkEffects::Init() { - SkAvoidXfermode::Init(); - SkBlurDrawLooper::Init(); - SkBlurImageFilter::Init(); - SkBlurMaskFilter::Init(); - SkColorFilter::Init(); - SkColorMatrixFilter::Init(); - SkCornerPathEffect::Init(); - SkDashPathEffect::Init(); - SkDiscretePathEffect::Init(); - SkGradientShader::Init(); - SkGroupShape::Init(); - SkLayerDrawLooper::Init(); - SkLayerRasterizer::Init(); - SkPath1DPathEffect::Init(); - SkPath2DPathEffect::Init(); - SkPixelXorXfermode::Init(); - SkRectShape::Init(); -} - -#endif diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp index 4bbc96c42f..c9929b4180 100644 --- a/src/effects/SkGradientShader.cpp +++ b/src/effects/SkGradientShader.cpp @@ -861,8 +861,6 @@ public: buffer.writeScalar(fEnd.fY); } - SK_DECLARE_FLATTENABLE_REGISTRAR() - protected: Linear_Gradient(SkFlattenableReadBuffer& buffer) : Gradient_Shader(buffer), @@ -2559,8 +2557,6 @@ SkShader* SkGradientShader::CreateSweep(SkScalar cx, SkScalar cy, SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkGradientShader) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Linear_Gradient) SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Radial_Gradient) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Sweep_Gradient) - SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(Two_Point_Radial_Gradient) SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 800d4a9ce4..5d71e239e9 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -218,3 +218,7 @@ SkColorFilter* SkTableColorFilter::CreateARGB(const uint8_t tableA[256], const uint8_t tableB[256]) { return SkNEW_ARGS(SkTable_ColorFilter, (tableA, tableR, tableG, tableB)); } + +SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkTableColorFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkTable_ColorFilter) +SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END diff --git a/src/effects/SkTestImageFilters.cpp b/src/effects/SkTestImageFilters.cpp index a772f64510..6378bc68b8 100755 --- a/src/effects/SkTestImageFilters.cpp +++ b/src/effects/SkTestImageFilters.cpp @@ -399,3 +399,8 @@ SkFlattenable::Factory SkDownSampleImageFilter::getFactory() { return CreateProc; } +SK_DEFINE_FLATTENABLE_REGISTRAR(SkOffsetImageFilter) +SK_DEFINE_FLATTENABLE_REGISTRAR(SkComposeImageFilter) +SK_DEFINE_FLATTENABLE_REGISTRAR(SkMergeImageFilter) +SK_DEFINE_FLATTENABLE_REGISTRAR(SkColorFilterImageFilter) +SK_DEFINE_FLATTENABLE_REGISTRAR(SkDownSampleImageFilter) diff --git a/src/ports/SkGlobalInitialization_chromium.cpp b/src/ports/SkGlobalInitialization_chromium.cpp index 6a7b213944..5a2119e5dd 100644 --- a/src/ports/SkGlobalInitialization_chromium.cpp +++ b/src/ports/SkGlobalInitialization_chromium.cpp @@ -17,15 +17,17 @@ #include "SkXfermode.h" void SkFlattenable::InitializeFlattenables() { - SkBitmapProcShader::Init(); - SkBlurImageFilter::Init(); - SkBlurMaskFilter::Init(); - SkColorFilter::Init(); - SkCornerPathEffect::Init(); - SkDashPathEffect::Init(); - SkGradientShader::Init(); - SkLayerDrawLooper::Init(); - SkXfermode::Init(); + + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapProcShader) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper) + + SkBlurMaskFilter::InitializeFlattenables(); + SkColorFilter::InitializeFlattenables(); + SkGradientShader::InitializeFlattenables(); + SkXfermode::InitializeFlattenables(); } void SkPixelRef::InitializeFlattenables() { diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp index 6be776a0fd..a03b922000 100644 --- a/src/ports/SkGlobalInitialization_default.cpp +++ b/src/ports/SkGlobalInitialization_default.cpp @@ -10,7 +10,6 @@ #if !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS #include "SkBitmapProcShader.h" -#include "SkEffects.h" #include "SkFlipPixelRef.h" #include "SkImageRef_ashmem.h" #include "SkImageRef_GlobalPool.h" @@ -20,12 +19,70 @@ #include "SkShape.h" #include "SkXfermode.h" +#include "Sk1DPathEffect.h" +#include "Sk2DPathEffect.h" +#include "SkAvoidXfermode.h" +#include "SkBlurDrawLooper.h" +#include "SkBlurImageFilter.h" +#include "SkBlurMaskFilter.h" +#include "SkColorFilter.h" +#include "SkColorMatrixFilter.h" +#include "SkColorShader.h" +#include "SkCornerPathEffect.h" +#include "SkDashPathEffect.h" +#include "SkDiscretePathEffect.h" +#include "SkEmptyShader.h" +#include "SkFlattenable.h" +#include "SkGradientShader.h" +#include "SkGroupShape.h" +#include "SkLayerDrawLooper.h" +#include "SkLayerRasterizer.h" +#include "SkMorphologyImageFilter.h" +#include "SkPathEffect.h" +#include "SkPixelXorXfermode.h" +#include "SkRectShape.h" +#include "SkTableColorFilter.h" +#include "SkTestImageFilters.h" + void SkFlattenable::InitializeFlattenables() { - SkBitmapProcShader::Init(); - SkEffects::Init(); - SkPathEffect::Init(); - SkShape::Init(); - SkXfermode::Init(); + + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkAvoidXfermode) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBitmapProcShader) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurDrawLooper) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorMatrixFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorShader) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposePathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkCornerPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDashPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDilateImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiscretePathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkEmptyShader) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkErodeImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkGroupShape) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerDrawLooper) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLayerRasterizer) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath1DPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPath2DPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPixelXorXfermode) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkRectShape) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkStrokePathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSumPathEffect) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkShape) + + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOffsetImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkMergeImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkColorFilterImageFilter) + SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDownSampleImageFilter) + + SkBlurMaskFilter::InitializeFlattenables(); + SkColorFilter::InitializeFlattenables(); + SkGradientShader::InitializeFlattenables(); + SkTableColorFilter::InitializeFlattenables(); + SkXfermode::InitializeFlattenables(); + + } void SkPixelRef::InitializeFlattenables() { diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp index 3b28fe766d..72a5c9299c 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -415,12 +415,7 @@ static void appendPtr(SkString* str, const void* ptr, const char name[]) { static void appendFlattenable(SkString* str, const SkFlattenable* ptr, const char name[]) { if (ptr) { - SkString info; - if (ptr->toDumpString(&info)) { - str->appendf(" %s", info.c_str()); - } else { - str->appendf(" %s:%p", name, ptr); - } + str->appendf(" %s:%p", name, ptr); } } -- 2.34.1