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 "SkXfermodeImageFilter.h" | 22 #include "SkXfermodeImageFilter.h" |
23 | 23 |
24 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm
ageFilter doesn't | 24 // More closely models how Blink's OffsetFilter works as of 10/23/13. SkOffsetIm
ageFilter doesn't |
25 // perform a draw and this one does. | 25 // perform a draw and this one does. |
26 class SimpleOffsetFilter : public SkImageFilter { | 26 class SimpleOffsetFilter : public SkImageFilter { |
27 public: | 27 public: |
28 class Registrar { | 28 class Registrar { |
29 public: | 29 public: |
30 Registrar() { | 30 Registrar() { |
31 SkFlattenable::Register("SimpleOffsetFilter", | 31 SkFlattenable::Register("SimpleOffsetFilter", |
32 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
33 SimpleOffsetFilter::DeepCreateProc, | |
34 #else | |
35 SimpleOffsetFilter::CreateProc, | 32 SimpleOffsetFilter::CreateProc, |
36 #endif | |
37 SimpleOffsetFilter::GetFlattenableType()); | 33 SimpleOffsetFilter::GetFlattenableType()); |
38 } | 34 } |
39 }; | 35 }; |
40 static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input)
{ | 36 static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input)
{ |
41 return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input)); | 37 return SkNEW_ARGS(SimpleOffsetFilter, (dx, dy, input)); |
42 } | 38 } |
43 | 39 |
44 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context&
ctx, | 40 virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context&
ctx, |
45 SkBitmap* dst, SkIPoint* offset) const SK_OVERRID
E { | 41 SkBitmap* dst, SkIPoint* offset) const SK_OVERRID
E { |
46 SkBitmap source = src; | 42 SkBitmap source = src; |
(...skipping 15 matching lines...) Expand all Loading... |
62 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain
t); | 58 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain
t); |
63 *dst = device->accessBitmap(false); | 59 *dst = device->accessBitmap(false); |
64 offset->fX += bounds.left(); | 60 offset->fX += bounds.left(); |
65 offset->fY += bounds.top(); | 61 offset->fY += bounds.top(); |
66 return true; | 62 return true; |
67 } | 63 } |
68 | 64 |
69 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); | 65 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); |
70 | 66 |
71 protected: | 67 protected: |
72 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
73 explicit SimpleOffsetFilter(SkReadBuffer& buffer) | |
74 : SkImageFilter(1, buffer) { | |
75 fDX = buffer.readScalar(); | |
76 fDY = buffer.readScalar(); | |
77 } | |
78 #endif | |
79 | |
80 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { | 68 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { |
81 this->INHERITED::flatten(buffer); | 69 this->INHERITED::flatten(buffer); |
82 buffer.writeScalar(fDX); | 70 buffer.writeScalar(fDX); |
83 buffer.writeScalar(fDY); | 71 buffer.writeScalar(fDY); |
84 } | 72 } |
85 | 73 |
86 private: | 74 private: |
87 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) | 75 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) |
88 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {} | 76 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {} |
89 | 77 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 219 |
232 private: | 220 private: |
233 typedef GM INHERITED; | 221 typedef GM INHERITED; |
234 SkBitmap fBitmap; | 222 SkBitmap fBitmap; |
235 }; | 223 }; |
236 | 224 |
237 /////////////////////////////////////////////////////////////////////////////// | 225 /////////////////////////////////////////////////////////////////////////////// |
238 | 226 |
239 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 227 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
240 static skiagm::GMRegistry reg(MyFactory); | 228 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |