diff options
author | Robert Phillips <robertphillips@google.com> | 2017-01-18 10:08:39 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-18 16:22:59 +0000 |
commit | 2c86249465c28a532c8be55b6ba497021e3110ec (patch) | |
tree | b33ecbfb9bfdb8e848e461ea67beeca1097d9cb6 /tests | |
parent | dfff166db5d5226dc002a22ab3e3097ef971d615 (diff) |
Move read/write-Pixels up to GrSurfaceContext
This still needs to be propagated out in several ways:
replace more instances of GrSurface::read/write-Pixels
add colorSpace to more instances of the TextureContext
but it establishes a beach-head and is exciting enough as is.
Change-Id: If86035aa0245e70b54541e83722b3c75bc5ade13
Reviewed-on: https://skia-review.googlesource.com/7172
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')
-rw-r--r-- | tests/CopySurfaceTest.cpp | 2 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 30 |
2 files changed, 20 insertions, 12 deletions
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index 951d27249f..efb6b2d43d 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -91,7 +91,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { } sk_sp<GrSurfaceContext> sContext = - context->contextPriv().makeWrappedSurfaceContext(dst); + context->contextPriv().makeWrappedSurfaceContext(dst, nullptr); bool result = sContext->copy(src.get(), srcRect, dstPoint); diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 1f04de5903..29aee9ccf9 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -20,6 +20,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrContextPriv.h" #include "GrRenderTargetContext.h" #include "GrGpu.h" #include "GrResourceProvider.h" @@ -626,7 +627,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target( } static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> surface, - std::function<GrSurface*(SkSurface*)> grSurfaceGetter, + std::function<sk_sp<GrSurfaceContext>(SkSurface*)> grSurfaceGetter, uint32_t expectedValue) { if (!surface) { ERRORF(reporter, "Could not create GPU SkSurface."); @@ -637,13 +638,15 @@ static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> su std::unique_ptr<uint32_t[]> pixels(new uint32_t[w * h]); sk_memset32(pixels.get(), ~expectedValue, w * h); - sk_sp<GrSurface> grSurface(SkSafeRef(grSurfaceGetter(surface.get()))); - if (!grSurface) { + sk_sp<GrSurfaceContext> grSurfaceContext(grSurfaceGetter(surface.get())); + if (!grSurfaceContext) { ERRORF(reporter, "Could access render target of GPU SkSurface."); return; } surface.reset(); - grSurface->readPixels(0, 0, w, h, kRGBA_8888_GrPixelConfig, pixels.get()); + + SkImageInfo ii = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType); + grSurfaceContext->readPixels(ii, pixels.get(), 0, 0, 0); for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { uint32_t pixel = pixels.get()[y * w + x]; @@ -666,16 +669,21 @@ static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> su DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = { + std::function<sk_sp<GrSurfaceContext>(SkSurface*)> grSurfaceContextGetters[] = { + [] (SkSurface* s){ + return sk_ref_sp(s->getCanvas()->internal_private_accessTopLayerRenderTargetContext()); + }, [] (SkSurface* s){ - GrRenderTargetContext* rtc = - s->getCanvas()->internal_private_accessTopLayerRenderTargetContext(); - return rtc->accessRenderTarget(); }, - [] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot()); - return as_IB(i)->peekTexture(); } + sk_sp<SkImage> i(s->makeImageSnapshot()); + SkImage_Gpu* gpuImage = (SkImage_Gpu *) as_IB(i); + sk_sp<GrSurfaceProxy> proxy = gpuImage->refProxy(); + GrContext* context = gpuImage->context(); + return context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), + gpuImage->refColorSpace()); + } }; - for (auto grSurfaceGetter : grSurfaceGetters) { + for (auto grSurfaceGetter : grSurfaceContextGetters) { // Test that non-wrapped RTs are created clear. for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) { auto surface = surface_func(context, kPremul_SkAlphaType, nullptr); |