Index: gm/blurrect.cpp |
diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp |
index 835d6aea7d55f1adbfc1cc98b80912c9ae8434e7..a56c51b3ca5b25f6171a1bfb5830c71d9dbd3512 100644 |
--- a/gm/blurrect.cpp |
+++ b/gm/blurrect.cpp |
@@ -139,6 +139,89 @@ private: |
typedef GM INHERITED; |
}; |
+ |
+class BlurRectDirectGM : public skiagm::GM { |
+ SkString fName; |
+ int fGMWidth, fGMHeight; |
+ int fPadding, fMargin; |
+public: |
+ BlurRectDirectGM(const char name[]) |
+ : fName(name), |
+ fGMWidth(1200), |
+ fGMHeight(1024), |
+ fPadding(10), |
+ fMargin(100) |
+ { |
+ } |
+ |
+protected: |
+ virtual SkString onShortName() { |
+ return fName; |
+ } |
+ |
+ virtual SkISize onISize() { |
+ return SkISize::Make(fGMWidth, fGMHeight); |
+ } |
+ |
+ virtual void onDraw(SkCanvas* canvas) { |
+ const int widths[] = {25, 5, 5, 100, 150, 25}; |
+ const int heights[] = {100, 100, 5, 25, 150, 25}; |
+ const SkBlurStyle styles[] = {kNormal_SkBlurStyle, kInner_SkBlurStyle, kOuter_SkBlurStyle}; |
+ const float radii[] = {20, 5, 10}; |
+ |
+ canvas->translate(50,20); |
+ |
+ int cur_x = 0; |
+ int cur_y = 0; |
+ |
+ int max_height = 0; |
+ |
+ for (size_t i = 0 ; i < SK_ARRAY_COUNT(widths) ; i++) { |
+ int width = widths[i]; |
+ int height = heights[i]; |
+ SkRect r; |
+ r.setWH(SkIntToScalar(width), SkIntToScalar(height)); |
+ SkAutoCanvasRestore autoRestore(canvas, true); |
+ |
+ for (size_t j = 0 ; j < SK_ARRAY_COUNT(radii) ; j++) { |
+ float radius = radii[j]; |
+ for (size_t k = 0 ; k < SK_ARRAY_COUNT(styles) ; k++) { |
+ SkBlurStyle style = styles[k]; |
+ |
+ SkMask mask; |
+ SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(radius), &mask, r, style); |
+ |
+ SkAutoMaskFreeImage amfi(mask.fImage); |
+ |
+ SkBitmap bm; |
+ bm.installMaskPixels(mask); |
+ |
+ if (cur_x + bm.width() >= fGMWidth - fMargin) { |
+ cur_x = 0; |
+ cur_y += max_height + fPadding; |
+ max_height = 0; |
+ } |
+ |
+ canvas->save(); |
+ canvas->translate(cur_x, cur_y); |
+ canvas->translate(-(bm.width() - r.width())/2, -(bm.height()-r.height())/2); |
+ canvas->drawBitmap(bm, 0.f, 0.f, NULL); |
+ canvas->restore(); |
+ |
+ cur_x += bm.width() + fPadding; |
+ if (bm.height() > max_height) |
+ max_height = bm.height(); |
+ } |
+ } |
+ } |
+ } |
+ |
+ virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } |
+ |
+private: |
+ typedef GM INHERITED; |
+}; |
+ |
class BlurRectCompareGM : public skiagm::GM { |
SkString fName; |
unsigned int fRectWidth, fRectHeight; |
@@ -308,77 +391,4 @@ private: |
////////////////////////////////////////////////////////////////////////////// |
DEF_GM(return new BlurRectGM("blurrects", 0xFF);) |
- |
-static const SkScalar kBig = 20; |
-static const SkScalar kSmall = 2; |
- |
-// regular size rects, blurs should be small enough not to completely overlap. |
- |
-DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_normal_fast", 25, 100, kSmall, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_normal_fast", 25, 100, kBig, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_normal_slow", 25, 100, kSmall, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_normal_slow", 25, 100, kBig, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_inner_fast", 25, 100, kSmall, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_inner_fast", 25, 100, kBig, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_inner_slow", 25, 100, kSmall, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_inner_slow", 25, 100, kBig, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_outer_fast", 25, 100, kSmall, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_outer_fast", 25, 100, kBig, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_outer_slow", 25, 100, kSmall, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_outer_slow", 25, 100, kBig, kOuter_SkBlurStyle);) |
- |
-// skinny tall rects, blurs overlap in X but not y |
- |
-DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_normal_fast", 5, 100, kSmall, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_normal_fast", 5, 100, kBig, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_normal_slow", 5, 100, kSmall, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_normal_slow", 5, 100, kBig, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_inner_fast", 5, 100, kSmall, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_inner_fast", 5, 100, kBig, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_inner_slow", 5, 100, kSmall, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_inner_slow", 5, 100, kBig, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_outer_fast", 5, 100, kSmall, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_outer_fast", 5, 100, kBig, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_outer_slow", 5, 100, kSmall, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_outer_slow", 5, 100, kBig, kOuter_SkBlurStyle);) |
- |
-// tiny rects, blurs overlap in X and Y |
- |
-DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_normal_fast", 5, 5, kSmall, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_normal_fast", 5, 5, kBig, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_normal_slow", 5, 5, kSmall, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_normal_slow", 5, 5, kBig, kNormal_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_inner_fast", 5, 5, kSmall, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_inner_fast", 5, 5, kBig, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_inner_slow", 5, 5, kSmall, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_inner_slow", 5, 5, kBig, kInner_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_outer_fast", 5, 5, kSmall, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_outer_fast", 5, 5, kBig, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_outer_slow", 5, 5, kSmall, kOuter_SkBlurStyle);) |
-DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_outer_slow", 5, 5, kBig, kOuter_SkBlurStyle);) |
- |
- |
-#if 0 |
-// dont' need to GM the gaussian convolution; it's slow and intended |
-// as a ground truth comparison only. Leaving these here in case we |
-// ever want to turn these back on for debugging reasons. |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_1_simple", 25, 100, 1);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_2_simple", 25, 100, 2);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_3_simple", 25, 100, 3);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_4_simple", 25, 100, 4);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_5_simple", 25, 100, 5);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_6_simple", 25, 100, 6);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_7_simple", 25, 100, 7);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_8_simple", 25, 100, 8);) |
-DEF_GM(return new BlurRectGroundTruthGM( "blurrect_25_100_9_simple", 25, 100, 9);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_10_simple", 25, 100, 10);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_11_simple", 25, 100, 11);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_12_simple", 25, 100, 12);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_13_simple", 25, 100, 13);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_14_simple", 25, 100, 14);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_15_simple", 25, 100, 15);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_16_simple", 25, 100, 16);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_17_simple", 25, 100, 17);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_18_simple", 25, 100, 18);) |
-DEF_GM(return new BlurRectGroundTruthGM("blurrect_25_100_19_simple", 25, 100, 19);) |
-#endif |
+DEF_GM(return new BlurRectDirectGM("blurrect_gallery");) |