Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: include/core/SkFlattenable.h

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Minor fixes Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/core/SkFlattenable.h
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index 58e69fd416cb049b56d881942f6f77ebb676e93d..1ee828f537bda6c58c1e702ad485cd335633278f 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -16,7 +16,8 @@ class SkFlattenableReadBuffer;
class SkFlattenableWriteBuffer;
#define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
- SkFlattenable::Registrar(#flattenable, flattenable::CreateProc);
+ SkFlattenable::Registrar(#flattenable, flattenable::CreateProc, \
+ flattenable::GetEffectType());
#define SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() static void InitializeFlattenables();
@@ -35,6 +36,27 @@ class SkFlattenableWriteBuffer;
return SkNEW_ARGS(flattenable, (buffer)); \
}
+/** For SkFlattenable derived objects with a valid type
+ This macro should only be used in base class objects in core
+ */
+#define SK_DEFINE_FLATTENABLE_EFFECT_TYPE(flattenable) \
+ static SkEffectType GetEffectType() { \
+ return k##flattenable##_SkEffectType; \
+ }
+
+enum SkEffectType {
Stephen White 2013/10/16 20:27:24 Just to bikeshed a little, is SkEffectType a good
reed1 2013/10/16 20:38:16 Totally agree. I started that name, but it doesn't
+ kSkColorFilter_SkEffectType,
+ kSkDrawLooper_SkEffectType,
+ kSkImageFilter_SkEffectType,
+ kSkMaskFilter_SkEffectType,
+ kSkPathEffect_SkEffectType,
+ kSkPixelRef_SkEffectType,
+ kSkRasterizer_SkEffectType,
+ kSkShader_SkEffectType,
+ kSkUnitMapper_SkEffectType,
+ kSkXfermode_SkEffectType,
+};
+
/** \class SkFlattenable
SkFlattenable is the base class for objects that need to be flattened
@@ -55,14 +77,20 @@ public:
*/
virtual Factory getFactory() = 0;
+ /** Returns the name of the object's class
+ */
+ const char* getTypeName() { return FactoryToName(getFactory()); }
+
static Factory NameToFactory(const char name[]);
static const char* FactoryToName(Factory);
- static void Register(const char name[], Factory);
+ static bool NameToType(const char name[], SkEffectType* type);
+
+ static void Register(const char name[], Factory, SkEffectType);
class Registrar {
public:
- Registrar(const char name[], Factory factory) {
- SkFlattenable::Register(name, factory);
+ Registrar(const char name[], Factory factory, SkEffectType type) {
+ SkFlattenable::Register(name, factory, type);
}
};
@@ -75,7 +103,7 @@ protected:
virtual void flatten(SkFlattenableWriteBuffer&) const;
private:
- static void InitializeFlattenables();
+ static void InitializeFlattenablesIfNeeded();
friend class SkGraphics;
friend class SkFlattenableWriteBuffer;

Powered by Google App Engine
This is Rietveld 408576698