aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RectangleTextureTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-13 09:01:40 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-13 17:57:13 +0000
commit4431de6af930a8638c194b072558ea3a4b79d908 (patch)
tree49a3f17bb0abc6fcb43d8c7ce58061e0bb9822a7 /tests/RectangleTextureTest.cpp
parent36aa176d0d32f9cea3d1998fac3c295d31e1d596 (diff)
Add a deferred copy surface
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. Change-Id: Iab1867668d8146a766201158a251b9174438ee2b Reviewed-on: https://skia-review.googlesource.com/5773 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/RectangleTextureTest.cpp')
-rw-r--r--tests/RectangleTextureTest.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index cc0c4d1e31..587160448c 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -15,7 +15,7 @@
#include "gl/GLTestContext.h"
static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context,
- GrTexture* texture, uint32_t expectedPixelValues[]) {
+ GrSurface* texture, uint32_t expectedPixelValues[]) {
int pixelCnt = texture->width() * texture->height();
SkAutoTMalloc<uint32_t> pixels(pixelCnt);
memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt);
@@ -52,22 +52,30 @@ static void test_write_pixels(skiatest::Reporter* reporter, GrContext* context,
}
static void test_copy_surface_src(skiatest::Reporter* reporter, GrContext* context,
- GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
+ GrTexture* rectTexture, uint32_t expectedPixelValues[]) {
+ GrSurfaceDesc copyDstDesc;
+ copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig;
+ copyDstDesc.fWidth = rectTexture->width();
+ copyDstDesc.fHeight = rectTexture->height();
+
for (auto flags : {kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag}) {
- GrSurfaceDesc copyDstDesc;
- copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig;
- copyDstDesc.fWidth = rectangleTexture->width();
- copyDstDesc.fHeight = rectangleTexture->height();
copyDstDesc.fFlags = flags;
- sk_sp<GrTexture> dst(
- context->textureProvider()->createTexture(copyDstDesc, SkBudgeted::kYes));
- context->copySurface(dst.get(), rectangleTexture);
- test_read_pixels(reporter, context, dst.get(), expectedPixelValues);
+
+ sk_sp<GrSurfaceProxy> dst(GrSurfaceProxy::TestCopy(context, copyDstDesc,
+ rectTexture, SkBudgeted::kYes));
+
+ GrSurface* dstSurf = dst->instantiate(context->textureProvider());
+
+ test_read_pixels(reporter, context, dstSurf, expectedPixelValues);
}
}
static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* context,
GrTexture* rectangleTexture) {
+
+ sk_sp<GrSurfaceContext> sContext(context->contextPriv().makeWrappedSurfaceContext(
+ sk_ref_sp(rectangleTexture)));
+
int pixelCnt = rectangleTexture->width() * rectangleTexture->height();
SkAutoTMalloc<uint32_t> pixels(pixelCnt);
for (int y = 0; y < rectangleTexture->width(); ++y) {
@@ -81,10 +89,13 @@ static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte
copySrcDesc.fWidth = rectangleTexture->width();
copySrcDesc.fHeight = rectangleTexture->height();
copySrcDesc.fFlags = flags;
- sk_sp<GrTexture> src(context->textureProvider()->createTexture(
- copySrcDesc, SkBudgeted::kYes, pixels.get(), 0));
- context->copySurface(rectangleTexture, src.get());
+ sk_sp<GrSurfaceProxy> src(GrSurfaceProxy::MakeDeferred(*context->caps(),
+ context->textureProvider(),
+ copySrcDesc,
+ SkBudgeted::kYes, pixels.get(), 0));
+ sContext->copy(src.get());
+
test_read_pixels(reporter, context, rectangleTexture, pixels.get());
}
}