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

Side by Side Diff: gm/blurrect.cpp

Issue 471473002: Optimize CSS box-shadow performance (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: store SkMask and SkCachedData in cache Created 6 years, 2 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 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 SkRect r; 182 SkRect r;
183 r.setWH(SkIntToScalar(width), SkIntToScalar(height)); 183 r.setWH(SkIntToScalar(width), SkIntToScalar(height));
184 SkAutoCanvasRestore autoRestore(canvas, true); 184 SkAutoCanvasRestore autoRestore(canvas, true);
185 185
186 for (size_t j = 0 ; j < SK_ARRAY_COUNT(radii) ; j++) { 186 for (size_t j = 0 ; j < SK_ARRAY_COUNT(radii) ; j++) {
187 float radius = radii[j]; 187 float radius = radii[j];
188 for (size_t k = 0 ; k < SK_ARRAY_COUNT(styles) ; k++) { 188 for (size_t k = 0 ; k < SK_ARRAY_COUNT(styles) ; k++) {
189 SkBlurStyle style = styles[k]; 189 SkBlurStyle style = styles[k];
190 190
191 SkMask mask; 191 SkMask mask;
192 SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(radius ), &mask, r, style); 192 SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(radius ), &mask, NULL, r, style);
193 193
194 SkAutoMaskFreeImage amfi(mask.fImage); 194 SkAutoMaskFreeImage amfi(mask.fImage);
195 195
196 SkBitmap bm; 196 SkBitmap bm;
197 bm.installMaskPixels(mask); 197 bm.installMaskPixels(mask);
198 198
199 if (cur_x + bm.width() >= fGMWidth - fMargin) { 199 if (cur_x + bm.width() >= fGMWidth - fMargin) {
200 cur_x = 0; 200 cur_x = 0;
201 cur_y += max_height + fPadding; 201 cur_y += max_height + fPadding;
202 max_height = 0; 202 max_height = 0;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 public: 298 public:
299 BlurRectFastGM(const char name[], unsigned int rectWidth, 299 BlurRectFastGM(const char name[], unsigned int rectWidth,
300 unsigned int rectHeight, float blurRadius, 300 unsigned int rectHeight, float blurRadius,
301 SkBlurStyle style) : 301 SkBlurStyle style) :
302 INHERITED(name, rectWidth, rectHeight, blurRadius, style) { 302 INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
303 } 303 }
304 304
305 protected: 305 protected:
306 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { 306 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
307 return SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radiu s()), 307 return SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radiu s()),
308 m, r, this->style()); 308 m, NULL, r, this->style());
309 } 309 }
310 private: 310 private:
311 typedef BlurRectCompareGM INHERITED; 311 typedef BlurRectCompareGM INHERITED;
312 }; 312 };
313 313
314 class BlurRectSlowGM: public BlurRectCompareGM { 314 class BlurRectSlowGM: public BlurRectCompareGM {
315 public: 315 public:
316 BlurRectSlowGM(const char name[], unsigned int rectWidth, unsigned int rectH eight, 316 BlurRectSlowGM(const char name[], unsigned int rectWidth, unsigned int rectH eight,
317 float blurRadius, SkBlurStyle style) 317 float blurRadius, SkBlurStyle style)
318 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) { 318 : INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
319 } 319 }
320 320
321 protected: 321 protected:
322 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE { 322 virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
323 SkMask src; 323 SkMask src;
324 r.roundOut(&src.fBounds); 324 r.roundOut(&src.fBounds);
325 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o rigin 325 src.fBounds.offset(-src.fBounds.fLeft, -src.fBounds.fTop); // move to o rigin
326 src.fFormat = SkMask::kA8_Format; 326 src.fFormat = SkMask::kA8_Format;
327 src.fRowBytes = src.fBounds.width(); 327 src.fRowBytes = src.fBounds.width();
328 src.fImage = SkMask::AllocImage(src.computeTotalImageSize()); 328 src.fImage = SkMask::AllocImage(src.computeTotalImageSize());
329 SkAutoMaskFreeImage amfi(src.fImage); 329 SkAutoMaskFreeImage amfi(src.fImage);
330 330
331 memset(src.fImage, 0xff, src.computeTotalImageSize()); 331 memset(src.fImage, 0xff, src.computeTotalImageSize());
332 332
333 return SkBlurMask::BoxBlur(m, src, 333 return SkBlurMask::BoxBlur(m, NULL, src,
334 SkBlurMask::ConvertRadiusToSigma(this->radius ()), 334 SkBlurMask::ConvertRadiusToSigma(this->radius ()),
335 this->style(), this->getQuality()); 335 this->style(), this->getQuality());
336 } 336 }
337 337
338 virtual SkBlurQuality getQuality() { 338 virtual SkBlurQuality getQuality() {
339 return kHigh_SkBlurQuality; 339 return kHigh_SkBlurQuality;
340 } 340 }
341 private: 341 private:
342 typedef BlurRectCompareGM INHERITED; 342 typedef BlurRectCompareGM INHERITED;
343 }; 343 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 385 }
386 private: 386 private:
387 typedef BlurRectCompareGM INHERITED; 387 typedef BlurRectCompareGM INHERITED;
388 }; 388 };
389 389
390 390
391 ////////////////////////////////////////////////////////////////////////////// 391 //////////////////////////////////////////////////////////////////////////////
392 392
393 DEF_GM(return new BlurRectGM("blurrects", 0xFF);) 393 DEF_GM(return new BlurRectGM("blurrects", 0xFF);)
394 DEF_GM(return new BlurRectDirectGM("blurrect_gallery");) 394 DEF_GM(return new BlurRectDirectGM("blurrect_gallery");)
OLDNEW
« no previous file with comments | « bench/BlurRectBench.cpp ('k') | gyp/core.gypi » ('j') | include/core/SkMaskFilter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698