diff --git a/gm/bc1_transparency.cpp b/gm/bc1_transparency.cpp index 5ff654faa2..080849691d 100644 --- a/gm/bc1_transparency.cpp +++ b/gm/bc1_transparency.cpp @@ -12,7 +12,7 @@ #include "include/gpu/GrRecordingContext.h" #include "src/core/SkCompressedDataUtils.h" #include "src/gpu/GrCaps.h" -#include "src/gpu/GrRecordingContextPriv.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/image/SkImage_Base.h" #include "src/image/SkImage_GpuBase.h" @@ -120,8 +120,7 @@ static void draw_image(SkCanvas* canvas, sk_sp image, int x, int y) { bool isCompressed = false; if (image && image->isTextureBacked()) { - GrRecordingContext* rContext = ((SkImage_GpuBase*) image.get())->context(); - const GrCaps* caps = rContext->priv().caps(); + const GrCaps* caps = as_IB(image)->context()->priv().caps(); GrTextureProxy* proxy = as_IB(image)->peekProxy(); isCompressed = caps->isFormatCompressed(proxy->backendFormat()); diff --git a/gm/compressed_textures.cpp b/gm/compressed_textures.cpp index 6db0758690..c25dd255e7 100644 --- a/gm/compressed_textures.cpp +++ b/gm/compressed_textures.cpp @@ -25,8 +25,8 @@ #include "include/gpu/GrRecordingContext.h" #include "src/core/SkCompressedDataUtils.h" #include "src/core/SkMipmap.h" -#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrDataUtils.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h" #include "src/image/SkImage_Base.h" #include "src/image/SkImage_GpuBase.h" @@ -275,8 +275,7 @@ private: bool isCompressed = false; if (image->isTextureBacked()) { - GrRecordingContext* rContext = ((SkImage_GpuBase*) image)->context(); - const GrCaps* caps = rContext->priv().caps(); + const GrCaps* caps = as_IB(image)->context()->priv().caps(); GrTextureProxy* proxy = as_IB(image)->peekProxy(); isCompressed = caps->isFormatCompressed(proxy->backendFormat()); diff --git a/gm/exoticformats.cpp b/gm/exoticformats.cpp index 71a85f2938..ed1a392124 100644 --- a/gm/exoticformats.cpp +++ b/gm/exoticformats.cpp @@ -13,6 +13,7 @@ #include "include/gpu/GrRecordingContext.h" #include "src/core/SkCompressedDataUtils.h" #include "src/core/SkMipmap.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/gl/GrGLDefines.h" #include "src/image/SkImage_Base.h" @@ -380,8 +381,7 @@ protected: bool isCompressed = false; if (image->isTextureBacked()) { - GrRecordingContext* rContext = ((SkImage_GpuBase*) image)->context(); - const GrCaps* caps = rContext->priv().caps(); + const GrCaps* caps = as_IB(image)->context()->priv().caps(); GrTextureProxy* proxy = as_IB(image)->peekProxy(); isCompressed = caps->isFormatCompressed(proxy->backendFormat()); diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index bb785b74ee..75dcecfcd2 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -313,11 +313,8 @@ protected: return; } - // CONTEXT TODO: remove this use of the 'backdoor' to create an image - GrContext* tmp = canvas->recordingContext()->priv().backdoor(); - // No API to draw a GrTexture directly, so we cheat and create a private image subclass - sk_sp texImage(new SkImage_Gpu(sk_ref_sp(tmp), + sk_sp texImage(new SkImage_Gpu(sk_ref_sp(canvas->recordingContext()), image->uniqueID(), std::move(view), image->colorType(), image->alphaType(), image->refColorSpace())); diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp index 0f121fa212..8d81c9bf62 100644 --- a/gm/showmiplevels.cpp +++ b/gm/showmiplevels.cpp @@ -337,7 +337,7 @@ class ShowMipLevels3 : public skiagm::GM { } DrawResult onDraw(SkCanvas* canvas, SkString*) override { - if (canvas->getGrContext()) { + if (canvas->recordingContext()) { // mips not supported yet return DrawResult::kSkip; } diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp index 960d6a6a1e..716ca9a67e 100644 --- a/gm/wacky_yuv_formats.cpp +++ b/gm/wacky_yuv_formats.cpp @@ -1779,7 +1779,7 @@ protected: for (auto cs : {kRec709_SkYUVColorSpace, kRec601_SkYUVColorSpace, kJPEG_SkYUVColorSpace, kBT2020_SkYUVColorSpace}) { split_into_yuv(fOrig.get(), cs, fPM); - auto img = SkImage::MakeFromYUVAPixmaps(canvas->getGrContext(), cs, fPM, indices, + auto img = SkImage::MakeFromYUVAPixmaps(canvas->recordingContext(), cs, fPM, indices, fPM[0].info().dimensions(), kTopLeft_GrSurfaceOrigin, false, false, nullptr); diff --git a/include/core/SkImage.h b/include/core/SkImage.h index cd6196f9f8..7b12a829a9 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -500,9 +500,9 @@ public: @return created SkImage, or nullptr */ static sk_sp MakeFromYUVAPixmaps( - GrContext* context, SkYUVColorSpace yuvColorSpace, const SkPixmap yuvaPixmaps[], - const SkYUVAIndex yuvaIndices[4], SkISize imageSize, GrSurfaceOrigin imageOrigin, - bool buildMips, bool limitToMaxTextureSize = false, + GrRecordingContext* context, SkYUVColorSpace yuvColorSpace, + const SkPixmap yuvaPixmaps[], const SkYUVAIndex yuvaIndices[4], SkISize imageSize, + GrSurfaceOrigin imageOrigin, bool buildMips, bool limitToMaxTextureSize = false, sk_sp imageColorSpace = nullptr); /** To be deprecated. diff --git a/include/gpu/GrRecordingContext.h b/include/gpu/GrRecordingContext.h index 108f859255..62ea0bd062 100644 --- a/include/gpu/GrRecordingContext.h +++ b/include/gpu/GrRecordingContext.h @@ -237,10 +237,10 @@ private: }; /** - * Safely cast a possibly-null recording context to direct context. + * Safely cast a possibly-null base context to direct context. */ -static inline GrDirectContext* GrAsDirectContext(GrRecordingContext* recording) { - return recording ? recording->asDirectContext() : nullptr; +static inline GrDirectContext* GrAsDirectContext(GrContext_Base* base) { + return base ? base->asDirectContext() : nullptr; } #endif diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index 702cda2477..a2a3219111 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -316,8 +316,7 @@ sk_sp SkSpecialImage::CopyFromRaster(const SkIRect& subset, static sk_sp wrap_proxy_in_image(GrRecordingContext* context, GrSurfaceProxyView view, SkColorType colorType, SkAlphaType alphaType, sk_sp colorSpace) { - // CONTEXT TODO: remove this use of 'backdoor' to create an SkImage - return sk_make_sp(sk_ref_sp(context->priv().backdoor()), + return sk_make_sp(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view), colorType, alphaType, std::move(colorSpace)); } @@ -354,8 +353,9 @@ public: // than expected backing texture (unlikely) or the 'fit' of the SurfaceProxy needs // to be tightened (if it is deferred). sk_sp img = - sk_sp(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()), this->uniqueID(), - fView, this->colorType(), fAlphaType, fColorSpace)); + sk_sp(new SkImage_Gpu(sk_ref_sp(canvas->recordingContext()), + this->uniqueID(), fView, this->colorType(), + fAlphaType, fColorSpace)); canvas->drawImageRect(img, this->subset(), dst, paint, SkCanvas::kStrict_SrcRectConstraint); @@ -436,8 +436,7 @@ public: colorType = colorSpace && colorSpace->gammaIsLinear() ? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType; SkImageInfo info = SkImageInfo::Make(size, colorType, at, sk_ref_sp(colorSpace)); - // CONTEXT TODO: remove this use of 'backdoor' to create an SkSurface - return SkSurface::MakeRenderTarget(fContext->priv().backdoor(), SkBudgeted::kYes, info); + return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kYes, info); } private: diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index d82192a96c..2739138b04 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -17,6 +17,7 @@ #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrDrawingManager.h" #include "src/gpu/GrGpu.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrMemoryPool.h" #include "src/gpu/GrPathRendererChain.h" #include "src/gpu/GrProxyProvider.h" diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp index be5c6a28bd..c8ec9ddffd 100644 --- a/src/gpu/GrImageTextureMaker.cpp +++ b/src/gpu/GrImageTextureMaker.cpp @@ -8,7 +8,7 @@ #include "src/gpu/GrImageTextureMaker.h" #include "src/gpu/GrColorSpaceXform.h" -#include "src/gpu/GrContextPriv.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/SkGr.h" #include "src/gpu/effects/GrBicubicEffect.h" diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index cb9c20aca9..37d3dd26d4 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -31,6 +31,7 @@ #if SK_SUPPORT_GPU #include "include/gpu/GrDirectContext.h" #include "src/gpu/GrContextPriv.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/image/SkImage_Gpu.h" #endif #include "include/gpu/GrBackendSurface.h" diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 638d161a39..2371ec148c 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -24,6 +24,7 @@ class GrTexture; #include class GrDirectContext; +class GrImageContext; class GrSamplerState; class SkCachedData; struct SkYUVASizeInfo; @@ -75,7 +76,7 @@ public: ReadPixelsCallback, ReadPixelsContext); - virtual GrContext* context() const { return nullptr; } + virtual GrImageContext* context() const { return nullptr; } /** this->context() try-casted to GrDirectContext. Useful for migrations – avoid otherwise! */ GrDirectContext* directContext() const; diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index edccb588d2..1b437bb423 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -29,6 +29,7 @@ #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrDrawingManager.h" #include "src/gpu/GrGpu.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrImageInfo.h" #include "src/gpu/GrImageTextureMaker.h" #include "src/gpu/GrProxyProvider.h" @@ -43,7 +44,7 @@ #include "src/gpu/gl/GrGLTexture.h" #include "src/image/SkImage_Gpu.h" -SkImage_Gpu::SkImage_Gpu(sk_sp context, uint32_t uniqueID, GrSurfaceProxyView view, +SkImage_Gpu::SkImage_Gpu(sk_sp context, uint32_t uniqueID, GrSurfaceProxyView view, SkColorType ct, SkAlphaType at, sk_sp colorSpace) : INHERITED(std::move(context), view.proxy()->backingStoreDimensions(), uniqueID, ct, at, colorSpace) @@ -196,8 +197,7 @@ static sk_sp new_wrapped_texture_common(GrRecordingContext* rContext, GrSwizzle swizzle = rContext->priv().caps()->getReadSwizzle(proxy->backendFormat(), colorType); GrSurfaceProxyView view(std::move(proxy), origin, swizzle); - auto grContext = rContext->priv().backdoor(); - return sk_make_sp(sk_ref_sp(grContext), kNeedNewImageUniqueID, std::move(view), + return sk_make_sp(sk_ref_sp(rContext), kNeedNewImageUniqueID, std::move(view), GrColorTypeToSkColorType(colorType), at, std::move(colorSpace)); } @@ -234,8 +234,7 @@ sk_sp SkImage::MakeFromCompressedTexture(GrRecordingContext* rContext, SkColorType ct = GrCompressionTypeToSkColorType(type); GrSurfaceProxyView view(std::move(proxy), origin, GrSwizzle::RGBA()); - auto grContext = rContext->priv().backdoor(); - return sk_make_sp(sk_ref_sp(grContext), kNeedNewImageUniqueID, std::move(view), + return sk_make_sp(sk_ref_sp(rContext), kNeedNewImageUniqueID, std::move(view), ct, at, std::move(cs)); } @@ -351,10 +350,8 @@ sk_sp SkImage_Gpu::ConvertYUVATexturesToRGB(GrRecordingContext* rContex SkColorType ct = GrColorTypeToSkColorType(renderTargetContext->colorInfo().colorType()); SkAlphaType at = GetAlphaTypeFromYUVAIndices(yuvaIndices); - // TODO: Remove this use of backdoor. - GrContext* backdoorGrCtx = rContext->priv().backdoor(); // MDB: this call is okay bc we know 'renderTargetContext' was exact - return sk_make_sp(sk_ref_sp(backdoorGrCtx), kNeedNewImageUniqueID, + return sk_make_sp(sk_ref_sp(rContext), kNeedNewImageUniqueID, renderTargetContext->readSurfaceView(), ct, at, renderTargetContext->colorInfo().refColorSpace()); } @@ -596,7 +593,7 @@ sk_sp SkImage_Gpu::MakePromiseTexture(GrRecordingContext* context, GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType); GrSurfaceProxyView view(std::move(proxy), origin, swizzle); // CONTEXT TODO: rm this usage of the 'backdoor' to create an image - return sk_make_sp(sk_ref_sp(context->priv().backdoor()), kNeedNewImageUniqueID, + return sk_make_sp(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view), colorType, alphaType, std::move(colorSpace)); } diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index e62978e565..d6bb145226 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -23,8 +23,8 @@ struct SkYUVAIndex; class SkImage_Gpu : public SkImage_GpuBase { public: - SkImage_Gpu(sk_sp, uint32_t uniqueID, GrSurfaceProxyView, SkColorType, SkAlphaType, - sk_sp); + SkImage_Gpu(sk_sp, uint32_t uniqueID, GrSurfaceProxyView, SkColorType, + SkAlphaType, sk_sp); ~SkImage_Gpu() override; GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) override; diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp index bf59d5e66d..740def5c70 100644 --- a/src/image/SkImage_GpuBase.cpp +++ b/src/image/SkImage_GpuBase.cpp @@ -14,6 +14,7 @@ #include "src/core/SkBitmapCache.h" #include "src/core/SkTLList.h" #include "src/gpu/GrContextPriv.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrImageInfo.h" #include "src/gpu/GrProxyProvider.h" #include "src/gpu/GrRecordingContextPriv.h" @@ -24,7 +25,7 @@ #include "src/image/SkImage_Gpu.h" #include "src/image/SkReadPixelsRec.h" -SkImage_GpuBase::SkImage_GpuBase(sk_sp context, SkISize size, uint32_t uniqueID, +SkImage_GpuBase::SkImage_GpuBase(sk_sp context, SkISize size, uint32_t uniqueID, SkColorType ct, SkAlphaType at, sk_sp cs) : INHERITED(SkImageInfo::Make(size, ct, at, std::move(cs)), uniqueID) , fContext(std::move(context)) {} @@ -32,7 +33,7 @@ SkImage_GpuBase::SkImage_GpuBase(sk_sp context, SkISize size, uint32_ ////////////////////////////////////////////////////////////////////////////////////////////////// #if GR_TEST_UTILS -void SkImage_GpuBase::resetContext(sk_sp newContext) { +void SkImage_GpuBase::resetContext(sk_sp newContext) { SkASSERT(fContext->priv().matches(newContext.get())); fContext = newContext; } @@ -189,7 +190,8 @@ GrSurfaceProxyView SkImage_GpuBase::refView(GrRecordingContext* context, return {}; } - GrTextureAdjuster adjuster(fContext.get(), *this->view(context), this->imageInfo().colorInfo(), + + GrTextureAdjuster adjuster(context, *this->view(context), this->imageInfo().colorInfo(), this->uniqueID()); return adjuster.view(mipMapped); } @@ -251,7 +253,7 @@ GrTexture* SkImage_GpuBase::getTexture() const { bool SkImage_GpuBase::onIsValid(GrRecordingContext* context) const { // The base class has already checked that 'context' isn't abandoned (if it's not nullptr) - if (fContext->abandoned()) { + if (fContext->priv().abandoned()) { return false; } diff --git a/src/image/SkImage_GpuBase.h b/src/image/SkImage_GpuBase.h index 2f8144fbad..66785e1c05 100644 --- a/src/image/SkImage_GpuBase.h +++ b/src/image/SkImage_GpuBase.h @@ -15,14 +15,14 @@ #include "src/image/SkImage_Base.h" class GrColorSpaceXform; -class GrContext; class GrDirectContext; +class GrImageContext; class GrRenderTargetContext; class SkColorSpace; class SkImage_GpuBase : public SkImage_Base { public: - GrContext* context() const final { return fContext.get(); } + GrImageContext* context() const final { return fContext.get(); } bool getROPixels(GrDirectContext*, SkBitmap*, CachingHint) const final; sk_sp onMakeSubset(const SkIRect& subset, GrDirectContext*) const final; @@ -51,7 +51,7 @@ public: bool onIsValid(GrRecordingContext*) const final; #if GR_TEST_UTILS - void resetContext(sk_sp newContext); + void resetContext(sk_sp newContext); #endif static bool ValidateBackendTexture(const GrCaps*, const GrBackendTexture& tex, @@ -78,8 +78,8 @@ public: using PromiseImageTextureDoneProc = SkDeferredDisplayListRecorder::PromiseImageTextureDoneProc; protected: - SkImage_GpuBase(sk_sp, SkISize size, uint32_t uniqueID, SkColorType, SkAlphaType, - sk_sp); + SkImage_GpuBase(sk_sp, SkISize size, uint32_t uniqueID, SkColorType, + SkAlphaType, sk_sp); using PromiseImageApiVersion = SkDeferredDisplayListRecorder::PromiseImageApiVersion; // Helper for making a lazy proxy for a promise image. The PromiseDoneProc we be called, @@ -97,8 +97,7 @@ protected: GrSurfaceProxyView [4], const SkYUVAIndex [4]); - // TODO: Migrate this to something much weaker, such as GrContextThreadSafeProxy. - sk_sp fContext; + sk_sp fContext; private: using INHERITED = SkImage_Base; diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp index dd44235892..546c821b6d 100644 --- a/src/image/SkImage_GpuYUVA.cpp +++ b/src/image/SkImage_GpuYUVA.cpp @@ -19,6 +19,7 @@ #include "src/gpu/GrClip.h" #include "src/gpu/GrContextPriv.h" #include "src/gpu/GrGpu.h" +#include "src/gpu/GrImageContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRenderTargetContext.h" #include "src/gpu/GrTexture.h" @@ -30,7 +31,7 @@ static constexpr auto kAssumedColorType = kRGBA_8888_SkColorType; -SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp context, +SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp context, SkISize size, uint32_t uniqueID, SkYUVColorSpace colorSpace, @@ -39,8 +40,7 @@ SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp context, const SkYUVAIndex yuvaIndices[4], GrSurfaceOrigin origin, sk_sp imageColorSpace) - // CONTEXT TODO: rm this usage of the 'backdoor' to create an image - : INHERITED(sk_ref_sp(context->priv().backdoor()), + : INHERITED(std::move(context), size, uniqueID, kAssumedColorType, @@ -64,7 +64,7 @@ SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp context, } // For onMakeColorSpace() -SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp context, const SkImage_GpuYUVA* image, +SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp context, const SkImage_GpuYUVA* image, sk_sp targetCS) : INHERITED(std::move(context), image->dimensions(), kNeedNewImageUniqueID, kAssumedColorType, @@ -268,7 +268,8 @@ sk_sp SkImage::MakeFromYUVATextures(GrContext* ctx, imageColorSpace); } -sk_sp SkImage::MakeFromYUVAPixmaps(GrContext* context, SkYUVColorSpace yuvColorSpace, +sk_sp SkImage::MakeFromYUVAPixmaps(GrRecordingContext* context, + SkYUVColorSpace yuvColorSpace, const SkPixmap yuvaPixmaps[], const SkYUVAIndex yuvaIndices[4], SkISize imageSize, GrSurfaceOrigin imageOrigin, bool buildMips, diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h index 24287cf6fb..93f7f12d01 100644 --- a/src/image/SkImage_GpuYUVA.h +++ b/src/image/SkImage_GpuYUVA.h @@ -24,7 +24,7 @@ class SkImage_GpuYUVA : public SkImage_GpuBase { public: friend class GrYUVAImageTextureMaker; - SkImage_GpuYUVA(sk_sp, + SkImage_GpuYUVA(sk_sp, SkISize size, uint32_t uniqueID, SkYUVColorSpace, @@ -86,7 +86,7 @@ public: PromiseImageApiVersion); private: - SkImage_GpuYUVA(sk_sp, const SkImage_GpuYUVA* image, sk_sp); + SkImage_GpuYUVA(sk_sp, const SkImage_GpuYUVA* image, sk_sp); void flattenToRGB(GrRecordingContext*) const; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index d368e5e924..5402704531 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -103,9 +103,7 @@ sk_sp SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) { return nullptr; } - // CONTEXT TODO: remove this use of 'backdoor' to create an SkImage. The issue is that - // SkImages still require a GrContext but the SkGpuDevice only holds a GrRecordingContext. - GrContext* context = fDevice->recordingContext()->priv().backdoor(); + auto rContext = fDevice->recordingContext(); if (!rtc->asSurfaceProxy()) { return nullptr; @@ -119,7 +117,7 @@ sk_sp SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) { // want to ever retarget the SkSurface at another buffer we create. Force a copy now to // avoid copy-on-write. auto rect = subset ? *subset : SkIRect::MakeSize(rtc->dimensions()); - srcView = GrSurfaceProxyView::Copy(context, std::move(srcView), rtc->mipmapped(), rect, + srcView = GrSurfaceProxyView::Copy(rContext, std::move(srcView), rtc->mipmapped(), rect, SkBackingFit::kExact, budgeted); } @@ -129,7 +127,7 @@ sk_sp SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) { // The renderTargetContext coming out of SkGpuDevice should always be exact and the // above copy creates a kExact surfaceContext. SkASSERT(srcView.proxy()->priv().isExact()); - image = sk_make_sp(sk_ref_sp(context), kNeedNewImageUniqueID, + image = sk_make_sp(sk_ref_sp(rContext), kNeedNewImageUniqueID, std::move(srcView), info.colorType(), info.alphaType(), info.refColorSpace()); } diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 8af6c103b3..25c35435e7 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -409,7 +409,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn for (auto budgeted : {SkBudgeted::kNo, SkBudgeted::kYes}) { auto texImage = image->makeTextureImage(dContext, mipMapped, budgeted); if (!texImage) { - GrContext* imageContext = as_IB(image)->context(); + auto imageContext = as_IB(image)->context(); // We expect to fail if image comes from a different context if (!image->isTextureBacked() || imageContext == dContext) { ERRORF(reporter, "makeTextureImage failed."); @@ -593,17 +593,17 @@ DEF_GPUTEST(AbandonedContextImage, reporter, options) { auto rsurf = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100)); REPORTER_ASSERT(reporter, img->isValid(factory->get(type))); - REPORTER_ASSERT(reporter, img->isValid(rsurf->getCanvas()->getGrContext())); + REPORTER_ASSERT(reporter, img->isValid(rsurf->getCanvas()->recordingContext())); factory->get(type)->abandonContext(); REPORTER_ASSERT(reporter, !img->isValid(factory->get(type))); - REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->getGrContext())); + REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->recordingContext())); // This shouldn't crash. rsurf->getCanvas()->drawImage(img, 0, 0); // Give up all other refs on the context. factory.reset(nullptr); - REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->getGrContext())); + REPORTER_ASSERT(reporter, !img->isValid(rsurf->getCanvas()->recordingContext())); // This shouldn't crash. rsurf->getCanvas()->drawImage(img, 0, 0); } diff --git a/tools/DDLTileHelper.cpp b/tools/DDLTileHelper.cpp index d426b5cd15..8783bfd7ae 100644 --- a/tools/DDLTileHelper.cpp +++ b/tools/DDLTileHelper.cpp @@ -71,13 +71,10 @@ void DDLTileHelper::TileData::createDDL() { // stored in fReconstitutedPicture's promise images are incorrect. Patch them with the correct // one now. for (int i = 0; i < fPromiseImages.count(); ++i) { - // CONTEXT TODO: this can be converted to a recording context once images no longer - // hold GrContexts - GrContext* newContext = recordingCanvas->getGrContext(); - if (fPromiseImages[i]->isTextureBacked()) { + auto rContext = recordingCanvas->recordingContext(); SkImage_GpuBase* gpuImage = (SkImage_GpuBase*) fPromiseImages[i].get(); - gpuImage->resetContext(sk_ref_sp(newContext)); + gpuImage->resetContext(sk_ref_sp(rContext)); } } diff --git a/tools/gpu/YUVUtils.cpp b/tools/gpu/YUVUtils.cpp index d4f0488d29..87ce7120b1 100644 --- a/tools/gpu/YUVUtils.cpp +++ b/tools/gpu/YUVUtils.cpp @@ -75,7 +75,7 @@ bool LazyYUVImage::ensureYUVImage(GrRecordingContext* rContext) { return true; // Have already made a YUV image valid for this context. } // Try to make a new YUV image for this context. - fYUVImage = SkImage::MakeFromYUVAPixmaps(rContext->priv().backdoor(), + fYUVImage = SkImage::MakeFromYUVAPixmaps(rContext, fPixmaps.yuvaInfo().yuvColorSpace(), fPixmaps.planes().data(), fComponents,