diff options
author | brianosman <brianosman@google.com> | 2016-09-23 08:49:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-23 08:49:51 -0700 |
commit | a76554d2ae7f676776c1d472aa433b048f418ea9 (patch) | |
tree | 9c035426cb129653838b72242387c2de9fdf5634 /src/core | |
parent | 1cd88c4b759b3c5cbf663c55d1f1c30a4114ded9 (diff) |
Revert of Create special surfaces according to original device (not always in N32) (patchset #9 id:160001 of https://codereview.chromium.org/2349373004/ )
Reason for revert:
DM crash and/or TSAN failure
Original issue's description:
> Change SkSpecialImage::makeSurface and makeTightSurface to take output
> properties (color space), bounds, and (optional) alphaType.
>
> We were being pretty inconsistent before. Raster was honoring all
> components of the info. GPU was using the supplied color type, but
> propagating the source's color space. All call sites were saying N32.
>
> What we want to do is propagate the original device's color space, and
> pick a good format from that. Rather than force all the clients to
> jump through hoops constructing an SkImageInfo that meets our criteria,
> just have them supply the few bits we care about, and do everything else
> internally.
>
> This also lets us always use RGBA on GPU, but N32 on raster.
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2349373004
>
> Committed: https://skia.googlesource.com/skia/+/53c38087949252d27cde668368a3eeb59cc2eb00
TBR=robertphillips@google.com,reed@google.com,bsalomon@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review-Url: https://codereview.chromium.org/2366723004
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkImageFilter.cpp | 6 | ||||
-rw-r--r-- | src/core/SkMatrixImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/core/SkSpecialImage.cpp | 65 | ||||
-rw-r--r-- | src/core/SkSpecialImage.h | 11 |
4 files changed, 24 insertions, 62 deletions
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 9373dc1a1d..be48ca17ba 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -348,9 +348,9 @@ bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds, // around it. static sk_sp<SkSpecialImage> pad_image(SkSpecialImage* src, int newWidth, int newHeight, int offX, int offY) { - // We explicitly want to operate in the source's color space here - SkImageFilter::OutputProperties outProps(src->getColorSpace()); - sk_sp<SkSpecialSurface> surf(src->makeSurface(outProps, SkISize::Make(newWidth, newHeight))); + + SkImageInfo info = SkImageInfo::MakeN32Premul(newWidth, newHeight); + sk_sp<SkSpecialSurface> surf(src->makeSurface(info)); if (!surf) { return nullptr; } diff --git a/src/core/SkMatrixImageFilter.cpp b/src/core/SkMatrixImageFilter.cpp index 12efc64683..2e827d82a6 100644 --- a/src/core/SkMatrixImageFilter.cpp +++ b/src/core/SkMatrixImageFilter.cpp @@ -70,7 +70,9 @@ sk_sp<SkSpecialImage> SkMatrixImageFilter::onFilterImage(SkSpecialImage* source, SkIRect dstBounds; dstRect.roundOut(&dstBounds); - sk_sp<SkSpecialSurface> surf(input->makeSurface(ctx.outputProperties(), dstBounds.size())); + const SkImageInfo info = SkImageInfo::MakeN32Premul(dstBounds.width(), dstBounds.height()); + + sk_sp<SkSpecialSurface> surf(input->makeSurface(info)); if (!surf) { return nullptr; } diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index 5d62c6bc62..240d469219 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -52,13 +52,11 @@ public: 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; + virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const = 0; virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0; - virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const = 0; + virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const = 0; private: typedef SkSpecialImage INHERITED; @@ -153,14 +151,12 @@ sk_sp<GrTexture> SkSpecialImage::asTextureRef(GrContext* context) const { } #endif -sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const { - return as_SIB(this)->onMakeSurface(outProps, size, at); +sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) const { + return as_SIB(this)->onMakeSurface(info); } -sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const { - return as_SIB(this)->onMakeTightSurface(outProps, size, at); +sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageInfo& info) const { + return as_SIB(this)->onMakeTightSurface(info); } sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const { @@ -256,22 +252,7 @@ public: } #endif -// TODO: The raster implementations of image filters all currently assume that the pixels are -// legacy N32. Until they actually check the format and operate on sRGB or F16 data appropriately, -// we can't enable this. (They will continue to produce incorrect results, but less-so). -#define RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 0 - - sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const override { -#if RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 - SkColorSpace* colorSpace = outProps.colorSpace(); -#else - SkColorSpace* colorSpace = nullptr; -#endif - SkColorType colorType = colorSpace && colorSpace->gammaIsLinear() - ? kRGBA_F16_SkColorType : kN32_SkColorType; - SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at, - sk_ref_sp(colorSpace)); + sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override { return SkSpecialSurface::MakeRaster(info, nullptr); } @@ -297,17 +278,7 @@ public: return SkImage::MakeFromBitmap(subsetBM); } - sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const override { -#if RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 - SkColorSpace* colorSpace = outProps.colorSpace(); -#else - SkColorSpace* colorSpace = nullptr; -#endif - SkColorType colorType = colorSpace && colorSpace->gammaIsLinear() - ? kRGBA_F16_SkColorType : kN32_SkColorType; - SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at, - sk_ref_sp(colorSpace)); + sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override { return SkSurface::MakeRaster(info); } @@ -411,16 +382,16 @@ public: return fColorSpace.get(); } - sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const override { + sk_sp<SkSpecialSurface> onMakeSurface(const SkImageInfo& info) const override { if (!fTexture->getContext()) { return nullptr; } - SkColorSpace* colorSpace = outProps.colorSpace(); - return SkSpecialSurface::MakeRenderTarget( - fTexture->getContext(), size.width(), size.height(), - GrRenderableConfigForColorSpace(colorSpace), sk_ref_sp(colorSpace)); + GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext()->caps()); + + return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(), + info.width(), info.height(), + config, sk_ref_sp(info.colorSpace())); } sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { @@ -457,13 +428,7 @@ public: fAlphaType, subTx.get(), fColorSpace, SkBudgeted::kYes); } - sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, SkAlphaType at) const override { - SkColorSpace* colorSpace = outProps.colorSpace(); - SkColorType colorType = colorSpace && colorSpace->gammaIsLinear() - ? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType; - SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at, - sk_ref_sp(colorSpace)); + sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override { return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::kYes, info); } diff --git a/src/core/SkSpecialImage.h b/src/core/SkSpecialImage.h index c1f3791edf..cd8c3141fb 100644 --- a/src/core/SkSpecialImage.h +++ b/src/core/SkSpecialImage.h @@ -12,8 +12,7 @@ #include "SkRefCnt.h" #include "SkSurfaceProps.h" -#include "SkImageFilter.h" // for OutputProperties -#include "SkImageInfo.h" // for SkAlphaType +#include "SkImageInfo.h" // for SkAlphaType class GrContext; class GrTexture; @@ -87,17 +86,13 @@ public: /** * Create a new special surface with a backend that is compatible with this special image. */ - sk_sp<SkSpecialSurface> makeSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, - SkAlphaType at = kPremul_SkAlphaType) const; + sk_sp<SkSpecialSurface> makeSurface(const SkImageInfo&) const; /** * Create a new surface with a backend that is compatible with this special image. * TODO: switch this to makeSurface once we resolved the naming issue */ - sk_sp<SkSurface> makeTightSurface(const SkImageFilter::OutputProperties& outProps, - const SkISize& size, - SkAlphaType at = kPremul_SkAlphaType) const; + sk_sp<SkSurface> makeTightSurface(const SkImageInfo&) const; /** * Extract a subset of this special image and return it as a special image. |