OLD | NEW |
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 "gm.h" | 8 #include "gm.h" |
9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { | 51 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
52 SkPaint paint; | 52 SkPaint paint; |
53 | 53 |
54 SkIRect bounds; | 54 SkIRect bounds; |
55 r.roundOut(&bounds); | 55 r.roundOut(&bounds); |
56 | 56 |
57 SkBitmap bm; | 57 SkBitmap bm; |
58 bm.allocN32Pixels(bounds.width(), bounds.height()); | 58 bm.allocN32Pixels(bounds.width(), bounds.height()); |
59 bm.eraseColor(SK_ColorTRANSPARENT); | 59 bm.eraseColor(SK_ColorTRANSPARENT); |
60 SkCanvas c(bm); | 60 SkCanvas c(bm); |
61 draw_path(&c, r, NULL); | 61 draw_path(&c, r, nullptr); |
62 | 62 |
63 paint.setImageFilter(imf); | 63 paint.setImageFilter(imf); |
64 canvas->save(); | 64 canvas->save(); |
65 canvas->clipRect(r); | 65 canvas->clipRect(r); |
66 canvas->drawBitmap(bm, 0, 0, &paint); | 66 canvas->drawBitmap(bm, 0, 0, &paint); |
67 canvas->restore(); | 67 canvas->restore(); |
68 } | 68 } |
69 | 69 |
70 static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { | 70 static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
71 SkPaint paint; | 71 SkPaint paint; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 SkAutoTUnref<SkColorFilter> cf( | 119 SkAutoTUnref<SkColorFilter> cf( |
120 SkColorFilter::CreateModeFilter(SK_ColorMAGENTA, SkXfermode::kSrcIn_
Mode)); | 120 SkColorFilter::CreateModeFilter(SK_ColorMAGENTA, SkXfermode::kSrcIn_
Mode)); |
121 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get
())); | 121 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get
())); |
122 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10,
44, 44)), | 122 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10,
44, 44)), |
123 SkImageFilter::CropRect::kHasAll_CropEd
ge); | 123 SkImageFilter::CropRect::kHasAll_CropEd
ge); |
124 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -
100, 10, 10)), | 124 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -
100, 10, 10)), |
125 SkImageFilter::CropRect::kHasAll_CropE
dge); | 125 SkImageFilter::CropRect::kHasAll_CropE
dge); |
126 | 126 |
127 SkImageFilter* filters[] = { | 127 SkImageFilter* filters[] = { |
128 NULL, | 128 nullptr, |
129 SkDropShadowImageFilter::Create(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE
, | 129 SkDropShadowImageFilter::Create(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE
, |
130 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), | 130 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
131 SkDropShadowImageFilter::Create(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE
, | 131 SkDropShadowImageFilter::Create(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE
, |
132 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), | 132 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
133 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, | 133 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, |
134 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), | 134 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode), |
135 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, | 135 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, |
136 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, cf
if, NULL), | 136 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, cf
if, nullptr), |
137 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, | 137 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, |
138 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, NU
LL, &cropRect), | 138 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nu
llptr, &cropRect), |
139 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, | 139 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, |
140 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, NU
LL, &bogusRect), | 140 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nu
llptr, &bogusRect), |
141 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, | 141 SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE
, |
142 SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode), | 142 SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode), |
143 }; | 143 }; |
144 | 144 |
145 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); | 145 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
146 SkScalar MARGIN = SkIntToScalar(16); | 146 SkScalar MARGIN = SkIntToScalar(16); |
147 SkScalar DX = r.width() + MARGIN; | 147 SkScalar DX = r.width() + MARGIN; |
148 SkScalar DY = r.height() + MARGIN; | 148 SkScalar DY = r.height() + MARGIN; |
149 | 149 |
150 canvas->translate(MARGIN, MARGIN); | 150 canvas->translate(MARGIN, MARGIN); |
(...skipping 13 matching lines...) Expand all Loading... |
164 } | 164 } |
165 | 165 |
166 private: | 166 private: |
167 typedef GM INHERITED; | 167 typedef GM INHERITED; |
168 }; | 168 }; |
169 | 169 |
170 /////////////////////////////////////////////////////////////////////////////// | 170 /////////////////////////////////////////////////////////////////////////////// |
171 | 171 |
172 static skiagm::GM* MyFactory(void*) { return new DropShadowImageFilterGM; } | 172 static skiagm::GM* MyFactory(void*) { return new DropShadowImageFilterGM; } |
173 static skiagm::GMRegistry reg(MyFactory); | 173 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |