Index: src/core/SkCanvas.cpp |
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp |
index a31ded05864a9b436532e6320f09e8efc413cd7d..11dc739f4c4dc6aa0509f8ba404a56fa246817e4 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."); |