From fcf7829b67b798aff4c41c4688daa9c7381991e6 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Fri, 19 Jun 2015 11:49:52 -0700 Subject: remove SkDeviceProperties There is a lot more clean up to do here but this is probably a big enough bite. Review URL: https://codereview.chromium.org/1196683003 --- include/core/SkBitmapDevice.h | 7 ++++--- include/core/SkCanvas.h | 2 ++ include/core/SkDevice.h | 10 +++++----- include/core/SkPaint.h | 10 +++++----- include/core/SkSurfaceProps.h | 3 +++ include/gpu/GrContext.h | 6 +++--- include/gpu/GrDrawContext.h | 8 ++++---- include/utils/SkNoSaveLayerCanvas.h | 2 +- 8 files changed, 27 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h index a2101a2dd9..3ce06b0cc3 100644 --- a/include/core/SkBitmapDevice.h +++ b/include/core/SkBitmapDevice.h @@ -22,14 +22,15 @@ public: * any drawing to this device will have no effect. */ SkBitmapDevice(const SkBitmap& bitmap); -private: +protected: /** * Construct a new device with the specified bitmap as its backend. It is * valid for the bitmap to have no pixels associated with it. In that case, * any drawing to this device will have no effect. */ - SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties); - static SkBitmapDevice* Create(const SkImageInfo&, const SkDeviceProperties*); + SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps); +private: + static SkBitmapDevice* Create(const SkImageInfo&, const SkSurfaceProps*); public: static SkBitmapDevice* Create(const SkImageInfo& info) { return Create(info, NULL); diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index cfeaa5f1d1..6afaf3f319 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -1290,7 +1290,9 @@ private: kConservativeRasterClip_InitFlag = 1 << 0, }; SkCanvas(const SkIRect& bounds, InitFlags); + // TODO: remove this ctor - the basedevice should already have surface props SkCanvas(SkBaseDevice*, const SkSurfaceProps*, InitFlags); + SkCanvas(SkBaseDevice* device, InitFlags); void resetForNextPicture(const SkIRect& bounds); diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 3b5d38a6af..d9468daa56 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -13,6 +13,7 @@ #include "SkCanvas.h" #include "SkColor.h" #include "SkImageFilter.h" +#include "SkSurfaceProps.h" class SkClipStack; class SkDraw; @@ -21,7 +22,6 @@ struct SkIRect; class SkMatrix; class SkMetaData; class SkRegion; -struct SkDeviceProperties; class GrRenderTarget; class SK_API SkBaseDevice : public SkRefCnt { @@ -32,7 +32,7 @@ public: * Construct a new device. */ SkBaseDevice(); - explicit SkBaseDevice(const SkDeviceProperties&); + explicit SkBaseDevice(const SkSurfaceProps&); virtual ~SkBaseDevice(); SkMetaData& getMetaData(); @@ -315,8 +315,8 @@ protected: * If the device does handle a property, that property should be set to the identity value * for that property, effectively making it non-leaky. */ - const SkDeviceProperties& getLeakyProperties() const { - return *fLeakyProperties; + const SkSurfaceProps& getLeakyProperties() const { + return fLeakyProperties; } /** @@ -399,7 +399,7 @@ private: SkIPoint fOrigin; SkMetaData* fMetaData; - SkDeviceProperties* fLeakyProperties; // will always exist. + SkSurfaceProps fLeakyProperties; #ifdef SK_DEBUG bool fAttachedToCanvas; diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index e4be06e03e..b52b7c1b2d 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -20,7 +20,6 @@ class SkAutoGlyphCache; class SkColorFilter; class SkData; class SkDescriptor; -struct SkDeviceProperties; class SkReadBuffer; class SkWriteBuffer; class SkGlyph; @@ -33,6 +32,7 @@ class SkPathEffect; struct SkPoint; class SkRasterizer; class SkShader; +class SkSurfaceProps; class SkTypeface; typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, @@ -1066,15 +1066,15 @@ private: * Allocs an SkDescriptor on the heap and return it to the caller as a refcnted * SkData. Caller is responsible for managing the lifetime of this object. */ - void getScalerContextDescriptor(SkAutoDescriptor*, const SkDeviceProperties* deviceProperties, + void getScalerContextDescriptor(SkAutoDescriptor*, const SkSurfaceProps& surfaceProps, const SkMatrix*, bool ignoreGamma) const; - SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*, + SkGlyphCache* detachCache(const SkSurfaceProps* surfaceProps, const SkMatrix*, bool ignoreGamma) const; - void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatrix* deviceMatrix, + void descriptorProc(const SkSurfaceProps* surfaceProps, const SkMatrix* deviceMatrix, void (*proc)(SkTypeface*, const SkDescriptor*, void*), - void* context, bool ignoreGamma = false) const; + void* context, bool ignoreGamma) const; /* * The luminance color is used to determine which Gamma Canonical color to map to. This is diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h index 108359922f..9c90d3ef2a 100644 --- a/include/core/SkSurfaceProps.h +++ b/include/core/SkSurfaceProps.h @@ -71,6 +71,9 @@ public: bool isDisallowDither() const { return SkToBool(fFlags & kDisallowDither_Flag); } bool isUseDistanceFieldFonts() const { return SkToBool(fFlags & kUseDistanceFieldFonts_Flag); } + // TODO: remove this entry point + void setPixelGeometry_dont_use(SkPixelGeometry geo) { fPixelGeometry = geo; } + private: SkSurfaceProps(); diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index a98cf0bf91..8ff108e2a1 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -180,8 +180,8 @@ public: * * @return a draw context */ - GrDrawContext* drawContext(const SkDeviceProperties* devProps = NULL) { - return fDrawingMgr.drawContext(devProps); + GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps = NULL) { + return fDrawingMgr.drawContext(surfaceProps); } /////////////////////////////////////////////////////////////////////////// @@ -419,7 +419,7 @@ private: // Callers should take a ref if they rely on the GrDrawContext sticking around. // NULL will be returned if the context has been abandoned. - GrDrawContext* drawContext(const SkDeviceProperties* devProps); + GrDrawContext* drawContext(const SkSurfaceProps* surfaceProps); private: void cleanup(); diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h index 1688694133..12bf9430a8 100644 --- a/include/gpu/GrDrawContext.h +++ b/include/gpu/GrDrawContext.h @@ -10,6 +10,7 @@ #include "GrColor.h" #include "SkRefCnt.h" +#include "SkSurfaceProps.h" class GrBatch; class GrClip; @@ -23,7 +24,6 @@ class GrRenderTarget; class GrStrokeInfo; class GrSurface; class GrTextContext; -struct SkDeviceProperties; class SkDrawFilter; struct SkIPoint; struct SkIRect; @@ -244,14 +244,14 @@ private: friend class GrAtlasTextContext; // for access to drawBatch friend class GrContext; // for ctor - GrDrawContext(GrContext*, GrDrawTarget*, const SkDeviceProperties&); + GrDrawContext(GrContext*, GrDrawTarget*, const SkSurfaceProps&); // Sets the paint. Returns true on success; false on failure. bool prepareToDraw(GrPipelineBuilder*, GrRenderTarget* rt, const GrClip&, const GrPaint* paint); - GrTextContext* createTextContext(GrRenderTarget*, const SkDeviceProperties&); + GrTextContext* createTextContext(GrRenderTarget*, const SkSurfaceProps&); // A simpler version of the above which just returns true on success; false on failure. // Clip is *NOT* set @@ -273,7 +273,7 @@ private: GrDrawTarget* fDrawTarget; GrTextContext* fTextContext; // lazily created - SkDeviceProperties* fDevProps; // ptr b.c. SkDeviceProperties isn't public + SkSurfaceProps fSurfaceProps; }; #endif diff --git a/include/utils/SkNoSaveLayerCanvas.h b/include/utils/SkNoSaveLayerCanvas.h index 65cd4a8329..0cebefff18 100644 --- a/include/utils/SkNoSaveLayerCanvas.h +++ b/include/utils/SkNoSaveLayerCanvas.h @@ -17,7 +17,7 @@ class SK_API SkNoSaveLayerCanvas : public SkCanvas { public: SkNoSaveLayerCanvas(SkBaseDevice* device) - : INHERITED(device, NULL, kConservativeRasterClip_InitFlag) + : INHERITED(device, kConservativeRasterClip_InitFlag) {} protected: -- cgit v1.2.3