force readbuffer clients to use specialized readFoo for flattenables

BUG=
R=mtklein@google.com

Review URL: https://codereview.chromium.org/26702002

git-svn-id: http://skia.googlecode.com/svn/trunk@11803 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index ac0aadd..e76ec12 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -18,6 +18,7 @@
 #include "SkAnnotation.h"
 #include "SkColorFilter.h"
 #include "SkDrawLooper.h"
+#include "SkImageFilter.h"
 #include "SkMaskFilter.h"
 #include "SkOrderedReadBuffer.h"
 #include "SkPathEffect.h"
@@ -27,6 +28,22 @@
 #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) {
@@ -105,7 +122,7 @@
 
     void defFlattenable(PaintFlats pf, int index) {
         index--;
-        SkFlattenable* obj = fReader->readFlattenable();
+        SkFlattenable* obj = fReader->readFlattenable(paintflat_to_effecttype(pf));
         if (fFlatArray.count() == index) {
             *fFlatArray.append() = obj;
         } else {