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

Side by Side Diff: gm/blurcircles.cpp

Issue 276453002: New GM for testing circle blur optimization (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove some unnecessary includes Created 6 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h"
11 #include "SkCanvas.h"
12 #include "SkPaint.h"
13 #include "SkString.h"
14
15 class BlurCirclesGM : public skiagm::GM {
16 public:
17 BlurCirclesGM()
18 : fName("blurcircles") {
19 }
20
21 protected:
22 virtual uint32_t onGetFlags() const SK_OVERRIDE {
23 return kSkipTiled_Flag;
24 }
25
26 virtual SkString onShortName() SK_OVERRIDE {
27 return fName;
28 }
29
30 virtual SkISize onISize() SK_OVERRIDE {
31 return SkISize::Make(950, 950);
32 }
33
34 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
35 canvas->scale(1.5f, 1.5f);
36 canvas->translate(50,50);
37
38 const float blurRadii[] = { 1,5,10,20 };
39 const int circleRadii[] = { 5,10,25,50 };
40 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) {
41 SkAutoCanvasRestore autoRestore(canvas, true);
42 canvas->translate(0, SkIntToScalar(150*i));
43 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) {
44 SkMaskFilter* filter = SkBlurMaskFilter::Create(
45 kNormal_SkBlurStyle,
46 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i]) ),
47 SkBlurMaskFilter::kHighQuality_BlurFlag);
48 SkPaint paint;
49 paint.setColor(SK_ColorBLACK);
50 paint.setMaskFilter(filter)->unref();
51
52 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToSc alar(circleRadii[j]),paint);
53 canvas->translate(SkIntToScalar(150), 0);
54 }
55 }
56 }
57 private:
58 const SkString fName;
59
60 typedef skiagm::GM INHERITED;
61 };
62
63 DEF_GM(return new BlurCirclesGM();)
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698