aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ReadWriteAlphaTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-01-19 16:59:04 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-20 15:10:18 +0000
commitc949ce9d808dbf7c2db7dc0b85271969ba46b69a (patch)
tree14cce659a0861b970f99d80dbfb69a52975498a3 /tests/ReadWriteAlphaTest.cpp
parent4c76c41c981dd7ea95062a1895a6e3415b70bce1 (diff)
Replace some GrSurface:read/writePixels with the GrSurfaceContext equivalent
Change-Id: I7b11a323b0c74ee70f52b1bd8be376fb7188cb19 Reviewed-on: https://skia-review.googlesource.com/7204 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests/ReadWriteAlphaTest.cpp')
-rw-r--r--tests/ReadWriteAlphaTest.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index c0b7e94854..27c2260ed4 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -11,6 +11,9 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextPriv.h"
+#include "GrSurfaceContext.h"
+#include "GrSurfaceProxy.h"
#include "SkCanvas.h"
#include "SkSurface.h"
@@ -35,6 +38,7 @@ static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, cons
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
+ GrContext* context = ctxInfo.grContext();
unsigned char alphaData[X_SIZE * Y_SIZE];
static const int kClearValue = 0x2;
@@ -50,17 +54,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// We are initializing the texture with zeros here
memset(alphaData, 0, X_SIZE * Y_SIZE);
- sk_sp<GrTexture> texture(
- ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudgeted::kNo, alphaData,
- 0));
- if (!texture) {
+
+ sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(*context->caps(),
+ context->textureProvider(),
+ desc,
+ SkBudgeted::kNo,
+ alphaData, 0));
+ if (!sProxy) {
ERRORF(reporter, "Could not create alpha texture.");
return;
}
+ sk_sp<GrSurfaceContext> sContext(context->contextPriv().makeWrappedSurfaceContext(
+ sProxy, nullptr));
const SkImageInfo ii = SkImageInfo::MakeA8(X_SIZE, Y_SIZE);
- sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(ctxInfo.grContext(),
- SkBudgeted::kNo, ii));
+ sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
// create a distinctive texture
for (int y = 0; y < Y_SIZE; ++y) {
@@ -70,9 +78,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
}
for (auto rowBytes : kRowBytes) {
+
// upload the texture (do per-rowbytes iteration because we may overwrite below).
- bool result = texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- alphaData, 0);
+ bool result = sContext->writePixels(ii, alphaData, 0, 0, 0);
REPORTER_ASSERT_MESSAGE(reporter, result, "Initial A8 writePixels failed");
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
@@ -81,8 +89,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
// read the texture back
- result = texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- readback.get(), rowBytes);
+ result = sContext->readPixels(ii, readback.get(), rowBytes, 0, 0);
REPORTER_ASSERT_MESSAGE(reporter, result, "Initial A8 readPixels failed");
// make sure the original & read back versions match
@@ -153,8 +160,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
}
}
sk_sp<GrTexture> texture(
- ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudgeted::kNo,
- rgbaData, 0));
+ context->textureProvider()->createTexture(desc, SkBudgeted::kNo, rgbaData, 0));
if (!texture) {
// We always expect to be able to create a RGBA texture
if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {