aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/drawlooper.cpp (renamed from samplecode/SampleDrawLooper.cpp)87
-rw-r--r--gyp/SampleApp.gyp1
-rw-r--r--gyp/gmslides.gypi2
-rw-r--r--src/effects/SkLayerDrawLooper.cpp2
4 files changed, 49 insertions, 43 deletions
diff --git a/samplecode/SampleDrawLooper.cpp b/gm/drawlooper.cpp
index 7e317d764e..b4d6a18527 100644
--- a/samplecode/SampleDrawLooper.cpp
+++ b/gm/drawlooper.cpp
@@ -1,12 +1,11 @@
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SampleCode.h"
-#include "SkView.h"
+
+#include "gm.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
#include "SkRandom.h"
@@ -16,12 +15,48 @@
#define WIDTH 200
#define HEIGHT 200
-class LooperView : public SampleView {
+class DrawLooperGM : public skiagm::GM {
public:
+ DrawLooperGM() : fLooper(NULL) {
+ this->setBGColor(0xFFDDDDDD);
+ }
+
+ virtual ~DrawLooperGM() {
+ SkSafeUnref(fLooper);
+ }
+
+protected:
+ virtual SkISize onISize() {
+ return SkISize::Make(520, 160);
+ }
+
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("drawlooper");
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ this->init();
+
+ SkPaint paint;
+ paint.setTextSize(SkIntToScalar(72));
+ paint.setLooper(fLooper);
+
+ canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
+ SkIntToScalar(30), paint);
+
+ canvas->drawRectCoords(SkIntToScalar(150), SkIntToScalar(50),
+ SkIntToScalar(200), SkIntToScalar(100), paint);
+ canvas->drawText("Looper", 6, SkIntToScalar(230), SkIntToScalar(100),
+ paint);
+ }
+
+private:
SkLayerDrawLooper* fLooper;
- LooperView() {
+ void init() {
+ if (fLooper) return;
+
static const struct {
SkColor fColor;
SkPaint::Style fStyle;
@@ -34,9 +69,9 @@ public:
{ SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 },
{ 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), 3 }
};
-
+
fLooper = new SkLayerDrawLooper;
-
+
SkLayerDrawLooper::LayerInfo info;
info.fFlagsMask = SkPaint::kAntiAlias_Flag;
info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMaskFilter_Bit;
@@ -55,45 +90,13 @@ public:
paint->setMaskFilter(mf)->unref();
}
}
-
- this->setBGColor(0xFFDDDDDD);
- }
-
- virtual ~LooperView() {
- SkSafeUnref(fLooper);
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "DrawLooper");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- virtual void onDrawContent(SkCanvas* canvas) {
- SkPaint paint;
- paint.setTextSize(SkIntToScalar(72));
- paint.setLooper(fLooper);
-
- canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
- SkIntToScalar(30), paint);
-
- canvas->drawRectCoords(SkIntToScalar(150), SkIntToScalar(50),
- SkIntToScalar(200), SkIntToScalar(100), paint);
-
- canvas->drawText("Looper", 6, SkIntToScalar(230), SkIntToScalar(100),
- paint);
}
-private:
- typedef SampleView INHERITED;
+ typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
-static SkView* MyFactory() { return new LooperView; }
-static SkViewRegister reg(MyFactory);
+static skiagm::GM* MyFactory(void*) { return new DrawLooperGM; }
+static skiagm::GMRegistry reg(MyFactory);
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index bc128be28d..852d7f74bd 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -48,7 +48,6 @@
'../samplecode/SampleDegenerateTwoPtRadials.cpp',
'../samplecode/SampleDither.cpp',
'../samplecode/SampleDitherBitmap.cpp',
- '../samplecode/SampleDrawLooper.cpp',
'../samplecode/SampleEffects.cpp',
'../samplecode/SampleEmboss.cpp',
'../samplecode/SampleEmptyPath.cpp',
diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi
index 18592d62da..d1358f8062 100644
--- a/gyp/gmslides.gypi
+++ b/gyp/gmslides.gypi
@@ -22,6 +22,7 @@
'../gm/dashcubics.cpp',
'../gm/dashing.cpp',
'../gm/drawbitmaprect.cpp',
+ '../gm/drawlooper.cpp',
'../gm/extractbitmap.cpp',
'../gm/emptypath.cpp',
'../gm/filltypes.cpp',
@@ -34,6 +35,7 @@
'../gm/gradtext.cpp',
'../gm/hairmodes.cpp',
'../gm/hittestpath.cpp',
+ '../gm/image.cpp',
'../gm/imageblur.cpp',
'../gm/lighting.cpp',
'../gm/imagefiltersbase.cpp',
diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp
index 3a2685ccf9..c8da568a41 100644
--- a/src/effects/SkLayerDrawLooper.cpp
+++ b/src/effects/SkLayerDrawLooper.cpp
@@ -201,6 +201,7 @@ void SkLayerDrawLooper::flatten(SkFlattenableWriteBuffer& buffer) const {
Rec* rec = fRecs;
for (int i = 0; i < fCount; i++) {
+ buffer.writeInt(rec->fInfo.fFlagsMask);
buffer.writeInt(rec->fInfo.fPaintBits);
buffer.writeInt(rec->fInfo.fColorMode);
buffer.writeScalar(rec->fInfo.fOffset.fX);
@@ -220,6 +221,7 @@ SkLayerDrawLooper::SkLayerDrawLooper(SkFlattenableReadBuffer& buffer)
for (int i = 0; i < count; i++) {
LayerInfo info;
+ info.fFlagsMask = buffer.readInt();
info.fPaintBits = buffer.readInt();
info.fColorMode = (SkXfermode::Mode)buffer.readInt();
info.fOffset.fX = buffer.readScalar();