Migrate SkImage::MakeFromTexture to GrRecordingContext
Android migration landed in Android CL 12234077
Chrome migration is landing in Chrome CL 2335812
Note: makeFromCompressedTexture is not used by Chrome.
Bug: skia:104662
Change-Id: Ibbe6d412cf22e87188926383d10b21f780208e48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305102
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
diff --git a/tests/TextureBindingsResetTest.cpp b/tests/TextureBindingsResetTest.cpp
index 77dc86c..6977b29 100644
--- a/tests/TextureBindingsResetTest.cpp
+++ b/tests/TextureBindingsResetTest.cpp
@@ -18,9 +18,9 @@
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInfo) {
#define GL(F) GR_GL_CALL(ctxInfo.glContext()->gl(), F)
- auto context = ctxInfo.directContext();
- GrGpu* gpu = context->priv().getGpu();
- GrGLGpu* glGpu = static_cast<GrGLGpu*>(context->priv().getGpu());
+ auto dContext = ctxInfo.directContext();
+ GrGpu* gpu = dContext->priv().getGpu();
+ GrGLGpu* glGpu = static_cast<GrGLGpu*>(dContext->priv().getGpu());
struct Target {
GrGLenum fName;
@@ -69,9 +69,9 @@
};
// Initialize texture unit/target combo bindings to 0.
- context->flushAndSubmit();
+ dContext->flushAndSubmit();
resetBindings();
- context->resetContext();
+ dContext->resetContext();
// Test creating a texture and then resetting bindings.
static constexpr SkISize kDims = {10, 10};
@@ -79,15 +79,15 @@
auto tex = gpu->createTexture(kDims, format, GrRenderable::kNo, 1, GrMipmapped::kNo,
SkBudgeted::kNo, GrProtected::kNo);
REPORTER_ASSERT(reporter, tex);
- context->resetGLTextureBindings();
+ dContext->resetGLTextureBindings();
checkBindings();
resetBindings();
- context->resetContext();
+ dContext->resetContext();
// Test drawing and then resetting bindings. This should force a MIP regeneration if MIP
// maps are supported as well.
auto info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 1, nullptr);
+ auto surf = SkSurface::MakeRenderTarget(dContext, SkBudgeted::kYes, info, 1, nullptr);
surf->getCanvas()->clear(0x80FF0000);
auto img = surf->makeImageSnapshot();
surf->getCanvas()->clear(SK_ColorBLUE);
@@ -98,13 +98,13 @@
surf->getCanvas()->drawImage(img, 0, 0, &paint);
surf->getCanvas()->restore();
surf->flushAndSubmit();
- context->resetGLTextureBindings();
+ dContext->resetGLTextureBindings();
checkBindings();
resetBindings();
- context->resetContext();
+ dContext->resetContext();
if (supportExternal) {
- GrBackendTexture texture2D = context->createBackendTexture(
+ GrBackendTexture texture2D = dContext->createBackendTexture(
10, 10, kRGBA_8888_SkColorType,
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo, GrProtected::kNo);
GrGLTextureInfo info2D;
@@ -119,37 +119,37 @@
GrBackendTexture backendTexture(10, 10, GrMipmapped::kNo, infoExternal);
// Above texture creation will have messed with GL state and bindings.
resetBindings();
- context->resetContext();
- img = SkImage::MakeFromTexture(context, backendTexture, kTopLeft_GrSurfaceOrigin,
+ dContext->resetContext();
+ img = SkImage::MakeFromTexture(dContext, backendTexture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
REPORTER_ASSERT(reporter, img);
surf->getCanvas()->drawImage(img, 0, 0);
img.reset();
surf->flushAndSubmit();
- context->resetGLTextureBindings();
+ dContext->resetGLTextureBindings();
checkBindings();
resetBindings();
GL(DeleteTextures(1, &infoExternal.fID));
ctxInfo.glContext()->destroyEGLImage(eglImage);
- context->deleteBackendTexture(texture2D);
- context->resetContext();
+ dContext->deleteBackendTexture(texture2D);
+ dContext->resetContext();
}
if (supportRectangle) {
auto format = GrBackendFormat::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_RECTANGLE);
GrBackendTexture rectangleTexture =
- context->createBackendTexture(10, 10, format, GrMipmapped::kNo, GrRenderable::kNo);
+ dContext->createBackendTexture(10, 10, format, GrMipmapped::kNo, GrRenderable::kNo);
if (rectangleTexture.isValid()) {
- img = SkImage::MakeFromTexture(context, rectangleTexture, kTopLeft_GrSurfaceOrigin,
+ img = SkImage::MakeFromTexture(dContext, rectangleTexture, kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
REPORTER_ASSERT(reporter, img);
surf->getCanvas()->drawImage(img, 0, 0);
img.reset();
surf->flushAndSubmit();
- context->resetGLTextureBindings();
+ dContext->resetGLTextureBindings();
checkBindings();
resetBindings();
- context->deleteBackendTexture(rectangleTexture);
+ dContext->deleteBackendTexture(rectangleTexture);
}
}