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

Unified Diff: src/pipe/SkGPipeRead.cpp

Issue 23021015: Initial error handling code (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Comments fixed 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: src/pipe/SkGPipeRead.cpp
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index e76ec1240aa005990223f51857da6d45b6ab2350..ea811afca9ef44daa96cbe2d54113369c6ee0f08 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -28,22 +28,6 @@
#include "SkTypeface.h"
#include "SkXfermode.h"
-static SkEffectType paintflat_to_effecttype(PaintFlats pf) {
- static const uint8_t gEffectTypesInPaintFlatsOrder[] = {
- kColorFilter_SkEffectType,
- kDrawLooper_SkEffectType,
- kImageFilter_SkEffectType,
- kMaskFilter_SkEffectType,
- kPathEffect_SkEffectType,
- kRasterizer_SkEffectType,
- kShader_SkEffectType,
- kXfermode_SkEffectType,
- };
-
- SkASSERT((size_t)pf < SK_ARRAY_COUNT(gEffectTypesInPaintFlatsOrder));
- return (SkEffectType)gEffectTypesInPaintFlatsOrder[pf];
-}
-
static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat) {
SkASSERT(paintFlat < kCount_PaintFlats);
switch (paintFlat) {
@@ -53,6 +37,9 @@ static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat
case kDrawLooper_PaintFlat:
paint->setLooper((SkDrawLooper*)obj);
break;
+ case kImageFilter_PaintFlat:
+ paint->setImageFilter((SkImageFilter*)obj);
+ break;
case kMaskFilter_PaintFlat:
paint->setMaskFilter((SkMaskFilter*)obj);
break;
@@ -65,9 +52,6 @@ static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat
case kShader_PaintFlat:
paint->setShader((SkShader*)obj);
break;
- case kImageFilter_PaintFlat:
- paint->setImageFilter((SkImageFilter*)obj);
- break;
case kXfermode_PaintFlat:
paint->setXfermode((SkXfermode*)obj);
break;
@@ -76,6 +60,31 @@ static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat
}
}
+static SkFlattenable* read_paintflat(SkFlattenableReadBuffer* reader, unsigned paintFlat) {
+ SkASSERT(paintFlat < kCount_PaintFlats);
+ switch (paintFlat) {
+ case kColorFilter_PaintFlat:
+ return reader->readColorFilter();
+ case kDrawLooper_PaintFlat:
+ return reader->readDrawLooper();
+ case kImageFilter_PaintFlat:
+ return reader->readImageFilter();
+ case kMaskFilter_PaintFlat:
+ return reader->readMaskFilter();
+ case kPathEffect_PaintFlat:
+ return reader->readPathEffect();
+ case kRasterizer_PaintFlat:
+ return reader->readRasterizer();
+ case kShader_PaintFlat:
+ return reader->readShader();
+ case kXfermode_PaintFlat:
+ return reader->readXfermode();
+ default:
+ SkDEBUGFAIL("never gets here");
+ }
+ return NULL;
+}
+
template <typename T> class SkRefCntTDArray : public SkTDArray<T> {
public:
~SkRefCntTDArray() { this->unrefAll(); }
@@ -122,7 +131,7 @@ public:
void defFlattenable(PaintFlats pf, int index) {
index--;
- SkFlattenable* obj = fReader->readFlattenable(paintflat_to_effecttype(pf));
+ SkFlattenable* obj = read_paintflat(fReader, pf);
if (fFlatArray.count() == index) {
*fFlatArray.append() = obj;
} else {

Powered by Google App Engine
This is Rietveld 408576698