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

Side by Side Diff: gm/blurrect.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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 | « gm/blurquickreject.cpp ('k') | gm/blurroundrect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "gm.h" 8 #include "gm.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 SkAutoTUnref<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1]; 86 SkAutoTUnref<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1];
87 SkString fName; 87 SkString fName;
88 SkAlpha fAlpha; 88 SkAlpha fAlpha;
89 public: 89 public:
90 BlurRectGM(const char name[], U8CPU alpha) 90 BlurRectGM(const char name[], U8CPU alpha)
91 : fName(name) 91 : fName(name)
92 , fAlpha(SkToU8(alpha)) { 92 , fAlpha(SkToU8(alpha)) {
93 } 93 }
94 94
95 protected: 95 protected:
96 virtual void onOnceBeforeDraw() SK_OVERRIDE { 96 void onOnceBeforeDraw() SK_OVERRIDE {
97 for (int i = 0; i <= kLastEnum_SkBlurStyle; ++i) { 97 for (int i = 0; i <= kLastEnum_SkBlurStyle; ++i) {
98 fMaskFilters[i].reset(SkBlurMaskFilter::Create((SkBlurStyle)i, 98 fMaskFilters[i].reset(SkBlurMaskFilter::Create((SkBlurStyle)i,
99 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar (STROKE_WIDTH/2)), 99 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar (STROKE_WIDTH/2)),
100 SkBlurMaskFilter::kHighQuality_BlurFlag)); 100 SkBlurMaskFilter::kHighQuality_BlurFlag));
101 } 101 }
102 } 102 }
103 103
104 virtual SkString onShortName() SK_OVERRIDE { 104 SkString onShortName() SK_OVERRIDE {
105 return fName; 105 return fName;
106 } 106 }
107 107
108 virtual SkISize onISize() SK_OVERRIDE { 108 SkISize onISize() SK_OVERRIDE {
109 return SkISize::Make(860, 820); 109 return SkISize::Make(860, 820);
110 } 110 }
111 111
112 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 112 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
113 canvas->translate(STROKE_WIDTH*3/2, STROKE_WIDTH*3/2); 113 canvas->translate(STROKE_WIDTH*3/2, STROKE_WIDTH*3/2);
114 114
115 SkRect r = { 0, 0, 100, 50 }; 115 SkRect r = { 0, 0, 100, 50 };
116 SkScalar scales[] = { SK_Scalar1, 0.6f }; 116 SkScalar scales[] = { SK_Scalar1, 0.6f };
117 117
118 for (size_t s = 0; s < SK_ARRAY_COUNT(scales); ++s) { 118 for (size_t s = 0; s < SK_ARRAY_COUNT(scales); ++s) {
119 canvas->save(); 119 canvas->save();
120 for (size_t f = 0; f < SK_ARRAY_COUNT(fMaskFilters); ++f) { 120 for (size_t f = 0; f < SK_ARRAY_COUNT(fMaskFilters); ++f) {
121 SkPaint paint; 121 SkPaint paint;
122 paint.setMaskFilter(fMaskFilters[f]); 122 paint.setMaskFilter(fMaskFilters[f]);
(...skipping 17 matching lines...) Expand all
140 this->drawProcs(canvas, r, paintWithRadial, true, procs, SK_ARRA Y_COUNT(procs)); 140 this->drawProcs(canvas, r, paintWithRadial, true, procs, SK_ARRA Y_COUNT(procs));
141 canvas->restore(); 141 canvas->restore();
142 142
143 canvas->translate(0, SK_ARRAY_COUNT(procs) * r.height() * 4/3 * scales[s]); 143 canvas->translate(0, SK_ARRAY_COUNT(procs) * r.height() * 4/3 * scales[s]);
144 } 144 }
145 canvas->restore(); 145 canvas->restore();
146 canvas->translate(4 * r.width() * 4/3 * scales[s], 0); 146 canvas->translate(4 * r.width() * 4/3 * scales[s], 0);
147 } 147 }
148 } 148 }
149 149
150 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kSkipPipe_Flag | kS kipTiled_Flag; } 150 uint32_t onGetFlags() const SK_OVERRIDE { return kSkipPipe_Flag | kSkipTiled _Flag; }
151 151
152 private: 152 private:
153 void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint, 153 void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint,
154 bool doClip, const Proc procs[], size_t procsCount) { 154 bool doClip, const Proc procs[], size_t procsCount) {
155 SkAutoCanvasRestore acr(canvas, true); 155 SkAutoCanvasRestore acr(canvas, true);
156 for (size_t i = 0; i < procsCount; ++i) { 156 for (size_t i = 0; i < procsCount; ++i) {
157 if (doClip) { 157 if (doClip) {
158 SkRect clipRect(r); 158 SkRect clipRect(r);
159 clipRect.inset(STROKE_WIDTH/2, STROKE_WIDTH/2); 159 clipRect.inset(STROKE_WIDTH/2, STROKE_WIDTH/2);
160 canvas->save(); 160 canvas->save();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 class BlurRectFastGM: public BlurRectCompareGM { 329 class BlurRectFastGM: public BlurRectCompareGM {
330 public: 330 public:
331 BlurRectFastGM(const char name[], unsigned int rectWidth, 331 BlurRectFastGM(const char name[], unsigned int rectWidth,
332 unsigned int rectHeight, float blurRadius, 332 unsigned int rectHeight, float blurRadius,
333 SkBlurStyle style) : 333 SkBlurStyle style) :
334 INHERITED(name, rectWidth, rectHeight, blurRadius, style) { 334 INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
335 } 335 }
336 336
337 protected: 337 protected:
338 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { 338 bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
339 return SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radiu s()), 339 return SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radiu s()),
340 m, r, this->style()); 340 m, r, this->style());
341 } 341 }
342 private: 342 private:
343 typedef BlurRectCompareGM INHERITED; 343 typedef BlurRectCompareGM INHERITED;
344 }; 344 };
345 345
346 class BlurRectSlowGM: public BlurRectCompareGM { 346 class BlurRectSlowGM: public BlurRectCompareGM {
347 public: 347 public:
348 BlurRectSlowGM(const char name[], unsigned int rectWidth, unsigned int rectH eight, 348 BlurRectSlowGM(const char name[], unsigned int rectWidth, unsigned int rectH eight,
349 float blurRadius, SkBlurStyle style) 349 float blurRadius, SkBlurStyle style)
350 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) { 350 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
351 } 351 }
352 352
353 protected: 353 protected:
354 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { 354 bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
355 SkMask src; 355 SkMask src;
356 r.roundOut(&src.fBounds); 356 r.roundOut(&src.fBounds);
357 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o rigin 357 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o rigin
358 src.fFormat = SkMask::kA8_Format; 358 src.fFormat = SkMask::kA8_Format;
359 src.fRowBytes = src.fBounds.width(); 359 src.fRowBytes = src.fBounds.width();
360 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); 360 src.fImage = SkMask::AllocImage(src.computeTotalImageSize());
361 SkAutoMaskFreeImage amfi(src.fImage); 361 SkAutoMaskFreeImage amfi(src.fImage);
362 362
363 memset(src.fImage, 0xff, src.computeTotalImageSize()); 363 memset(src.fImage, 0xff, src.computeTotalImageSize());
364 364
(...skipping 10 matching lines...) Expand all
375 }; 375 };
376 376
377 class BlurRectSlowLowGM: public BlurRectSlowGM { 377 class BlurRectSlowLowGM: public BlurRectSlowGM {
378 public: 378 public:
379 BlurRectSlowLowGM(const char name[], unsigned int rectWidth, unsigned int re ctHeight, 379 BlurRectSlowLowGM(const char name[], unsigned int rectWidth, unsigned int re ctHeight,
380 float blurRadius, SkBlurStyle style) 380 float blurRadius, SkBlurStyle style)
381 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) { 381 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
382 } 382 }
383 383
384 protected: 384 protected:
385 virtual SkBlurQuality getQuality() SK_OVERRIDE { 385 SkBlurQuality getQuality() SK_OVERRIDE {
386 return kLow_SkBlurQuality; 386 return kLow_SkBlurQuality;
387 } 387 }
388 private: 388 private:
389 typedef BlurRectSlowGM INHERITED; 389 typedef BlurRectSlowGM INHERITED;
390 }; 390 };
391 391
392 class BlurRectGroundTruthGM: public BlurRectCompareGM { 392 class BlurRectGroundTruthGM: public BlurRectCompareGM {
393 public: 393 public:
394 BlurRectGroundTruthGM(const char name[], unsigned int rectWidth, unsigned in t rectHeight, 394 BlurRectGroundTruthGM(const char name[], unsigned int rectWidth, unsigned in t rectHeight,
395 float blurRadius, SkBlurStyle style) 395 float blurRadius, SkBlurStyle style)
396 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) { 396 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
397 } 397 }
398 398
399 protected: 399 protected:
400 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { 400 bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
401 SkMask src; 401 SkMask src;
402 r.roundOut(&src.fBounds); 402 r.roundOut(&src.fBounds);
403 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o rigin 403 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o rigin
404 src.fFormat = SkMask::kA8_Format; 404 src.fFormat = SkMask::kA8_Format;
405 src.fRowBytes = src.fBounds.width(); 405 src.fRowBytes = src.fBounds.width();
406 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); 406 src.fImage = SkMask::AllocImage(src.computeTotalImageSize());
407 SkAutoMaskFreeImage amfi(src.fImage); 407 SkAutoMaskFreeImage amfi(src.fImage);
408 408
409 memset(src.fImage, 0xff, src.computeTotalImageSize()); 409 memset(src.fImage, 0xff, src.computeTotalImageSize());
410 410
411 return SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this ->radius()), 411 return SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this ->radius()),
412 m, src, this->style()); 412 m, src, this->style());
413 } 413 }
414 414
415 virtual SkBlurQuality getQuality() { 415 virtual SkBlurQuality getQuality() {
416 return kHigh_SkBlurQuality; 416 return kHigh_SkBlurQuality;
417 } 417 }
418 private: 418 private:
419 typedef BlurRectCompareGM INHERITED; 419 typedef BlurRectCompareGM INHERITED;
420 }; 420 };
421 421
422 422
423 ////////////////////////////////////////////////////////////////////////////// 423 //////////////////////////////////////////////////////////////////////////////
424 424
425 DEF_GM(return new BlurRectGM("blurrects", 0xFF);) 425 DEF_GM(return new BlurRectGM("blurrects", 0xFF);)
426 DEF_GM(return new BlurRectDirectGM("blurrect_gallery");) 426 DEF_GM(return new BlurRectDirectGM("blurrect_gallery");)
OLDNEW
« no previous file with comments | « gm/blurquickreject.cpp ('k') | gm/blurroundrect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698