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

Unified Diff: include/core/SkFlattenableBuffers.h

Issue 26702002: force readbuffer clients to use specialized readFoo for flattenables (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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
« no previous file with comments | « no previous file | src/core/SkAnnotation.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkFlattenableBuffers.h
diff --git a/include/core/SkFlattenableBuffers.h b/include/core/SkFlattenableBuffers.h
index 03c03f3877e6f8e3f508d29e371d5c7ebd91624e..7a5cf811ac6f572aee9ac4e7a20a57947370dd39 100644
--- a/include/core/SkFlattenableBuffers.h
+++ b/include/core/SkFlattenableBuffers.h
@@ -29,6 +29,30 @@ class SkString;
class SkTypeface;
class SkWStream;
+class SkAnnotation;
+class SkColorTable;
+class SkData;
+class SkDataSet;
+class SkDrawLooper;
+class SkLight;
+class SkPixelRef;
+class SkUnitMapper;
+
+enum SkEffectType {
+ kColorFilter_SkEffectType,
+ kDrawLooper_SkEffectType,
+ kImageFilter_SkEffectType,
+ kMaskFilter_SkEffectType,
+ kPathEffect_SkEffectType,
+ kPixelRef_SkEffectType,
+ kRasterizer_SkEffectType,
+ kShader_SkEffectType,
+ kUnitMapper_SkEffectType,
+ kXfermode_SkEffectType,
+
+ kLight_SkEffectType,
+};
+
class SkFlattenableReadBuffer {
public:
SkFlattenableReadBuffer();
@@ -63,8 +87,63 @@ public:
virtual void readString(SkString* string) = 0;
virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) = 0;
+ SkFlattenable* readEffect(SkEffectType);
+
+ SkColorFilter* readColorFilter() {
+ return (SkColorFilter*)this->readEffect(kColorFilter_SkEffectType);
+ }
+ SkDrawLooper* readDrawLooper() {
+ return (SkDrawLooper*)this->readEffect(kDrawLooper_SkEffectType);
+ }
+ SkImageFilter* readImageFilter() {
+ return (SkImageFilter*)this->readEffect(kImageFilter_SkEffectType);
+ }
+ SkMaskFilter* readMaskFilter() {
+ return (SkMaskFilter*)this->readEffect(kMaskFilter_SkEffectType);
+ }
+ SkPathEffect* readPathEffect() {
+ return (SkPathEffect*)this->readEffect(kPathEffect_SkEffectType);
+ }
+ SkPixelRef* readPixelRef() {
+ return (SkPixelRef*)this->readEffect(kPixelRef_SkEffectType);
+ }
+ SkRasterizer* readRasterizer() {
+ return (SkRasterizer*)this->readEffect(kRasterizer_SkEffectType);
+ }
+ SkShader* readShader() {
+ return (SkShader*)this->readEffect(kShader_SkEffectType);
+ }
+ SkUnitMapper* readUnitMapper() {
+ return (SkUnitMapper*)this->readEffect(kUnitMapper_SkEffectType);
+ }
+ SkXfermode* readXfermode() {
+ return (SkXfermode*)this->readEffect(kXfermode_SkEffectType);
+ }
+
+ // Does support subclasses, but is internal to our impl, and is not in
+ // core...
+ //
+ SkLight* readLight() {
+ return (SkLight*)this->readEffect(kLight_SkEffectType);
+ }
+
+ // These flattenables do *not* support subclassing, so perhaps need not
+ // actually inherit from SkFlattenable
+ //
+ SkAnnotation* readAnnotation() {
+ return (SkAnnotation*)this->readAnnotation();
+ }
+ SkColorTable* readColorTable() {
+ return (SkColorTable*)this->readColorTable();
+ }
+ SkData* readData() {
+ return (SkData*)this->readFlattenable();
+ }
+ SkDataSet* readDataSet() {
+ return (SkDataSet*)this->readFlattenable();
+ }
+
// common data structures
- virtual SkFlattenable* readFlattenable() = 0;
virtual void readPoint(SkPoint* point) = 0;
virtual void readMatrix(SkMatrix* matrix) = 0;
virtual void readIRect(SkIRect* rect) = 0;
@@ -98,11 +177,15 @@ public:
return point;
}
+#if 0
template <typename T> T* readFlattenableT() {
sugoi 2013/10/09 20:26:55 Ok, so I've been thinking about this. Even though
return static_cast<T*>(this->readFlattenable());
}
+#endif
private:
+ virtual SkFlattenable* readFlattenable() = 0;
+
uint32_t fFlags;
};
« no previous file with comments | « no previous file | src/core/SkAnnotation.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698