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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 SkCanvas canvas(device); | 55 SkCanvas canvas(device); |
56 SkPaint paint; | 56 SkPaint paint; |
57 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 57 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
58 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain
t); | 58 canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &pain
t); |
59 *dst = device->accessBitmap(false); | 59 *dst = device->accessBitmap(false); |
60 offset->fX += bounds.left(); | 60 offset->fX += bounds.left(); |
61 offset->fY += bounds.top(); | 61 offset->fY += bounds.top(); |
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
| 65 SK_TO_STRING_OVERRIDE() |
65 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); | 66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter); |
66 | 67 |
67 protected: | 68 protected: |
68 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { | 69 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { |
69 this->INHERITED::flatten(buffer); | 70 this->INHERITED::flatten(buffer); |
70 buffer.writeScalar(fDX); | 71 buffer.writeScalar(fDX); |
71 buffer.writeScalar(fDY); | 72 buffer.writeScalar(fDY); |
72 } | 73 } |
73 | 74 |
74 private: | 75 private: |
75 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) | 76 SimpleOffsetFilter(SkScalar dx, SkScalar dy, SkImageFilter* input) |
76 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {} | 77 : SkImageFilter(1, &input), fDX(dx), fDY(dy) {} |
77 | 78 |
78 SkScalar fDX, fDY; | 79 SkScalar fDX, fDY; |
79 | 80 |
80 typedef SkImageFilter INHERITED; | 81 typedef SkImageFilter INHERITED; |
81 }; | 82 }; |
82 | 83 |
83 static SimpleOffsetFilter::Registrar gReg; | 84 static SimpleOffsetFilter::Registrar gReg; |
84 | 85 |
85 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) { | 86 SkFlattenable* SimpleOffsetFilter::CreateProc(SkReadBuffer& buffer) { |
86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 87 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
87 SkScalar dx = buffer.readScalar(); | 88 SkScalar dx = buffer.readScalar(); |
88 SkScalar dy = buffer.readScalar(); | 89 SkScalar dy = buffer.readScalar(); |
89 return Create(dx, dy, common.getInput(0)); | 90 return Create(dx, dy, common.getInput(0)); |
90 } | 91 } |
91 | 92 |
| 93 #ifndef SK_IGNORE_TO_STRING |
| 94 void SimpleOffsetFilter::toString(SkString* str) const { |
| 95 str->appendf("SimpleOffsetFilter: ("); |
| 96 str->append(")"); |
| 97 } |
| 98 #endif |
| 99 |
92 class ImageFiltersGraphGM : public skiagm::GM { | 100 class ImageFiltersGraphGM : public skiagm::GM { |
93 public: | 101 public: |
94 ImageFiltersGraphGM() {} | 102 ImageFiltersGraphGM() {} |
95 | 103 |
96 protected: | 104 protected: |
97 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 105 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
98 return kSkipTiled_Flag; | 106 return kSkipTiled_Flag; |
99 } | 107 } |
100 | 108 |
101 virtual SkString onShortName() { | 109 virtual SkString onShortName() { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 227 |
220 private: | 228 private: |
221 typedef GM INHERITED; | 229 typedef GM INHERITED; |
222 SkBitmap fBitmap; | 230 SkBitmap fBitmap; |
223 }; | 231 }; |
224 | 232 |
225 /////////////////////////////////////////////////////////////////////////////// | 233 /////////////////////////////////////////////////////////////////////////////// |
226 | 234 |
227 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 235 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
228 static skiagm::GMRegistry reg(MyFactory); | 236 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |