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

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: Address brian comments 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 "SkColorFilter.h"
13 #include "SkLayerDrawLooper.h"
bsalomon 2014/05/07 17:31:45 I think some of these #includes can be removed (pa
14 #include "SkPaint.h"
15 #include "SkPath.h"
16 #include "SkPoint.h"
17 #include "SkRect.h"
18 #include "SkRRect.h"
19 #include "SkString.h"
20 #include "SkXfermode.h"
21
22 class BlurCirclesGM : public skiagm::GM {
23 public:
24 BlurCirclesGM()
25 : fName("blurcircles") {
26 }
27
28 protected:
29
30 virtual SkString onShortName() SK_OVERRIDE {
31 return fName;
32 }
33
34 virtual SkISize onISize() SK_OVERRIDE {
35 return SkISize::Make(950, 950);
36 }
37
38 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
39 canvas->scale(1.5f, 1.5f);
40 canvas->translate(50,50);
41
42 const float blurRadii[] = { 1,5,10,20 };
43 const int circleRadii[] = { 5,10,25,50 };
44 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) {
45 SkAutoCanvasRestore autoRestore(canvas, true);
46 canvas->translate(0, SkIntToScalar(150*i));
47 for (size_t j = 0; j < SK_ARRAY_COUNT(circleRadii); ++j) {
48 SkMaskFilter* filter = SkBlurMaskFilter::Create(
49 kNormal_SkBlurStyle,
50 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i]) ),
51 SkBlurMaskFilter::kHighQuality_BlurFlag);
52 SkPaint paint;
53 paint.setColor(SK_ColorBLACK);
54 paint.setMaskFilter(filter)->unref();
55
56 canvas->drawCircle(SkIntToScalar(50),SkIntToScalar(50),SkIntToSc alar(circleRadii[j]),paint);
57 canvas->translate(SkIntToScalar(150), 0);
58 }
59 }
60 }
61 private:
62 const SkString fName;
63
64 typedef skiagm::GM INHERITED;
65 };
66
67 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