| OLD | NEW |
| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 uint32_t onGetFlags() const SK_OVERRIDE { return kSkipPipe_Flag | kSkipTiled
_Flag; } | |
| 151 | |
| 152 private: | 150 private: |
| 153 void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint, | 151 void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint, |
| 154 bool doClip, const Proc procs[], size_t procsCount) { | 152 bool doClip, const Proc procs[], size_t procsCount) { |
| 155 SkAutoCanvasRestore acr(canvas, true); | 153 SkAutoCanvasRestore acr(canvas, true); |
| 156 for (size_t i = 0; i < procsCount; ++i) { | 154 for (size_t i = 0; i < procsCount; ++i) { |
| 157 if (doClip) { | 155 if (doClip) { |
| 158 SkRect clipRect(r); | 156 SkRect clipRect(r); |
| 159 clipRect.inset(STROKE_WIDTH/2, STROKE_WIDTH/2); | 157 clipRect.inset(STROKE_WIDTH/2, STROKE_WIDTH/2); |
| 160 canvas->save(); | 158 canvas->save(); |
| 161 canvas->clipRect(r); | 159 canvas->clipRect(r); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 canvas->restore(); | 239 canvas->restore(); |
| 242 | 240 |
| 243 cur_x += bm.width() + fPadding; | 241 cur_x += bm.width() + fPadding; |
| 244 if (bm.height() > max_height) | 242 if (bm.height() > max_height) |
| 245 max_height = bm.height(); | 243 max_height = bm.height(); |
| 246 } | 244 } |
| 247 } | 245 } |
| 248 } | 246 } |
| 249 } | 247 } |
| 250 | 248 |
| 251 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } | |
| 252 | |
| 253 private: | 249 private: |
| 254 typedef GM INHERITED; | 250 typedef GM INHERITED; |
| 255 }; | 251 }; |
| 256 | 252 |
| 257 class BlurRectCompareGM : public skiagm::GM { | 253 class BlurRectCompareGM : public skiagm::GM { |
| 258 SkString fName; | 254 SkString fName; |
| 259 unsigned int fRectWidth, fRectHeight; | 255 unsigned int fRectWidth, fRectHeight; |
| 260 SkScalar fRadius; | 256 SkScalar fRadius; |
| 261 SkBlurStyle fStyle; | 257 SkBlurStyle fStyle; |
| 262 public: | 258 public: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 309 |
| 314 SkBitmap bm; | 310 SkBitmap bm; |
| 315 bm.installMaskPixels(mask); | 311 bm.installMaskPixels(mask); |
| 316 | 312 |
| 317 center_x = (canvas_size.fWidth - mask.fBounds.width())/2; | 313 center_x = (canvas_size.fWidth - mask.fBounds.width())/2; |
| 318 center_y = (canvas_size.fHeight - mask.fBounds.height())/2; | 314 center_y = (canvas_size.fHeight - mask.fBounds.height())/2; |
| 319 | 315 |
| 320 canvas->drawBitmap(bm, SkIntToScalar(center_x), SkIntToScalar(center_y),
NULL); | 316 canvas->drawBitmap(bm, SkIntToScalar(center_x), SkIntToScalar(center_y),
NULL); |
| 321 } | 317 } |
| 322 | 318 |
| 323 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } | |
| 324 | |
| 325 private: | 319 private: |
| 326 typedef GM INHERITED; | 320 typedef GM INHERITED; |
| 327 }; | 321 }; |
| 328 | 322 |
| 329 class BlurRectFastGM: public BlurRectCompareGM { | 323 class BlurRectFastGM: public BlurRectCompareGM { |
| 330 public: | 324 public: |
| 331 BlurRectFastGM(const char name[], unsigned int rectWidth, | 325 BlurRectFastGM(const char name[], unsigned int rectWidth, |
| 332 unsigned int rectHeight, float blurRadius, | 326 unsigned int rectHeight, float blurRadius, |
| 333 SkBlurStyle style) : | 327 SkBlurStyle style) : |
| 334 INHERITED(name, rectWidth, rectHeight, blurRadius, style) { | 328 INHERITED(name, rectWidth, rectHeight, blurRadius, style) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 411 } |
| 418 private: | 412 private: |
| 419 typedef BlurRectCompareGM INHERITED; | 413 typedef BlurRectCompareGM INHERITED; |
| 420 }; | 414 }; |
| 421 | 415 |
| 422 | 416 |
| 423 ////////////////////////////////////////////////////////////////////////////// | 417 ////////////////////////////////////////////////////////////////////////////// |
| 424 | 418 |
| 425 DEF_GM(return new BlurRectGM("blurrects", 0xFF);) | 419 DEF_GM(return new BlurRectGM("blurrects", 0xFF);) |
| 426 DEF_GM(return new BlurRectDirectGM("blurrect_gallery");) | 420 DEF_GM(return new BlurRectDirectGM("blurrect_gallery");) |
| OLD | NEW |