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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 SkISize onISize() override { | 208 SkISize onISize() override { |
209 return SkISize::Make(1050, 780); | 209 return SkISize::Make(1050, 780); |
210 } | 210 } |
211 | 211 |
212 void onOnceBeforeDraw() override { | 212 void onOnceBeforeDraw() override { |
213 gBleedRec[fBT].fBmpMaker(&fBitmapSmall, kSmallTextureSize, kSmallTexture
Size); | 213 gBleedRec[fBT].fBmpMaker(&fBitmapSmall, kSmallTextureSize, kSmallTexture
Size); |
214 fImageSmall.reset(SkImage::NewFromBitmap(fBitmapSmall)); | 214 fImageSmall.reset(SkImage::NewFromBitmap(fBitmapSmall)); |
215 | 215 |
216 // To exercise the GPU's tiling path we need a texture | 216 // To exercise the GPU's tiling path we need a texture |
217 // too big for the GPU to handle in one go | 217 // too big for the GPU to handle in one go |
218 gBleedRec[fBT].fBmpMaker(&fBitmapBig, 2*kMaxTextureSize, 2*kMaxTextureSi
ze); | 218 gBleedRec[fBT].fBmpMaker(&fBitmapBig, 2*kMaxTileSize, 2*kMaxTileSize); |
219 fImageBig.reset(SkImage::NewFromBitmap(fBitmapBig)); | 219 fImageBig.reset(SkImage::NewFromBitmap(fBitmapBig)); |
220 | 220 |
221 fShader.reset(gBleedRec[fBT].fShaderMaker()); | 221 fShader.reset(gBleedRec[fBT].fShaderMaker()); |
222 } | 222 } |
223 | 223 |
224 // Draw only the center of the small bitmap | 224 // Draw only the center of the small bitmap |
225 void drawCase1(SkCanvas* canvas, int transX, int transY, bool aa, | 225 void drawCase1(SkCanvas* canvas, int transX, int transY, bool aa, |
226 SkCanvas::SrcRectConstraint constraint, SkFilterQuality filte
r) { | 226 SkCanvas::SrcRectConstraint constraint, SkFilterQuality filte
r) { |
227 SkRect src = SkRect::MakeXYWH(2, 2, | 227 SkRect src = SkRect::MakeXYWH(2, 2, |
228 SkIntToScalar(kSmallTextureSize-4), | 228 SkIntToScalar(kSmallTextureSize-4), |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 SkTMax(corners[2].fX, corners[3
].fX)); | 371 SkTMax(corners[2].fX, corners[3
].fX)); |
372 maxX = SkTMax(maxX, x); | 372 maxX = SkTMax(maxX, x); |
373 canvas->restore(); | 373 canvas->restore(); |
374 } | 374 } |
375 canvas->restore(); | 375 canvas->restore(); |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 #if SK_SUPPORT_GPU | 379 #if SK_SUPPORT_GPU |
380 void modifyGrContextOptions(GrContextOptions* options) override { | 380 void modifyGrContextOptions(GrContextOptions* options) override { |
381 options->fMaxTextureSizeOverride = kMaxTextureSize; | 381 options->fMaxTileSizeOverride = kMaxTileSize; |
382 } | 382 } |
383 #endif | 383 #endif |
384 | 384 |
385 private: | 385 private: |
386 static const int kBlockSize = 70; | 386 static const int kBlockSize = 70; |
387 static const int kBlockSpacing = 5; | 387 static const int kBlockSpacing = 5; |
388 | 388 |
389 static const int kCol0X = kBlockSpacing; | 389 static const int kCol0X = kBlockSpacing; |
390 static const int kCol1X = 2*kBlockSpacing + kBlockSize; | 390 static const int kCol1X = 2*kBlockSpacing + kBlockSize; |
391 static const int kCol2X = 3*kBlockSpacing + 2*kBlockSize; | 391 static const int kCol2X = 3*kBlockSpacing + 2*kBlockSize; |
392 static const int kCol3X = 4*kBlockSpacing + 3*kBlockSize; | 392 static const int kCol3X = 4*kBlockSpacing + 3*kBlockSize; |
393 static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize; | 393 static const int kCol4X = 5*kBlockSpacing + 4*kBlockSize; |
394 static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize; | 394 static const int kCol5X = 6*kBlockSpacing + 5*kBlockSize; |
395 static const int kWidth = 7*kBlockSpacing + 6*kBlockSize; | 395 static const int kWidth = 7*kBlockSpacing + 6*kBlockSize; |
396 | 396 |
397 static const int kRow0Y = kBlockSpacing; | 397 static const int kRow0Y = kBlockSpacing; |
398 static const int kRow1Y = 2*kBlockSpacing + kBlockSize; | 398 static const int kRow1Y = 2*kBlockSpacing + kBlockSize; |
399 static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; | 399 static const int kRow2Y = 3*kBlockSpacing + 2*kBlockSize; |
400 static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; | 400 static const int kRow3Y = 4*kBlockSpacing + 3*kBlockSize; |
401 | 401 |
402 static const int kSmallTextureSize = 6; | 402 static const int kSmallTextureSize = 6; |
403 static const int kMaxTextureSize = 32; | 403 static const int kMaxTileSize = 32; |
404 | 404 |
405 SkBitmap fBitmapSmall; | 405 SkBitmap fBitmapSmall; |
406 SkBitmap fBitmapBig; | 406 SkBitmap fBitmapBig; |
407 SkAutoTUnref<SkImage> fImageSmall; | 407 SkAutoTUnref<SkImage> fImageSmall; |
408 SkAutoTUnref<SkImage> fImageBig; | 408 SkAutoTUnref<SkImage> fImageBig; |
409 | 409 |
410 SkAutoTUnref<SkShader> fShader; | 410 SkAutoTUnref<SkShader> fShader; |
411 | 411 |
412 const BleedTest fBT; | 412 const BleedTest fBT; |
413 | 413 |
414 typedef GM INHERITED; | 414 typedef GM INHERITED; |
415 }; | 415 }; |
416 | 416 |
417 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) | 417 DEF_GM( return new BleedGM(kUseBitmap_BleedTest); ) |
418 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) | 418 DEF_GM( return new BleedGM(kUseImage_BleedTest); ) |
419 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) | 419 DEF_GM( return new BleedGM(kUseAlphaBitmap_BleedTest); ) |
420 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) | 420 DEF_GM( return new BleedGM(kUseAlphaImage_BleedTest); ) |
421 #if 0 // Currently crashes GPU backend | |
422 DEF_GM(return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) | 421 DEF_GM(return new BleedGM(kUseAlphaBitmapShader_BleedTest); ) |
423 DEF_GM(return new BleedGM(kUseAlphaImageShader_BleedTest); ) | 422 DEF_GM(return new BleedGM(kUseAlphaImageShader_BleedTest); ) |
424 #endif | |
OLD | NEW |