robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
| 8 | #include "gm.h" |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 9 | #include "SkBlurMask.h" |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 10 | #include "SkBlurMaskFilter.h" |
robertphillips@google.com | b706117 | 2013-09-06 14:16:12 +0000 | [diff] [blame] | 11 | #include "SkCanvas.h" |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 12 | #include "SkGradientShader.h" |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 13 | #include "SkImage.h" |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 14 | #include "SkUtils.h" |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 15 | |
| 16 | #if SK_SUPPORT_GPU |
| 17 | #include "GrContext.h" |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 18 | #include "GrContextOptions.h" |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 19 | #include "SkGr.h" |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 20 | #endif |
| 21 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 22 | /** Holds either a bitmap or image to be rendered and a rect that indicates what part of the bitmap |
| 23 | or image should be tested by the GM. The area outside of the rect is present to check |
| 24 | for bleed due to filtering/blurring. */ |
| 25 | struct TestPixels { |
| 26 | enum Type { |
| 27 | kBitmap, |
| 28 | kImage |
| 29 | }; |
| 30 | Type fType; |
| 31 | SkBitmap fBitmap; |
| 32 | SkAutoTUnref<SkImage> fImage; |
| 33 | SkIRect fRect; // The region of the bitmap/image that should be rendered. |
| 34 | }; |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 35 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 36 | /** Creates a bitmap with two one-pixel rings around a checkerboard. The checkerboard is 2x2 |
| 37 | logically where each check has as many pixels as is necessary to fill the interior. The rect |
| 38 | to draw is set to the checkerboard portion. */ |
| 39 | template<typename PIXEL_TYPE> |
| 40 | bool make_ringed_bitmap(GrContext*, TestPixels* result, int width, int height, |
| 41 | SkColorType ct, SkAlphaType at, |
| 42 | PIXEL_TYPE outerRingColor, PIXEL_TYPE innerRingColor, |
| 43 | PIXEL_TYPE checkColor1, PIXEL_TYPE checkColor2) { |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 44 | SkASSERT(0 == width % 2 && 0 == height % 2); |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 45 | SkASSERT(width >= 6 && height >= 6); |
skia.committer@gmail.com | ed00084 | 2013-11-09 07:02:23 +0000 | [diff] [blame] | 46 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 47 | result->fType = TestPixels::kBitmap; |
| 48 | SkImageInfo info = SkImageInfo::Make(width, height, ct, at); |
| 49 | size_t rowBytes = SkAlign4(info.minRowBytes()); |
| 50 | result->fBitmap.allocPixels(info, rowBytes); |
| 51 | |
| 52 | PIXEL_TYPE* scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, 0); |
| 53 | for (int x = 0; x < width; ++x) { |
| 54 | scanline[x] = outerRingColor; |
| 55 | } |
| 56 | scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, 1); |
| 57 | scanline[0] = outerRingColor; |
| 58 | for (int x = 1; x < width - 1; ++x) { |
| 59 | scanline[x] = innerRingColor; |
| 60 | } |
| 61 | scanline[width - 1] = outerRingColor; |
| 62 | |
| 63 | for (int y = 2; y < height / 2; ++y) { |
| 64 | scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, y); |
| 65 | scanline[0] = outerRingColor; |
| 66 | scanline[1] = innerRingColor; |
| 67 | for (int x = 2; x < width / 2; ++x) { |
| 68 | scanline[x] = checkColor1; |
| 69 | } |
| 70 | for (int x = width / 2; x < width - 2; ++x) { |
| 71 | scanline[x] = checkColor2; |
| 72 | } |
| 73 | scanline[width - 2] = innerRingColor; |
| 74 | scanline[width - 1] = outerRingColor; |
| 75 | } |
| 76 | |
| 77 | for (int y = height / 2; y < height - 2; ++y) { |
| 78 | scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, y); |
| 79 | scanline[0] = outerRingColor; |
| 80 | scanline[1] = innerRingColor; |
| 81 | for (int x = 2; x < width / 2; ++x) { |
| 82 | scanline[x] = checkColor2; |
| 83 | } |
| 84 | for (int x = width / 2; x < width - 2; ++x) { |
| 85 | scanline[x] = checkColor1; |
| 86 | } |
| 87 | scanline[width - 2] = innerRingColor; |
| 88 | scanline[width - 1] = outerRingColor; |
| 89 | } |
| 90 | |
| 91 | scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, height - 2); |
| 92 | scanline[0] = outerRingColor; |
| 93 | for (int x = 1; x < width - 1; ++x) { |
| 94 | scanline[x] = innerRingColor; |
| 95 | } |
| 96 | scanline[width - 1] = outerRingColor; |
| 97 | |
| 98 | scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, height - 1); |
| 99 | for (int x = 0; x < width; ++x) { |
| 100 | scanline[x] = outerRingColor; |
| 101 | } |
| 102 | result->fBitmap.setImmutable(); |
| 103 | result->fRect.set(2, 2, width - 2, height - 2); |
| 104 | return true; |
| 105 | } |
| 106 | |
| 107 | /** Create a black and white checked texture with 2 1-pixel rings around the outside edge. |
| 108 | The inner ring is red and the outer ring is blue. */ |
| 109 | static bool make_ringed_color_bitmap(GrContext* ctx, TestPixels* result, int width, int height) { |
| 110 | static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); |
| 111 | static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 112 | static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); |
| 113 | static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 114 | return make_ringed_bitmap<SkPMColor>(ctx, result, width, height, kBGRA_8888_SkColorType, |
| 115 | kPremul_SkAlphaType, kBlue, kRed, kBlack, kWhite); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 116 | } |
| 117 | |
bsalomon | df85a72 | 2015-11-04 04:23:45 -0800 | [diff] [blame] | 118 | /** Makes a alpha bitmap with 1 wide rect/ring of 0s, an inset of 1s, and the interior is a 2x2 |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 119 | checker board of 3/4 and 1/2. The inner checkers are large enough to fill the interior with |
| 120 | the 2x2 checker grid. */ |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 121 | static bool make_ringed_alpha_bitmap(GrContext* ctx, TestPixels* result, int width, int height) { |
| 122 | static const uint8_t kZero = 0x00; |
| 123 | static const uint8_t kHalf = 0x80; |
| 124 | static const uint8_t k3Q = 0xC0; |
| 125 | static const uint8_t kOne = 0xFF; |
| 126 | return make_ringed_bitmap<uint8_t>(ctx, result, width, height, kAlpha_8_SkColorType, |
| 127 | kPremul_SkAlphaType, kZero, kOne, k3Q, kHalf); |
| 128 | } |
| 129 | |
| 130 | /** Helper to reuse above functions to produce images rather than bmps */ |
| 131 | static void bmp_to_image(TestPixels* result) { |
| 132 | SkASSERT(TestPixels::kBitmap == result->fType); |
| 133 | result->fImage.reset(SkImage::NewFromBitmap(result->fBitmap)); |
| 134 | SkASSERT(result->fImage); |
| 135 | result->fType = TestPixels::kImage; |
| 136 | result->fBitmap.reset(); |
| 137 | } |
| 138 | |
| 139 | /** Color image case. */ |
| 140 | bool make_ringed_color_image(GrContext* ctx, TestPixels* result, int width, int height) { |
| 141 | if (make_ringed_color_bitmap(ctx, result, width, height)) { |
| 142 | bmp_to_image(result); |
| 143 | return true; |
| 144 | } |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | /** Alpha image case. */ |
| 149 | bool make_ringed_alpha_image(GrContext* ctx, TestPixels* result, int width, int height) { |
| 150 | if (make_ringed_alpha_bitmap(ctx, result, width, height)) { |
| 151 | bmp_to_image(result); |
| 152 | return true; |
| 153 | } |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | /** Similar to make_ringed_bitmap with these modifications: |
| 158 | - The backing store is a texture. |
| 159 | - The texture is larger than the bitmap dimensions (it is surrounded by non-content |
| 160 | padding on the right/bottom of the contents.) |
| 161 | - The right/bottom sides of the rings are omitted so that the rect to draw is adjacent to |
| 162 | the texture padding. |
| 163 | */ |
| 164 | template <typename PIXEL_TYPE> |
| 165 | bool make_oversized_texture_bitmap(GrContext* ctx, TestPixels* result, int width, int height, |
| 166 | GrPixelConfig config, PIXEL_TYPE outerRingColor, |
| 167 | PIXEL_TYPE innerRingColor, PIXEL_TYPE checkColor1, |
| 168 | PIXEL_TYPE checkColor2, PIXEL_TYPE padColor) { |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 169 | SkASSERT(0 == width % 2 && 0 == height % 2); |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 170 | SkASSERT(width >= 6 && height >= 6); |
| 171 | #if SK_SUPPORT_GPU |
| 172 | if (!ctx) { |
| 173 | return false; |
| 174 | } |
| 175 | /** Put arbitrary pad to the right and below the bitmap content. */ |
| 176 | static const int kXPad = 10; |
| 177 | static const int kYPad = 17; |
| 178 | size_t rowBytes = (width + kXPad) * sizeof(PIXEL_TYPE); |
| 179 | SkAutoTMalloc<PIXEL_TYPE> pixels(rowBytes*(height + kYPad)); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 180 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 181 | PIXEL_TYPE* scanline = pixels.get(); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 182 | for (int x = 0; x < width; ++x) { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 183 | scanline[x] = outerRingColor; |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 184 | } |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 185 | for (int x = width; x < width + kXPad; ++x) { |
| 186 | scanline[x] = padColor; |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 187 | } |
| 188 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 189 | scanline = (PIXEL_TYPE*)((char*)scanline + rowBytes); |
| 190 | scanline[0] = outerRingColor; |
| 191 | for (int x = 1; x < width; ++x) { |
| 192 | scanline[x] = innerRingColor; |
| 193 | } |
| 194 | for (int x = width; x < width + kXPad; ++x) { |
| 195 | scanline[x] = padColor; |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 196 | } |
| 197 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 198 | for (int y = 2; y < height / 2 + 1; ++y) { |
| 199 | scanline = (PIXEL_TYPE*)((char*)scanline + rowBytes); |
| 200 | scanline[0] = outerRingColor; |
| 201 | scanline[1] = innerRingColor; |
| 202 | for (int x = 2; x < width / 2 + 1; ++x) { |
| 203 | scanline[x] = checkColor1; |
| 204 | } |
| 205 | for (int x = width / 2 + 1; x < width; ++x) { |
| 206 | scanline[x] = checkColor2; |
| 207 | } |
| 208 | for (int x = width; x < width + kXPad; ++x) { |
| 209 | scanline[x] = padColor; |
| 210 | } |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 211 | } |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 212 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 213 | for (int y = height / 2 + 1; y < height; ++y) { |
| 214 | scanline = (PIXEL_TYPE*)((char*)scanline + rowBytes); |
| 215 | scanline[0] = outerRingColor; |
| 216 | scanline[1] = innerRingColor; |
| 217 | for (int x = 2; x < width / 2 + 1; ++x) { |
| 218 | scanline[x] = checkColor2; |
| 219 | } |
| 220 | for (int x = width / 2 + 1; x < width; ++x) { |
| 221 | scanline[x] = checkColor1; |
| 222 | } |
| 223 | for (int x = width; x < width + kXPad; ++x) { |
| 224 | scanline[x] = padColor; |
| 225 | } |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 226 | } |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 227 | |
| 228 | for (int y = height; y < height + kYPad; ++y) { |
| 229 | scanline = (PIXEL_TYPE*)((char*)scanline + rowBytes); |
| 230 | for (int x = 0; x < width + kXPad; ++x) { |
| 231 | scanline[x] = padColor; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | GrSurfaceDesc desc; |
| 236 | desc.fConfig = config; |
| 237 | desc.fWidth = width + kXPad; |
| 238 | desc.fHeight = height + kYPad; |
| 239 | SkAutoTUnref<GrTexture> texture(ctx->textureProvider()->createTexture(desc, true, pixels.get(), |
| 240 | rowBytes)); |
| 241 | |
| 242 | if (!texture) { |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | GrWrapTextureInBitmap(texture, width, height, true, &result->fBitmap); |
| 247 | result->fType = TestPixels::kBitmap; |
| 248 | result->fBitmap.setImmutable(); |
| 249 | result->fRect.set(2, 2, width, height); |
| 250 | return true; |
| 251 | #else |
| 252 | return false; |
| 253 | #endif |
| 254 | } |
| 255 | |
| 256 | /** Make the color version of the oversized texture-backed bitmap */ |
| 257 | static bool make_ringed_oversized_color_texture_bitmap(GrContext* ctx, TestPixels* result, |
| 258 | int width, int height) { |
| 259 | static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); |
| 260 | static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); |
| 261 | static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); |
| 262 | static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); |
| 263 | static const SkPMColor kGreen = SkPreMultiplyColor(SK_ColorGREEN); |
| 264 | return make_oversized_texture_bitmap<SkPMColor>( |
| 265 | ctx, result, width, height, kSkia8888_GrPixelConfig, kBlue, kRed, kBlack, kWhite, kGreen); |
| 266 | } |
| 267 | |
| 268 | /** Make the alpha version of the oversized texture-backed bitmap */ |
| 269 | static bool make_ringed_oversized_alpha_texture_bitmap(GrContext* ctx, TestPixels* result, |
| 270 | int width, int height) { |
| 271 | static const uint8_t kZero = 0x00; |
| 272 | static const uint8_t kHalf = 0x80; |
| 273 | static const uint8_t k3Q = 0xC0; |
| 274 | static const uint8_t kOne = 0xFF; |
| 275 | static const uint8_t k1Q = 0x40; |
| 276 | return make_oversized_texture_bitmap<uint8_t>( |
| 277 | ctx, result, width, height, kAlpha_8_GrPixelConfig, kZero, kOne, k3Q, kHalf, k1Q); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static SkShader* make_shader() { |
| 281 | static const SkPoint pts[] = { {0, 0}, {20, 20} }; |
| 282 | static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; |
| 283 | return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kMirror_TileMode); |
| 284 | } |
| 285 | |
| 286 | static SkShader* make_null_shader() { return nullptr; } |
| 287 | |
| 288 | enum BleedTest { |
| 289 | kUseBitmap_BleedTest, |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 290 | kUseTextureBitmap_BleedTest, |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 291 | kUseImage_BleedTest, |
| 292 | kUseAlphaBitmap_BleedTest, |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 293 | kUseAlphaTextureBitmap_BleedTest, |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 294 | kUseAlphaImage_BleedTest, |
| 295 | kUseAlphaBitmapShader_BleedTest, |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 296 | kUseAlphaTextureBitmapShader_BleedTest, |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 297 | kUseAlphaImageShader_BleedTest, |
| 298 | }; |
| 299 | |
| 300 | const struct { |
| 301 | const char* fName; |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 302 | bool (*fPixelMaker)(GrContext*, TestPixels* result, int width, int height); |
| 303 | SkShader* (*fShaderMaker)(); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 304 | } gBleedRec[] = { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 305 | { "bleed", make_ringed_color_bitmap, make_null_shader }, |
| 306 | { "bleed_texture_bmp", make_ringed_oversized_color_texture_bitmap, make_null_shader }, |
| 307 | { "bleed_image", make_ringed_color_image, make_null_shader }, |
| 308 | { "bleed_alpha_bmp", make_ringed_alpha_bitmap, make_null_shader }, |
| 309 | { "bleed_alpha_texture_bmp", make_ringed_oversized_alpha_texture_bitmap, make_null_shader }, |
| 310 | { "bleed_alpha_image", make_ringed_alpha_image, make_null_shader }, |
| 311 | { "bleed_alpha_bmp_shader", make_ringed_alpha_bitmap, make_shader }, |
| 312 | { "bleed_alpha_texture_bmp_shader", make_ringed_oversized_alpha_texture_bitmap, make_shader }, |
| 313 | { "bleed_alpha_image_shader", make_ringed_alpha_image, make_shader }, |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 314 | }; |
| 315 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 316 | /** This GM exercises the behavior of the drawBitmapRect & drawImageRect calls. Specifically their |
| 317 | handling of : |
| 318 | - SrcRectConstraint(bleed vs.no - bleed) |
| 319 | - handling of the sub - region feature(area - of - interest) of drawBitmap* |
| 320 | - handling of 8888 vs. A8 (including presence of a shader in the A8 case). |
| 321 | - (gpu - only) handling of tiled vs.non - tiled drawing) |
| 322 | - (gpu - only) texture's backing a bmp where the texture is larger than the bmp. |
| 323 | In particular, we should never see the padding outside of an SkBitmap's sub - region (green for |
| 324 | 8888, 1/4 for alpha). In some instances we can see the two outer rings outside of the area o |
| 325 | interest (i.e., the inner four checks) due to AA or filtering if allowed by the |
| 326 | SrcRectConstraint. |
| 327 | */ |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 328 | class BleedGM : public skiagm::GM { |
| 329 | public: |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 330 | BleedGM(BleedTest bt) : fCreatedPixels(false), fBT(bt){} |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 331 | |
| 332 | protected: |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 333 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 334 | SkString onShortName() override { |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 335 | return SkString(gBleedRec[fBT].fName); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 336 | } |
| 337 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 338 | SkISize onISize() override { |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 339 | return SkISize::Make(1200, 1080); |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 340 | } |
| 341 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 342 | void drawPixels(SkCanvas* canvas, const TestPixels& pixels, const SkRect& src, |
| 343 | const SkRect& dst, const SkPaint* paint, |
| 344 | SkCanvas::SrcRectConstraint constraint) { |
| 345 | if (TestPixels::kBitmap == pixels.fType) { |
| 346 | canvas->drawBitmapRect(pixels.fBitmap, src, dst, paint, constraint); |
| 347 | } else { |
| 348 | canvas->drawImageRect(pixels.fImage, src, dst, paint, constraint); |
| 349 | } |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 350 | } |
| 351 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 352 | // Draw the area of interest of the small image |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 353 | void drawCase1(SkCanvas* canvas, int transX, int transY, bool aa, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 354 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 355 | |
| 356 | SkRect src = SkRect::Make(fSmallTestPixels.fRect); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 357 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 358 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 359 | |
| 360 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 361 | paint.setFilterQuality(filter); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 362 | paint.setShader(fShader); |
| 363 | paint.setColor(SK_ColorBLUE); |
| 364 | paint.setAntiAlias(aa); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 365 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 366 | this->drawPixels(canvas, fSmallTestPixels, src, dst, &paint, constraint); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 367 | } |
| 368 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 369 | // Draw the area of interest of the large image |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 370 | void drawCase2(SkCanvas* canvas, int transX, int transY, bool aa, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 371 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 372 | SkRect src = SkRect::Make(fBigTestPixels.fRect); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 373 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 374 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 375 | |
| 376 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 377 | paint.setFilterQuality(filter); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 378 | paint.setShader(fShader); |
| 379 | paint.setColor(SK_ColorBLUE); |
| 380 | paint.setAntiAlias(aa); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 381 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 382 | this->drawPixels(canvas, fBigTestPixels, src, dst, &paint, constraint); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 383 | } |
| 384 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 385 | // Draw upper-left 1/4 of the area of interest of the large image |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 386 | void drawCase3(SkCanvas* canvas, int transX, int transY, bool aa, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 387 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 388 | SkRect src = SkRect::MakeXYWH(SkIntToScalar(fBigTestPixels.fRect.fLeft), |
| 389 | SkIntToScalar(fBigTestPixels.fRect.fTop), |
| 390 | fBigTestPixels.fRect.width()/2.f, |
| 391 | fBigTestPixels.fRect.height()/2.f); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 392 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 393 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 394 | |
| 395 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 396 | paint.setFilterQuality(filter); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 397 | paint.setShader(fShader); |
| 398 | paint.setColor(SK_ColorBLUE); |
| 399 | paint.setAntiAlias(aa); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 400 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 401 | this->drawPixels(canvas, fBigTestPixels, src, dst, &paint, constraint); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 402 | } |
| 403 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 404 | // Draw the area of interest of the small image with a normal blur |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 405 | void drawCase4(SkCanvas* canvas, int transX, int transY, bool aa, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 406 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 407 | SkRect src = SkRect::Make(fSmallTestPixels.fRect); |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 408 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 409 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 410 | |
| 411 | SkPaint paint; |
reed | 93a1215 | 2015-03-16 10:08:34 -0700 | [diff] [blame] | 412 | paint.setFilterQuality(filter); |
commit-bot@chromium.org | e396455 | 2014-04-28 16:25:35 +0000 | [diff] [blame] | 413 | SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 414 | SkBlurMask::ConvertRadiusToSigma(3)); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 415 | paint.setMaskFilter(mf)->unref(); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 416 | paint.setShader(fShader); |
| 417 | paint.setColor(SK_ColorBLUE); |
| 418 | paint.setAntiAlias(aa); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 419 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 420 | this->drawPixels(canvas, fSmallTestPixels, src, dst, &paint, constraint); |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 421 | } |
| 422 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 423 | // Draw the area of interest of the small image with a outer blur |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 424 | void drawCase5(SkCanvas* canvas, int transX, int transY, bool aa, |
| 425 | SkCanvas::SrcRectConstraint constraint, SkFilterQuality filter) { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 426 | SkRect src = SkRect::Make(fSmallTestPixels.fRect); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 427 | SkRect dst = SkRect::MakeXYWH(SkIntToScalar(transX), SkIntToScalar(transY), |
| 428 | SkIntToScalar(kBlockSize), SkIntToScalar(kBlockSize)); |
| 429 | |
| 430 | SkPaint paint; |
| 431 | paint.setFilterQuality(filter); |
| 432 | SkMaskFilter* mf = SkBlurMaskFilter::Create(kOuter_SkBlurStyle, |
| 433 | SkBlurMask::ConvertRadiusToSigma(7)); |
| 434 | paint.setMaskFilter(mf)->unref(); |
| 435 | paint.setShader(fShader); |
| 436 | paint.setColor(SK_ColorBLUE); |
| 437 | paint.setAntiAlias(aa); |
| 438 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 439 | this->drawPixels(canvas, fSmallTestPixels, src, dst, &paint, constraint); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 440 | } |
| 441 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 442 | void onDraw(SkCanvas* canvas) override { |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 443 | // We don't create pixels in an onOnceBeforeDraw() override because we want access to |
| 444 | // GrContext. |
| 445 | GrContext* context = canvas->getGrContext(); |
| 446 | #if SK_SUPPORT_GPU |
| 447 | // Workaround for SampleApp. |
| 448 | if (GrTexture* tex = fBigTestPixels.fBitmap.getTexture()) { |
| 449 | if (tex->wasDestroyed()) { |
| 450 | fCreatedPixels = false; |
| 451 | } |
| 452 | } |
| 453 | #endif |
| 454 | bool madePixels = fCreatedPixels; |
| 455 | |
| 456 | if (!madePixels) { |
| 457 | madePixels = gBleedRec[fBT].fPixelMaker(context, &fSmallTestPixels, kSmallTextureSize, |
| 458 | kSmallTextureSize); |
| 459 | madePixels &= gBleedRec[fBT].fPixelMaker(context, &fBigTestPixels, 2 * kMaxTileSize, |
| 460 | 2 * kMaxTileSize); |
| 461 | fCreatedPixels = madePixels; |
| 462 | } |
| 463 | |
| 464 | // Assume that if we coulnd't make the bitmap/image it's because it's a GPU test on a |
| 465 | // non-GPU backend. |
| 466 | if (!madePixels) { |
| 467 | skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | fShader.reset(gBleedRec[fBT].fShaderMaker()); |
| 472 | |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 473 | canvas->clear(SK_ColorGRAY); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 474 | SkTDArray<SkMatrix> matrices; |
| 475 | // Draw with identity |
| 476 | *matrices.append() = SkMatrix::I(); |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 477 | |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 478 | // Draw with rotation and scale down in x, up in y. |
| 479 | SkMatrix m; |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 480 | static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlockSpacing); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 481 | m.setTranslate(0, kBottom); |
| 482 | m.preRotate(15.f, 0, kBottom + kBlockSpacing); |
| 483 | m.preScale(0.71f, 1.22f); |
| 484 | *matrices.append() = m; |
| 485 | |
| 486 | // Align the next set with the middle of the previous in y, translated to the right in x. |
| 487 | SkPoint corners[] = {{0, 0}, { 0, kBottom }, { kWidth, kBottom }, {kWidth, 0} }; |
| 488 | matrices[matrices.count()-1].mapPoints(corners, 4); |
| 489 | SkScalar y = (corners[0].fY + corners[1].fY + corners[2].fY + corners[3].fY) / 4; |
| 490 | SkScalar x = SkTMax(SkTMax(corners[0].fX, corners[1].fX), |
| 491 | SkTMax(corners[2].fX, corners[3].fX)); |
| 492 | m.setTranslate(x, y); |
| 493 | m.preScale(0.2f, 0.2f); |
| 494 | *matrices.append() = m; |
| 495 | |
| 496 | SkScalar maxX = 0; |
| 497 | for (int antiAlias = 0; antiAlias < 2; ++antiAlias) { |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 498 | canvas->save(); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 499 | canvas->translate(maxX, 0); |
| 500 | for (int m = 0; m < matrices.count(); ++m) { |
| 501 | canvas->save(); |
| 502 | canvas->concat(matrices[m]); |
| 503 | bool aa = SkToBool(antiAlias); |
| 504 | |
| 505 | // First draw a column with no bleeding and no filtering |
| 506 | this->drawCase1(canvas, kCol0X, kRow0Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
| 507 | this->drawCase2(canvas, kCol0X, kRow1Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
| 508 | this->drawCase3(canvas, kCol0X, kRow2Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
| 509 | this->drawCase4(canvas, kCol0X, kRow3Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 510 | this->drawCase5(canvas, kCol0X, kRow4Y, aa, SkCanvas::kStrict_SrcRectConstraint, kNone_SkFilterQuality); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 511 | |
| 512 | // Then draw a column with no bleeding and low filtering |
| 513 | this->drawCase1(canvas, kCol1X, kRow0Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
| 514 | this->drawCase2(canvas, kCol1X, kRow1Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
| 515 | this->drawCase3(canvas, kCol1X, kRow2Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
| 516 | this->drawCase4(canvas, kCol1X, kRow3Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 517 | this->drawCase5(canvas, kCol1X, kRow4Y, aa, SkCanvas::kStrict_SrcRectConstraint, kLow_SkFilterQuality); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 518 | |
| 519 | // Then draw a column with no bleeding and high filtering |
| 520 | this->drawCase1(canvas, kCol2X, kRow0Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
| 521 | this->drawCase2(canvas, kCol2X, kRow1Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
| 522 | this->drawCase3(canvas, kCol2X, kRow2Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
| 523 | this->drawCase4(canvas, kCol2X, kRow3Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 524 | this->drawCase5(canvas, kCol2X, kRow4Y, aa, SkCanvas::kStrict_SrcRectConstraint, kHigh_SkFilterQuality); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 525 | |
| 526 | // Then draw a column with bleeding and no filtering (bleed should have no effect w/out blur) |
| 527 | this->drawCase1(canvas, kCol3X, kRow0Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
| 528 | this->drawCase2(canvas, kCol3X, kRow1Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
| 529 | this->drawCase3(canvas, kCol3X, kRow2Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
| 530 | this->drawCase4(canvas, kCol3X, kRow3Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 531 | this->drawCase5(canvas, kCol3X, kRow4Y, aa, SkCanvas::kFast_SrcRectConstraint, kNone_SkFilterQuality); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 532 | |
| 533 | // Then draw a column with bleeding and low filtering |
| 534 | this->drawCase1(canvas, kCol4X, kRow0Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
| 535 | this->drawCase2(canvas, kCol4X, kRow1Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
| 536 | this->drawCase3(canvas, kCol4X, kRow2Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
| 537 | this->drawCase4(canvas, kCol4X, kRow3Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 538 | this->drawCase5(canvas, kCol4X, kRow4Y, aa, SkCanvas::kFast_SrcRectConstraint, kLow_SkFilterQuality); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 539 | |
| 540 | // Finally draw a column with bleeding and high filtering |
| 541 | this->drawCase1(canvas, kCol5X, kRow0Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
| 542 | this->drawCase2(canvas, kCol5X, kRow1Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
| 543 | this->drawCase3(canvas, kCol5X, kRow2Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
| 544 | this->drawCase4(canvas, kCol5X, kRow3Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 545 | this->drawCase5(canvas, kCol5X, kRow4Y, aa, SkCanvas::kFast_SrcRectConstraint, kHigh_SkFilterQuality); |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 546 | |
| 547 | SkPoint corners[] = { { 0, 0 },{ 0, kBottom },{ kWidth, kBottom },{ kWidth, 0 } }; |
| 548 | matrices[m].mapPoints(corners, 4); |
| 549 | SkScalar x = kBlockSize + SkTMax(SkTMax(corners[0].fX, corners[1].fX), |
| 550 | SkTMax(corners[2].fX, corners[3].fX)); |
| 551 | maxX = SkTMax(maxX, x); |
| 552 | canvas->restore(); |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 553 | } |
commit-bot@chromium.org | d6ca4ac | 2013-11-22 20:34:59 +0000 | [diff] [blame] | 554 | canvas->restore(); |
| 555 | } |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 556 | } |
| 557 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 558 | #if SK_SUPPORT_GPU |
| 559 | void modifyGrContextOptions(GrContextOptions* options) override { |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 560 | options->fMaxTileSizeOverride = kMaxTileSize; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 561 | } |
| 562 | #endif |
| 563 | |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 564 | private: |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 565 | static const int kBlockSize = 70; |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 566 | static const int kBlockSpacing = 12; |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 567 | |
| 568 | static const int kCol0X = kBlockSpacing; |
| 569 | static const int kCol1X = 2*kBlockSpacing + kBlockSize; |
| 570 | static const int kCol2X = 3*kBlockSpacing + 2*kBlockSize; |
| 571 | static const int kCol3X = 4*kBlockSpacing + 3*kBlockSize; |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 572 | static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize; |
| 573 | static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 574 | static const int kWidth = 7*kBlockSpacing + 6*kBlockSize; |
robertphillips@google.com | d7ca661 | 2013-08-20 12:09:32 +0000 | [diff] [blame] | 575 | |
| 576 | static const int kRow0Y = kBlockSpacing; |
| 577 | static const int kRow1Y = 2*kBlockSpacing + kBlockSize; |
| 578 | static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; |
robertphillips@google.com | 2cc0b47 | 2013-08-20 16:51:20 +0000 | [diff] [blame] | 579 | static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; |
bsalomon | f57ef1c | 2015-11-04 04:36:12 -0800 | [diff] [blame] | 580 | static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 581 | |
commit-bot@chromium.org | ec39b50 | 2013-11-08 15:09:22 +0000 | [diff] [blame] | 582 | static const int kSmallTextureSize = 6; |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 583 | static const int kMaxTileSize = 32; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 584 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 585 | bool fCreatedPixels; |
| 586 | TestPixels fBigTestPixels; |
| 587 | TestPixels fSmallTestPixels; |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 588 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 589 | SkAutoTUnref<SkShader> fShader; |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 590 | |
bsalomon | 5c1262d | 2015-11-09 10:06:06 -0800 | [diff] [blame] | 591 | const BleedTest fBT; |
robertphillips@google.com | aaa9b29 | 2013-07-25 21:34:00 +0000 | [diff] [blame] | 592 | |
| 593 | typedef GM INHERITED; |
| 594 | }; |
| 595 | |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 596 | |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 597 | DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 598 | DEF_GM( return new BleedGM(kUseTextureBitmap_BleedTest); ) |
reed | a5517e2 | 2015-07-14 10:54:12 -0700 | [diff] [blame] | 599 | DEF_GM( return new BleedGM(kUseImage_BleedTest); ) |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 600 | DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 601 | DEF_GM( return new BleedGM(kUseAlphaTextureBitmap_BleedTest); ) |
bsalomon | 9003d1e | 2015-10-23 11:13:01 -0700 | [diff] [blame] | 602 | DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) |
bsalomon | 9c58654 | 2015-11-02 12:33:21 -0800 | [diff] [blame] | 603 | DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) |
| 604 | DEF_GM( return new BleedGM(kUseAlphaTextureBitmapShader_BleedTest); ) |
| 605 | DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) |