Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: gm/blurcircles.cpp

Issue 1311583005: Add special case circle blur for Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no-GPU build Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/effects.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/blurcircles.cpp
diff --git a/gm/blurcircles.cpp b/gm/blurcircles.cpp
index e4f956fc43adb94b8a6b7f8f0c1d83c8e537836a..74490ce4240613ac967eafd2a8b386d21c93324d 100644
--- a/gm/blurcircles.cpp
+++ b/gm/blurcircles.cpp
@@ -14,37 +14,43 @@
class BlurCirclesGM : public skiagm::GM {
public:
- BlurCirclesGM()
- : fName("blurcircles") {
- }
+ BlurCirclesGM() { }
protected:
+ bool runAsBench() const override { return true; }
SkString onShortName() override {
- return fName;
+ return SkString("blurcircles");
}
SkISize onISize() override {
return SkISize::Make(950, 950);
}
+ void onOnceBeforeDraw() override {
+ const float blurRadii[kNumBlurs] = { 1,5,10,20 };
+
+ for (int i = 0; i < kNumBlurs; ++i) {
+ fBlurFilters[i].reset(SkBlurMaskFilter::Create(
+ kNormal_SkBlurStyle,
+ SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
+ SkBlurMaskFilter::kHighQuality_BlurFlag));
+ }
+ }
+
void onDraw(SkCanvas* canvas) override {
canvas->scale(1.5f, 1.5f);
canvas->translate(50,50);
- const float blurRadii[] = { 1,5,10,20 };
const int circleRadii[] = { 5,10,25,50 };
- for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) {
+
+ for (size_t i = 0; i < kNumBlurs; ++i) {
SkAutoCanvasRestore autoRestore(canvas, true);
canvas->translate(0, SkIntToScalar(150*i));
for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) {
- SkMaskFilter* filter = SkBlurMaskFilter::Create(
- kNormal_SkBlurStyle,
- SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
- SkBlurMaskFilter::kHighQuality_BlurFlag);
SkPaint paint;
paint.setColor(SK_ColorBLACK);
- paint.setMaskFilter(filter)->unref();
+ paint.setMaskFilter(fBlurFilters[i]);
canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToScalar(circleRadii[j]),paint);
canvas->translate(SkIntToScalar(150), 0);
@@ -52,7 +58,9 @@ protected:
}
}
private:
- const SkString fName;
+ static const int kNumBlurs = 4;
+
+ SkAutoTUnref<SkMaskFilter> fBlurFilters[kNumBlurs];
typedef skiagm::GM INHERITED;
};
« no previous file with comments | « no previous file | gyp/effects.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698