remove unneeded device:lockpixels
authorreed <reed@chromium.org>
Tue, 26 May 2015 04:21:27 +0000 (21:21 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 26 May 2015 04:21:27 +0000 (21:21 -0700)
BUG=skia:
TBR=

Review URL: https://codereview.chromium.org/1156073003

include/core/SkBitmapDevice.h
include/core/SkDevice.h
src/core/SkBitmapDevice.cpp
src/utils/SkDeferredCanvas.cpp

index 69adc9a..f0f959a 100644 (file)
@@ -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;
index b474687..3bdcfcf 100644 (file)
@@ -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
index 5b2fc38..995b427 100644 (file)
@@ -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) {
index 7d0a8e8..40004fb 100644 (file)
@@ -252,9 +252,6 @@ protected:
                     const SkPaint&) override
         {SkASSERT(0);}
 
-    void lockPixels() override {}
-    void unlockPixels() override {}
-
     bool canHandleImageFilter(const SkImageFilter*) override {
         return false;
     }