diff options
author | 2014-06-14 04:24:56 -0700 | |
---|---|---|
committer | 2014-06-14 04:24:57 -0700 | |
commit | f252f64f17efddf7235682a96d155d7c86c898e3 (patch) | |
tree | 2e840b4d3030b9163c908bb710bb91b0893bd99f | |
parent | 937fdeb8a2c1fde03ffd6df40a673692fd69e768 (diff) |
hide virtuals on device for width/height/isopaque
R=bsalomon@google.com
NOTREECHECKS=True
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/334993002
-rw-r--r-- | gyp/skia_for_android_framework_defines.gypi | 1 | ||||
-rw-r--r-- | gyp/skia_for_chromium_defines.gypi | 1 | ||||
-rw-r--r-- | include/core/SkBitmapDevice.h | 12 | ||||
-rw-r--r-- | include/core/SkDevice.h | 32 | ||||
-rw-r--r-- | include/core/SkImageInfo.h | 7 | ||||
-rw-r--r-- | include/gpu/SkGpuDevice.h | 12 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 3 | ||||
-rw-r--r-- | src/gpu/GrPictureUtils.cpp | 3 | ||||
-rw-r--r-- | src/utils/SkDeferredCanvas.cpp | 15 | ||||
-rw-r--r-- | src/utils/SkGatherPixelRefsAndRects.h | 3 | ||||
-rw-r--r-- | src/utils/SkPictureUtils.cpp | 6 |
11 files changed, 36 insertions, 59 deletions
diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi index 223d504337..39a6b62a78 100644 --- a/gyp/skia_for_android_framework_defines.gypi +++ b/gyp/skia_for_android_framework_defines.gypi @@ -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. diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi index 938893bb72..cb75613ed6 100644 --- a/gyp/skia_for_chromium_defines.gypi +++ b/gyp/skia_for_chromium_defines.gypi @@ -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', diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h index 48b0386dc2..cc6d2adc6c 100644 --- a/include/core/SkBitmapDevice.h +++ b/include/core/SkBitmapDevice.h @@ -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; /** diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 25ad499386..4b3db126f1 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -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 diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index d66158d02c..b955433329 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -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; } diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h index b4234e84d2..0b6bbc1857 100644 --- a/include/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h @@ -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; diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 6c5c0f391d..6a09c0b9db 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -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) { diff --git a/src/gpu/GrPictureUtils.cpp b/src/gpu/GrPictureUtils.cpp index 77113ad426..6fed2f6d9f 100644 --- a/src/gpu/GrPictureUtils.cpp +++ b/src/gpu/GrPictureUtils.cpp @@ -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(); } diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index ea7d71e252..641974b1ed 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -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(); } diff --git a/src/utils/SkGatherPixelRefsAndRects.h b/src/utils/SkGatherPixelRefsAndRects.h index bd6f2e54e6..df3651e2e5 100644 --- a/src/utils/SkGatherPixelRefsAndRects.h +++ b/src/utils/SkGatherPixelRefsAndRects.h @@ -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(); } diff --git a/src/utils/SkPictureUtils.cpp b/src/utils/SkPictureUtils.cpp index 46a0660774..702a78dda2 100644 --- a/src/utils/SkPictureUtils.cpp +++ b/src/utils/SkPictureUtils.cpp @@ -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; |