Disable LCD text when drawing SkPictureImageFilter content
No-Tree-Checks: true
No-Try: true
No-Presubmit: true
TBR=robertphillips@google.com
Bug: 878874
Change-Id: I6c1e4a024014079dfdca5d8082acc43640049f85
Reviewed-on: https://skia-review.googlesource.com/155922
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Robert Phillips <robertphillips@google.com>
(cherry picked from commit e0e8393e10ea290defeaabd486e1467ac1798033)
Reviewed-on: https://skia-review.googlesource.com/157592
Commit-Queue: Khusal Sagar <khushalsagar@chromium.org>
Reviewed-by: Khusal Sagar <khushalsagar@chromium.org>
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 14c2a5b..222504c 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -55,7 +55,8 @@
virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps,
- const SkISize& size, SkAlphaType at) const = 0;
+ const SkISize& size, SkAlphaType at,
+ const SkSurfaceProps* = nullptr) const = 0;
virtual sk_sp<SkImage> onAsImage(const SkIRect* subset) const = 0;
@@ -152,8 +153,9 @@
#endif
sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageFilter::OutputProperties& outProps,
- const SkISize& size, SkAlphaType at) const {
- return as_SIB(this)->onMakeSurface(outProps, size, at);
+ const SkISize& size, SkAlphaType at,
+ const SkSurfaceProps* props) const {
+ return as_SIB(this)->onMakeSurface(outProps, size, at, props);
}
sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageFilter::OutputProperties& outProps,
@@ -255,7 +257,8 @@
#define RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 0
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps,
- const SkISize& size, SkAlphaType at) const override {
+ const SkISize& size, SkAlphaType at,
+ const SkSurfaceProps* props) const override {
#if RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16
SkColorSpace* colorSpace = outProps.colorSpace();
#else
@@ -265,7 +268,7 @@
? kRGBA_F16_SkColorType : kN32_SkColorType;
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));
- return SkSpecialSurface::MakeRaster(info, nullptr);
+ return SkSpecialSurface::MakeRaster(info, props);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
@@ -428,14 +431,16 @@
}
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps,
- const SkISize& size, SkAlphaType at) const override {
+ const SkISize& size, SkAlphaType at,
+ const SkSurfaceProps* props) const override {
if (!fContext) {
return nullptr;
}
return SkSpecialSurface::MakeRenderTarget(
fContext, size.width(), size.height(),
- SkColorType2GrPixelConfig(outProps.colorType()), sk_ref_sp(outProps.colorSpace()));
+ SkColorType2GrPixelConfig(outProps.colorType()), sk_ref_sp(outProps.colorSpace()),
+ props);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
diff --git a/src/core/SkSpecialImage.h b/src/core/SkSpecialImage.h
index d694fa2..48284598 100644
--- a/src/core/SkSpecialImage.h
+++ b/src/core/SkSpecialImage.h
@@ -91,7 +91,8 @@
*/
sk_sp<SkSpecialSurface> makeSurface(const SkImageFilter::OutputProperties& outProps,
const SkISize& size,
- SkAlphaType at = kPremul_SkAlphaType) const;
+ SkAlphaType at = kPremul_SkAlphaType,
+ const SkSurfaceProps* props = nullptr) const;
/**
* Create a new surface with a backend that is compatible with this special image.
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index f7cddcd..a45b40b 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -166,14 +166,16 @@
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
int width, int height,
GrPixelConfig config,
- sk_sp<SkColorSpace> colorSpace) {
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props) {
if (!context) {
return nullptr;
}
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- SkBackingFit::kApprox, width, height, config, std::move(colorSpace)));
+ SkBackingFit::kApprox, width, height, config, std::move(colorSpace), 1,
+ GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h
index 2c138a3..b04b28d 100644
--- a/src/core/SkSpecialSurface.h
+++ b/src/core/SkSpecialSurface.h
@@ -62,7 +62,8 @@
static sk_sp<SkSpecialSurface> MakeRenderTarget(GrContext*,
int width, int height,
GrPixelConfig config,
- sk_sp<SkColorSpace> colorSpace);
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* = nullptr);
#endif
/**
diff --git a/src/effects/imagefilters/SkPictureImageFilter.cpp b/src/effects/imagefilters/SkPictureImageFilter.cpp
index b9c298d..a25dee5 100644
--- a/src/effects/imagefilters/SkPictureImageFilter.cpp
+++ b/src/effects/imagefilters/SkPictureImageFilter.cpp
@@ -99,11 +99,17 @@
SkASSERT(!bounds.isEmpty());
- sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
+ // Given the standard usage of the picture image filter (i.e., to render content at a fixed
+ // resolution that, most likely, differs from the screen's) disable LCD text.
+ SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
+ sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size(),
+ kPremul_SkAlphaType, &props));
if (!surf) {
return nullptr;
}
+ SkASSERT(kUnknown_SkPixelGeometry == surf->props().pixelGeometry());
+
SkCanvas* canvas = surf->getCanvas();
SkASSERT(canvas);
canvas->clear(0x0);