aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkCanvas.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-03-13 08:46:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-13 08:46:12 -0700
commitf7076a13e2d4269903b34ef2780e1c84723e4477 (patch)
tree0341a3d6020bf1d0153f9a882d74080d42435e90 /src/core/SkCanvas.cpp
parentfd45079314b739979492601fc7a242aff24c58a3 (diff)
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 Review URL: https://codereview.chromium.org/1006923002
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r--src/core/SkCanvas.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index a31ded0586..11dc739f4c 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,
- true, SkCanvas::kFullLayer_SaveLayerStrategy);
+ 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, false, strategy);
+ this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, 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, false, strategy);
+ this->internalSaveLayer(bounds, paint, flags, strategy);
return this->getSaveCount() - 1;
}
void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags,
- bool justForImageFilter, SaveLayerStrategy strategy) {
+ SaveLayerStrategy strategy) {
#ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
flags |= kClipToLayer_SaveFlag;
#endif
@@ -917,21 +917,13 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
return;
}
- // 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);
+ if (isOpaque && paint) {
+ // TODO: perhaps add a query to filters so we might preserve opaqueness...
+ if (paint->getImageFilter() || paint->getColorFilter()) {
+ isOpaque = false;
}
}
-
- bool isOpaque = !SkToBool(flags & kHasAlphaLayer_SaveFlag);
SkImageInfo info = SkImageInfo::MakeN32(ir.width(), ir.height(),
isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
@@ -941,12 +933,17 @@ void SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint, Sav
return;
}
- SkBaseDevice::Usage usage = SkBaseDevice::kSaveLayer_Usage;
+ 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 ?
+ //
if (paint && paint->getImageFilter()) {
- usage = SkBaseDevice::kImageFilter_Usage;
+ usage = SkBaseDevice::kPossible_TileUsage;
}
- device = device->onCreateCompatibleDevice(SkBaseDevice::CreateInfo(info, usage,
- fProps.pixelGeometry()));
+#endif
+ device = device->onCreateDevice(SkBaseDevice::CreateInfo(info, usage, fProps.pixelGeometry()),
+ paint);
if (NULL == device) {
SkErrorInternals::SetError( kInternalError_SkError,
"Unable to create device for layer.");