aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-13 18:48:08 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-13 18:48:20 +0000
commit293d696fcfb9f1c83019c4b15c4864cd6649ed78 (patch)
tree851514d761f33f5c508ddb8009338723cf52f27a /tests
parent3c41773fcd5c8f4462aefcb2a5927aecdb2a1806 (diff)
Revert "Add a deferred copy surface"
This reverts commit 4431de6af930a8638c194b072558ea3a4b79d908. Reason for revert: ANGLE errors (at the very least) Original change's description: > 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> > TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I61408d9e306b9b1ab32f93ab086e95184e12857f Reviewed-on: https://skia-review.googlesource.com/5938 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CopySurfaceTest.cpp36
-rw-r--r--tests/EGLImageTest.cpp13
-rw-r--r--tests/GrTextureStripAtlasTest.cpp119
-rw-r--r--tests/IntTextureTest.cpp70
-rw-r--r--tests/RectangleTextureTest.cpp37
5 files changed, 96 insertions, 179 deletions
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 68113e7ecc..053b456f57 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -10,9 +10,6 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrContextPriv.h"
-#include "GrSurfaceContext.h"
-#include "GrSurfaceProxy.h"
#include "GrTexture.h"
#include "GrTextureProvider.h"
@@ -71,29 +68,22 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
dstDesc.fOrigin = dOrigin;
dstDesc.fFlags = dFlags;
- sk_sp<GrSurfaceProxy> src(GrSurfaceProxy::MakeDeferred(
- *context->caps(),
- context->textureProvider(),
- srcDesc, SkBudgeted::kNo,
- srcPixels.get(),
- kRowBytes));
-
- sk_sp<GrSurfaceProxy> dst(GrSurfaceProxy::MakeDeferred(
- *context->caps(),
- context->textureProvider(),
- dstDesc, SkBudgeted::kNo,
- dstPixels.get(),
- kRowBytes));
+ sk_sp<GrTexture> src(
+ context->textureProvider()->createTexture(srcDesc, SkBudgeted::kNo,
+ srcPixels.get(),
+ kRowBytes));
+ sk_sp<GrTexture> dst(
+ context->textureProvider()->createTexture(dstDesc, SkBudgeted::kNo,
+ dstPixels.get(),
+ kRowBytes));
if (!src || !dst) {
ERRORF(reporter,
"Could not create surfaces for copy surface test.");
continue;
}
- sk_sp<GrSurfaceContext> sContext =
- context->contextPriv().makeTestSurfaceContext(dst);
-
- bool result = sContext->copy(src.get(), srcRect, dstPoint);
+ bool result
+ = context->copySurface(dst.get(), src.get(), srcRect, dstPoint);
bool expectedResult = true;
SkIPoint dstOffset = { dstPoint.fX - srcRect.fLeft,
@@ -130,11 +120,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
continue;
}
- GrSurface* dstSurf = dst->instantiate(context->textureProvider());
-
sk_memset32(read.get(), 0, kW * kH);
- if (!dstSurf->readPixels(0, 0, kW, kH, baseDesc.fConfig, read.get(),
- kRowBytes)) {
+ if (!dst->readPixels(0, 0, kW, kH, baseDesc.fConfig, read.get(),
+ kRowBytes)) {
ERRORF(reporter, "Error calling readPixels");
continue;
}
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 0dcacf9b6b..f78a0ea02a 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -10,7 +10,6 @@
#include "GrContext.h"
#include "GrContextFactory.h"
#include "GrShaderCaps.h"
-#include "GrSurfaceContext.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLUtil.h"
#include "gl/GLTestContext.h"
@@ -41,7 +40,7 @@ static void cleanup(GLTestContext* glctx0, GrGLuint texID0, GLTestContext* glctx
}
static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context,
- GrSurface* externalTexture, uint32_t expectedPixelValues[]) {
+ GrTexture* externalTexture, uint32_t expectedPixelValues[]) {
int pixelCnt = externalTexture->width() * externalTexture->height();
SkAutoTMalloc<uint32_t> pixels(pixelCnt);
memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt);
@@ -77,13 +76,9 @@ static void test_copy_surface(skiatest::Reporter* reporter, GrContext* context,
copyDesc.fWidth = externalTexture->width();
copyDesc.fHeight = externalTexture->height();
copyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
-
- sk_sp<GrSurfaceProxy> copy(GrSurfaceProxy::TestCopy(context, copyDesc,
- externalTexture, SkBudgeted::kYes));
-
- GrSurface* copySurf = copy->instantiate(context->textureProvider());
-
- test_read_pixels(reporter, context, copySurf, expectedPixelValues);
+ sk_sp<GrTexture> copy(context->textureProvider()->createTexture(copyDesc, SkBudgeted::kYes));
+ context->copySurface(copy.get(), externalTexture);
+ test_read_pixels(reporter, context, copy.get(), expectedPixelValues);
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
diff --git a/tests/GrTextureStripAtlasTest.cpp b/tests/GrTextureStripAtlasTest.cpp
index 86d3cfcd9b..60b8a6dcc4 100644
--- a/tests/GrTextureStripAtlasTest.cpp
+++ b/tests/GrTextureStripAtlasTest.cpp
@@ -9,7 +9,6 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "GrContextPriv.h"
#include "GrGpu.h"
#include "GrTextureStripAtlas.h"
#include "GrTypes.h"
@@ -22,97 +21,51 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTextureStripAtlasFlush, reporter, ctxInfo)
desc.fWidth = 32;
desc.fHeight = 32;
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ GrTexture* texture = context->textureProvider()->createTexture(desc, SkBudgeted::kYes,
+ nullptr, 0);
- sk_sp<GrSurfaceProxy> srcProxy;
- GrSurfaceProxy* srcPtr = nullptr;
+ GrSurfaceDesc targetDesc = desc;
+ targetDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+ GrTexture* target = context->textureProvider()->createTexture(targetDesc, SkBudgeted::kYes,
+ nullptr, 0);
- {
- SkAutoTMalloc<uint32_t> pixels(desc.fWidth * desc.fHeight);
- memset(pixels.get(), 0xFF, sizeof(uint32_t) * desc.fWidth * desc.fHeight);
+ SkAutoTMalloc<uint32_t> pixels(desc.fWidth * desc.fHeight);
+ memset(pixels.get(), 0xFF, sizeof(uint32_t) * desc.fWidth * desc.fHeight);
+ texture->writePixels(0, 0, desc.fWidth, desc.fHeight, kRGBA_8888_GrPixelConfig, pixels.get());
- srcProxy = GrSurfaceProxy::MakeDeferred(*context->caps(), context->textureProvider(),
- desc, SkBudgeted::kYes,
- pixels.get(), 0);
- }
-
- // Add a pending read to the src texture, and then make it available for reuse.
- sk_sp<GrSurfaceProxy> targetProxy;
-
- {
- GrSurfaceDesc targetDesc = desc;
- targetDesc.fFlags = kRenderTarget_GrSurfaceFlag;
-
- // We can't use GrSurfaceProxy::Copy bc we may be changing the dst proxy type
- sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(
- targetDesc,
- SkBudgeted::kYes));
- REPORTER_ASSERT(reporter, dstContext);
-
- if (!dstContext->copy(srcProxy.get())) {
- return;
- }
-
- targetProxy = sk_ref_sp(dstContext->asDeferredSurface());
- srcPtr = srcProxy.release();
- }
+ // Add a pending read to the texture, and then make it available for reuse.
+ context->copySurface(target, texture);
+ texture->unref();
// Create an atlas with parameters that allow it to reuse the texture.
- GrTextureStripAtlas* atlas;
-
- {
- GrTextureStripAtlas::Desc atlasDesc;
- atlasDesc.fContext = context;
- atlasDesc.fConfig = desc.fConfig;
- atlasDesc.fWidth = desc.fWidth;
- atlasDesc.fHeight = desc.fHeight;
- atlasDesc.fRowHeight = 1;
- atlas = GrTextureStripAtlas::GetAtlas(atlasDesc);
- }
+ GrTextureStripAtlas::Desc atlasDesc;
+ atlasDesc.fContext = context;
+ atlasDesc.fConfig = desc.fConfig;
+ atlasDesc.fWidth = desc.fWidth;
+ atlasDesc.fHeight = desc.fHeight;
+ atlasDesc.fRowHeight = 1;
+ GrTextureStripAtlas* atlas = GrTextureStripAtlas::GetAtlas(atlasDesc);
// Write to the atlas' texture.
- int lockedRow;
-
- {
- SkImageInfo info = SkImageInfo::MakeN32(desc.fWidth, desc.fHeight, kPremul_SkAlphaType);
- size_t rowBytes = desc.fWidth * GrBytesPerPixel(desc.fConfig);
- SkBitmap bitmap;
- bitmap.allocPixels(info, rowBytes);
- memset(bitmap.getPixels(), 1, rowBytes * desc.fHeight);
- lockedRow = atlas->lockRow(bitmap);
- }
+ SkImageInfo info = SkImageInfo::MakeN32(desc.fWidth, desc.fHeight, kPremul_SkAlphaType);
+ size_t rowBytes = desc.fWidth * GrBytesPerPixel(desc.fConfig);
+ SkBitmap bitmap;
+ bitmap.allocPixels(info, rowBytes);
+ memset(bitmap.getPixels(), 1, rowBytes * desc.fHeight);
+ int row = atlas->lockRow(bitmap);
+ if (!context->caps()->preferVRAMUseOverFlushes())
+ REPORTER_ASSERT(reporter, texture == atlas->getTexture());
// The atlas' use of its texture shouldn't change which pixels got copied to the target.
- {
- SkAutoTMalloc<uint8_t> actualPixels(sizeof(uint32_t) * desc.fWidth * desc.fHeight);
-
- // TODO: move readPixels to GrSurfaceProxy?
- GrSurface* surf = targetProxy->instantiate(context->textureProvider());
-
- bool success = surf->readPixels(0, 0, desc.fWidth, desc.fHeight,
- kRGBA_8888_GrPixelConfig, actualPixels.get());
- REPORTER_ASSERT(reporter, success);
-
- bool good = true;
-
- const uint8_t* bytes = actualPixels.get();
- for (size_t i = 0; i < sizeof(uint32_t) * desc.fWidth * desc.fHeight; ++i, ++bytes) {
- if (0xFF != *bytes) {
- good = false;
- break;
- }
- }
-
- REPORTER_ASSERT(reporter, good);
- }
-
- if (!context->caps()->preferVRAMUseOverFlushes()) {
- // This is kindof dodgy since we released it!
- GrSurface* srcSurface = srcPtr->instantiate(context->textureProvider());
-
- REPORTER_ASSERT(reporter, srcSurface == atlas->getTexture());
- }
-
- atlas->unlockRow(lockedRow);
+ SkAutoTMalloc<uint32_t> actualPixels(desc.fWidth * desc.fHeight);
+ bool success = target->readPixels(0, 0, desc.fWidth, desc.fHeight, kRGBA_8888_GrPixelConfig,
+ actualPixels.get());
+ REPORTER_ASSERT(reporter, success);
+ REPORTER_ASSERT(reporter,
+ !memcmp(pixels.get(), actualPixels.get(),
+ sizeof(uint32_t) * desc.fWidth * desc.fHeight));
+ target->unref();
+ atlas->unlockRow(row);
}
#endif
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index 5e3fde2f75..a6eaf98aea 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -95,48 +95,40 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, !success);
// Test that copying from one integer texture to another succeeds.
- {
- 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());
- }
+ sk_sp<GrTexture> copy(context->textureProvider()->createTexture(desc, 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);
+ 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());
}
- // 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);
+ // 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;
+ }
+ 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);
}
// We overwrite the top left quarter of the texture with the bottom right quarter of the
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 587160448c..cc0c4d1e31 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,
- GrSurface* texture, uint32_t expectedPixelValues[]) {
+ GrTexture* texture, uint32_t expectedPixelValues[]) {
int pixelCnt = texture->width() * texture->height();
SkAutoTMalloc<uint32_t> pixels(pixelCnt);
memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt);
@@ -52,30 +52,22 @@ static void test_write_pixels(skiatest::Reporter* reporter, GrContext* context,
}
static void test_copy_surface_src(skiatest::Reporter* reporter, GrContext* context,
- GrTexture* rectTexture, uint32_t expectedPixelValues[]) {
- GrSurfaceDesc copyDstDesc;
- copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig;
- copyDstDesc.fWidth = rectTexture->width();
- copyDstDesc.fHeight = rectTexture->height();
-
+ GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
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<GrSurfaceProxy> dst(GrSurfaceProxy::TestCopy(context, copyDstDesc,
- rectTexture, SkBudgeted::kYes));
-
- GrSurface* dstSurf = dst->instantiate(context->textureProvider());
-
- test_read_pixels(reporter, context, dstSurf, expectedPixelValues);
+ sk_sp<GrTexture> dst(
+ context->textureProvider()->createTexture(copyDstDesc, SkBudgeted::kYes));
+ context->copySurface(dst.get(), rectangleTexture);
+ test_read_pixels(reporter, context, dst.get(), 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) {
@@ -89,13 +81,10 @@ 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));
- sk_sp<GrSurfaceProxy> src(GrSurfaceProxy::MakeDeferred(*context->caps(),
- context->textureProvider(),
- copySrcDesc,
- SkBudgeted::kYes, pixels.get(), 0));
- sContext->copy(src.get());
-
+ context->copySurface(rectangleTexture, src.get());
test_read_pixels(reporter, context, rectangleTexture, pixels.get());
}
}