Make ManagedBackendTexture fail on invalid GrBackendTexture
Makes it more sensible. A bunch of call sites we're already written to expect this. Update some others. Change-Id: I77c28045ebf01e6aa9d92d2ebc37287604ec10c9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332544 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
1277971939
commit
88d7e625f9
@ -55,6 +55,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
|
||||
mipMapped,
|
||||
renderable,
|
||||
GrProtected::kNo);
|
||||
if (!mbet) {
|
||||
ERRORF(reporter, "Could not make texture.");
|
||||
return;
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> proxy;
|
||||
sk_sp<SkImage> image;
|
||||
|
@ -1001,6 +1001,10 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
|
||||
|
||||
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
|
||||
ctx, 100, 100, kRGBA_8888_SkColorType, GrMipmapped::kNo, GrRenderable::kNo);
|
||||
if (!mbet) {
|
||||
ERRORF(reporter, "Could not make texture.");
|
||||
return;
|
||||
}
|
||||
GrXferProcessor::DstProxyView fakeDstProxyView;
|
||||
{
|
||||
sk_sp<GrTextureProxy> proxy = proxyProvider->wrapBackendTexture(
|
||||
|
@ -361,6 +361,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
for (auto ioType : {kRead_GrIOType, kRW_GrIOType}) {
|
||||
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithData(
|
||||
dContext, srcPixmap, GrRenderable::kNo, GrProtected::kNo);
|
||||
if (!mbet) {
|
||||
ERRORF(reporter, "Could not make texture.");
|
||||
return;
|
||||
}
|
||||
auto proxy = proxyProvider->wrapBackendTexture(mbet->texture(), kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo, ioType,
|
||||
mbet->refCountedCallback());
|
||||
|
@ -489,12 +489,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter
|
||||
|
||||
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
|
||||
dContext, kSize, kSize, colorType, GrMipmapped::kNo, GrRenderable::kNo);
|
||||
if (!mbet) {
|
||||
ERRORF(reporter, "Could not create texture with color type %d.", colorType);
|
||||
continue;
|
||||
sk_sp<SkImage> img;
|
||||
if (mbet) {
|
||||
img = SkImage::MakeFromTexture(dContext, mbet->texture(), kTopLeft_GrSurfaceOrigin,
|
||||
colorType, kOpaque_SkAlphaType, nullptr);
|
||||
}
|
||||
auto img = SkImage::MakeFromTexture(dContext, mbet->texture(), kTopLeft_GrSurfaceOrigin,
|
||||
colorType, kOpaque_SkAlphaType, nullptr);
|
||||
REPORTER_ASSERT(reporter, can == SkToBool(img),
|
||||
"colorTypeSupportedAsImage:%d, actual:%d, ct:%d", can, SkToBool(img),
|
||||
colorType);
|
||||
@ -839,6 +838,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_NewFromTextureRelease, reporter, c
|
||||
GrProtected::kNo);
|
||||
if (!mbet) {
|
||||
ERRORF(reporter, "couldn't create backend texture\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TextureReleaseChecker releaseChecker;
|
||||
|
@ -31,6 +31,9 @@ sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext* dContext,
|
||||
src = &temp;
|
||||
}
|
||||
auto mbet = ManagedBackendTexture::MakeWithData(dContext, src, 1, renderable, GrProtected::kNo);
|
||||
if (!mbet) {
|
||||
return nullptr;
|
||||
}
|
||||
return SkImage::MakeFromTexture(dContext,
|
||||
mbet->texture(),
|
||||
origin,
|
||||
@ -61,7 +64,9 @@ sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext* dContext,
|
||||
mipmapped,
|
||||
renderable,
|
||||
GrProtected::kNo);
|
||||
|
||||
if (!mbet) {
|
||||
return nullptr;
|
||||
}
|
||||
return SkImage::MakeFromTexture(dContext,
|
||||
mbet->texture(),
|
||||
origin,
|
||||
|
@ -98,6 +98,9 @@ inline sk_sp<ManagedBackendTexture> ManagedBackendTexture::MakeWithData(GrDirect
|
||||
mbet->fTexture = dContext->createBackendTexture(std::forward<Args>(args)...,
|
||||
ReleaseProc,
|
||||
mbet->releaseContext());
|
||||
if (!mbet->fTexture.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return mbet;
|
||||
}
|
||||
|
||||
@ -105,9 +108,14 @@ template <typename... Args>
|
||||
inline sk_sp<ManagedBackendTexture> ManagedBackendTexture::MakeWithoutData(
|
||||
GrDirectContext* dContext,
|
||||
Args&&... args) {
|
||||
GrBackendTexture texture =
|
||||
dContext->createBackendTexture(std::forward<Args>(args)...);
|
||||
if (!texture.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<ManagedBackendTexture> mbet(new ManagedBackendTexture);
|
||||
mbet->fDContext = sk_ref_sp(dContext);
|
||||
mbet->fTexture = dContext->createBackendTexture(std::forward<Args>(args)...);
|
||||
mbet->fTexture = std::move(texture);
|
||||
return mbet;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user