From cd1d41e7c1cbfed08b08f6a769cff7f86bc80a3c Mon Sep 17 00:00:00 2001 From: reed Date: Mon, 25 May 2015 21:21:27 -0700 Subject: [PATCH] remove unneeded device:lockpixels BUG=skia: TBR= Review URL: https://codereview.chromium.org/1156073003 --- include/core/SkBitmapDevice.h | 8 ++------ include/core/SkDevice.h | 8 -------- src/core/SkBitmapDevice.cpp | 26 ++++++++++++++------------ src/utils/SkDeferredCanvas.cpp | 3 --- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h index 69adc9a1c1..f0f959a579 100644 --- a/include/core/SkBitmapDevice.h +++ b/include/core/SkBitmapDevice.h @@ -119,12 +119,8 @@ protected: bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) override; bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) override; void* onAccessPixels(SkImageInfo* info, size_t* rowBytes) override; - - /** Called when this device is installed into a Canvas. Balanced by a call - to unlockPixels() when the device is removed from a Canvas. - */ - void lockPixels() override; - void unlockPixels() override; + void onAttachToCanvas(SkCanvas*) override; + void onDetachFromCanvas() override; private: friend class SkCanvas; diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index b474687cfb..3bdcfcf8a3 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -104,7 +104,6 @@ public: */ virtual void onAttachToCanvas(SkCanvas*) { SkASSERT(!fAttachedToCanvas); - this->lockPixels(); #ifdef SK_DEBUG fAttachedToCanvas = true; #endif @@ -118,7 +117,6 @@ public: */ virtual void onDetachFromCanvas() { SkASSERT(fAttachedToCanvas); - this->unlockPixels(); #ifdef SK_DEBUG fAttachedToCanvas = false; #endif @@ -251,12 +249,6 @@ protected: */ virtual const SkBitmap& onAccessBitmap() = 0; - /** Called when this device is installed into a Canvas. Balanced by a call - to unlockPixels() when the device is removed from a Canvas. - */ - virtual void lockPixels() {} - virtual void unlockPixels() {} - /** * Override and return true for filters that the device can handle * intrinsically. Doing so means that SkCanvas will pass-through this diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 5b2fc38e32..995b427697 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -120,18 +120,6 @@ SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa return SkBitmapDevice::Create(cinfo.fInfo, &leaky); } -void SkBitmapDevice::lockPixels() { - if (fBitmap.lockPixelsAreWritable()) { - fBitmap.lockPixels(); - } -} - -void SkBitmapDevice::unlockPixels() { - if (fBitmap.lockPixelsAreWritable()) { - fBitmap.unlockPixels(); - } -} - const SkBitmap& SkBitmapDevice::onAccessBitmap() { return fBitmap; } @@ -172,6 +160,20 @@ bool SkBitmapDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s return fBitmap.readPixels(dstInfo, dstPixels, dstRowBytes, x, y); } +void SkBitmapDevice::onAttachToCanvas(SkCanvas* canvas) { + INHERITED::onAttachToCanvas(canvas); + if (fBitmap.lockPixelsAreWritable()) { + fBitmap.lockPixels(); + } +} + +void SkBitmapDevice::onDetachFromCanvas() { + INHERITED::onDetachFromCanvas(); + if (fBitmap.lockPixelsAreWritable()) { + fBitmap.unlockPixels(); + } +} + /////////////////////////////////////////////////////////////////////////////// void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index 7d0a8e8593..40004fbddb 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -252,9 +252,6 @@ protected: const SkPaint&) override {SkASSERT(0);} - void lockPixels() override {} - void unlockPixels() override {} - bool canHandleImageFilter(const SkImageFilter*) override { return false; }