diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-31 14:32:38 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-31 14:32:38 +0000 |
commit | 076f4c9791c3710a3714452b61d61fd049601f57 (patch) | |
tree | 9a248fa84e2b592aca10a21aafa4703d5fd05be0 | |
parent | c5907e53e5caebfb3ffe3741ee7bb160192261ee (diff) |
fix LayerDrawLooper to record its fFlagsMask
convert SampleDrawLooper to a GM
git-svn-id: http://skia.googlecode.com/svn/trunk@4854 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/drawlooper.cpp (renamed from samplecode/SampleDrawLooper.cpp) | 87 | ||||
-rw-r--r-- | gyp/SampleApp.gyp | 1 | ||||
-rw-r--r-- | gyp/gmslides.gypi | 2 | ||||
-rw-r--r-- | src/effects/SkLayerDrawLooper.cpp | 2 |
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(); |