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

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/SkBitmap.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 8e1652a775a67bdd84290bd27a7b05c8536f2058..51016c737ffbc705b697809830c0ad0ab9164c5c 100644
--- a/include/core/SkFlattenableBuffers.h
+++ b/include/core/SkFlattenableBuffers.h
@@ -15,6 +15,7 @@
#include "SkPoint.h"
class SkBitmap;
+class SkDrawLooper;
class SkFlattenable;
struct SkIRect;
class SkMatrix;
@@ -28,8 +29,22 @@ class SkRegion;
class SkStream;
class SkString;
class SkTypeface;
+class SkUnitMapper;
class SkWStream;
+enum SkEffectType {
+ kColorFilter_SkEffectType,
+ kDrawLooper_SkEffectType,
+ kImageFilter_SkEffectType,
+ kMaskFilter_SkEffectType,
+ kPathEffect_SkEffectType,
+ kPixelRef_SkEffectType,
+ kRasterizer_SkEffectType,
+ kShader_SkEffectType,
+ kUnitMapper_SkEffectType,
+ kXfermode_SkEffectType,
+};
+
class SkFlattenableReadBuffer {
public:
SkFlattenableReadBuffer();
@@ -64,8 +79,40 @@ public:
virtual void readString(SkString* string) = 0;
virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding) = 0;
+ virtual SkFlattenable* readFlattenable(SkEffectType) = 0;
+
+ SkColorFilter* readColorFilter() {
+ return (SkColorFilter*)this->readFlattenable(kColorFilter_SkEffectType);
+ }
+ SkDrawLooper* readDrawLooper() {
+ return (SkDrawLooper*)this->readFlattenable(kDrawLooper_SkEffectType);
+ }
+ SkImageFilter* readImageFilter() {
+ return (SkImageFilter*)this->readFlattenable(kImageFilter_SkEffectType);
+ }
+ SkMaskFilter* readMaskFilter() {
+ return (SkMaskFilter*)this->readFlattenable(kMaskFilter_SkEffectType);
+ }
+ SkPathEffect* readPathEffect() {
+ return (SkPathEffect*)this->readFlattenable(kPathEffect_SkEffectType);
+ }
+ SkPixelRef* readPixelRef() {
+ return (SkPixelRef*)this->readFlattenable(kPixelRef_SkEffectType);
+ }
+ SkRasterizer* readRasterizer() {
+ return (SkRasterizer*)this->readFlattenable(kRasterizer_SkEffectType);
+ }
+ SkShader* readShader() {
+ return (SkShader*)this->readFlattenable(kShader_SkEffectType);
+ }
+ SkUnitMapper* readUnitMapper() {
+ return (SkUnitMapper*)this->readFlattenable(kUnitMapper_SkEffectType);
+ }
+ SkXfermode* readXfermode() {
+ return (SkXfermode*)this->readFlattenable(kXfermode_SkEffectType);
+ }
+
// 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;
@@ -106,10 +153,6 @@ public:
return SkData::NewFromMalloc(buffer, len);
}
- template <typename T> T* readFlattenableT() {
- return static_cast<T*>(this->readFlattenable());
- }
-
private:
uint32_t fFlags;
};
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698