| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 int width, int height) { | 270 int width, int height) { |
| 271 static const uint8_t kZero = 0x00; | 271 static const uint8_t kZero = 0x00; |
| 272 static const uint8_t kHalf = 0x80; | 272 static const uint8_t kHalf = 0x80; |
| 273 static const uint8_t k3Q = 0xC0; | 273 static const uint8_t k3Q = 0xC0; |
| 274 static const uint8_t kOne = 0xFF; | 274 static const uint8_t kOne = 0xFF; |
| 275 static const uint8_t k1Q = 0x40; | 275 static const uint8_t k1Q = 0x40; |
| 276 return make_oversized_texture_bitmap<uint8_t>( | 276 return make_oversized_texture_bitmap<uint8_t>( |
| 277 ctx, result, width, height, kAlpha_8_GrPixelConfig, kZero, kOne, k3Q, kH
alf, k1Q); | 277 ctx, result, width, height, kAlpha_8_GrPixelConfig, kZero, kOne, k3Q, kH
alf, k1Q); |
| 278 } | 278 } |
| 279 | 279 |
| 280 static SkShader* make_shader() { | 280 static sk_sp<SkShader> make_shader() { |
| 281 static const SkPoint pts[] = { {0, 0}, {20, 20} }; | 281 static const SkPoint pts[] = { {0, 0}, {20, 20} }; |
| 282 static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; | 282 static const SkColor colors[] = { SK_ColorGREEN, SK_ColorYELLOW }; |
| 283 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kMi
rror_TileMode); | 283 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kMirr
or_TileMode); |
| 284 } | 284 } |
| 285 | 285 |
| 286 static SkShader* make_null_shader() { return nullptr; } | 286 static sk_sp<SkShader> make_null_shader() { return nullptr; } |
| 287 | 287 |
| 288 enum BleedTest { | 288 enum BleedTest { |
| 289 kUseBitmap_BleedTest, | 289 kUseBitmap_BleedTest, |
| 290 kUseTextureBitmap_BleedTest, | 290 kUseTextureBitmap_BleedTest, |
| 291 kUseImage_BleedTest, | 291 kUseImage_BleedTest, |
| 292 kUseAlphaBitmap_BleedTest, | 292 kUseAlphaBitmap_BleedTest, |
| 293 kUseAlphaTextureBitmap_BleedTest, | 293 kUseAlphaTextureBitmap_BleedTest, |
| 294 kUseAlphaImage_BleedTest, | 294 kUseAlphaImage_BleedTest, |
| 295 kUseAlphaBitmapShader_BleedTest, | 295 kUseAlphaBitmapShader_BleedTest, |
| 296 kUseAlphaTextureBitmapShader_BleedTest, | 296 kUseAlphaTextureBitmapShader_BleedTest, |
| 297 kUseAlphaImageShader_BleedTest, | 297 kUseAlphaImageShader_BleedTest, |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 const struct { | 300 const struct { |
| 301 const char* fName; | 301 const char* fName; |
| 302 bool (*fPixelMaker)(GrContext*, TestPixels* result, int width, int height); | 302 bool (*fPixelMaker)(GrContext*, TestPixels* result, int width, int height); |
| 303 SkShader* (*fShaderMaker)(); | 303 sk_sp<SkShader> (*fShaderMaker)(); |
| 304 } gBleedRec[] = { | 304 } gBleedRec[] = { |
| 305 { "bleed", make_ringed_color_bitmap,
make_null_shader }, | 305 { "bleed", make_ringed_color_bitmap,
make_null_shader }, |
| 306 { "bleed_texture_bmp", make_ringed_oversized_color_texture_bitm
ap, 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 }, | 307 { "bleed_image", make_ringed_color_image,
make_null_shader }, |
| 308 { "bleed_alpha_bmp", make_ringed_alpha_bitmap,
make_null_shader }, | 308 { "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 }, | 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 }, | 310 { "bleed_alpha_image", make_ringed_alpha_image,
make_null_shader }, |
| 311 { "bleed_alpha_bmp_shader", make_ringed_alpha_bitmap,
make_shader }, | 311 { "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 }, | 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 }, | 313 { "bleed_alpha_image_shader", make_ringed_alpha_image,
make_shader }, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 fCreatedPixels = madePixels; | 461 fCreatedPixels = madePixels; |
| 462 } | 462 } |
| 463 | 463 |
| 464 // Assume that if we coulnd't make the bitmap/image it's because it's a
GPU test on a | 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. | 465 // non-GPU backend. |
| 466 if (!madePixels) { | 466 if (!madePixels) { |
| 467 skiagm::GM::DrawGpuOnlyMessage(canvas); | 467 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 468 return; | 468 return; |
| 469 } | 469 } |
| 470 | 470 |
| 471 fShader.reset(gBleedRec[fBT].fShaderMaker()); | 471 fShader = gBleedRec[fBT].fShaderMaker(); |
| 472 | 472 |
| 473 canvas->clear(SK_ColorGRAY); | 473 canvas->clear(SK_ColorGRAY); |
| 474 SkTDArray<SkMatrix> matrices; | 474 SkTDArray<SkMatrix> matrices; |
| 475 // Draw with identity | 475 // Draw with identity |
| 476 *matrices.append() = SkMatrix::I(); | 476 *matrices.append() = SkMatrix::I(); |
| 477 | 477 |
| 478 // Draw with rotation and scale down in x, up in y. | 478 // Draw with rotation and scale down in x, up in y. |
| 479 SkMatrix m; | 479 SkMatrix m; |
| 480 static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlo
ckSpacing); | 480 static const SkScalar kBottom = SkIntToScalar(kRow4Y + kBlockSize + kBlo
ckSpacing); |
| 481 m.setTranslate(0, kBottom); | 481 m.setTranslate(0, kBottom); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 575 |
| 576 static const int kRow0Y = kBlockSpacing; | 576 static const int kRow0Y = kBlockSpacing; |
| 577 static const int kRow1Y = 2*kBlockSpacing + kBlockSize; | 577 static const int kRow1Y = 2*kBlockSpacing + kBlockSize; |
| 578 static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; | 578 static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; |
| 579 static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; | 579 static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; |
| 580 static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize; | 580 static const int kRow4Y = 5*kBlockSpacing + 4*kBlockSize; |
| 581 | 581 |
| 582 static const int kSmallTextureSize = 6; | 582 static const int kSmallTextureSize = 6; |
| 583 static const int kMaxTileSize = 32; | 583 static const int kMaxTileSize = 32; |
| 584 | 584 |
| 585 bool fCreatedPixels; | 585 bool fCreatedPixels; |
| 586 TestPixels fBigTestPixels; | 586 TestPixels fBigTestPixels; |
| 587 TestPixels fSmallTestPixels; | 587 TestPixels fSmallTestPixels; |
| 588 | 588 |
| 589 SkAutoTUnref<SkShader> fShader; | 589 sk_sp<SkShader> fShader; |
| 590 | 590 |
| 591 const BleedTest fBT; | 591 const BleedTest fBT; |
| 592 | 592 |
| 593 typedef GM INHERITED; | 593 typedef GM INHERITED; |
| 594 }; | 594 }; |
| 595 | 595 |
| 596 | 596 |
| 597 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) | 597 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) |
| 598 DEF_GM( return new BleedGM(kUseTextureBitmap_BleedTest); ) | 598 DEF_GM( return new BleedGM(kUseTextureBitmap_BleedTest); ) |
| 599 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) | 599 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) |
| 600 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) | 600 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) |
| 601 DEF_GM( return new BleedGM(kUseAlphaTextureBitmap_BleedTest); ) | 601 DEF_GM( return new BleedGM(kUseAlphaTextureBitmap_BleedTest); ) |
| 602 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) | 602 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) |
| 603 DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) | 603 DEF_GM( return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) |
| 604 DEF_GM( return new BleedGM(kUseAlphaTextureBitmapShader_BleedTest); ) | 604 DEF_GM( return new BleedGM(kUseAlphaTextureBitmapShader_BleedTest); ) |
| 605 DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) | 605 DEF_GM( return new BleedGM(kUseAlphaImageShader_BleedTest); ) |
| OLD | NEW |