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

Side by Side Diff: bench/RectoriBench.cpp

Issue 1821533002: guard rasterizer and drawlooper setters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update android sdk Created 4 years, 9 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
OLDNEW
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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 p.addRect(outer); 46 p.addRect(outer);
47 p.addRect(inner); 47 p.addRect(inner);
48 p.setFillType(SkPath::kEvenOdd_FillType); 48 p.setFillType(SkPath::kEvenOdd_FillType);
49 49
50 // This will be used to translate the normal draw outside the 50 // This will be used to translate the normal draw outside the
51 // clip rect and translate the blurred version back inside 51 // clip rect and translate the blurred version back inside
52 SkScalar translate = 2.0f * size; 52 SkScalar translate = 2.0f * size;
53 53
54 SkPaint paint; 54 SkPaint paint;
55 paint.setLooper(this->createLooper(-translate, blurSigma))->unref(); 55 paint.setLooper(this->createLooper(-translate, blurSigma));
56 paint.setColor(0xff000000 | Random.nextU()); 56 paint.setColor(0xff000000 | Random.nextU());
57 paint.setAntiAlias(true); 57 paint.setAntiAlias(true);
58 58
59 canvas->save(); 59 canvas->save();
60 // clip always equals inner rect so we get the inside blur 60 // clip always equals inner rect so we get the inside blur
61 canvas->clipRect(inner); 61 canvas->clipRect(inner);
62 canvas->translate(translate, 0); 62 canvas->translate(translate, 0);
63 canvas->drawPath(p, paint); 63 canvas->drawPath(p, paint);
64 canvas->restore(); 64 canvas->restore();
65 } 65 }
66 } 66 }
67 67
68 private: 68 private:
69 enum { 69 enum {
70 W = 640, 70 W = 640,
71 H = 480, 71 H = 480,
72 }; 72 };
73 73
74 SkLayerDrawLooper* createLooper(SkScalar xOff, SkScalar sigma) { 74 sk_sp<SkDrawLooper> createLooper(SkScalar xOff, SkScalar sigma) {
75 SkLayerDrawLooper::Builder looperBuilder; 75 SkLayerDrawLooper::Builder looperBuilder;
76 76
77 //----------------------------------------------- 77 //-----------------------------------------------
78 SkLayerDrawLooper::LayerInfo info; 78 SkLayerDrawLooper::LayerInfo info;
79 79
80 // TODO: add a color filter to better match what is seen in the wild 80 // TODO: add a color filter to better match what is seen in the wild
81 info.fPaintBits = /* SkLayerDrawLooper::kColorFilter_Bit |*/ 81 info.fPaintBits = /* SkLayerDrawLooper::kColorFilter_Bit |*/
82 SkLayerDrawLooper::kMaskFilter_Bit; 82 SkLayerDrawLooper::kMaskFilter_Bit;
83 info.fColorMode = SkXfermode::kDst_Mode; 83 info.fColorMode = SkXfermode::kDst_Mode;
84 info.fOffset.set(xOff, 0); 84 info.fOffset.set(xOff, 0);
85 info.fPostTranslate = false; 85 info.fPostTranslate = false;
86 86
87 SkPaint* paint = looperBuilder.addLayer(info); 87 SkPaint* paint = looperBuilder.addLayer(info);
88 88
89 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 89 SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
90 sigma, 90 sigma,
91 SkBlurMaskFilter::kHighQuali ty_BlurFlag); 91 SkBlurMaskFilter::kHighQuali ty_BlurFlag);
92 paint->setMaskFilter(mf)->unref(); 92 paint->setMaskFilter(mf)->unref();
93 93
94 //----------------------------------------------- 94 //-----------------------------------------------
95 info.fPaintBits = 0; 95 info.fPaintBits = 0;
96 info.fOffset.set(0, 0); 96 info.fOffset.set(0, 0);
97 97
98 paint = looperBuilder.addLayer(info); 98 paint = looperBuilder.addLayer(info);
99 return looperBuilder.detachLooper(); 99 return looperBuilder.detach();
100 } 100 }
101 101
102 typedef Benchmark INHERITED; 102 typedef Benchmark INHERITED;
103 }; 103 };
104 104
105 DEF_BENCH(return new RectoriBench();) 105 DEF_BENCH(return new RectoriBench();)
OLDNEW
« no previous file with comments | « bench/BlurRoundRectBench.cpp ('k') | gm/blurroundrect.cpp » ('j') | gm/circles.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698