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

Side by Side Diff: gm/blurquickreject.cpp

Issue 17035007: Fix quickReject computation for blurs (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: updated Created 7 years, 4 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 | Annotate | Revision Log
« 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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 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 "SkCanvas.h"
10 #include "SkBlurMaskFilter.h"
11
12 // This GM tests out the quick reject bounds of the blur mask filter. It draws
13 // four blurred rects around a central clip. The blurred rect geometry outset
14 // by the blur radius does not overlap the clip rect so, if the blur clipping
15 // just uses the radius, they will be clipped out (and the result will differ
16 // from the result if quick reject were disabled. If the blur clipping uses
17 // the correct 3 sigma bound then the images with and without quick rejecting
18 // will be the same.
19 class BlurQuickRejectGM : public skiagm::GM {
20 public:
21 BlurQuickRejectGM() {}
22
23 protected:
24 virtual SkString onShortName() SK_OVERRIDE {
25 return SkString("blurquickreject");
26 }
27
28 virtual SkISize onISize() SK_OVERRIDE {
29 return SkISize::Make(kWidth, kHeight);
30 }
31
32 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
33 static const SkScalar kBlurRadius = SkIntToScalar(20);
34 static const SkScalar kBoxSize = SkIntToScalar(100);
35
36 SkRect clipRect = SkRect::MakeXYWH(0, 0, kBoxSize, kBoxSize);
37 SkRect blurRects[] = {
38 { -kBoxSize - (kBlurRadius+1), 0, -(kBlurRadius+1), kBoxSize },
39 { 0, -kBoxSize - (kBlurRadius+1), kBoxSize, -(kBlurRadius+1) },
40 { kBoxSize+kBlurRadius+1, 0, 2*kBoxSize+kBlurRadius+1, kBoxSize },
41 { 0, kBoxSize+kBlurRadius+1, kBoxSize, 2*kBoxSize+kBlurRadius+1 }
42 };
43 SkColor colors[] = {
44 SK_ColorRED,
45 SK_ColorGREEN,
46 SK_ColorBLUE,
47 SK_ColorYELLOW,
48 };
49 SkASSERT(SK_ARRAY_COUNT(colors) == SK_ARRAY_COUNT(blurRects));
50
51 SkPaint hairlinePaint;
52 hairlinePaint.setStyle(SkPaint::kStroke_Style);
53 hairlinePaint.setColor(SK_ColorWHITE);
54 hairlinePaint.setStrokeWidth(0);
55
56 SkPaint blurPaint;
57 blurPaint.setFilterBitmap(true);
58 SkMaskFilter* mf = SkBlurMaskFilter::Create(kBlurRadius,
59 SkBlurMaskFilter::kNormal_Bl urStyle);
60 blurPaint.setMaskFilter(mf)->unref();
61
62 canvas->clear(SK_ColorBLACK);
63 canvas->save();
64 canvas->translate(kBoxSize, kBoxSize);
65 canvas->drawRect(clipRect, hairlinePaint);
66 canvas->clipRect(clipRect);
67 for (int i = 0; i < SK_ARRAY_COUNT(blurRects); ++i) {
68 blurPaint.setColor(colors[i]);
69 canvas->drawRect(blurRects[i], blurPaint);
70 canvas->drawRect(blurRects[i], hairlinePaint);
71 }
72 canvas->restore();
73 }
74
75 private:
76 static const int kWidth = 300;
77 static const int kHeight = 300;
78
79 typedef GM INHERITED;
80 };
81
82 DEF_GM( return new BlurQuickRejectGM(); )
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