| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
| 10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 Type fType; | 30 Type fType; |
| 31 SkBitmap fBitmap; | 31 SkBitmap fBitmap; |
| 32 sk_sp<SkImage> fImage; | 32 sk_sp<SkImage> fImage; |
| 33 SkIRect fRect; // The region of the bitmap/image that should be ren
dered. | 33 SkIRect fRect; // The region of the bitmap/image that should be ren
dered. |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 /** Creates a bitmap with two one-pixel rings around a checkerboard. The checker
board is 2x2 | 36 /** Creates a bitmap with two one-pixel rings around a checkerboard. The checker
board is 2x2 |
| 37 logically where each check has as many pixels as is necessary to fill the in
terior. The rect | 37 logically where each check has as many pixels as is necessary to fill the in
terior. The rect |
| 38 to draw is set to the checkerboard portion. */ | 38 to draw is set to the checkerboard portion. */ |
| 39 template<typename PIXEL_TYPE> | 39 template<typename PIXEL_TYPE> |
| 40 bool make_ringed_bitmap(GrContext*, TestPixels* result, int width, int height, | 40 bool make_ringed_bitmap(TestPixels* result, int width, int height, |
| 41 SkColorType ct, SkAlphaType at, | 41 SkColorType ct, SkAlphaType at, |
| 42 PIXEL_TYPE outerRingColor, PIXEL_TYPE innerRingColor, | 42 PIXEL_TYPE outerRingColor, PIXEL_TYPE innerRingColor, |
| 43 PIXEL_TYPE checkColor1, PIXEL_TYPE checkColor2) { | 43 PIXEL_TYPE checkColor1, PIXEL_TYPE checkColor2) { |
| 44 SkASSERT(0 == width % 2 && 0 == height % 2); | 44 SkASSERT(0 == width % 2 && 0 == height % 2); |
| 45 SkASSERT(width >= 6 && height >= 6); | 45 SkASSERT(width >= 6 && height >= 6); |
| 46 | 46 |
| 47 result->fType = TestPixels::kBitmap; | 47 result->fType = TestPixels::kBitmap; |
| 48 SkImageInfo info = SkImageInfo::Make(width, height, ct, at); | 48 SkImageInfo info = SkImageInfo::Make(width, height, ct, at); |
| 49 size_t rowBytes = SkAlign4(info.minRowBytes()); | 49 size_t rowBytes = SkAlign4(info.minRowBytes()); |
| 50 result->fBitmap.allocPixels(info, rowBytes); | 50 result->fBitmap.allocPixels(info, rowBytes); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, height - 1); | 98 scanline = (PIXEL_TYPE*)result->fBitmap.getAddr(0, height - 1); |
| 99 for (int x = 0; x < width; ++x) { | 99 for (int x = 0; x < width; ++x) { |
| 100 scanline[x] = outerRingColor; | 100 scanline[x] = outerRingColor; |
| 101 } | 101 } |
| 102 result->fBitmap.setImmutable(); | 102 result->fBitmap.setImmutable(); |
| 103 result->fRect.set(2, 2, width - 2, height - 2); | 103 result->fRect.set(2, 2, width - 2, height - 2); |
| 104 return true; | 104 return true; |
| 105 } | 105 } |
| 106 | 106 |
| 107 /** Create a black and white checked texture with 2 1-pixel rings around the out
side edge. | 107 /** Create a black and white checked bitmap with 2 1-pixel rings around the outs
ide edge. |
| 108 The inner ring is red and the outer ring is blue. */ | 108 The inner ring is red and the outer ring is blue. */ |
| 109 static bool make_ringed_color_bitmap(GrContext* ctx, TestPixels* result, int wid
th, int height) { | 109 static bool make_ringed_color_bitmap(TestPixels* result, int width, int height)
{ |
| 110 static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); | 110 static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); |
| 111 static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); | 111 static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); |
| 112 static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); | 112 static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); |
| 113 static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); | 113 static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); |
| 114 return make_ringed_bitmap<SkPMColor>(ctx, result, width, height, kBGRA_8888_
SkColorType, | 114 return make_ringed_bitmap<SkPMColor>(result, width, height, kBGRA_8888_SkCol
orType, |
| 115 kPremul_SkAlphaType, kBlue, kRed, kBlac
k, kWhite); | 115 kPremul_SkAlphaType, kBlue, kRed, kBlac
k, kWhite); |
| 116 } | 116 } |
| 117 | 117 |
| 118 /** Makes a alpha bitmap with 1 wide rect/ring of 0s, an inset of 1s, and the in
terior is a 2x2 | 118 /** Makes a alpha bitmap with 1 wide rect/ring of 0s, an inset of 1s, and the in
terior is a 2x2 |
| 119 checker board of 3/4 and 1/2. The inner checkers are large enough to fill th
e interior with | 119 checker board of 3/4 and 1/2. The inner checkers are large enough to fill th
e interior with |
| 120 the 2x2 checker grid. */ | 120 the 2x2 checker grid. */ |
| 121 static bool make_ringed_alpha_bitmap(GrContext* ctx, TestPixels* result, int wid
th, int height) { | 121 static bool make_ringed_alpha_bitmap(TestPixels* result, int width, int height)
{ |
| 122 static const uint8_t kZero = 0x00; | 122 static const uint8_t kZero = 0x00; |
| 123 static const uint8_t kHalf = 0x80; | 123 static const uint8_t kHalf = 0x80; |
| 124 static const uint8_t k3Q = 0xC0; | 124 static const uint8_t k3Q = 0xC0; |
| 125 static const uint8_t kOne = 0xFF; | 125 static const uint8_t kOne = 0xFF; |
| 126 return make_ringed_bitmap<uint8_t>(ctx, result, width, height, kAlpha_8_SkCo
lorType, | 126 return make_ringed_bitmap<uint8_t>(result, width, height, kAlpha_8_SkColorTy
pe, |
| 127 kPremul_SkAlphaType, kZero, kOne, k3Q, kH
alf); | 127 kPremul_SkAlphaType, kZero, kOne, k3Q, kH
alf); |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** Helper to reuse above functions to produce images rather than bmps */ | 130 /** Helper to reuse above functions to produce images rather than bmps */ |
| 131 static void bmp_to_image(TestPixels* result) { | 131 static void bmp_to_image(TestPixels* result) { |
| 132 SkASSERT(TestPixels::kBitmap == result->fType); | 132 SkASSERT(TestPixels::kBitmap == result->fType); |
| 133 result->fImage = SkImage::MakeFromBitmap(result->fBitmap); | 133 result->fImage = SkImage::MakeFromBitmap(result->fBitmap); |
| 134 SkASSERT(result->fImage); | 134 SkASSERT(result->fImage); |
| 135 result->fType = TestPixels::kImage; | 135 result->fType = TestPixels::kImage; |
| 136 result->fBitmap.reset(); | 136 result->fBitmap.reset(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /** Color image case. */ | 139 /** Color image case. */ |
| 140 bool make_ringed_color_image(GrContext* ctx, TestPixels* result, int width, int
height) { | 140 bool make_ringed_color_image(TestPixels* result, int width, int height) { |
| 141 if (make_ringed_color_bitmap(ctx, result, width, height)) { | 141 if (make_ringed_color_bitmap(result, width, height)) { |
| 142 bmp_to_image(result); | 142 bmp_to_image(result); |
| 143 return true; | 143 return true; |
| 144 } | 144 } |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** Alpha image case. */ | 148 /** Alpha image case. */ |
| 149 bool make_ringed_alpha_image(GrContext* ctx, TestPixels* result, int width, int
height) { | 149 bool make_ringed_alpha_image(TestPixels* result, int width, int height) { |
| 150 if (make_ringed_alpha_bitmap(ctx, result, width, height)) { | 150 if (make_ringed_alpha_bitmap(result, width, height)) { |
| 151 bmp_to_image(result); | 151 bmp_to_image(result); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 return false; | 154 return false; |
| 155 } | 155 } |
| 156 | 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 dr
aw 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 outerRingCol
or, | |
| 167 PIXEL_TYPE innerRingColor, PIXEL_TYPE checkCo
lor1, | |
| 168 PIXEL_TYPE checkColor2, PIXEL_TYPE padColor)
{ | |
| 169 SkASSERT(0 == width % 2 && 0 == height % 2); | |
| 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)); | |
| 180 | |
| 181 PIXEL_TYPE* scanline = pixels.get(); | |
| 182 for (int x = 0; x < width; ++x) { | |
| 183 scanline[x] = outerRingColor; | |
| 184 } | |
| 185 for (int x = width; x < width + kXPad; ++x) { | |
| 186 scanline[x] = padColor; | |
| 187 } | |
| 188 | |
| 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; | |
| 196 } | |
| 197 | |
| 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 } | |
| 211 } | |
| 212 | |
| 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 } | |
| 226 } | |
| 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( | |
| 240 desc, SkBudgeted::kYes, pixels.get(), 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, TestPixel
s* 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, TestPixel
s* 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, kH
alf, k1Q); | |
| 278 } | |
| 279 | |
| 280 static sk_sp<SkShader> make_shader() { | 157 static sk_sp<SkShader> make_shader() { |
| 281 static const SkPoint pts[] = { {0, 0}, {20, 20} }; | 158 static const SkPoint pts[] = { {0, 0}, {20, 20} }; |
| 282 static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; | 159 static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; |
| 283 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kMirr
or_TileMode); | 160 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kMirr
or_TileMode); |
| 284 } | 161 } |
| 285 | 162 |
| 286 static sk_sp<SkShader> make_null_shader() { return nullptr; } | 163 static sk_sp<SkShader> make_null_shader() { return nullptr; } |
| 287 | 164 |
| 288 enum BleedTest { | 165 enum BleedTest { |
| 289 kUseBitmap_BleedTest, | 166 kUseBitmap_BleedTest, |
| 290 kUseTextureBitmap_BleedTest, | |
| 291 kUseImage_BleedTest, | 167 kUseImage_BleedTest, |
| 292 kUseAlphaBitmap_BleedTest, | 168 kUseAlphaBitmap_BleedTest, |
| 293 kUseAlphaTextureBitmap_BleedTest, | |
| 294 kUseAlphaImage_BleedTest, | 169 kUseAlphaImage_BleedTest, |
| 295 kUseAlphaBitmapShader_BleedTest, | 170 kUseAlphaBitmapShader_BleedTest, |
| 296 kUseAlphaTextureBitmapShader_BleedTest, | |
| 297 kUseAlphaImageShader_BleedTest, | 171 kUseAlphaImageShader_BleedTest, |
| 298 }; | 172 }; |
| 299 | 173 |
| 300 const struct { | 174 const struct { |
| 301 const char* fName; | 175 const char* fName; |
| 302 bool (*fPixelMaker)(GrContext*, TestPixels* result, int width, int height); | 176 bool (*fPixelMaker)(TestPixels* result, int width, int height); |
| 303 sk_sp<SkShader> (*fShaderMaker)(); | 177 sk_sp<SkShader> (*fShaderMaker)(); |
| 304 } gBleedRec[] = { | 178 } gBleedRec[] = { |
| 305 { "bleed", make_ringed_color_bitmap,
make_null_shader }, | 179 { "bleed", make_ringed_color_bitmap,
make_null_shader }, |
| 306 { "bleed_texture_bmp", make_ringed_oversized_color_texture_bitm
ap, make_null_shader }, | |
| 307 { "bleed_image", make_ringed_color_image,
make_null_shader }, | 180 { "bleed_image", make_ringed_color_image,
make_null_shader }, |
| 308 { "bleed_alpha_bmp", make_ringed_alpha_bitmap,
make_null_shader }, | 181 { "bleed_alpha_bmp", make_ringed_alpha_bitmap,
make_null_shader }, |
| 309 { "bleed_alpha_texture_bmp", make_ringed_oversized_alpha_texture_bitm
ap, make_null_shader }, | |
| 310 { "bleed_alpha_image", make_ringed_alpha_image,
make_null_shader }, | 182 { "bleed_alpha_image", make_ringed_alpha_image,
make_null_shader }, |
| 311 { "bleed_alpha_bmp_shader", make_ringed_alpha_bitmap,
make_shader }, | 183 { "bleed_alpha_bmp_shader", make_ringed_alpha_bitmap,
make_shader }, |
| 312 { "bleed_alpha_texture_bmp_shader", make_ringed_oversized_alpha_texture_bitm
ap, make_shader }, | |
| 313 { "bleed_alpha_image_shader", make_ringed_alpha_image,
make_shader }, | 184 { "bleed_alpha_image_shader", make_ringed_alpha_image,
make_shader }, |
| 314 }; | 185 }; |
| 315 | 186 |
| 316 /** This GM exercises the behavior of the drawBitmapRect & drawImageRect calls.
Specifically their | 187 /** This GM exercises the behavior of the drawBitmapRect & drawImageRect calls.
Specifically their |
| 317 handling of : | 188 handling of : |
| 318 - SrcRectConstraint(bleed vs.no - bleed) | 189 - SrcRectConstraint(bleed vs.no - bleed) |
| 319 - handling of the sub - region feature(area - of - interest) of drawBitmap* | 190 - 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). | 191 - 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 | 192 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 outsi
de of the area o | 193 8888, 1/4 for alpha). In some instances we can see the two outer rings outsi
de of the area o |
| 325 interest (i.e., the inner four checks) due to AA or filtering if allowed by
the | 194 interest (i.e., the inner four checks) due to AA or filtering if allowed by
the |
| 326 SrcRectConstraint. | 195 SrcRectConstraint. |
| 327 */ | 196 */ |
| 328 class BleedGM : public skiagm::GM { | 197 class BleedGM : public skiagm::GM { |
| 329 public: | 198 public: |
| 330 BleedGM(BleedTest bt) : fCreatedPixels(false), fBT(bt){} | 199 BleedGM(BleedTest bt) : fBT(bt){} |
| 331 | 200 |
| 332 protected: | 201 protected: |
| 333 | 202 |
| 334 SkString onShortName() override { | 203 SkString onShortName() override { |
| 335 return SkString(gBleedRec[fBT].fName); | 204 return SkString(gBleedRec[fBT].fName); |
| 336 } | 205 } |
| 337 | 206 |
| 338 SkISize onISize() override { | 207 SkISize onISize() override { |
| 339 return SkISize::Make(1200, 1080); | 208 return SkISize::Make(1200, 1080); |
| 340 } | 209 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 paint.setFilterQuality(filter); | 299 paint.setFilterQuality(filter); |
| 431 paint.setMaskFilter(SkBlurMaskFilter::Make(kOuter_SkBlurStyle, | 300 paint.setMaskFilter(SkBlurMaskFilter::Make(kOuter_SkBlurStyle, |
| 432 SkBlurMask::ConvertRadiusToSi
gma(7))); | 301 SkBlurMask::ConvertRadiusToSi
gma(7))); |
| 433 paint.setShader(fShader); | 302 paint.setShader(fShader); |
| 434 paint.setColor(SK_ColorBLUE); | 303 paint.setColor(SK_ColorBLUE); |
| 435 paint.setAntiAlias(aa); | 304 paint.setAntiAlias(aa); |
| 436 | 305 |
| 437 this->drawPixels(canvas, fSmallTestPixels, src, dst, &paint, constraint)
; | 306 this->drawPixels(canvas, fSmallTestPixels, src, dst, &paint, constraint)
; |
| 438 } | 307 } |
| 439 | 308 |
| 309 void onOnceBeforeDraw() override { |
| 310 SkAssertResult(gBleedRec[fBT].fPixelMaker(&fSmallTestPixels, kSmallSize,
kSmallSize)); |
| 311 SkAssertResult(gBleedRec[fBT].fPixelMaker(&fBigTestPixels, 2 * kMaxTileS
ize, |
| 312 2 * kMaxTileSize)); |
| 313 } |
| 314 |
| 440 void onDraw(SkCanvas* canvas) override { | 315 void onDraw(SkCanvas* canvas) override { |
| 441 // We don't create pixels in an onOnceBeforeDraw() override because we w
ant access to | |
| 442 // GrContext. | |
| 443 GrContext* context = canvas->getGrContext(); | |
| 444 #if SK_SUPPORT_GPU | |
| 445 // Workaround for SampleApp. | |
| 446 if (GrTexture* tex = fBigTestPixels.fBitmap.getTexture()) { | |
| 447 if (tex->wasDestroyed()) { | |
| 448 fCreatedPixels = false; | |
| 449 } | |
| 450 } | |
| 451 #endif | |
| 452 bool madePixels = fCreatedPixels; | |
| 453 | |
| 454 if (!madePixels) { | |
| 455 madePixels = gBleedRec[fBT].fPixelMaker(context, &fSmallTestPixels,
kSmallTextureSize, | |
| 456 kSmallTextureSize); | |
| 457 madePixels &= gBleedRec[fBT].fPixelMaker(context, &fBigTestPixels, 2
* kMaxTileSize, | |
| 458 2 * kMaxTileSize); | |
| 459 fCreatedPixels = madePixels; | |
| 460 } | |
| 461 | |
| 462 // Assume that if we coulnd't make the bitmap/image it's because it's a
GPU test on a | |
| 463 // non-GPU backend. | |
| 464 if (!madePixels) { | |
| 465 skiagm::GM::DrawGpuOnlyMessage(canvas); | |
| 466 return; | |
| 467 } | |
| 468 | |
| 469 fShader = gBleedRec[fBT].fShaderMaker(); | 316 fShader = gBleedRec[fBT].fShaderMaker(); |
| 470 | 317 |
| 471 canvas->clear(SK_ColorGRAY); | 318 canvas->clear(SK_ColorGRAY); |
| 472 SkTDArray<SkMatrix> matrices; | 319 SkTDArray<SkMatrix> matrices; |
| 473 // Draw with identity | 320 // Draw with identity |
| 474 *matrices.append() = SkMatrix::I(); | 321 *matrices.append() = SkMatrix::I(); |
| 475 | 322 |
| 476 // Draw with rotation and scale down in x, up in y. | 323 // Draw with rotation and scale down in x, up in y. |
| 477 SkMatrix m; | 324 SkMatrix m; |
| 478 static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlo
ckSpacing); | 325 static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlo
ckSpacing); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize; | 417 static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize; |
| 571 static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize; | 418 static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize; |
| 572 static const int kWidth = 7*kBlockSpacing + 6*kBlockSize; | 419 static const int kWidth = 7*kBlockSpacing + 6*kBlockSize; |
| 573 | 420 |
| 574 static const int kRow0Y = kBlockSpacing; | 421 static const int kRow0Y = kBlockSpacing; |
| 575 static const int kRow1Y = 2*kBlockSpacing + kBlockSize; | 422 static const int kRow1Y = 2*kBlockSpacing + kBlockSize; |
| 576 static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; | 423 static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; |
| 577 static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; | 424 static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; |
| 578 static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize; | 425 static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize; |
| 579 | 426 |
| 580 static const int kSmallTextureSize = 6; | 427 static const int kSmallSize = 6; |
| 581 static const int kMaxTileSize = 32; | 428 static const int kMaxTileSize = 32; |
| 582 | 429 |
| 583 bool fCreatedPixels; | |
| 584 TestPixels fBigTestPixels; | 430 TestPixels fBigTestPixels; |
| 585 TestPixels fSmallTestPixels; | 431 TestPixels fSmallTestPixels; |
| 586 | 432 |
| 587 sk_sp<SkShader> fShader; | 433 sk_sp<SkShader> fShader; |
| 588 | 434 |
| 589 const BleedTest fBT; | 435 const BleedTest fBT; |
| 590 | 436 |
| 591 typedef GM INHERITED; | 437 typedef GM INHERITED; |
| 592 }; | 438 }; |
| 593 | 439 |
| 594 | 440 |
| 595 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) | 441 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) |
| 596 DEF_GM( return new BleedGM(kUseTextureBitmap_BleedTest); ) | |
| 597 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) | 442 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) |
| 598 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) | 443 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) |
| 599 DEF_GM( return new BleedGM(kUseAlphaTextureBitmap_BleedTest); ) | |
| 600 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) | 444 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) |
| 601 DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) | 445 DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) |
| 602 DEF_GM( return new BleedGM(kUseAlphaTextureBitmapShader_BleedTest); ) | |
| 603 DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) | 446 DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) |
| OLD | NEW |