Downgrade SkImage to GrImageContext

We still occasionally downcast, so this is not airtight,
but it (1) allows us to know where we are downcasting and
(2) lets us move away from GrContext (and hopefully remove
it sooner than later.)

All three canaries are currently broken =( so here we go!

Bug: skia:104662
Change-Id: I84efe132574690b62ea512e194e4f9e318e9c050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316218
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Adlai Holler 2020-09-14 11:58:06 -04:00 committed by Skia Commit-Bot
parent 34b19c5750
commit 302e8fb771
23 changed files with 63 additions and 72 deletions

View File

@ -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<SkImage> 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());

View File

@ -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());

View File

@ -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());

View File

@ -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<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(tmp),
sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(canvas->recordingContext()),
image->uniqueID(), std::move(view),
image->colorType(), image->alphaType(),
image->refColorSpace()));

View File

@ -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;
}

View File

@ -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);

View File

@ -500,9 +500,9 @@ public:
@return created SkImage, or nullptr
*/
static sk_sp<SkImage> 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<SkColorSpace> imageColorSpace = nullptr);
/** To be deprecated.

View File

@ -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

View File

@ -316,8 +316,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::CopyFromRaster(const SkIRect& subset,
static sk_sp<SkImage> wrap_proxy_in_image(GrRecordingContext* context, GrSurfaceProxyView view,
SkColorType colorType, SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace) {
// CONTEXT TODO: remove this use of 'backdoor' to create an SkImage
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context->priv().backdoor()),
return sk_make_sp<SkImage_Gpu>(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<SkImage> img =
sk_sp<SkImage>(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()), this->uniqueID(),
fView, this->colorType(), fAlphaType, fColorSpace));
sk_sp<SkImage>(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:

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -24,6 +24,7 @@ class GrTexture;
#include <new>
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;

View File

@ -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<GrContext> context, uint32_t uniqueID, GrSurfaceProxyView view,
SkImage_Gpu::SkImage_Gpu(sk_sp<GrImageContext> context, uint32_t uniqueID, GrSurfaceProxyView view,
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> colorSpace)
: INHERITED(std::move(context), view.proxy()->backingStoreDimensions(), uniqueID,
ct, at, colorSpace)
@ -196,8 +197,7 @@ static sk_sp<SkImage> 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<SkImage_Gpu>(sk_ref_sp(grContext), kNeedNewImageUniqueID, std::move(view),
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(rContext), kNeedNewImageUniqueID, std::move(view),
GrColorTypeToSkColorType(colorType), at, std::move(colorSpace));
}
@ -234,8 +234,7 @@ sk_sp<SkImage> 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<SkImage_Gpu>(sk_ref_sp(grContext), kNeedNewImageUniqueID, std::move(view),
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(rContext), kNeedNewImageUniqueID, std::move(view),
ct, at, std::move(cs));
}
@ -351,10 +350,8 @@ sk_sp<SkImage> 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<SkImage_Gpu>(sk_ref_sp(backdoorGrCtx), kNeedNewImageUniqueID,
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(rContext), kNeedNewImageUniqueID,
renderTargetContext->readSurfaceView(), ct, at,
renderTargetContext->colorInfo().refColorSpace());
}
@ -596,7 +593,7 @@ sk_sp<SkImage> 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<SkImage_Gpu>(sk_ref_sp(context->priv().backdoor()), kNeedNewImageUniqueID,
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID,
std::move(view), colorType, alphaType, std::move(colorSpace));
}

View File

@ -23,8 +23,8 @@ struct SkYUVAIndex;
class SkImage_Gpu : public SkImage_GpuBase {
public:
SkImage_Gpu(sk_sp<GrContext>, uint32_t uniqueID, GrSurfaceProxyView, SkColorType, SkAlphaType,
sk_sp<SkColorSpace>);
SkImage_Gpu(sk_sp<GrImageContext>, uint32_t uniqueID, GrSurfaceProxyView, SkColorType,
SkAlphaType, sk_sp<SkColorSpace>);
~SkImage_Gpu() override;
GrSemaphoresSubmitted onFlush(GrDirectContext*, const GrFlushInfo&) override;

View File

@ -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<GrContext> context, SkISize size, uint32_t uniqueID,
SkImage_GpuBase::SkImage_GpuBase(sk_sp<GrImageContext> context, SkISize size, uint32_t uniqueID,
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> 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<GrContext> context, SkISize size, uint32_
//////////////////////////////////////////////////////////////////////////////////////////////////
#if GR_TEST_UTILS
void SkImage_GpuBase::resetContext(sk_sp<GrContext> newContext) {
void SkImage_GpuBase::resetContext(sk_sp<GrImageContext> 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;
}

View File

@ -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<SkImage> 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<GrContext> newContext);
void resetContext(sk_sp<GrImageContext> newContext);
#endif
static bool ValidateBackendTexture(const GrCaps*, const GrBackendTexture& tex,
@ -78,8 +78,8 @@ public:
using PromiseImageTextureDoneProc = SkDeferredDisplayListRecorder::PromiseImageTextureDoneProc;
protected:
SkImage_GpuBase(sk_sp<GrContext>, SkISize size, uint32_t uniqueID, SkColorType, SkAlphaType,
sk_sp<SkColorSpace>);
SkImage_GpuBase(sk_sp<GrImageContext>, SkISize size, uint32_t uniqueID, SkColorType,
SkAlphaType, sk_sp<SkColorSpace>);
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<GrContext> fContext;
sk_sp<GrImageContext> fContext;
private:
using INHERITED = SkImage_Base;

View File

@ -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<GrRecordingContext> context,
SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrImageContext> context,
SkISize size,
uint32_t uniqueID,
SkYUVColorSpace colorSpace,
@ -39,8 +40,7 @@ SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrRecordingContext> context,
const SkYUVAIndex yuvaIndices[4],
GrSurfaceOrigin origin,
sk_sp<SkColorSpace> 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<GrRecordingContext> context,
}
// For onMakeColorSpace()
SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrContext> context, const SkImage_GpuYUVA* image,
SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrImageContext> context, const SkImage_GpuYUVA* image,
sk_sp<SkColorSpace> targetCS)
: INHERITED(std::move(context), image->dimensions(), kNeedNewImageUniqueID,
kAssumedColorType,
@ -268,7 +268,8 @@ sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrContext* ctx,
imageColorSpace);
}
sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(GrContext* context, SkYUVColorSpace yuvColorSpace,
sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(GrRecordingContext* context,
SkYUVColorSpace yuvColorSpace,
const SkPixmap yuvaPixmaps[],
const SkYUVAIndex yuvaIndices[4], SkISize imageSize,
GrSurfaceOrigin imageOrigin, bool buildMips,

View File

@ -24,7 +24,7 @@ class SkImage_GpuYUVA : public SkImage_GpuBase {
public:
friend class GrYUVAImageTextureMaker;
SkImage_GpuYUVA(sk_sp<GrRecordingContext>,
SkImage_GpuYUVA(sk_sp<GrImageContext>,
SkISize size,
uint32_t uniqueID,
SkYUVColorSpace,
@ -86,7 +86,7 @@ public:
PromiseImageApiVersion);
private:
SkImage_GpuYUVA(sk_sp<GrContext>, const SkImage_GpuYUVA* image, sk_sp<SkColorSpace>);
SkImage_GpuYUVA(sk_sp<GrImageContext>, const SkImage_GpuYUVA* image, sk_sp<SkColorSpace>);
void flattenToRGB(GrRecordingContext*) const;

View File

@ -103,9 +103,7 @@ sk_sp<SkImage> 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<SkImage> 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<SkImage> 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<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID,
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(rContext), kNeedNewImageUniqueID,
std::move(srcView), info.colorType(), info.alphaType(),
info.refColorSpace());
}

View File

@ -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);
}

View File

@ -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));
}
}

View File

@ -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,