From 8e14d660b2a434bc708a70180c84210883611683 Mon Sep 17 00:00:00 2001 From: reed Date: Fri, 13 Mar 2015 12:34:32 -0700 Subject: Revert of Revert of Revert of Change device creation to see the (optional) layer-paint (patchset #1 id:1 of https://codereview.chromium.org/1006923002/) Reason for revert: platform_canvas tests failures skia_unittests (with patch) skia_unittests (with patch) PlatformCanvas.TranslateLayer failed 2 Flakiness dashboard failures: PlatformCanvas.TranslateLayer PlatformCanvas.FillLayer Original issue's description: > Revert of Revert of Change device creation to see the (optional) layer-paint (patchset #1 id:1 of https://codereview.chromium.org/1008863002/) > > Reason for revert: > guard in chrome has landed > > Original issue's description: > > Revert of Change device creation to see the (optional) layer-paint (patchset #9 id:160001 of https://codereview.chromium.org/988413003/) > > > > Reason for revert: > > need to have chrome opt-in for the older API before this can land (in chrome) > > > > Original issue's description: > > > Change device creation to see the (optional) layer-paint > > > > > > Motivation: > > > > > > PDFDevice currently relies on 1) being told that the layer's paint has an imagefilter, and in the case, it creates a rasterdevice. It then relies on (2) canvas itself sniffing the layer's paint and offering to apply-the-imagefilter to call drawSprite instead of drawDevice. > > > > > > This subtle interchange is fragile, and also does not support other unsupported PDF features like colorfilters. This CL is a step toward making this use-raster-instead-of-native approach to layers more completely in the subclass' hands. > > > > > > Committed: https://skia.googlesource.com/skia/+/1182d9a96b80bd12183ee7c81325a979a51ee0c0 > > > > TBR=halcanary@google.com,senorblanco@google.com,robertphillips@google.com > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > > > Committed: https://skia.googlesource.com/skia/+/0e040f7da2fdfeb49aa60d24117306e3b1e6ea90 > > TBR=halcanary@google.com,senorblanco@google.com,robertphillips@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Committed: https://skia.googlesource.com/skia/+/f7076a13e2d4269903b34ef2780e1c84723e4477 TBR=halcanary@google.com,senorblanco@google.com,robertphillips@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1001423002 --- include/core/SkBitmapDevice.h | 8 +++++-- include/core/SkCanvas.h | 3 ++- include/core/SkDevice.h | 48 ++++++++++++++++++---------------------- include/device/xps/SkXPSDevice.h | 4 +++- 4 files changed, 32 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/include/core/SkBitmapDevice.h b/include/core/SkBitmapDevice.h index caff6857da..8ca6a523be 100644 --- a/include/core/SkBitmapDevice.h +++ b/include/core/SkBitmapDevice.h @@ -98,7 +98,11 @@ protected: const SkColor colors[], SkXfermode* xmode, const uint16_t indices[], int indexCount, const SkPaint& paint) SK_OVERRIDE; - virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, const SkPaint&) SK_OVERRIDE; + /** The SkBaseDevice passed will be an SkBaseDevice which was returned by a call to + onCreateCompatibleDevice on this device with kSaveLayer_Usage. + */ + virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, + const SkPaint&) SK_OVERRIDE; /////////////////////////////////////////////////////////////////////////// @@ -141,7 +145,7 @@ private: // any clip information. void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE; - SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) SK_OVERRIDE; + SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE; const void* peekPixels(SkImageInfo*, size_t* rowBytes) SK_OVERRIDE; diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 836f7b1115..74bf909c21 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -1321,7 +1321,8 @@ private: void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst, const SkPaint* paint); void internalDrawPaint(const SkPaint& paint); - void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy); + void internalSaveLayer(const SkRect* bounds, const SkPaint* paint, + SaveFlags, bool justForImageFilter, SaveLayerStrategy strategy); void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); // shared by save() and saveLayer() diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h index 684a08404c..c7c5c30b3a 100644 --- a/include/core/SkDevice.h +++ b/include/core/SkDevice.h @@ -125,9 +125,10 @@ public: }; protected: - enum TileUsage { - kPossible_TileUsage, //!< the created device may be drawn tiled - kNever_TileUsage, //!< the created device will never be drawn tiled + enum Usage { + kGeneral_Usage, + kSaveLayer_Usage, // onCreateCompatibleDevice(cinfo); - } -#else - /** - * Create a new device based on CreateInfo. If the paint is not null, then it represents a - * preview of how the new device will be composed with its creator device (this). - */ - virtual SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) { - return NULL; - } -#endif - virtual void initForRootLayer(SkPixelGeometry geo); private: diff --git a/include/device/xps/SkXPSDevice.h b/include/device/xps/SkXPSDevice.h index 10dab81183..514259dbaa 100644 --- a/include/device/xps/SkXPSDevice.h +++ b/include/device/xps/SkXPSDevice.h @@ -135,6 +135,8 @@ protected: int x, int y, const SkPaint& paint) SK_OVERRIDE; + bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE; + private: class TypefaceUse : ::SkNoncopyable { public: @@ -309,7 +311,7 @@ private: const SkVector& ppuScale, IXpsOMPath* shadedPath); - SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) SK_OVERRIDE; + SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE; // Disable the default copy and assign implementation. SkXPSDevice(const SkXPSDevice&); -- cgit v1.2.3