aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/IntTextureTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-13 15:29:42 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-13 22:01:58 +0000
commit398487a850431cf495330d4023607df5305a311f (patch)
tree7ab227c99eaab21554428f7a94e0c2df67be009a /tests/IntTextureTest.cpp
parent24f19780d1e76595c049d8cad4352de839cfc6b5 (diff)
Add a deferred copy surface (take 2)
This CL forces all GrSurface copies to go through a GrSurfaceContext (rather than GrContext). There is a bit of goofiness going on here until read/writePixels is also consolidated in GrSurfaceContext and a proxy-backed SkImage/SkSurface is added. This is a reland of https://skia-review.googlesource.com/c/5773/ (Add a deferred copy surface) Change-Id: Ide560f569aede5e622420dc2f30eef76357d69f4 Reviewed-on: https://skia-review.googlesource.com/5939 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/IntTextureTest.cpp')
-rw-r--r--tests/IntTextureTest.cpp70
1 files changed, 39 insertions, 31 deletions
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index a6eaf98aea..5e3fde2f75 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -95,40 +95,48 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, !success);
// Test that copying from one integer texture to another succeeds.
- sk_sp<GrTexture> copy(context->textureProvider()->createTexture(desc, SkBudgeted::kYes));
- REPORTER_ASSERT(reporter, copy);
- if (!copy) {
- return;
- }
- success = context->copySurface(copy.get(), texture.get());
- REPORTER_ASSERT(reporter, success);
- if (!success) {
- return;
- }
- sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
- success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get());
- REPORTER_ASSERT(reporter, success);
- if (success) {
- check_pixels(reporter, kS, kS, testData.get(), readData.get());
+ {
+ sk_sp<GrSurfaceProxy> copy(GrSurfaceProxy::TestCopy(context, desc,
+ texture.get(), SkBudgeted::kYes));
+ REPORTER_ASSERT(reporter, copy);
+ if (!copy) {
+ return;
+ }
+
+ GrSurface* copySurface = copy->instantiate(context->textureProvider());
+ REPORTER_ASSERT(reporter, copySurface);
+ if (!copySurface) {
+ return;
+ }
+
+ sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
+ success = copySurface->readPixels(0, 0, kS, kS,
+ kRGBA_8888_sint_GrPixelConfig, readData.get());
+ REPORTER_ASSERT(reporter, success);
+ if (success) {
+ check_pixels(reporter, kS, kS, testData.get(), readData.get());
+ }
}
- // Test that copying to a non-integer texture fails.
- GrSurfaceDesc nonIntDesc = desc;
- nonIntDesc.fConfig = kRGBA_8888_GrPixelConfig;
- copy.reset(context->textureProvider()->createTexture(nonIntDesc, SkBudgeted::kYes));
- REPORTER_ASSERT(reporter, copy);
- if (!copy) {
- return;
+
+ // Test that copying to a non-integer (8888) texture fails.
+ {
+ GrSurfaceDesc nonIntDesc = desc;
+ nonIntDesc.fConfig = kRGBA_8888_GrPixelConfig;
+
+ sk_sp<GrSurfaceProxy> copy(GrSurfaceProxy::TestCopy(context, nonIntDesc,
+ texture.get(), SkBudgeted::kYes));
+ REPORTER_ASSERT(reporter, !copy);
}
- success = context->copySurface(copy.get(), texture.get());
- REPORTER_ASSERT(reporter, !success);
- nonIntDesc.fConfig = kRGBA_half_GrPixelConfig;
- copy.reset(context->textureProvider()->createTexture(nonIntDesc, SkBudgeted::kYes));
- REPORTER_ASSERT(reporter, copy ||
- !context->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig));
- if (copy) {
- success = context->copySurface(copy.get(), texture.get());
- REPORTER_ASSERT(reporter, !success);
+
+ // Test that copying to a non-integer (RGBA_half) texture fails.
+ if (context->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig)) {
+ GrSurfaceDesc nonIntDesc = desc;
+ nonIntDesc.fConfig = kRGBA_half_GrPixelConfig;
+
+ sk_sp<GrSurfaceProxy> copy(GrSurfaceProxy::TestCopy(context, nonIntDesc,
+ texture.get(), SkBudgeted::kYes));
+ REPORTER_ASSERT(reporter, !copy);
}
// We overwrite the top left quarter of the texture with the bottom right quarter of the