From 2084ffa9a3fa7eb3c7e17ec5b55750be9942bafc Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 27 Mar 2017 17:32:18 -0400 Subject: [PATCH] Revert "Fix SkImage_Gpu::getROPixels" This reverts commit f4d443fd1bd8cffbcd7a07a48f3488ae871414e9. Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=705156 Original change's description: > Fix SkImage_Gpu::getROPixels > > The dstColorSpace is a badly named parameter. It's a hint about where/how > the returned pixels are going to be used. Raster and GPU are meant to > ignore that information - codecs use it to drive our decoding heuristic. > > I've adopted that name in several places, although it's quite bad. Maybe > usageColorSpace would be better? > > Bug: skia: > Change-Id: I99acaac4bed57ed8acd8433e1c5b39a60c3af09e > Reviewed-on: https://skia-review.googlesource.com/10109 > Reviewed-by: Matt Sarett > Commit-Queue: Brian Osman > TBR=msarett@google.com,robertphillips@google.com,brianosman@google.com,reed@google.com,reviews@skia.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Id46226e41ca287ef3351710815ae2e842da4d293 Reviewed-on: https://skia-review.googlesource.com/10210 Reviewed-by: Brian Salomon Commit-Queue: Brian Salomon --- src/image/SkImage_Gpu.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 68a2df0..1dcc69c 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -62,6 +62,10 @@ SkImageInfo SkImage_Gpu::onImageInfo() const { return SkImageInfo::Make(fProxy->width(), fProxy->height(), ct, fAlphaType, fColorSpace); } +static SkImageInfo make_info(int w, int h, SkAlphaType at, sk_sp colorSpace) { + return SkImageInfo::MakeN32(w, h, at, std::move(colorSpace)); +} + bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace, CachingHint chint) const { const auto desc = SkBitmapCacheDesc::Make(this); if (SkBitmapCache::Find(desc, dst)) { @@ -71,12 +75,15 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace, Cachin return true; } - if (!dst->tryAllocPixels(this->onImageInfo())) { + SkImageInfo ii = make_info(this->width(), this->height(), this->alphaType(), + sk_ref_sp(dstColorSpace)); + if (!dst->tryAllocPixels(ii)) { return false; } - sk_sp sContext = - fContext->contextPriv().makeWrappedSurfaceContext(fProxy, fColorSpace); + sk_sp sContext = fContext->contextPriv().makeWrappedSurfaceContext( + fProxy, + fColorSpace); if (!sContext) { return false; } @@ -188,8 +195,9 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size flags = GrContext::kUnpremul_PixelOpsFlag; } - sk_sp sContext = - fContext->contextPriv().makeWrappedSurfaceContext(fProxy, fColorSpace); + sk_sp sContext = fContext->contextPriv().makeWrappedSurfaceContext( + fProxy, + fColorSpace); if (!sContext) { return false; } -- 2.7.4