bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Ben Wagner | b607a8f | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 8 | #include "SkTypes.h" |
Ben Wagner | 1a462bd | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 9 | |
Ben Wagner | b607a8f | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 10 | #include "GrColor.h" |
Ben Wagner | 501c17c | 2018-03-12 20:04:31 +0000 | [diff] [blame] | 11 | #include "GrContext.h" |
Ben Wagner | b607a8f | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 12 | #include "GrContextFactory.h" |
| 13 | #include "GrContextOptions.h" |
| 14 | #include "GrContextPriv.h" |
Ben Wagner | 501c17c | 2018-03-12 20:04:31 +0000 | [diff] [blame] | 15 | #include "GrRenderTargetContext.h" |
Ben Wagner | b607a8f | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 16 | #include "GrTypes.h" |
| 17 | #include "SkBitmap.h" |
Ben Wagner | 501c17c | 2018-03-12 20:04:31 +0000 | [diff] [blame] | 18 | #include "SkCanvas.h" |
Ben Wagner | b607a8f | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 19 | #include "SkColor.h" |
| 20 | #include "SkColorSpace.h" |
| 21 | #include "SkImageInfo.h" |
| 22 | #include "SkPaint.h" |
| 23 | #include "SkRect.h" |
| 24 | #include "SkRefCnt.h" |
Ben Wagner | 501c17c | 2018-03-12 20:04:31 +0000 | [diff] [blame] | 25 | #include "SkSurface.h" |
Ben Wagner | b607a8f | 2018-03-12 13:46:21 -0400 | [diff] [blame] | 26 | #include "Test.h" |
| 27 | |
| 28 | #include <cstring> |
| 29 | #include <memory> |
Robert Phillips | dbfecd0 | 2017-10-18 15:44:08 -0400 | [diff] [blame] | 30 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 31 | static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t expectedValue, |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 32 | uint32_t* actualValue, int* failX, int* failY) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 33 | int w = rect.width(); |
| 34 | int h = rect.height(); |
Ben Wagner | 7ecc596 | 2016-11-02 17:07:33 -0400 | [diff] [blame] | 35 | std::unique_ptr<uint32_t[]> pixels(new uint32_t[w * h]); |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 36 | memset(pixels.get(), ~expectedValue, sizeof(uint32_t) * w * h); |
Robert Phillips | 301431d | 2017-03-29 12:08:49 -0400 | [diff] [blame] | 37 | |
| 38 | SkImageInfo dstInfo = SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType); |
| 39 | |
| 40 | if (!rtc->readPixels(dstInfo, pixels.get(), 0, rect.fLeft, rect.fTop)) { |
| 41 | return false; |
| 42 | } |
| 43 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 44 | for (int y = 0; y < h; ++y) { |
| 45 | for (int x = 0; x < w; ++x) { |
| 46 | uint32_t pixel = pixels.get()[y * w + x]; |
| 47 | if (pixel != expectedValue) { |
| 48 | *actualValue = pixel; |
| 49 | *failX = x + rect.fLeft; |
| 50 | *failY = y + rect.fTop; |
| 51 | return false; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | return true; |
| 56 | } |
| 57 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 58 | sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) { |
Robert Phillips | 0c4b7b1 | 2018-03-06 08:20:37 -0500 | [diff] [blame] | 59 | return context->contextPriv().makeDeferredRenderTargetContext( |
| 60 | SkBackingFit::kExact, w, h, |
| 61 | kRGBA_8888_GrPixelConfig, nullptr); |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 64 | static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 65 | static const int kW = 10; |
| 66 | static const int kH = 10; |
| 67 | |
| 68 | SkIRect fullRect = SkIRect::MakeWH(kW, kH); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 69 | sk_sp<GrRenderTargetContext> rtContext; |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 70 | |
| 71 | // A rectangle that is inset by one on all sides and the 1-pixel wide rectangles that surround |
| 72 | // it. |
| 73 | SkIRect mid1Rect = SkIRect::MakeXYWH(1, 1, kW-2, kH-2); |
| 74 | SkIRect outerLeftEdge = SkIRect::MakeXYWH(0, 0, 1, kH); |
| 75 | SkIRect outerTopEdge = SkIRect::MakeXYWH(0, 0, kW, 1); |
| 76 | SkIRect outerRightEdge = SkIRect::MakeXYWH(kW-1, 0, 1, kH); |
| 77 | SkIRect outerBottomEdge = SkIRect::MakeXYWH(0, kH-1, kW, 1); |
| 78 | |
| 79 | // A rectangle that is inset by two on all sides and the 1-pixel wide rectangles that surround |
| 80 | // it. |
| 81 | SkIRect mid2Rect = SkIRect::MakeXYWH(2, 2, kW-4, kH-4); |
| 82 | SkIRect innerLeftEdge = SkIRect::MakeXYWH(1, 1, 1, kH-2); |
| 83 | SkIRect innerTopEdge = SkIRect::MakeXYWH(1, 1, kW-2, 1); |
| 84 | SkIRect innerRightEdge = SkIRect::MakeXYWH(kW-2, 1, 1, kH-2); |
| 85 | SkIRect innerBottomEdge = SkIRect::MakeXYWH(1, kH-2, kW-2, 1); |
| 86 | |
| 87 | uint32_t actualValue; |
| 88 | int failX, failY; |
| 89 | |
| 90 | static const GrColor kColor1 = 0xABCDEF01; |
| 91 | static const GrColor kColor2 = ~kColor1; |
| 92 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 93 | rtContext = newRTC(context, kW, kH); |
| 94 | SkASSERT(rtContext); |
| 95 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 96 | // Check a full clear |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 97 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 98 | if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 99 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 100 | failX, failY); |
| 101 | } |
| 102 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 103 | rtContext = newRTC(context, kW, kH); |
| 104 | SkASSERT(rtContext); |
| 105 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 106 | // Check two full clears, same color |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 107 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 108 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 109 | if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 110 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 111 | failX, failY); |
| 112 | } |
| 113 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 114 | rtContext = newRTC(context, kW, kH); |
| 115 | SkASSERT(rtContext); |
| 116 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 117 | // Check two full clears, different colors |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 118 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 119 | rtContext->clear(&fullRect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 120 | if (!check_rect(rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 121 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, |
| 122 | failX, failY); |
| 123 | } |
| 124 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 125 | rtContext = newRTC(context, kW, kH); |
| 126 | SkASSERT(rtContext); |
| 127 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 128 | // Test a full clear followed by a same color inset clear |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 129 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 130 | rtContext->clear(&mid1Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 131 | if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 132 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 133 | failX, failY); |
| 134 | } |
| 135 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 136 | rtContext = newRTC(context, kW, kH); |
| 137 | SkASSERT(rtContext); |
| 138 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 139 | // Test a inset clear followed by same color full clear |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 140 | rtContext->clear(&mid1Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 141 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 142 | if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 143 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 144 | failX, failY); |
| 145 | } |
| 146 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 147 | rtContext = newRTC(context, kW, kH); |
| 148 | SkASSERT(rtContext); |
| 149 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 150 | // Test a full clear followed by a different color inset clear |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 151 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 152 | rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 153 | if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 154 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, |
| 155 | failX, failY); |
| 156 | } |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 157 | if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || |
| 158 | !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || |
| 159 | !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || |
| 160 | !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 161 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 162 | failX, failY); |
| 163 | } |
| 164 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 165 | rtContext = newRTC(context, kW, kH); |
| 166 | SkASSERT(rtContext); |
| 167 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 168 | // Test a inset clear followed by a different full clear |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 169 | rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 170 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 171 | if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 172 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 173 | failX, failY); |
| 174 | } |
| 175 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 176 | rtContext = newRTC(context, kW, kH); |
| 177 | SkASSERT(rtContext); |
| 178 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 179 | // Check three nested clears from largest to smallest where outermost and innermost are same |
| 180 | // color. |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 181 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 182 | rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 183 | rtContext->clear(&mid2Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 184 | if (!check_rect(rtContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 185 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 186 | failX, failY); |
| 187 | } |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 188 | if (!check_rect(rtContext.get(), innerLeftEdge, kColor2, &actualValue, &failX, &failY) || |
| 189 | !check_rect(rtContext.get(), innerTopEdge, kColor2, &actualValue, &failX, &failY) || |
| 190 | !check_rect(rtContext.get(), innerRightEdge, kColor2, &actualValue, &failX, &failY) || |
| 191 | !check_rect(rtContext.get(), innerBottomEdge, kColor2, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 192 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, |
| 193 | failX, failY); |
| 194 | } |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 195 | if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || |
| 196 | !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || |
| 197 | !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || |
| 198 | !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 199 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 200 | failX, failY); |
| 201 | } |
| 202 | |
Robert Phillips | e4d45bf | 2017-06-02 14:53:40 -0400 | [diff] [blame] | 203 | rtContext = newRTC(context, kW, kH); |
| 204 | SkASSERT(rtContext); |
| 205 | |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 206 | // Swap the order of the second two clears in the above test. |
Chris Dalton | 344e903 | 2017-12-11 15:42:09 -0700 | [diff] [blame] | 207 | rtContext->clear(&fullRect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 208 | rtContext->clear(&mid2Rect, kColor1, GrRenderTargetContext::CanClearFullscreen::kNo); |
| 209 | rtContext->clear(&mid1Rect, kColor2, GrRenderTargetContext::CanClearFullscreen::kNo); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 210 | if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 211 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue, |
| 212 | failX, failY); |
| 213 | } |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 214 | if (!check_rect(rtContext.get(), outerLeftEdge, kColor1, &actualValue, &failX, &failY) || |
| 215 | !check_rect(rtContext.get(), outerTopEdge, kColor1, &actualValue, &failX, &failY) || |
| 216 | !check_rect(rtContext.get(), outerRightEdge, kColor1, &actualValue, &failX, &failY) || |
| 217 | !check_rect(rtContext.get(), outerBottomEdge, kColor1, &actualValue, &failX, &failY)) { |
bsalomon | e63ffef | 2016-02-05 07:17:34 -0800 | [diff] [blame] | 218 | ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue, |
| 219 | failX, failY); |
| 220 | } |
| 221 | } |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 222 | |
| 223 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearOp, reporter, ctxInfo) { |
| 224 | clear_op_test(reporter, ctxInfo.grContext()); |
| 225 | if (ctxInfo.backend() == kOpenGL_GrBackend) { |
| 226 | GrContextOptions options(ctxInfo.options()); |
| 227 | options.fUseDrawInsteadOfGLClear = GrContextOptions::Enable::kYes; |
| 228 | sk_gpu_test::GrContextFactory workaroundFactory(options); |
| 229 | clear_op_test(reporter, workaroundFactory.get(ctxInfo.type())); |
| 230 | } |
| 231 | } |
| 232 | |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 233 | void fullscreen_clear_with_layer_test(skiatest::Reporter* reporter, GrContext* context) { |
| 234 | const SkImageInfo ii = SkImageInfo::Make(400, 77, kRGBA_8888_SkColorType, kPremul_SkAlphaType); |
| 235 | |
| 236 | sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, ii); |
| 237 | SkCanvas* canvas = surf->getCanvas(); |
| 238 | |
| 239 | SkPaint paints[2]; |
| 240 | paints[0].setColor(SK_ColorGREEN); |
| 241 | paints[1].setColor(SK_ColorGRAY); |
| 242 | |
| 243 | static const int kLeftX = 158; |
| 244 | static const int kMidX = 258; |
| 245 | static const int kRightX = 383; |
| 246 | static const int kTopY = 26; |
| 247 | static const int kBotY = 51; |
| 248 | |
| 249 | const SkRect rects[2] = { |
| 250 | { kLeftX, kTopY, kMidX, kBotY }, |
| 251 | { kMidX, kTopY, kRightX, kBotY }, |
| 252 | }; |
| 253 | |
| 254 | for (int i = 0; i < 2; ++i) { |
| 255 | // the bounds parameter is required to cause a full screen clear |
| 256 | canvas->saveLayer(&rects[i], nullptr); |
| 257 | canvas->drawRect(rects[i], paints[i]); |
| 258 | canvas->restore(); |
| 259 | } |
| 260 | |
| 261 | SkBitmap bm; |
| 262 | bm.allocPixels(ii, 0); |
| 263 | |
| 264 | SkAssertResult(surf->readPixels(bm, 0, 0)); |
| 265 | |
| 266 | bool isCorrect = true; |
| 267 | for (int y = kTopY; isCorrect && y < kBotY; ++y) { |
| 268 | const uint32_t* sl = bm.getAddr32(0, y); |
| 269 | |
| 270 | for (int x = kLeftX; x < kMidX; ++x) { |
| 271 | if (SK_ColorGREEN != sl[x]) { |
| 272 | isCorrect = false; |
| 273 | break; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | for (int x = kMidX; x < kRightX; ++x) { |
| 278 | if (SK_ColorGRAY != sl[x]) { |
| 279 | isCorrect = false; |
| 280 | break; |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | REPORTER_ASSERT(reporter, isCorrect); |
| 286 | } |
| 287 | // From crbug.com/768134 |
| 288 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FullScreenClearWithLayers, reporter, ctxInfo) { |
| 289 | fullscreen_clear_with_layer_test(reporter, ctxInfo.grContext()); |
| 290 | if (ctxInfo.backend() == kOpenGL_GrBackend) { |
| 291 | GrContextOptions options(ctxInfo.options()); |
| 292 | options.fUseDrawInsteadOfGLClear = GrContextOptions::Enable::kYes; |
| 293 | sk_gpu_test::GrContextFactory workaroundFactory(options); |
| 294 | fullscreen_clear_with_layer_test(reporter, workaroundFactory.get(ctxInfo.type())); |
| 295 | } |
| 296 | } |