From 589a39eb81d25fa7af95e7366db17ac7a70a7d03 Mon Sep 17 00:00:00 2001 From: reed Date: Sat, 20 Aug 2016 07:59:19 -0700 Subject: store info in basedevice, change getter to non-virtual const& BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2261003003 Review-Url: https://codereview.chromium.org/2261003003 --- include/core/SkBitmapDevice.h | 2 -- include/core/SkDevice.h | 12 +++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'include/core') diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h index bb6d6ec1e8..31c0aa3a35 100644 --- a/include/core/SkBitmapDevice.h +++ b/include/core/SkBitmapDevice.h @@ -58,8 +58,6 @@ public: static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps&); - SkImageInfo imageInfo() const override; - protected: bool onShouldDisableLCD(const SkPaint&) const override; diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 76549ca5d0..44b8791386 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -30,7 +30,7 @@ public: /** * Construct a new device. */ - explicit SkBaseDevice(const SkSurfaceProps&); + explicit SkBaseDevice(const SkImageInfo&, const SkSurfaceProps&); virtual ~SkBaseDevice(); SkMetaData& getMetaData(); @@ -39,7 +39,7 @@ public: * Return ImageInfo for this device. If the canvas is not backed by pixels * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. */ - virtual SkImageInfo imageInfo() const; + const SkImageInfo& imageInfo() const { return fInfo; } /** * Return SurfaceProps for this device. @@ -371,9 +371,15 @@ private: virtual SkImageFilterCache* getImageFilterCache() { return NULL; } + friend class SkBitmapDevice; + void privateResize(int w, int h) { + *const_cast(&fInfo) = fInfo.makeWH(w, h); + } + SkIPoint fOrigin; SkMetaData* fMetaData; - SkSurfaceProps fSurfaceProps; + const SkImageInfo fInfo; + const SkSurfaceProps fSurfaceProps; #ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP SkBitmap fLegacyBitmap; -- cgit v1.2.3