diff options
author | 2015-03-13 07:28:28 -0700 | |
---|---|---|
committer | 2015-03-13 07:28:29 -0700 | |
commit | 0e040f7da2fdfeb49aa60d24117306e3b1e6ea90 (patch) | |
tree | 7f2d8465c88766c158c1816cc60021866a55f651 /src/core/SkCanvas.cpp | |
parent | 1182d9a96b80bd12183ee7c81325a979a51ee0c0 (diff) |
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
Review URL: https://codereview.chromium.org/1008863002
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r-- | src/core/SkCanvas.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 11dc739f4c..a31ded0586 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -299,7 +299,7 @@ public: SkPaint tmp; tmp.setImageFilter(fOrigPaint.getImageFilter()); (void)canvas->internalSaveLayer(bounds, &tmp, SkCanvas::kARGB_ClipLayer_SaveFlag, - SkCanvas::kFullLayer_SaveLayerStrategy); + true, SkCanvas::kFullLayer_SaveLayerStrategy); // we'll clear the imageFilter for the actual draws in next(), so // it will only be applied during the restore(). fDoClearImageFilter = true; @@ -880,7 +880,7 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) { } SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag); fSaveCount += 1; - this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, strategy); + this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, false, strategy); return this->getSaveCount() - 1; } @@ -890,12 +890,12 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags fl } SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags); fSaveCount += 1; - this->internalSaveLayer(bounds, paint, flags, strategy); + this->internalSaveLayer(bounds, paint, flags, false, strategy); return this->getSaveCount() - 1; } void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags, - SaveLayerStrategy strategy) { + bool justForImageFilter, SaveLayerStrategy strategy) { #ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG flags |= kClipToLayer_SaveFlag; #endif @@ -917,13 +917,21 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav return; } - bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); - if (isOpaque && paint) { - // TODO: perhaps add a query to filters so we might preserve opaqueness... - if (paint->getImageFilter() || paint->getColorFilter()) { - isOpaque = false; + // Kill the imagefilter if our device doesn't allow it + SkLazyPaint lazyP; + if (paint && paint->getImageFilter()) { + if (!this->getTopDevice()->allowImageFilter(paint->getImageFilter())) { + if (justForImageFilter) { + // early exit if the layer was just for the imageFilter + return; + } + SkPaint* p = lazyP.set(*paint); + p->setImageFilter(NULL); + paint = p; } } + + bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag); SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(), isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); @@ -933,17 +941,12 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav return; } - SkBaseDevice::TileUsage usage = SkBaseDevice::kNever_TileUsage; -#if 1 - // this seems needed for current GMs, but makes us draw slower on the GPU - // Related to https://code.google.com/p/skia/issues/detail?id=3519 ? - // + SkBaseDevice::Usage usage = SkBaseDevice::kSaveLayer_Usage; if (paint && paint->getImageFilter()) { - usage = SkBaseDevice::kPossible_TileUsage; + usage = SkBaseDevice::kImageFilter_Usage; } -#endif - device = device->onCreateDevice(SkBaseDevice::CreateInfo(info, usage, fProps.pixelGeometry()), - paint); + device = device->onCreateCompatibleDevice(SkBaseDevice::CreateInfo(info, usage, + fProps.pixelGeometry())); if (NULL == device) { SkErrorInternals::SetError( kInternalError_SkError, "Unable to create device for layer."); |