aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-11 05:58:58 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-11 05:58:58 +0000
commit0faac1e8579088a39f38d02ff675f14d7deb608d (patch)
tree4e4cdee1aa1af6b2012bc0aa7ab9ccdcd097dc56
parentc1c5b15e41eaae5edeb032d994a619ea05c3d0a5 (diff)
remove some dead code in pipes
inherit from SampleView for more samples add L key to toggle using SkGPipe git-svn-id: http://skia.googlecode.com/svn/trunk@1296 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--samplecode/SampleApp.cpp28
-rw-r--r--samplecode/SampleBigGradient.cpp9
-rw-r--r--samplecode/SampleCode.h7
-rw-r--r--samplecode/SampleComplexClip.cpp4
-rw-r--r--samplecode/SampleDitherBitmap.cpp14
-rw-r--r--samplecode/SampleEncode.cpp37
-rw-r--r--samplecode/SampleExtractAlpha.cpp14
-rw-r--r--samplecode/SampleGM.cpp12
-rw-r--r--samplecode/SamplePath.cpp54
-rw-r--r--samplecode/SamplePolyToPoly.cpp12
-rw-r--r--samplecode/SampleTiling.cpp9
-rw-r--r--src/pipe/SkGPipePriv.h19
-rw-r--r--src/pipe/SkGPipeRead.cpp104
-rw-r--r--src/pipe/SkGPipeWrite.cpp7
14 files changed, 91 insertions, 239 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 7ab6609fdb..bbde4144ed 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -284,6 +284,7 @@ private:
bool fRotate;
bool fScale;
bool fRequestGrabImage;
+ bool fUsePipe;
bool fMeasureFPS;
SkMSec fMeasureFPS_Time;
@@ -423,6 +424,7 @@ SampleWindow::SampleWindow(void* hwnd) : INHERITED(hwnd) {
fRotate = false;
fScale = false;
fRequestGrabImage = false;
+ fUsePipe = false;
fMeasureFPS = false;
fLCDState = kUnknown_SkTriState;
fAAState = kUnknown_SkTriState;
@@ -861,6 +863,7 @@ void SampleWindow::beforeChild(SkView* child, SkCanvas* canvas) {
} else {
(void)SampleView::SetRepeatDraw(child, 1);
}
+ (void)SampleView::SetUsePipe(child, fUsePipe);
}
void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) {
@@ -1034,6 +1037,10 @@ bool SampleWindow::onHandleChar(SkUnichar uni) {
case 'o':
this->zoomOut();
break;
+ case 'p':
+ fUsePipe = !fUsePipe;
+ this->inval(NULL);
+ break;
case 'r':
fRotate = !fRotate;
this->inval(NULL);
@@ -1315,6 +1322,7 @@ void SampleWindow::onSizeChange() {
///////////////////////////////////////////////////////////////////////////////
static const char repeat_count_tag[] = "sample-set-repeat-count";
+static const char set_use_pipe_tag[] = "sample-set-use-pipe";
bool SampleView::SetRepeatDraw(SkView* view, int count) {
SkEvent evt(repeat_count_tag);
@@ -1322,11 +1330,21 @@ bool SampleView::SetRepeatDraw(SkView* view, int count) {
return view->doEvent(evt);
}
+bool SampleView::SetUsePipe(SkView* view, bool pred) {
+ SkEvent evt(set_use_pipe_tag);
+ evt.setFast32(pred);
+ return view->doEvent(evt);
+}
+
bool SampleView::onEvent(const SkEvent& evt) {
if (evt.isType(repeat_count_tag)) {
fRepeatCount = evt.getFast32();
return true;
}
+ if (evt.isType(set_use_pipe_tag)) {
+ fUsePipe = !!evt.getFast32();
+ return true;
+ }
return this->INHERITED::onEvent(evt);
}
@@ -1370,8 +1388,10 @@ SimplePC::~SimplePC() {
// SkASSERT(SkGPipeReader::kDone_Status == fStatus);
sk_free(fBlock);
- SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten,
- fAtomsWritten, fStatus);
+ if (fTotalWritten) {
+ SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten,
+ fAtomsWritten, fStatus);
+ }
}
void* SimplePC::requestBlock(size_t minRequest, size_t* actual) {
@@ -1404,7 +1424,9 @@ void SampleView::onDraw(SkCanvas* canvas) {
#ifdef TEST_GPIPE
SimplePC controller(canvas);
SkGPipeWriter writer;
- canvas = writer.startRecording(&controller);
+ if (fUsePipe) {
+ canvas = writer.startRecording(&controller);
+ }
#endif
for (int i = 0; i < fRepeatCount; i++) {
diff --git a/samplecode/SampleBigGradient.cpp b/samplecode/SampleBigGradient.cpp
index 5d6d247bcd..5ebb5162f3 100644
--- a/samplecode/SampleBigGradient.cpp
+++ b/samplecode/SampleBigGradient.cpp
@@ -10,7 +10,7 @@ static SkShader* make_grad(SkScalar w, SkScalar h) {
SkShader::kClamp_TileMode);
}
-class BigGradientView : public SkView {
+class BigGradientView : public SampleView {
public:
BigGradientView() {}
@@ -24,10 +24,7 @@ protected:
return this->INHERITED::onQuery(evt);
}
- void drawBG(SkCanvas* canvas) {
- }
-
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDrawContent(SkCanvas* canvas) {
SkRect r;
r.set(0, 0, this->width(), this->height());
SkPaint p;
@@ -36,7 +33,7 @@ protected:
}
private:
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleCode.h b/samplecode/SampleCode.h
index 0c706ee3d1..de40d1e025 100644
--- a/samplecode/SampleCode.h
+++ b/samplecode/SampleCode.h
@@ -49,11 +49,14 @@ private:
class SampleView : public SkView {
public:
- SampleView() : fRepeatCount(1), fBGColor(SK_ColorWHITE) {}
+ SampleView() : fRepeatCount(1), fBGColor(SK_ColorWHITE) {
+ fUsePipe = false;
+ }
void setBGColor(SkColor color) { fBGColor = color; }
static bool SetRepeatDraw(SkView*, int count);
+ static bool SetUsePipe(SkView*, bool);
protected:
virtual void onDrawBackground(SkCanvas*);
@@ -68,6 +71,8 @@ private:
int fRepeatCount;
SkColor fBGColor;
+ bool fUsePipe;
+
typedef SkView INHERITED;
};
diff --git a/samplecode/SampleComplexClip.cpp b/samplecode/SampleComplexClip.cpp
index 29bc8050c2..8ee078b2fa 100644
--- a/samplecode/SampleComplexClip.cpp
+++ b/samplecode/SampleComplexClip.cpp
@@ -136,10 +136,6 @@ protected:
canvas->restore();
}
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
- this->inval(NULL);
- return this->INHERITED::onFindClickHandler(x, y);
- }
private:
typedef SampleView INHERITED;
};
diff --git a/samplecode/SampleDitherBitmap.cpp b/samplecode/SampleDitherBitmap.cpp
index 1000fdfaa0..91199c2ec9 100644
--- a/samplecode/SampleDitherBitmap.cpp
+++ b/samplecode/SampleDitherBitmap.cpp
@@ -70,7 +70,7 @@ static SkBitmap make_bitmap() {
return bm;
}
-class DitherBitmapView : public SkView {
+class DitherBitmapView : public SampleView {
SkBitmap fBM8;
SkBitmap fBM32;
public:
@@ -78,6 +78,8 @@ public:
test_pathregion();
fBM8 = make_bitmap();
fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config);
+
+ this->setBGColor(0xFFDDDDDD);
}
protected:
@@ -90,10 +92,6 @@ protected:
return this->INHERITED::onQuery(evt);
}
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
- }
-
static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) {
SkAutoLockPixels alp(*bm); // needed for ctable
bm->setIsOpaque(isOpaque);
@@ -121,9 +119,7 @@ protected:
canvas->drawBitmap(bitmap, x, SkIntToScalar(bm.height() + 10), &paint);
}
- virtual void onDraw(SkCanvas* canvas) {
- drawBG(canvas);
-
+ virtual void onDrawContent(SkCanvas* canvas) {
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
draw2(canvas, fBM8);
@@ -135,7 +131,7 @@ protected:
}
private:
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleEncode.cpp b/samplecode/SampleEncode.cpp
index b09b2ebef6..f4ea1950aa 100644
--- a/samplecode/SampleEncode.cpp
+++ b/samplecode/SampleEncode.cpp
@@ -106,7 +106,7 @@ static void make_name(SkString* name, int config, int ext) {
#include <sys/stat.h>
-class EncodeView : public SkView {
+class EncodeView : public SampleView {
public:
SkBitmap* fBitmaps;
size_t fBitmapCount;
@@ -140,6 +140,7 @@ public:
fBitmaps = NULL;
fBitmapCount = 0;
#endif
+ this->setBGColor(0xFFDDDDDD);
}
virtual ~EncodeView() {
@@ -156,38 +157,12 @@ protected:
return this->INHERITED::onQuery(evt);
}
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
-// canvas->drawColor(SK_ColorWHITE);
- }
-
- virtual void onDraw(SkCanvas* canvas) {
- this->drawBG(canvas);
-
+ virtual void onDrawContent(SkCanvas* canvas) {
if (fBitmapCount == 0) {
return;
}
SkPaint paint;
- if (false) {
-// SkColor colors[] = { 0xFE000000, SK_ColorWHITE };
- SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
- SkShader* shader = SkGradientShader::CreateSweep(SkIntToScalar(50), SkIntToScalar(50),
- colors, NULL, 2);
- paint.setShader(shader)->unref();
-
- SkRect r;
- r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100));
- canvas->drawRect(r, paint);
-
- canvas->translate(SkIntToScalar(200), SkIntToScalar(200));
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(SkIntToScalar(10));
- canvas->drawOval(r, paint);
- return;
- }
-
paint.setAntiAlias(true);
paint.setTextAlign(SkPaint::kCenter_Align);
@@ -238,12 +213,8 @@ protected:
return this->INHERITED::onFindClickHandler(x, y);
}
- virtual bool onClick(Click* click) {
- return this->INHERITED::onClick(click);
- }
-
private:
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleExtractAlpha.cpp b/samplecode/SampleExtractAlpha.cpp
index 928f2ca8fa..860272d892 100644
--- a/samplecode/SampleExtractAlpha.cpp
+++ b/samplecode/SampleExtractAlpha.cpp
@@ -40,7 +40,7 @@ static SkBitmap make_bitmap() {
return bm;
}
-class ExtractAlphaView : public SkView {
+class ExtractAlphaView : public SampleView {
SkBitmap fBM8;
SkBitmap fBM32;
SkBitmap fBM4;
@@ -49,6 +49,8 @@ public:
fBM8 = make_bitmap();
fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config);
fBM8.copyTo(&fBM4, SkBitmap::kARGB_4444_Config);
+
+ this->setBGColor(0xFFDDDDDD);
}
protected:
@@ -61,13 +63,7 @@ protected:
return this->INHERITED::onQuery(evt);
}
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
- }
-
- virtual void onDraw(SkCanvas* canvas) {
- drawBG(canvas);
-
+ virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
@@ -84,7 +80,7 @@ protected:
}
private:
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleGM.cpp b/samplecode/SampleGM.cpp
index 5c9ea76c93..2f9f046d3f 100644
--- a/samplecode/SampleGM.cpp
+++ b/samplecode/SampleGM.cpp
@@ -44,13 +44,15 @@ private:
///////////////////////////////////////////////////////////////////////////////
-class GMView : public SkView {
+class GMView : public SampleView {
Iter fIter;
GM* fGM;
public:
GMView() {
fGM = fIter.next();
this->postNextGM();
+
+ this->setBGColor(0xFFDDDDDD);
}
protected:
@@ -77,11 +79,7 @@ protected:
return this->INHERITED::onEvent(evt);
}
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
- }
-
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDrawContent(SkCanvas* canvas) {
fGM->draw(canvas);
}
@@ -90,7 +88,7 @@ private:
(new SkEvent("next-gm"))->post(this->getSinkID(), 1500);
}
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 187de223a0..4fef377a97 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -74,7 +74,7 @@ static void test_cubic2() {
canvas.drawPath(path, paint);
}
-class PathView : public SkView {
+class PathView : public SampleView {
public:
int fDStroke, fStroke, fMinStroke, fMaxStroke;
SkPath fPath[6];
@@ -116,14 +116,11 @@ public:
fPath[5].moveTo(SkIntToScalar(52), SkIntToScalar(50));
fPath[5].lineTo(SkIntToScalar(50), SkIntToScalar(V));
fPath[5].lineTo(SkIntToScalar(50), SkIntToScalar(50));
+
+ this->setBGColor(0xFFDDDDDD);
}
- virtual ~PathView()
- {
- }
-
- void nextStroke()
- {
+ void nextStroke() {
fStroke += fDStroke;
if (fStroke > fMaxStroke || fStroke < fMinStroke)
fDStroke = -fDStroke;
@@ -131,24 +128,15 @@ public:
protected:
// overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt)
- {
- if (SampleCode::TitleQ(*evt))
- {
+ virtual bool onQuery(SkEvent* evt) {
+ if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Paths");
return true;
}
return this->INHERITED::onQuery(evt);
}
- void drawBG(SkCanvas* canvas)
- {
- canvas->drawColor(0xFFDDDDDD);
-// canvas->drawColor(SK_ColorWHITE);
- }
-
- void drawPath(SkCanvas* canvas, const SkPath& path, SkPaint::Join j)
- {
+ void drawPath(SkCanvas* canvas, const SkPath& path, SkPaint::Join j) {
SkPaint paint;
paint.setAntiAlias(true);
@@ -156,26 +144,22 @@ protected:
paint.setStrokeJoin(j);
paint.setStrokeWidth(SkIntToScalar(fStroke));
- if (fShowHairline)
- {
+ if (fShowHairline) {
SkPath fill;
paint.getFillPath(path, &fill);
paint.setStrokeWidth(0);
canvas->drawPath(fill, paint);
- }
- else
+ } else {
canvas->drawPath(path, paint);
+ }
paint.setColor(SK_ColorRED);
paint.setStrokeWidth(0);
canvas->drawPath(path, paint);
}
- virtual void onDraw(SkCanvas* canvas)
- {
- this->drawBG(canvas);
-
+ virtual void onDrawContent(SkCanvas* canvas) {
canvas->translate(SkIntToScalar(50), SkIntToScalar(50));
static const SkPaint::Join gJoins[] = {
@@ -184,11 +168,9 @@ protected:
SkPaint::kRound_Join
};
- for (int i = 0; i < SK_ARRAY_COUNT(gJoins); i++)
- {
+ for (int i = 0; i < SK_ARRAY_COUNT(gJoins); i++) {
canvas->save();
- for (int j = 0; j < SK_ARRAY_COUNT(fPath); j++)
- {
+ for (int j = 0; j < SK_ARRAY_COUNT(fPath); j++) {
this->drawPath(canvas, fPath[j], gJoins[i]);
canvas->translate(SkIntToScalar(200), 0);
}
@@ -201,20 +183,14 @@ protected:
this->inval(NULL);
}
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y)
- {
+ virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
fShowHairline = !fShowHairline;
this->inval(NULL);
return this->INHERITED::onFindClickHandler(x, y);
}
- virtual bool onClick(Click* click)
- {
- return this->INHERITED::onClick(click);
- }
-
private:
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SamplePolyToPoly.cpp b/samplecode/SamplePolyToPoly.cpp
index ccfe430e42..29a47f7109 100644
--- a/samplecode/SamplePolyToPoly.cpp
+++ b/samplecode/SamplePolyToPoly.cpp
@@ -8,7 +8,7 @@
extern bool SkSetPoly3To3(SkMatrix* matrix, const SkPoint src[3], const SkPoint dst[3]);
-class PolyToPolyView : public SkView {
+class PolyToPolyView : public SampleView {
public:
PolyToPolyView() {
// tests
@@ -72,10 +72,6 @@ protected:
return this->INHERITED::onQuery(evt);
}
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(SK_ColorWHITE);
- }
-
static void doDraw(SkCanvas* canvas, SkPaint* paint, const int isrc[],
const int idst[], int count) {
SkMatrix matrix;
@@ -110,9 +106,7 @@ protected:
canvas->restore();
}
- virtual void onDraw(SkCanvas* canvas) {
- this->drawBG(canvas);
-
+ virtual void onDrawContent(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStrokeWidth(SkIntToScalar(4));
@@ -153,7 +147,7 @@ protected:
}
private:
- typedef SkView INHERITED;
+ typedef SampleView INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index 025049e191..b3c73d7f58 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -151,15 +151,6 @@ protected:
canvas->drawPicture(fTextPicture);
}
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
- this->inval(NULL);
- return this->INHERITED::onFindClickHandler(x, y);
- }
-
- virtual bool onClick(Click* click) {
- return this->INHERITED::onClick(click);
- }
-
private:
typedef SampleView INHERITED;
};
diff --git a/src/pipe/SkGPipePriv.h b/src/pipe/SkGPipePriv.h
index 30d8b9324a..c3b4e4c992 100644
--- a/src/pipe/SkGPipePriv.h
+++ b/src/pipe/SkGPipePriv.h
@@ -25,6 +25,7 @@
// these must be contiguous, 0...N-1
enum PaintFlats {
kColorFilter_PaintFlat,
+ kDrawLooper_PaintFlat,
kMaskFilter_PaintFlat,
kPathEffect_PaintFlat,
kRasterizer_PaintFlat,
@@ -71,16 +72,8 @@ enum DrawOps {
kPaintOp_DrawOp,
- kDef_PaintFlat_DrawOp,
-
- kDef_ColorFilter_DrawOp,
- kDef_DrawLooper_DrawOp,
- kDef_MaskFilter_DrawOp,
- kDef_PathEffect_DrawOp,
- kDef_Rasterizer_DrawOp,
- kDef_Shader_DrawOp,
kDef_Typeface_DrawOp,
- kDef_Xfermode_DrawOp,
+ kDef_Flattenable_DrawOp,
// these are signals to playback, not drawing verbs
kDone_DrawOp,
@@ -170,14 +163,6 @@ enum PaintOps {
kTypeface_PaintOp, // arg inline (index) - text
kFlatIndex_PaintOp, // flags=paintflat, data=index
-
- kPathEffect_PaintOp,
- kShader_PaintOp,
- kXfermode_PaintOp,
- kMaskFilter_PaintOp,
- kColorFilter_PaintOp,
- kRasterizer_PaintOp,
- kDrawLooper_PaintOp,
};
#define PAINTOPS_OP_BITS 8
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index d33258c85a..ee20d80890 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -37,6 +37,9 @@ static void set_paintflat(SkPaint* paint, SkFlattenable* obj, unsigned paintFlat
case kColorFilter_PaintFlat:
paint->setColorFilter((SkColorFilter*)obj);
break;
+ case kDrawLooper_PaintFlat:
+ paint->setLooper((SkDrawLooper*)obj);
+ break;
case kMaskFilter_PaintFlat:
paint->setMaskFilter((SkMaskFilter*)obj);
break;
@@ -94,53 +97,10 @@ public:
const void* data = fReader->skip(SkAlign4(size));
SkMemoryStream stream(data, size, false);
*fTypefaces.append() = SkTypeface::Deserialize(&stream);
- }
- void addColorFilter() {
- *fColorFilters.append() = (SkColorFilter*)fReader->readFlattenable();
- }
- void addDrawLooper() {
- *fDrawLoopers.append() = (SkDrawLooper*)fReader->readFlattenable();
- }
- void addMaskFilter() {
- *fMaskFilters.append() = (SkMaskFilter*)fReader->readFlattenable();
- }
- void addPathEffect() {
- *fPathEffects.append() = (SkPathEffect*)fReader->readFlattenable();
- }
- void addRasterizer() {
- *fRasterizers.append() = (SkRasterizer*)fReader->readFlattenable();
- }
- void addShader() {
- *fShaders.append() = (SkShader*)fReader->readFlattenable();
- }
- void addXfermode() {
- *fXfermodes.append() = (SkXfermode*)fReader->readFlattenable();
- }
-
- void setColorFilter(SkPaint* paint, unsigned id) {
- paint->setColorFilter(id ? fColorFilters[id - 1] : NULL);
- }
- void setLooper(SkPaint* paint, unsigned id) {
- paint->setLooper(id ? fDrawLoopers[id - 1] : NULL);
- }
- void setMaskFilter(SkPaint* paint, unsigned id) {
- paint->setMaskFilter(id ? fMaskFilters[id - 1] : NULL);
- }
- void setPathEffect(SkPaint* paint, unsigned id) {
- paint->setPathEffect(id ? fPathEffects[id - 1] : NULL);
- }
- void setRasterizer(SkPaint* paint, unsigned id) {
- paint->setRasterizer(id ? fRasterizers[id - 1] : NULL);
- }
- void setShader(SkPaint* paint, unsigned id) {
- paint->setShader(id ? fShaders[id - 1] : NULL);
- }
+ }
void setTypeface(SkPaint* paint, unsigned id) {
paint->setTypeface(id ? fTypefaces[id - 1] : NULL);
}
- void setXfermode(SkPaint* paint, unsigned id) {
- paint->setXfermode(id ? fXfermodes[id - 1] : NULL);
- }
SkFlattenableReadBuffer* fReader;
SkTDArray<SkFlattenable*> fFlatArray;
@@ -489,13 +449,6 @@ static void paintOp_rp(SkCanvas*, SkReader32* reader, uint32_t op32,
}
case kTypeface_PaintOp: state->setTypeface(p, data); break;
- case kPathEffect_PaintOp: state->setPathEffect(p, data); break;
- case kShader_PaintOp: state->setShader(p, data); break;
- case kXfermode_PaintOp: state->setXfermode(p, data); break;
- case kMaskFilter_PaintOp: state->setMaskFilter(p, data); break;
- case kColorFilter_PaintOp: state->setColorFilter(p, data); break;
- case kRasterizer_PaintOp: state->setRasterizer(p, data); break;
- case kDrawLooper_PaintOp: state->setLooper(p, data); break;
default: SkASSERT(!"bad paintop"); return;
}
SkASSERT(reader->offset() <= stop);
@@ -505,6 +458,10 @@ static void paintOp_rp(SkCanvas*, SkReader32* reader, uint32_t op32,
///////////////////////////////////////////////////////////////////////////////
+static void def_Typeface_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
+ state->addTypeface();
+}
+
static void def_PaintFlat_rp(SkCanvas*, SkReader32*, uint32_t op32,
SkGPipeState* state) {
PaintFlats pf = (PaintFlats)DrawOp_unpackFlags(op32);
@@ -512,38 +469,6 @@ static void def_PaintFlat_rp(SkCanvas*, SkReader32*, uint32_t op32,
state->defFlattenable(pf, index);
}
-static void def_ColorFilter_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addColorFilter();
-}
-
-static void def_DrawLooper_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addDrawLooper();
-}
-
-static void def_MaskFilter_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addMaskFilter();
-}
-
-static void def_PathEffect_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addPathEffect();
-}
-
-static void def_Rasterizer_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addRasterizer();
-}
-
-static void def_Shader_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addShader();
-}
-
-static void def_Typeface_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addTypeface();
-}
-
-static void def_Xfermode_rp(SkCanvas*, SkReader32*, uint32_t, SkGPipeState* state) {
- state->addXfermode();
-}
-
///////////////////////////////////////////////////////////////////////////////
static void skip_rp(SkCanvas*, SkReader32* reader, uint32_t op32, SkGPipeState*) {
@@ -586,16 +511,11 @@ static const ReadProc gReadTable[] = {
setMatrix_rp,
skew_rp,
translate_rp,
+
paintOp_rp,
- def_PaintFlat_rp,
- def_ColorFilter_rp,
- def_DrawLooper_rp,
- def_MaskFilter_rp,
- def_PathEffect_rp,
- def_Rasterizer_rp,
- def_Shader_rp,
def_Typeface_rp,
- def_Xfermode_rp,
+ def_PaintFlat_rp,
+
done_rp
};
@@ -635,6 +555,8 @@ SkGPipeReader::Status SkGPipeReader::playback(const void* data, size_t length) {
fState = new SkGPipeState;
}
+ SkASSERT(SK_ARRAY_COUNT(gReadTable) == (kDone_DrawOp + 1));
+
const ReadProc* table = gReadTable;
SkFlattenableReadBuffer reader(data, length);
SkCanvas* canvas = fCanvas;
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 04625b7e5d..0a56be6d44 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -25,6 +25,7 @@
#include "SkTypeface.h"
#include "SkWriter32.h"
#include "SkColorFilter.h"
+#include "SkDrawLooper.h"
#include "SkMaskFilter.h"
#include "SkRasterizer.h"
#include "SkShader.h"
@@ -33,6 +34,7 @@ static SkFlattenable* get_paintflat(const SkPaint& paint, unsigned paintFlat) {
SkASSERT(paintFlat < kCount_PaintFlats);
switch (paintFlat) {
case kColorFilter_PaintFlat: return paint.getColorFilter();
+ case kDrawLooper_PaintFlat: return paint.getLooper();
case kMaskFilter_PaintFlat: return paint.getMaskFilter();
case kPathEffect_PaintFlat: return paint.getPathEffect();
case kRasterizer_PaintFlat: return paint.getRasterizer();
@@ -222,7 +224,7 @@ int SkGPipeCanvas::flattenToIndex(SkFlattenable* obj, PaintFlats paintflat) {
// SkDebugf("--- add flattenable[%d] size=%d index=%d\n", paintflat, len, copy->fIndex);
if (this->needOpBytes(len)) {
- this->writeOp(kDef_PaintFlat_DrawOp, paintflat, copy->fIndex);
+ this->writeOp(kDef_Flattenable_DrawOp, paintflat, copy->fIndex);
fWriter.write(copy->data(), len);
}
}
@@ -590,7 +592,8 @@ void SkGPipeCanvas::drawTextOnPath(const void* text, size_t byteLength,
}
void SkGPipeCanvas::drawPicture(SkPicture& picture) {
- UNIMPLEMENTED
+ // we want to playback the picture into individual draw calls
+ this->INHERITED::drawPicture(picture);
}
void SkGPipeCanvas::drawShape(SkShape* shape) {