hide virtuals on device for width/height/isopaque
authorreed <reed@chromium.org>
Sat, 14 Jun 2014 11:24:56 +0000 (04:24 -0700)
committerCommit bot <commit-bot@chromium.org>
Sat, 14 Jun 2014 11:24:57 +0000 (04:24 -0700)
R=bsalomon@google.com
NOTREECHECKS=True

Author: reed@chromium.org

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

gyp/skia_for_android_framework_defines.gypi
gyp/skia_for_chromium_defines.gypi
include/core/SkBitmapDevice.h
include/core/SkDevice.h
include/core/SkImageInfo.h
include/gpu/SkGpuDevice.h
src/core/SkDevice.cpp
src/gpu/GrPictureUtils.cpp
src/utils/SkDeferredCanvas.cpp
src/utils/SkGatherPixelRefsAndRects.h
src/utils/SkPictureUtils.cpp

index 223d504..39a6b62 100644 (file)
@@ -16,6 +16,7 @@
       'SK_SUPPORT_LEGACY_SETCONFIG_INFO',
       'SK_SUPPORT_LEGACY_SETCONFIG',
       'SK_SUPPORT_LEGACY_IMAGEDECODER_CONFIG',
+      'SK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE',
       # Needed until we fix skbug.com/2440.
       'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
       # Transitional, for deprecated SkCanvas::SaveFlags methods.
index 938893b..cb75613 100644 (file)
@@ -14,6 +14,7 @@
     #
     'skia_for_chromium_defines': [
       'SK_SUPPORT_LEGACY_GETTOPDEVICE',
+      'SK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE',
       'SK_SUPPORT_LEGACY_N32_NAME',
       'SK_SUPPORT_LEGACY_SETCONFIG',
       'SK_IGNORE_ETC1_SUPPORT',
index 48b0386..cc6d2ad 100644 (file)
@@ -33,18 +33,6 @@ public:
     static SkBitmapDevice* Create(const SkImageInfo&,
                                   const SkDeviceProperties* = NULL);
 
-    /** Return the width of the device (in pixels).
-    */
-    virtual int width() const SK_OVERRIDE { return fBitmap.width(); }
-    /** Return the height of the device (in pixels).
-    */
-    virtual int height() const SK_OVERRIDE { return fBitmap.height(); }
-
-    /** Returns true if the device's bitmap's config treats every pixels as
-        implicitly opaque.
-    */
-    virtual bool isOpaque() const SK_OVERRIDE { return fBitmap.isOpaque(); }
-
     virtual SkImageInfo imageInfo() const SK_OVERRIDE;
 
     /**
index 25ad499..4b3db12 100644 (file)
@@ -44,13 +44,6 @@ public:
 
     SkMetaData& getMetaData();
 
-    /** Return the width of the device (in pixels).
-    */
-    virtual int width() const = 0;
-    /** Return the height of the device (in pixels).
-    */
-    virtual int height() const = 0;
-
     /** Return the image properties of the device. */
     virtual const SkDeviceProperties& getDeviceProperties() const {
         //Currently, all the properties are leaky.
@@ -74,10 +67,27 @@ public:
         bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height());
     }
 
-    /** Returns true if the device's bitmap's config treats every pixel as
-        implicitly opaque.
-    */
-    virtual bool isOpaque() const = 0;
+#ifdef SK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE
+    virtual int width() const {
+        return this->imageInfo().width();
+    }
+    virtual int height() const {
+        return this->imageInfo().height();
+    }
+    virtual bool isOpaque() const {
+        return this->imageInfo().isOpaque();
+    }
+#else
+    int width() const {
+        return this->imageInfo().width();
+    }
+    int height() const {
+        return this->imageInfo().height();
+    }
+    bool isOpaque() const {
+        return this->imageInfo().isOpaque();
+    }
+#endif
 
     /** Return the bitmap associated with this device. Call this each time you need
         to access the bitmap, as it notifies the subclass to perform any flushing
index d66158d..b955433 100644 (file)
@@ -176,6 +176,13 @@ struct SkImageInfo {
         return info;
     }
 
+    static SkImageInfo MakeUnknown() {
+        SkImageInfo info = {
+            0, 0, kUnknown_SkColorType, kIgnore_SkAlphaType
+        };
+        return info;
+    }
+
     int width() const { return fWidth; }
     int height() const { return fHeight; }
     SkColorType colorType() const { return fColorType; }
index b4234e8..0b6bbc1 100644 (file)
@@ -71,16 +71,8 @@ public:
 
     virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
 
-    // overrides from SkBaseDevice
-    virtual int width() const SK_OVERRIDE {
-        return NULL == fRenderTarget ? 0 : fRenderTarget->width();
-    }
-    virtual int height() const SK_OVERRIDE {
-        return NULL == fRenderTarget ? 0 : fRenderTarget->height();
-    }
-    virtual bool isOpaque() const SK_OVERRIDE {
-        return NULL == fRenderTarget ? false
-                                     : kRGB_565_GrPixelConfig == fRenderTarget->config();
+    virtual SkImageInfo imageInfo() const SK_OVERRIDE {
+        return fRenderTarget ? fRenderTarget->info() : SkImageInfo::MakeUnknown();
     }
 
     virtual void clear(SkColor color) SK_OVERRIDE;
index 6c5c0f3..6a09c0b 100644 (file)
@@ -49,9 +49,8 @@ SkMetaData& SkBaseDevice::getMetaData() {
     return *fMetaData;
 }
 
-// TODO: should make this guy pure-virtual.
 SkImageInfo SkBaseDevice::imageInfo() const {
-    return SkImageInfo::MakeUnknown(this->width(), this->height());
+    return SkImageInfo::MakeUnknown();
 }
 
 const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) {
index 77113ad..6fed2f6 100644 (file)
@@ -48,9 +48,6 @@ public:
 
     virtual ~GrGatherDevice() { }
 
-    virtual int width() const SK_OVERRIDE { return fInfo.fSize.width(); }
-    virtual int height() const SK_OVERRIDE { return fInfo.fSize.height(); }
-    virtual bool isOpaque() const SK_OVERRIDE { return false; }
     virtual SkImageInfo imageInfo() const SK_OVERRIDE {
         return fEmptyBitmap.info();
     }
index ea7d71e..641974b 100644 (file)
@@ -157,9 +157,6 @@ public:
     void setMaxRecordingStorage(size_t);
     void recordedDrawCommand();
 
-    virtual int width() const SK_OVERRIDE;
-    virtual int height() const SK_OVERRIDE;
-    virtual bool isOpaque() const SK_OVERRIDE;
     virtual SkImageInfo imageInfo() const SK_OVERRIDE;
 
     virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
@@ -426,18 +423,6 @@ SkImage* SkDeferredDevice::newImageSnapshot() {
     return fSurface ? fSurface->newImageSnapshot() : NULL;
 }
 
-int SkDeferredDevice::width() const {
-    return immediateDevice()->width();
-}
-
-int SkDeferredDevice::height() const {
-    return immediateDevice()->height();
-}
-
-bool SkDeferredDevice::isOpaque() const {
-    return immediateDevice()->isOpaque();
-}
-
 SkImageInfo SkDeferredDevice::imageInfo() const {
     return immediateDevice()->imageInfo();
 }
index bd6f2e5..df3651e 100644 (file)
@@ -35,9 +35,6 @@ public:
         SkSafeUnref(fPRCont);
     }
 
-    virtual int width() const SK_OVERRIDE { return fSize.width(); }
-    virtual int height() const SK_OVERRIDE { return fSize.height(); }
-    virtual bool isOpaque() const SK_OVERRIDE { return false; }
     virtual SkImageInfo imageInfo() const SK_OVERRIDE {
         return fEmptyBitmap.info();
     }
index 46a0660..702a78d 100644 (file)
@@ -58,9 +58,9 @@ public:
         fPRSet = prset;
     }
 
-    virtual int width() const SK_OVERRIDE { return fSize.width(); }
-    virtual int height() const SK_OVERRIDE { return fSize.height(); }
-    virtual bool isOpaque() const SK_OVERRIDE { return false; }
+    virtual SkImageInfo imageInfo() const SK_OVERRIDE {
+        return SkImageInfo::MakeUnknown(fSize.width(), fSize.height());
+    }
     virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE { return NULL; }
     virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE {
         return false;