aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--debugger/SkDebugCanvas.cpp11
-rw-r--r--forth/SampleForth.cpp263
-rw-r--r--src/gpu/app-android.cpp393
-rw-r--r--src/gpu/gr_hello_world.cpp37
-rw-r--r--src/utils/SkDumpCanvas.cpp17
-rw-r--r--src/utils/SkNWayCanvas.cpp7
6 files changed, 24 insertions, 704 deletions
diff --git a/debugger/SkDebugCanvas.cpp b/debugger/SkDebugCanvas.cpp
index db9154e15b..b970bb940b 100644
--- a/debugger/SkDebugCanvas.cpp
+++ b/debugger/SkDebugCanvas.cpp
@@ -11,12 +11,19 @@
#include "SkDebugCanvas.h"
#include "SkDrawCommand.h"
-SkDebugCanvas::SkDebugCanvas(int width, int height) {
+static SkBitmap make_noconfig_bm(int width, int height) {
+ SkBitmap bm;
+ bm.setConfig(SkBitmap::kNo_Config, width, height);
+ return bm;
+}
+
+SkDebugCanvas::SkDebugCanvas(int width, int height)
+ : INHERITED(make_noconfig_bm(width, height)) {
// TODO(chudy): Free up memory from all draw commands in destructor.
fWidth = width;
fHeight = height;
+ // do we need fBm anywhere?
fBm.setConfig(SkBitmap::kNo_Config, fWidth, fHeight);
- this->setBitmapDevice(fBm);
fFilter = false;
fIndex = 0;
fUserOffset.set(0,0);
diff --git a/forth/SampleForth.cpp b/forth/SampleForth.cpp
deleted file mode 100644
index 8fa6a4f7ea..0000000000
--- a/forth/SampleForth.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-
-/*
- * 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 "SkColorPriv.h"
-#include "SkGradientShader.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkUtils.h"
-#include "Forth.h"
-
-class MyOutput : public ForthOutput {
-public:
- SkString fStr;
-
- virtual void show(const char text[]) {
- fStr.set(text);
- }
-};
-
-class SkForthCtx {
-public:
- SkCanvas fCanvas;
- SkPaint fPaint;
-
- void init(const SkBitmap& bm) {
- fCanvas.setBitmapDevice(bm);
- fPaint.setAntiAlias(true);
- }
-};
-
-class SkForthCtx_FW : public ForthWord {
-public:
- SkForthCtx_FW() : fCtx(NULL) {}
-
- void setCtx(SkForthCtx* ctx) { fCtx = ctx; }
-
- SkCanvas* canvas() const { return &fCtx->fCanvas; }
- SkPaint* paint() const { return &fCtx->fPaint; }
-
-private:
- SkForthCtx* fCtx;
-};
-
-class setColor_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- paint()->setColor(fe->pop());
- }
-
- static SkForthCtx_FW* New() { return new setColor_FW; }
-};
-
-class setStyle_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- paint()->setStyle((SkPaint::Style)fe->pop());
- }
-
- static SkForthCtx_FW* New() { return new setStyle_FW; }
-};
-
-class setStrokeWidth_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- paint()->setStrokeWidth(fe->fpop());
- }
-
- static SkForthCtx_FW* New() { return new setStrokeWidth_FW; }
-};
-
-class translate_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- SkScalar dy = fe->fpop();
- SkScalar dx = fe->fpop();
- canvas()->translate(dx, dy);
- }
-
- static SkForthCtx_FW* New() { return new translate_FW; }
-};
-
-class drawColor_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- canvas()->drawColor(fe->pop());
- }
-
- static SkForthCtx_FW* New() { return new drawColor_FW; }
-};
-
-class drawRect_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- SkRect r;
- r.fBottom = fe->fpop();
- r.fRight = fe->fpop();
- r.fTop = fe->fpop();
- r.fLeft = fe->fpop();
- canvas()->drawRect(r, *paint());
- }
-
- static SkForthCtx_FW* New() { return new drawRect_FW; }
-};
-
-class drawCircle_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- SkScalar radius = fe->fpop();
- SkScalar y = fe->fpop();
- SkScalar x = fe->fpop();
- canvas()->drawCircle(x, y, radius, *paint());
- }
-
- static SkForthCtx_FW* New() { return new drawCircle_FW; }
-};
-
-class drawLine_FW : public SkForthCtx_FW {
-public:
- virtual void exec(ForthEngine* fe) {
- SkScalar x0, y0, x1, y1;
- y1 = fe->fpop();
- x1 = fe->fpop();
- y0 = fe->fpop();
- x0 = fe->fpop();
- canvas()->drawLine(x0, y0, x1, y1, *paint());
- }
-
- static SkForthCtx_FW* New() { return new drawLine_FW; }
-};
-
-static const struct {
- const char* fName;
- SkForthCtx_FW* (*fProc)();
-} gWordRecs[] = {
- { "setColor", setColor_FW::New },
- { "setStyle", setStyle_FW::New },
- { "setStrokeWidth", setStrokeWidth_FW::New },
- { "translate", translate_FW::New },
- { "drawColor", drawColor_FW::New },
- { "drawRect", drawRect_FW::New },
- { "drawCircle", drawCircle_FW::New },
- { "drawLine", drawLine_FW::New },
-};
-
-static void load_words(ForthEnv* env, SkForthCtx* ctx) {
- for (size_t i = 0; i < SK_ARRAY_COUNT(gWordRecs); i++) {
- SkForthCtx_FW* word = gWordRecs[i].fProc();
- word->setCtx(ctx);
- env->addWord(gWordRecs[i].fName, word);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void Forth_test_stdwords(bool verbose);
-
-class ForthView : public SkView {
- ForthEnv fEnv;
- ForthWord* fOnClickWord;
-
- SkBitmap fBM;
- SkForthCtx fContext;
-public:
- ForthView() {
- Forth_test_stdwords(false);
-
- load_words(&fEnv, &fContext);
-
- fBM.setConfig(SkBitmap::kARGB_8888_Config, 640, 480);
- fBM.allocPixels();
- fBM.eraseColor(0);
- fContext.init(fBM);
-
- fEnv.parse(": mycolor ( x. y. -- x. y. ) OVER OVER f< IF #FFFF0000 ELSE #FF0000FF THEN setColor ;");
- fEnv.parse(": view.onClick ( x. y. -- ) mycolor 10. drawCircle ;");
- fOnClickWord = fEnv.findWord("view.onClick");
-#if 0
- env.parse(
- ": draw1 "
- "10. setStrokeWidth 1 setStyle #FF000000 setColor "
- "10. 20. 200. 100. drawLine "
- "0 setStyle #80FF0000 setColor "
- "50. 50. 250. 150. drawRect "
- ";");
- env.parse("#FF0000FF drawColor "
- "draw1 "
- "150. 120. translate "
- "draw1 "
- );
-#endif
- }
-
- virtual ~ForthView() {
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "Forth");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- void drawBG(SkCanvas* canvas) {
- canvas->drawColor(0xFFDDDDDD);
- }
-
- void test_onClick(ForthEnv* env) {
- ForthWord* word = env->findWord("view.onClick");
- if (word) {
- const intptr_t idata[2] = { 40, 2 };
- intptr_t odata[1] = { -1 };
- ForthCallBlock block;
- block.in_data = idata;
- block.in_count = 2;
- block.out_data = odata;
- block.out_count = 1;
- word->call(&block);
- SkDebugf("after view.onClick depth %d count %d top %d\n",
- block.out_depth, block.out_count, odata[0]);
- } else {
- SkDebugf("------ view.onClick not found\n");
- }
- }
-
- virtual void onDraw(SkCanvas* canvas) {
- drawBG(canvas);
- canvas->drawBitmap(fBM, 0, 0, NULL);
- }
-
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
- return fOnClickWord ? new Click(this) : NULL;
- }
-
- virtual bool onClick(Click* click) {
- intptr_t idata[2] = {
- f2i_bits(click->fCurr.fX), f2i_bits(click->fCurr.fY)
- };
- ForthCallBlock block;
- block.in_data = idata;
- block.in_count = 2;
- block.out_count = 0;
- fOnClickWord->call(&block);
- this->inval(NULL);
- return true;
- }
-
-private:
- typedef SkView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new ForthView; }
-static SkViewRegister reg(MyFactory);
-
diff --git a/src/gpu/app-android.cpp b/src/gpu/app-android.cpp
deleted file mode 100644
index c656b59a3f..0000000000
--- a/src/gpu/app-android.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-
-/*
- * 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 <jni.h>
-#include <sys/time.h>
-#include <time.h>
-#include <android/log.h>
-#include <stdint.h>
-
-#include "GrContext.h"
-#include "SkGpuCanvas.h"
-#include "SkPaint.h"
-#include "SkString.h"
-#include "SkTime.h"
-
-#include "gl/GrGLConfig.h"
-
-static GrContext* make_context() {
- SkDebugf("---- before create\n");
- GrContext* ctx = GrContext::Create(GrGpu::kOpenGL_Shaders_Engine, 0);
- SkDebugf("---- after create %p\n", ctx);
- return ctx;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void gr_run_unittests() {}
-
-#include "FlingState.h"
-#include "SkTouchGesture.h"
-#include "SkView.h"
-
-typedef SkView* (*SkViewFactory)();
-
-// these values must match those in Ganesh.java
-enum TouchState {
- kUnknown_TouchState,
- kDown_TouchState,
- kMoved_TouchState,
- kUp_TouchState
-};
-
-struct State {
- State();
- ~State();
-
- int countSlides() const { return fFactory.count(); }
- const char* getSlideTitle(int index) const;
- void chooseSlide(int index) {
- SkDebugf("----- index %d\n", index);
- if (index < fFactory.count()) {
- this->setView(fFactory[index]());
- }
- }
-
- void setViewport(int w, int h);
- int getWidth() const { return fViewport.fX; }
- int getHeight() const { return fViewport.fY; }
-
- void handleTouch(void*, TouchState, float x, float y);
- void applyMatrix(SkCanvas*);
-
- SkView* getView() const { return fView; }
-
-private:
- SkView* fView;
- SkIPoint fViewport;
-
- SkTouchGesture fGesture;
-
- SkTDArray<SkViewFactory> fFactory;
-
- void setView(SkView* view) {
- SkSafeUnref(fView);
- fView = view;
-
- view->setVisibleP(true);
- view->setClipToBounds(false);
- view->setSize(SkIntToScalar(fViewport.fX),
- SkIntToScalar(fViewport.fY));
- }
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-#include "SampleCode.h"
-
-SkViewRegister* SkViewRegister::gHead;
-SkViewRegister::SkViewRegister(SkViewFactory fact) : fFact(fact) {
- static bool gOnce;
- if (!gOnce) {
- gHead = NULL;
- gOnce = true;
- }
-
- fChain = gHead;
- gHead = this;
-}
-
-static const char gCharEvtName[] = "SampleCode_Char_Event";
-static const char gKeyEvtName[] = "SampleCode_Key_Event";
-static const char gTitleEvtName[] = "SampleCode_Title_Event";
-static const char gPrefSizeEvtName[] = "SampleCode_PrefSize_Event";
-static const char gFastTextEvtName[] = "SampleCode_FastText_Event";
-
-bool SampleCode::CharQ(const SkEvent& evt, SkUnichar* outUni) {
- if (evt.isType(gCharEvtName, sizeof(gCharEvtName) - 1)) {
- if (outUni) {
- *outUni = evt.getFast32();
- }
- return true;
- }
- return false;
-}
-
-bool SampleCode::KeyQ(const SkEvent& evt, SkKey* outKey) {
- if (evt.isType(gKeyEvtName, sizeof(gKeyEvtName) - 1)) {
- if (outKey) {
- *outKey = (SkKey)evt.getFast32();
- }
- return true;
- }
- return false;
-}
-
-bool SampleCode::TitleQ(const SkEvent& evt) {
- return evt.isType(gTitleEvtName, sizeof(gTitleEvtName) - 1);
-}
-
-void SampleCode::TitleR(SkEvent* evt, const char title[]) {
- GrAssert(evt && TitleQ(*evt));
- evt->setString(gTitleEvtName, title);
-}
-
-bool SampleCode::PrefSizeQ(const SkEvent& evt) {
- return evt.isType(gPrefSizeEvtName, sizeof(gPrefSizeEvtName) - 1);
-}
-
-void SampleCode::PrefSizeR(SkEvent* evt, SkScalar width, SkScalar height) {
- GrAssert(evt && PrefSizeQ(*evt));
- SkScalar size[2];
- size[0] = width;
- size[1] = height;
- evt->setScalars(gPrefSizeEvtName, 2, size);
-}
-
-bool SampleCode::FastTextQ(const SkEvent& evt) {
- return evt.isType(gFastTextEvtName, sizeof(gFastTextEvtName) - 1);
-}
-
-static SkMSec gAnimTime;
-static SkMSec gAnimTimePrev;
-
-SkMSec SampleCode::GetAnimTime() { return gAnimTime; }
-SkMSec SampleCode::GetAnimTimeDelta() { return gAnimTime - gAnimTimePrev; }
-SkScalar SampleCode::GetAnimSecondsDelta() {
- return SkDoubleToScalar(GetAnimTimeDelta() / 1000.0);
-}
-
-SkScalar SampleCode::GetAnimScalar(SkScalar speed, SkScalar period) {
- // since gAnimTime can be up to 32 bits, we can't convert it to a float
- // or we'll lose the low bits. Hence we use doubles for the intermediate
- // calculations
- double seconds = (double)gAnimTime / 1000.0;
- double value = SkScalarToDouble(speed) * seconds;
- if (period) {
- value = ::fmod(value, SkScalarToDouble(period));
- }
- return SkDoubleToScalar(value);
-}
-
-static void drawIntoCanvas(State* state, SkCanvas* canvas) {
- gAnimTime = SkTime::GetMSecs();
- SkView* view = state->getView();
- view->draw(canvas);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static void resetGpuState();
-
-State::State() {
- fViewport.set(0, 0);
-
- const SkViewRegister* reg = SkViewRegister::Head();
- while (reg) {
- *fFactory.append() = reg->factory();
- reg = reg->next();
- }
-
- SkDebugf("----- %d slides\n", fFactory.count());
- fView = NULL;
- this->chooseSlide(0);
-}
-
-State::~State() {
- SkSafeUnref(fView);
-}
-
-void State::setViewport(int w, int h) {
- fViewport.set(w, h);
- if (fView) {
- fView->setSize(SkIntToScalar(w), SkIntToScalar(h));
- }
- resetGpuState();
-}
-
-const char* State::getSlideTitle(int index) const {
- SkEvent evt(gTitleEvtName);
- evt.setFast32(index);
- {
- SkView* view = fFactory[index]();
- view->doQuery(&evt);
- view->unref();
- }
- return evt.findString(gTitleEvtName);
-}
-
-void State::handleTouch(void* owner, TouchState state, float x, float y) {
- switch (state) {
- case kDown_TouchState:
- fGesture.touchBegin(owner, x, y);
- break;
- case kMoved_TouchState:
- fGesture.touchMoved(owner, x, y);
- break;
- case kUp_TouchState:
- fGesture.touchEnd(owner);
- break;
- }
-}
-
-void State::applyMatrix(SkCanvas* canvas) {
- const SkMatrix& localM = fGesture.localM();
- if (localM.getType() & SkMatrix::kScale_Mask) {
- canvas->setExternalMatrix(&localM);
- }
- canvas->concat(localM);
- canvas->concat(fGesture.globalM());
-}
-
-static State* get_state() {
- static State* gState;
- if (NULL == gState) {
- gState = SkNEW(State);
- }
- return gState;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static GrContext* gContext;
-static int gWidth;
-static int gHeight;
-static float gX, gY;
-
-static void resetGpuState() {
- if (NULL == gContext) {
- SkDebugf("creating context for first time\n");
- gContext = make_context();
- } else {
- SkDebugf("------ gContext refcnt=%d\n", gContext->refcnt());
- gContext->abandonAllTextures();
- gContext->unref();
- gContext = make_context();
- }
-}
-
-static void doDraw() {
- if (NULL == gContext) {
- gContext = make_context();
- }
-
- State* state = get_state();
- SkBitmap viewport;
- viewport.setConfig(SkBitmap::kARGB_8888_Config,
- state->getWidth(), state->getHeight());
-
- SkGpuCanvas canvas(gContext);
-
- canvas.setBitmapDevice(viewport);
- state->applyMatrix(&canvas);
-
- drawIntoCanvas(state, &canvas);
-
- GrGLCheckErr();
- GrGLClearErr();
-// gContext->checkError();
-// gContext->clearError();
-
- if (true) {
- static const int FRAME_COUNT = 32;
- static SkMSec gDuration;
-
- static SkMSec gNow;
- static int gFrameCounter;
- if (++gFrameCounter == FRAME_COUNT) {
- gFrameCounter = 0;
- SkMSec now = SkTime::GetMSecs();
-
- gDuration = now - gNow;
- gNow = now;
- }
-
- int fps = (FRAME_COUNT * 1000) / gDuration;
- SkString str;
- str.printf("FPS=%3d MS=%3d", fps, gDuration / FRAME_COUNT);
-
- SkGpuCanvas c(gContext);
- c.setBitmapDevice(viewport);
-
- SkPaint p;
- p.setAntiAlias(true);
- SkRect r = { 0, 0, 110, 16 };
- p.setColor(SK_ColorWHITE);
- c.drawRect(r, p);
- p.setColor(SK_ColorBLACK);
- c.drawText(str.c_str(), str.size(), 4, 12, p);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-extern "C" {
- JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeSurfaceCreated(
- JNIEnv*, jobject);
- JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeViewport(JNIEnv*, jobject,
- jint w, jint h);
- JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeDrawFrame(JNIEnv*, jobject);
- JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeTouch(JNIEnv*, jobject,
- jint id, jint type, jfloat x, jfloat y);
-
- JNIEXPORT int JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeCountSlides(JNIEnv*, jobject);
- JNIEXPORT jobject JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeGetSlideTitle(JNIEnv*, jobject, jint index);
- JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeChooseSlide(JNIEnv*, jobject, jint index);
-}
-
-JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeSurfaceCreated(
- JNIEnv*, jobject) {
- SkDebugf("------ nativeSurfaceCreated\n");
- resetGpuState();
- SkDebugf("------ end nativeSurfaceCreated\n");
-}
-
-JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeViewport(JNIEnv*, jobject,
- jint w, jint h) {
- State* state = get_state();
- SkDebugf("---- state.setviewport %p %d %d\n", state, w, h);
- state->setViewport(w, h);
- SkDebugf("---- end setviewport\n");
-}
-
-JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeDrawFrame(JNIEnv*, jobject) {
- doDraw();
-}
-
-union IntPtr {
- jint fInt;
- void* fPtr;
-};
-static void* int2ptr(jint n) {
- IntPtr data;
- data.fInt = n;
- return data.fPtr;
-}
-
-JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeTouch(JNIEnv*, jobject,
- jint id, jint type, jfloat x, jfloat y) {
- get_state()->handleTouch(int2ptr(id), (TouchState)type, x, y);
-}
-
-////////////
-
-JNIEXPORT int JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeCountSlides(JNIEnv*, jobject) {
- return get_state()->countSlides();
-}
-
-JNIEXPORT jobject JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeGetSlideTitle(JNIEnv* env, jobject, jint index) {
- return env->NewStringUTF(get_state()->getSlideTitle(index));
-}
-
-JNIEXPORT void JNICALL Java_com_tetrark_ganesh_MyRenderer_nativeChooseSlide(JNIEnv*, jobject, jint index) {
- get_state()->chooseSlide(index);
-}
-
-
-
-
-
diff --git a/src/gpu/gr_hello_world.cpp b/src/gpu/gr_hello_world.cpp
deleted file mode 100644
index e9e8f8dfd0..0000000000
--- a/src/gpu/gr_hello_world.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-
-/*
- * 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 "gl/SkGLCanvas.h"
-#include "SkBitmap.h"
-#include "SkPaint.h"
-#include "gl/SkGpuGLShaders.h"
-
-extern "C" {
- void gr_hello_world();
-}
-
-void gr_hello_world() {
- static GrGpu* gGpu;
- if (NULL == gGpu) {
- gGpu = SkNEW(SkGpuGLShaders);
- }
-
- SkGLCanvas canvas(gGpu);
- SkBitmap bm;
-
- bm.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT);
- canvas.setBitmapDevice(bm);
-
- canvas.drawColor(SK_ColorWHITE);
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setTextSize(30);
- canvas.drawText("Hello Kno", 9, 40, 40, paint);
-}
-
-
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index b3f463d48d..d250901efc 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -157,15 +157,18 @@ static void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc
///////////////////////////////////////////////////////////////////////////////
-SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : fNestLevel(0) {
- SkSafeRef(dumper);
- fDumper = dumper;
-
+static SkBitmap make_wideopen_bm() {
static const int WIDE_OPEN = 16384;
- SkBitmap emptyBitmap;
+
+ SkBitmap bm;
+ bm.setConfig(SkBitmap::kNo_Config, WIDE_OPEN, WIDE_OPEN);
+ return bm;
+}
- emptyBitmap.setConfig(SkBitmap::kNo_Config, WIDE_OPEN, WIDE_OPEN);
- this->setBitmapDevice(emptyBitmap);
+SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : INHERITED(make_wideopen_bm()) {
+ fNestLevel = 0;
+ SkSafeRef(dumper);
+ fDumper = dumper;
}
SkDumpCanvas::~SkDumpCanvas() {
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 2ca80ce2d1..3b781631a3 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -7,12 +7,15 @@
*/
#include "SkNWayCanvas.h"
-SkNWayCanvas::SkNWayCanvas(int width, int height) {
+static SkBitmap make_noconfig_bm(int width, int height) {
SkBitmap bm;
bm.setConfig(SkBitmap::kNo_Config, width, height);
- this->setBitmapDevice(bm);
+ return bm;
}
+SkNWayCanvas::SkNWayCanvas(int width, int height)
+ : INHERITED(make_noconfig_bm(width, height)) {}
+
SkNWayCanvas::~SkNWayCanvas() {
this->removeAll();
}