Rename view getters in various image subclasses.

This also changes the SkImage_Base header to return a const& view and
then removes the equivalent version in SkImage_GpuBase.

Bug: skia:9556
Change-Id: Ica096693a22c0fc590786058c055fb28387c80a1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268624
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-02-05 10:37:27 -05:00 committed by Skia Commit-Bot
parent d3a32c5425
commit 37c127f558
24 changed files with 79 additions and 75 deletions

View File

@ -176,7 +176,10 @@ public:
surface->getCanvas()->translate(-100, -100); surface->getCanvas()->translate(-100, -100);
surface->getCanvas()->drawPicture(pic); surface->getCanvas()->drawPicture(pic);
sk_sp<SkImage> image(surface->makeImageSnapshot()); sk_sp<SkImage> image(surface->makeImageSnapshot());
fView = as_IB(image)->asSurfaceProxyViewRef(fCtx.get()); const GrSurfaceProxyView* view = as_IB(image)->view(fCtx.get());
if (view) {
fView = *view;
}
} }
} }
protected: protected:

View File

@ -118,8 +118,9 @@ GrSurfaceProxyView SkPictureImageGenerator::onGenerateTexture(
if (!image) { if (!image) {
return {}; return {};
} }
GrSurfaceProxyView view = as_IB(image)->asSurfaceProxyViewRef(ctx); const GrSurfaceProxyView* view = as_IB(image)->view(ctx);
SkASSERT(!willNeedMipMaps || GrMipMapped::kYes == view.asTextureProxy()->mipMapped()); SkASSERT(view);
return view; SkASSERT(!willNeedMipMaps || GrMipMapped::kYes == view->asTextureProxy()->mipMapped());
return *view;
} }
#endif #endif

View File

@ -52,7 +52,7 @@ public:
virtual SkColorSpace* onGetColorSpace() const = 0; virtual SkColorSpace* onGetColorSpace() const = 0;
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
virtual GrSurfaceProxyView onAsSurfaceProxyViewRef(GrRecordingContext* context) const = 0; virtual GrSurfaceProxyView onView(GrRecordingContext* context) const = 0;
#endif #endif
// This subset is relative to the backing store's coordinate frame, it has already been mapped // This subset is relative to the backing store's coordinate frame, it has already been mapped
@ -155,8 +155,8 @@ SkColorSpace* SkSpecialImage::getColorSpace() const {
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrSurfaceProxyView SkSpecialImage::asSurfaceProxyViewRef(GrRecordingContext* context) const { GrSurfaceProxyView SkSpecialImage::view(GrRecordingContext* context) const {
return as_SIB(this)->onAsSurfaceProxyViewRef(context); return as_SIB(this)->onView(context);
} }
#endif #endif
@ -207,13 +207,12 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(GrRecordingContext* context,
SkASSERT(rect_fits(subset, image->width(), image->height())); SkASSERT(rect_fits(subset, image->width(), image->height()));
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrSurfaceProxyView view = as_IB(image)->asSurfaceProxyViewRef(context); if (const GrSurfaceProxyView* view = as_IB(image)->view(context)) {
if (view.proxy()) {
if (!as_IB(image)->context()->priv().matches(context)) { if (!as_IB(image)->context()->priv().matches(context)) {
return nullptr; return nullptr;
} }
return MakeDeferredFromGpu(context, subset, image->uniqueID(), std::move(view), return MakeDeferredFromGpu(context, subset, image->uniqueID(), *view,
SkColorTypeToGrColorType(image->colorType()), SkColorTypeToGrColorType(image->colorType()),
image->refColorSpace(), props); image->refColorSpace(), props);
} else } else
@ -262,7 +261,7 @@ public:
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrSurfaceProxyView onAsSurfaceProxyViewRef(GrRecordingContext* context) const override { GrSurfaceProxyView onView(GrRecordingContext* context) const override {
if (context) { if (context) {
return GrMakeCachedBitmapProxyView(context, fBitmap); return GrMakeCachedBitmapProxyView(context, fBitmap);
} }
@ -424,9 +423,7 @@ public:
GrRecordingContext* onGetContext() const override { return fContext; } GrRecordingContext* onGetContext() const override { return fContext; }
GrSurfaceProxyView onAsSurfaceProxyViewRef(GrRecordingContext* context) const override { GrSurfaceProxyView onView(GrRecordingContext* context) const override { return fView; }
return fView;
}
bool onGetROPixels(SkBitmap* dst) const override { bool onGetROPixels(SkBitmap* dst) const override {
const auto desc = SkBitmapCacheDesc::Make(this->uniqueID(), this->subset()); const auto desc = SkBitmapCacheDesc::Make(this->uniqueID(), this->subset());

View File

@ -148,7 +148,7 @@ public:
* coordinates must be mapped from the content rect (e.g. relative to 'subset()') to the proxy's * coordinates must be mapped from the content rect (e.g. relative to 'subset()') to the proxy's
* space (offset by subset().topLeft()). * space (offset by subset().topLeft()).
*/ */
GrSurfaceProxyView asSurfaceProxyViewRef(GrRecordingContext*) const; GrSurfaceProxyView view(GrRecordingContext*) const;
#endif #endif
/** /**

View File

@ -149,7 +149,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(const Context& c
if (ctx.gpuBacked()) { if (ctx.gpuBacked()) {
auto context = ctx.getContext(); auto context = ctx.getContext();
GrSurfaceProxyView inputView = (input->asSurfaceProxyViewRef(context)); GrSurfaceProxyView inputView = (input->view(context));
SkASSERT(inputView.asTextureProxy()); SkASSERT(inputView.asTextureProxy());
const GrProtected isProtected = inputView.proxy()->isProtected(); const GrProtected isProtected = inputView.proxy()->isProtected();

View File

@ -336,13 +336,13 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
GrProtected isProtected = GrProtected::kNo; GrProtected isProtected = GrProtected::kNo;
if (background) { if (background) {
backgroundView = background->asSurfaceProxyViewRef(context); backgroundView = background->view(context);
SkASSERT(backgroundView.proxy()); SkASSERT(backgroundView.proxy());
isProtected = backgroundView.proxy()->isProtected(); isProtected = backgroundView.proxy()->isProtected();
} }
if (foreground) { if (foreground) {
foregroundView = foreground->asSurfaceProxyViewRef(context); foregroundView = foreground->view(context);
SkASSERT(foregroundView.proxy()); SkASSERT(foregroundView.proxy());
isProtected = foregroundView.proxy()->isProtected(); isProtected = foregroundView.proxy()->isProtected();
} }

View File

@ -643,7 +643,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
auto context = ctx.getContext(); auto context = ctx.getContext();
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context); GrSurfaceProxyView inputView = input->view(context);
if (!inputView.proxy()) { if (!inputView.proxy()) {
return nullptr; return nullptr;
} }

View File

@ -335,8 +335,8 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
if (ctx.gpuBacked()) { if (ctx.gpuBacked()) {
auto context = ctx.getContext(); auto context = ctx.getContext();
GrSurfaceProxyView colorView = color->asSurfaceProxyViewRef(context); GrSurfaceProxyView colorView = color->view(context);
GrSurfaceProxyView displView = displ->asSurfaceProxyViewRef(context); GrSurfaceProxyView displView = displ->view(context);
if (!colorView.proxy() || !displView.proxy()) { if (!colorView.proxy() || !displView.proxy()) {
return nullptr; return nullptr;
} }

View File

@ -485,7 +485,7 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
auto context = ctx.getContext(); auto context = ctx.getContext();
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context); GrSurfaceProxyView inputView = input->view(context);
SkASSERT(inputView.asTextureProxy()); SkASSERT(inputView.asTextureProxy());
auto renderTargetContext = GrRenderTargetContext::Make( auto renderTargetContext = GrRenderTargetContext::Make(

View File

@ -122,7 +122,7 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilterImpl::onFilterImage(const Context& c
if (ctx.gpuBacked()) { if (ctx.gpuBacked()) {
auto context = ctx.getContext(); auto context = ctx.getContext();
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context); GrSurfaceProxyView inputView = input->view(context);
SkASSERT(inputView.asTextureProxy()); SkASSERT(inputView.asTextureProxy());
const auto isProtected = inputView.proxy()->isProtected(); const auto isProtected = inputView.proxy()->isProtected();

View File

@ -419,7 +419,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(const Co
// fall-back, which saves us from having to do the xform during the filter itself. // fall-back, which saves us from having to do the xform during the filter itself.
input = ImageToColorSpace(input.get(), ctx.colorType(), ctx.colorSpace()); input = ImageToColorSpace(input.get(), ctx.colorType(), ctx.colorSpace());
GrSurfaceProxyView inputView = input->asSurfaceProxyViewRef(context); GrSurfaceProxyView inputView = input->view(context);
SkASSERT(inputView.asTextureProxy()); SkASSERT(inputView.asTextureProxy());
const auto isProtected = inputView.proxy()->isProtected(); const auto isProtected = inputView.proxy()->isProtected();

View File

@ -555,7 +555,7 @@ static void apply_morphology_pass(GrRenderTargetContext* renderTargetContext,
static sk_sp<SkSpecialImage> apply_morphology( static sk_sp<SkSpecialImage> apply_morphology(
GrRecordingContext* context, SkSpecialImage* input, const SkIRect& rect, GrRecordingContext* context, SkSpecialImage* input, const SkIRect& rect,
MorphType morphType, SkISize radius, const SkImageFilter_Base::Context& ctx) { MorphType morphType, SkISize radius, const SkImageFilter_Base::Context& ctx) {
GrSurfaceProxyView srcView = input->asSurfaceProxyViewRef(context); GrSurfaceProxyView srcView = input->view(context);
SkAlphaType srcAlphaType = input->alphaType(); SkAlphaType srcAlphaType = input->alphaType();
SkASSERT(srcView.asTextureProxy()); SkASSERT(srcView.asTextureProxy());
sk_sp<SkColorSpace> colorSpace = ctx.refColorSpace(); sk_sp<SkColorSpace> colorSpace = ctx.refColorSpace();

View File

@ -249,11 +249,11 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
GrSurfaceProxyView backgroundView, foregroundView; GrSurfaceProxyView backgroundView, foregroundView;
if (background) { if (background) {
backgroundView = background->asSurfaceProxyViewRef(context); backgroundView = background->view(context);
} }
if (foreground) { if (foreground) {
foregroundView = foreground->asSurfaceProxyViewRef(context); foregroundView = foreground->view(context);
} }
GrPaint paint; GrPaint paint;

View File

@ -65,9 +65,13 @@ GrSurfaceProxyView GrYUVAImageTextureMaker::refOriginalTextureProxyView(
} }
if (willBeMipped) { if (willBeMipped) {
return fImage->asMippedTextureProxyViewRef(this->context()); return fImage->refMippedView(this->context());
} else { } else {
return fImage->asSurfaceProxyViewRef(this->context()); if (const GrSurfaceProxyView* view = fImage->view(this->context())) {
return *view;
} else {
return {};
}
} }
} }

View File

@ -1020,7 +1020,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
} }
SkASSERT(result->isTextureBacked()); SkASSERT(result->isTextureBacked());
GrSurfaceProxyView view = result->asSurfaceProxyViewRef(this->context()); GrSurfaceProxyView view = result->view(this->context());
if (!view.proxy()) { if (!view.proxy()) {
return; return;
} }
@ -1211,12 +1211,13 @@ sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) { sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) {
SkPixmap pm; SkPixmap pm;
if (image->isTextureBacked()) { if (image->isTextureBacked()) {
auto view = as_IB(image)->asSurfaceProxyViewRef(this->context()); const GrSurfaceProxyView* view = as_IB(image)->view(this->context());
SkASSERT(view);
return SkSpecialImage::MakeDeferredFromGpu(fContext.get(), return SkSpecialImage::MakeDeferredFromGpu(fContext.get(),
SkIRect::MakeWH(image->width(), image->height()), SkIRect::MakeWH(image->width(), image->height()),
image->uniqueID(), image->uniqueID(),
std::move(view), *view,
SkColorTypeToGrColorType(image->colorType()), SkColorTypeToGrColorType(image->colorType()),
image->refColorSpace(), image->refColorSpace(),
&this->surfaceProps()); &this->surfaceProps());

View File

@ -59,11 +59,11 @@ public:
virtual GrTextureProxy* peekProxy() const { return nullptr; } virtual GrTextureProxy* peekProxy() const { return nullptr; }
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const { return nullptr; } virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const { return nullptr; }
// This returns a copy of the GrSurfaceProxyView which essentially refs the contained // If it exists, this returns a pointer to the GrSurfaceProxyView of image. The caller does not
// GrSurfaceProxy. Callers should check if the proxy of the returned view is null. // own the returned view and must copy it if they want to gain a ref to the internal proxy.
virtual GrSurfaceProxyView asSurfaceProxyViewRef(GrRecordingContext*) const { // If the returned view is not null, then it is guaranteed to have a valid proxy. Additionally
return GrSurfaceProxyView(); // this call will flatten a SkImage_GpuYUV to a single texture.
} virtual const GrSurfaceProxyView* view(GrRecordingContext*) const { return nullptr; }
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState, virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
SkScalar scaleAdjust[2]) const = 0; SkScalar scaleAdjust[2]) const = 0;

View File

@ -434,13 +434,12 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, GrMipMapped mipMapp
return nullptr; return nullptr;
} }
GrSurfaceProxyView view = as_IB(this)->asSurfaceProxyViewRef(context); const GrSurfaceProxyView* view = as_IB(this)->view(context);
SkASSERT(view.asTextureProxy()); SkASSERT(view && view->asTextureProxy());
if (GrMipMapped::kNo == mipMapped || view.asTextureProxy()->mipMapped() == mipMapped) { if (GrMipMapped::kNo == mipMapped || view->asTextureProxy()->mipMapped() == mipMapped) {
return sk_ref_sp(const_cast<SkImage*>(this)); return sk_ref_sp(const_cast<SkImage*>(this));
} }
GrTextureAdjuster adjuster(context, std::move(view), this->imageInfo().colorInfo(), GrTextureAdjuster adjuster(context, *view, this->imageInfo().colorInfo(), this->uniqueID());
this->uniqueID());
return create_image_from_producer(context, &adjuster, this->uniqueID(), mipMapped); return create_image_from_producer(context, &adjuster, this->uniqueID(), mipMapped);
} }

View File

@ -36,11 +36,11 @@ public:
return fView.asTextureProxyRef(); return fView.asTextureProxyRef();
} }
GrSurfaceProxyView asSurfaceProxyViewRef(GrRecordingContext* context) const override { const GrSurfaceProxyView* view(GrRecordingContext* context) const override {
return fView; if (!fView.proxy()) {
} return nullptr;
const GrSurfaceProxyView& getSurfaceProxyView(GrRecordingContext* context) const override { }
return fView; return &fView;
} }
bool onIsTextureBacked() const override { bool onIsTextureBacked() const override {

View File

@ -114,13 +114,14 @@ bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
} }
} }
GrSurfaceProxyView view = this->asSurfaceProxyViewRef(direct); const GrSurfaceProxyView* view = this->view(direct);
SkASSERT(view);
GrColorType grColorType = SkColorTypeAndFormatToGrColorType(fContext->priv().caps(), GrColorType grColorType = SkColorTypeAndFormatToGrColorType(fContext->priv().caps(),
this->colorType(), this->colorType(),
view.proxy()->backendFormat()); view->proxy()->backendFormat());
auto sContext = GrSurfaceContext::Make(direct, std::move(view), grColorType, auto sContext = GrSurfaceContext::Make(direct, *view, grColorType, this->alphaType(),
this->alphaType(), this->refColorSpace()); this->refColorSpace());
if (!sContext) { if (!sContext) {
return false; return false;
} }
@ -142,15 +143,15 @@ sk_sp<SkImage> SkImage_GpuBase::onMakeSubset(GrRecordingContext* context,
return nullptr; return nullptr;
} }
const GrSurfaceProxyView& view = this->getSurfaceProxyView(context); const GrSurfaceProxyView* view = this->view(context);
SkASSERT(view.proxy()); SkASSERT(view && view->proxy());
GrColorType grColorType = SkColorTypeToGrColorType(this->colorType()); GrColorType grColorType = SkColorTypeToGrColorType(this->colorType());
GrSurfaceProxyView copyView = GrSurfaceProxyView copyView =
GrSurfaceProxy::Copy(context, view.proxy(), view.origin(), grColorType, GrSurfaceProxy::Copy(context, view->proxy(), view->origin(), grColorType,
GrMipMapped::kNo, subset, SkBackingFit::kExact, GrMipMapped::kNo, subset, SkBackingFit::kExact,
view.proxy()->isBudgeted()); view->proxy()->isBudgeted());
if (!copyView.proxy()) { if (!copyView.proxy()) {
return nullptr; return nullptr;
@ -173,13 +174,14 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels,
return false; return false;
} }
GrSurfaceProxyView view = this->asSurfaceProxyViewRef(direct); const GrSurfaceProxyView* view = this->view(direct);
SkASSERT(view);
GrColorType grColorType = SkColorTypeAndFormatToGrColorType(fContext->priv().caps(), GrColorType grColorType = SkColorTypeAndFormatToGrColorType(fContext->priv().caps(),
this->colorType(), this->colorType(),
view.proxy()->backendFormat()); view->proxy()->backendFormat());
auto sContext = GrSurfaceContext::Make(direct, std::move(view), grColorType, auto sContext = GrSurfaceContext::Make(direct, *view, grColorType, this->alphaType(),
this->alphaType(), this->refColorSpace()); this->refColorSpace());
if (!sContext) { if (!sContext) {
return false; return false;
} }
@ -195,8 +197,8 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrRecordingContext* con
return nullptr; return nullptr;
} }
GrTextureAdjuster adjuster(fContext.get(), this->asSurfaceProxyViewRef(context), GrTextureAdjuster adjuster(fContext.get(), *this->view(context), this->imageInfo().colorInfo(),
this->imageInfo().colorInfo(), this->uniqueID()); this->uniqueID());
return adjuster.viewForParams(params, scaleAdjust).asTextureProxyRef(); return adjuster.viewForParams(params, scaleAdjust).asTextureProxyRef();
} }

View File

@ -34,8 +34,6 @@ public:
return this->INHERITED::asTextureProxyRef(context); return this->INHERITED::asTextureProxyRef(context);
} }
virtual const GrSurfaceProxyView& getSurfaceProxyView(GrRecordingContext* context) const = 0;
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState, sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
SkScalar scaleAdjust[2]) const final; SkScalar scaleAdjust[2]) const final;

View File

@ -174,7 +174,7 @@ sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef(GrRecordingContext* con
return fRGBView.asTextureProxyRef(); return fRGBView.asTextureProxyRef();
} }
GrSurfaceProxyView SkImage_GpuYUVA::asMippedTextureProxyViewRef(GrRecordingContext* context) const { GrSurfaceProxyView SkImage_GpuYUVA::refMippedView(GrRecordingContext* context) const {
// if invalid or already has miplevels // if invalid or already has miplevels
this->flattenToRGB(context); this->flattenToRGB(context);
if (!fRGBView.proxy() || GrMipMapped::kYes == fRGBView.asTextureProxy()->mipMapped()) { if (!fRGBView.proxy() || GrMipMapped::kYes == fRGBView.asTextureProxy()->mipMapped()) {
@ -194,9 +194,12 @@ GrSurfaceProxyView SkImage_GpuYUVA::asMippedTextureProxyViewRef(GrRecordingConte
return {}; return {};
} }
GrSurfaceProxyView SkImage_GpuYUVA::asSurfaceProxyViewRef(GrRecordingContext* context) const { const GrSurfaceProxyView* SkImage_GpuYUVA::view(GrRecordingContext* context) const {
this->flattenToRGB(context); this->flattenToRGB(context);
return fRGBView; if (!fRGBView.proxy()) {
return nullptr;
}
return &fRGBView;
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -35,11 +35,7 @@ public:
GrTextureProxy* peekProxy() const override; GrTextureProxy* peekProxy() const override;
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override; sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override;
GrSurfaceProxyView asSurfaceProxyViewRef(GrRecordingContext* context) const override; const GrSurfaceProxyView* view(GrRecordingContext* context) const override;
const GrSurfaceProxyView& getSurfaceProxyView(GrRecordingContext* context) const override {
this->flattenToRGB(context);
return fRGBView;
}
bool onIsTextureBacked() const override { bool onIsTextureBacked() const override {
SkASSERT(fProxies[0] || fRGBView.proxy()); SkASSERT(fProxies[0] || fRGBView.proxy());
@ -56,7 +52,7 @@ public:
bool setupMipmapsForPlanes(GrRecordingContext*) const; bool setupMipmapsForPlanes(GrRecordingContext*) const;
// Returns a ref-ed texture proxy view with miplevels // Returns a ref-ed texture proxy view with miplevels
GrSurfaceProxyView asMippedTextureProxyViewRef(GrRecordingContext*) const; GrSurfaceProxyView refMippedView(GrRecordingContext*) const;
#if GR_TEST_UTILS #if GR_TEST_UTILS
bool testingOnly_IsFlattened() const { bool testingOnly_IsFlattened() const {

View File

@ -71,9 +71,9 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked()); REPORTER_ASSERT(reporter, isGPUBacked == img->isTextureBacked());
//-------------- //--------------
// Test asSurfaceProxyViewRef - as long as there is a context this should succeed // Test view - as long as there is a context this should succeed
if (context) { if (context) {
GrSurfaceProxyView view = img->asSurfaceProxyViewRef(context); GrSurfaceProxyView view = img->view(context);
REPORTER_ASSERT(reporter, view.asTextureProxy()); REPORTER_ASSERT(reporter, view.asTextureProxy());
} }

View File

@ -782,7 +782,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
auto makeImageSurfaceContext = [context](SkSurface* surface) { auto makeImageSurfaceContext = [context](SkSurface* surface) {
sk_sp<SkImage> i(surface->makeImageSnapshot()); sk_sp<SkImage> i(surface->makeImageSnapshot());
SkImage_Gpu* gpuImage = (SkImage_Gpu*)as_IB(i); SkImage_Gpu* gpuImage = (SkImage_Gpu*)as_IB(i);
return GrSurfaceContext::Make(context, gpuImage->asSurfaceProxyViewRef(context), return GrSurfaceContext::Make(context, *gpuImage->view(context),
SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType, SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
gpuImage->refColorSpace()); gpuImage->refColorSpace());
}; };