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 | 9 |
10 #include "SkArithmeticMode.h" | 10 #include "SkArithmeticMode.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "SkTestImageFilters.h" | 22 #include "SkTestImageFilters.h" |
23 #include "SkXfermodeImageFilter.h" | 23 #include "SkXfermodeImageFilter.h" |
24 | 24 |
25 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm
ageFilter doesn't | 25 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm
ageFilter doesn't |
26 // perform a draw and this one does. | 26 // perform a draw and this one does. |
27 class SimpleOffsetFilter : public SkImageFilter { | 27 class SimpleOffsetFilter : public SkImageFilter { |
28 public: | 28 public: |
29 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) | 29 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) |
30 : SkImageFilter(input), fDX(dx), fDY(dy) {} | 30 : SkImageFilter(input), fDX(dx), fDY(dy) {} |
31 | 31 |
32 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix
& ctm, | 32 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context&
ctx, |
33 SkBitmap* dst, SkIPoint* offset) const SK_OVERRID
E { | 33 SkBitmap* dst, SkIPoint* offset) const SK_OVERRID
E { |
34 SkBitmap source = src; | 34 SkBitmap source = src; |
35 SkImageFilter* input = getInput(0); | 35 SkImageFilter* input = getInput(0); |
36 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 36 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
37 if (NULL != input && !input->filterImage(proxy, src, ctm, &source, &srcO
ffset)) { | 37 if (NULL != input && !input->filterImage(proxy, src, ctx, &source, &srcO
ffset)) { |
38 return false; | 38 return false; |
39 } | 39 } |
40 | 40 |
41 SkIRect bounds; | 41 SkIRect bounds; |
42 source.getBounds(&bounds); | 42 source.getBounds(&bounds); |
43 | 43 |
44 if (!this->applyCropRect(&bounds, ctm)) { | 44 if (!this->applyCropRect(&bounds, ctx.ctm())) { |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo
unds.height())); | 48 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo
unds.height())); |
49 SkCanvas canvas(device); | 49 SkCanvas canvas(device); |
50 SkPaint paint; | 50 SkPaint paint; |
51 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 51 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
52 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain
t); | 52 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain
t); |
53 *dst = device->accessBitmap(false); | 53 *dst = device->accessBitmap(false); |
54 offset->fX += bounds.left(); | 54 offset->fX += bounds.left(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 private: | 208 private: |
209 typedef GM INHERITED; | 209 typedef GM INHERITED; |
210 SkBitmap fBitmap; | 210 SkBitmap fBitmap; |
211 bool fInitialized; | 211 bool fInitialized; |
212 }; | 212 }; |
213 | 213 |
214 /////////////////////////////////////////////////////////////////////////////// | 214 /////////////////////////////////////////////////////////////////////////////// |
215 | 215 |
216 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 216 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
217 static skiagm::GMRegistry reg(MyFactory); | 217 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |