aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ReadPixelsTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-06 07:59:41 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-06 12:45:02 +0000
commite78b7259c3d5cbed77b4390150cfb699b0b59cd4 (patch)
treeb31944a68b1c88c5f87d2023157b473f01348feb /tests/ReadPixelsTest.cpp
parent43b9c6bbf66b0927a99062c68dff9ea8358f82db (diff)
Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv (take 3)
This is in service of: https://skia-review.googlesource.com/c/11125/ (Add parallel proxyID to StencilOps & RenderTargetOpList) where I want a better choke point for texture creation to improve discard handling. This is a re-reland of: https://skia-review.googlesource.com/c/11200/ (Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv) Change-Id: Icfb9dd223418dd460405efd2bfd9d1c356beed1a Reviewed-on: https://skia-review.googlesource.com/11412 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ReadPixelsTest.cpp')
-rw-r--r--tests/ReadPixelsTest.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 774f0af06a..c67e62b090 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -16,6 +16,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrResourceProvider.h"
#include "SkGr.h"
#endif
@@ -123,11 +124,16 @@ static void fill_src_canvas(SkCanvas* canvas) {
}
#if SK_SUPPORT_GPU
-static void fill_src_texture(GrTexture* texture) {
+static void fill_src_texture(GrContext* context, GrTextureProxy* proxy) {
SkBitmap bmp = make_src_bitmap();
bmp.lockPixels();
- texture->writePixels(0, 0, DEV_W, DEV_H, kSkia8888_GrPixelConfig, bmp.getPixels(),
- bmp.rowBytes());
+
+ SkDEBUGCODE(bool result =) context->contextPriv().writeSurfacePixels(
+ proxy, nullptr,
+ 0, 0, DEV_W, DEV_H,
+ kSkia8888_GrPixelConfig, nullptr,
+ bmp.getPixels(), bmp.rowBytes());
+ SkASSERT(result);
bmp.unlockPixels();
}
#endif
@@ -436,8 +442,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) {
#endif
#if SK_SUPPORT_GPU
-static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* texture) {
- fill_src_texture(texture);
+static void test_readpixels_texture(skiatest::Reporter* reporter,
+ GrContext* context, sk_sp<GrTextureProxy> proxy) {
+ fill_src_texture(context, proxy.get());
for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
const SkIRect& srcRect = gReadPixelsTestRects[rect];
for (BitmapInit bmi = kFirstBitmapInit; bmi <= kLast_BitmapInit; bmi = nextBMI(bmi)) {
@@ -452,16 +459,18 @@ static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex
// Try doing the read directly from a non-renderable texture
if (startsWithPixels) {
fill_dst_bmp_with_init_data(&bmp);
- GrPixelConfig dstConfig =
- SkImageInfo2GrPixelConfig(bmp.info(), *texture->getContext()->caps());
+ GrPixelConfig dstConfig = SkImageInfo2GrPixelConfig(bmp.info(),
+ *context->caps());
uint32_t flags = 0;
if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaType) {
- flags = GrContext::kUnpremul_PixelOpsFlag;
+ flags = GrContextPriv::kUnpremul_PixelOpsFlag;
}
bmp.lockPixels();
- bool success = texture->readPixels(srcRect.fLeft, srcRect.fTop, bmp.width(),
- bmp.height(), dstConfig, bmp.getPixels(),
- bmp.rowBytes(), flags);
+ bool success = context->contextPriv().readSurfacePixels(
+ proxy.get(), nullptr,
+ srcRect.fLeft, srcRect.fTop, bmp.width(),
+ bmp.height(), dstConfig, nullptr,
+ bmp.getPixels(), bmp.rowBytes(), flags);
bmp.unlockPixels();
check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop,
success, true,
@@ -481,9 +490,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
desc.fHeight = DEV_H;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fOrigin = origin;
- sk_sp<GrTexture> texture(ctxInfo.grContext()->resourceProvider()->createTexture(desc,
- SkBudgeted::kNo));
- test_readpixels_texture(reporter, texture.get());
+ sk_sp<GrTexture> texture =
+ ctxInfo.grContext()->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ test_readpixels_texture(reporter, ctxInfo.grContext(),
+ GrSurfaceProxy::MakeWrapped(std::move(texture)));
}
}
}