aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ClearTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-10-18 08:33:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-18 12:55:06 +0000
commit43f8bf0f784f4182ed0fca9053ecf570caf7ad70 (patch)
tree2a705f6737fceb0d322d6a91d51b01160d68e844 /tests/ClearTest.cpp
parent57caa660c024cf6fda5e1fba8cb21224b51375fe (diff)
Move clear-as-draw workaround to GrGLGpu and expose via GrContextOptions.
Bug: skia:7154 Change-Id: I23ffc11dab4a377fbd6b7e4e33722b3fa0793d58 Reviewed-on: https://skia-review.googlesource.com/60681 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ClearTest.cpp')
-rw-r--r--tests/ClearTest.cpp83
1 files changed, 81 insertions, 2 deletions
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index bcd0899867..c1c39dc4ea 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -43,8 +43,7 @@ sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
kRGBA_8888_GrPixelConfig, nullptr);
}
-DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) {
- GrContext* context = ctxInfo.grContext();
+static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
static const int kW = 10;
static const int kH = 10;
@@ -202,4 +201,84 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) {
failX, failY);
}
}
+
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) {
+ clear_op_test(reporter, ctxInfo.grContext());
+ if (ctxInfo.backend() == kOpenGL_GrBackend) {
+ GrContextOptions options(ctxInfo.options());
+ options.fUseDrawInsteadOfGLClear = GrContextOptions::Enable::kYes;
+ sk_gpu_test::GrContextFactory workaroundFactory(options);
+ clear_op_test(reporter, workaroundFactory.get(ctxInfo.type()));
+ }
+}
+
+#if 0
+
+void fullscreen_clear_with_layer_test(skiatest::Reporter* reporter, GrContext* context) {
+ const SkImageInfo ii = SkImageInfo::Make(400, 77, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
+
+ sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, ii);
+ SkCanvas* canvas = surf->getCanvas();
+
+ SkPaint paints[2];
+ paints[0].setColor(SK_ColorGREEN);
+ paints[1].setColor(SK_ColorGRAY);
+
+ static const int kLeftX = 158;
+ static const int kMidX = 258;
+ static const int kRightX = 383;
+ static const int kTopY = 26;
+ static const int kBotY = 51;
+
+ const SkRect rects[2] = {
+ { kLeftX, kTopY, kMidX, kBotY },
+ { kMidX, kTopY, kRightX, kBotY },
+ };
+
+ for (int i = 0; i < 2; ++i) {
+ // the bounds parameter is required to cause a full screen clear
+ canvas->saveLayer(&rects[i], nullptr);
+ canvas->drawRect(rects[i], paints[i]);
+ canvas->restore();
+ }
+
+ SkBitmap bm;
+ bm.allocPixels(ii, 0);
+
+ SkAssertResult(surf->readPixels(bm, 0, 0));
+
+ bool isCorrect = true;
+ for (int y = kTopY; isCorrect && y < kBotY; ++y) {
+ const uint32_t* sl = bm.getAddr32(0, y);
+
+ for (int x = kLeftX; x < kMidX; ++x) {
+ if (SK_ColorGREEN != sl[x]) {
+ isCorrect = false;
+ break;
+ }
+ }
+
+ for (int x = kMidX; x < kRightX; ++x) {
+ if (SK_ColorGRAY != sl[x]) {
+ isCorrect = false;
+ break;
+ }
+ }
+ }
+
+ REPORTER_ASSERT(reporter, isCorrect);
+}
+// From crbug.com/768134
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FullScreenClearWithLayers, reporter, ctxInfo) {
+ fullscreen_clear_with_layer_test(reporter, ctxInfo.grContext());
+ if (ctxInfo.backend() == kOpenGL_GrBackend) {
+ GrContextOptions options(ctxInfo.options());
+ options.fUseDrawInsteadOfGLClear = GrContextOptions::Enable::kYes;
+ sk_gpu_test::GrContextFactory workaroundFactory(options);
+ fullscreen_clear_with_layer_test(reporter, workaroundFactory.get(ctxInfo.type()));
+ }
+}
+
+#endif
+
#endif