aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/BlendTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-06 11:18:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-06 20:03:40 +0000
commitd7cda9a6f050c30e65b0744b3cfb45cecdc40834 (patch)
tree0c1cca24a20927e155ad306aa5ff43bca4713bcc /tests/BlendTest.cpp
parentcf1b022c53afda781ff76fe206d8c93966b1c267 (diff)
Make GrCopySurfaceOp friendlier to GrSurfaceProxy
Change-Id: Iba8c068bd96ab154d466e485a9db31dd552138de Reviewed-on: https://skia-review.googlesource.com/11325 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/BlendTest.cpp')
-rw-r--r--tests/BlendTest.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp
index 2d16fb2ff2..08190f1762 100644
--- a/tests/BlendTest.cpp
+++ b/tests/BlendTest.cpp
@@ -84,23 +84,26 @@ DEF_TEST(Blend_byte_multiply, r) {
namespace {
static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
GrContext* context, int sampleCnt, int width, int height, GrPixelConfig config,
+ GrSurfaceOrigin origin,
sk_sp<GrTexture>* backingSurface) {
GrSurfaceDesc backingDesc;
- backingDesc.fHeight = height;
+ backingDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+ backingDesc.fOrigin = origin;
backingDesc.fWidth = width;
+ backingDesc.fHeight = height;
backingDesc.fConfig = config;
- backingDesc.fOrigin = kDefault_GrSurfaceOrigin;
- backingDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+ backingDesc.fSampleCnt = sampleCnt;
*backingSurface = context->resourceProvider()->createTexture(backingDesc, SkBudgeted::kNo);
GrBackendTextureDesc desc;
- desc.fConfig = config;
+ desc.fFlags = kRenderTarget_GrBackendTextureFlag;
+ desc.fOrigin = origin;
desc.fWidth = width;
desc.fHeight = height;
- desc.fFlags = kRenderTarget_GrBackendTextureFlag;
- desc.fTextureHandle = (*backingSurface)->getTextureHandle();
+ desc.fConfig = config;
desc.fSampleCnt = sampleCnt;
+ desc.fTextureHandle = (*backingSurface)->getTextureHandle();
sk_sp<SkSurface> surface =
SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc, nullptr);
return surface;
@@ -127,31 +130,35 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo)
};
struct TestCase {
- RectAndSamplePoint rectAndPoints;
- SkRect clip;
- int sampleCnt;
+ RectAndSamplePoint fRectAndPoints;
+ SkRect fClip;
+ int fSampleCnt;
+ GrSurfaceOrigin fOrigin;
};
std::vector<TestCase> testCases;
- for (int sampleCnt : {0, 4}) {
- for (auto rectAndPoints : allRectsAndPoints) {
- for (auto clip : {SkRect::MakeXYWH(0, 0, 10, 10), SkRect::MakeXYWH(1, 1, 8, 8)}) {
- testCases.push_back({rectAndPoints, clip, sampleCnt});
+ for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
+ for (int sampleCnt : {0, 4}) {
+ for (auto rectAndPoints : allRectsAndPoints) {
+ for (auto clip : {SkRect::MakeXYWH(0, 0, 10, 10), SkRect::MakeXYWH(1, 1, 8, 8)}) {
+ testCases.push_back({rectAndPoints, clip, sampleCnt, origin});
+ }
}
}
}
// Run each test case:
for (auto testCase : testCases) {
- int sampleCnt = testCase.sampleCnt;
- SkRect paintRect = testCase.rectAndPoints.rect;
- SkIPoint outPoint = testCase.rectAndPoints.outPoint;
- SkIPoint inPoint = testCase.rectAndPoints.inPoint;
+ int sampleCnt = testCase.fSampleCnt;
+ SkRect paintRect = testCase.fRectAndPoints.rect;
+ SkIPoint outPoint = testCase.fRectAndPoints.outPoint;
+ SkIPoint inPoint = testCase.fRectAndPoints.inPoint;
+ GrSurfaceOrigin origin = testCase.fOrigin;
sk_sp<GrTexture> backingSurface;
// BGRA forces a framebuffer blit on ES2.
sk_sp<SkSurface> surface = create_gpu_surface_backend_texture_as_render_target(
- context, sampleCnt, kWidth, kHeight, kConfig, &backingSurface);
+ context, sampleCnt, kWidth, kHeight, kConfig, origin, &backingSurface);
if (!surface && sampleCnt > 0) {
// Some platforms don't support MSAA.
@@ -161,7 +168,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ES2BlendWithNoTexture, reporter, ctxInfo)
// Fill our canvas with 0xFFFF80
SkCanvas* canvas = surface->getCanvas();
- canvas->clipRect(testCase.clip, false);
+ canvas->clipRect(testCase.fClip, false);
SkPaint black_paint;
black_paint.setColor(SkColorSetRGB(0xFF, 0xFF, 0x80));
canvas->drawRect(SkRect::MakeXYWH(0, 0, kWidth, kHeight), black_paint);