OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkMergeImageFilter.h" | 8 #include "SkMergeImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 SkMergeImageFilter::~SkMergeImageFilter() { | 61 SkMergeImageFilter::~SkMergeImageFilter() { |
62 | 62 |
63 if (fModes != SkTCast<uint8_t*>(fStorage)) { | 63 if (fModes != SkTCast<uint8_t*>(fStorage)) { |
64 sk_free(fModes); | 64 sk_free(fModes); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 68 bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
69 const SkMatrix& ctm, | 69 const Context& ctx, |
70 SkBitmap* result, SkIPoint* offset) const
{ | 70 SkBitmap* result, SkIPoint* offset) const
{ |
71 if (countInputs() < 1) { | 71 if (countInputs() < 1) { |
72 return false; | 72 return false; |
73 } | 73 } |
74 | 74 |
75 SkIRect bounds; | 75 SkIRect bounds; |
76 src.getBounds(&bounds); | 76 src.getBounds(&bounds); |
77 if (!this->applyCropRect(&bounds, ctm)) { | 77 if (!this->applyCropRect(&bounds, ctx.ctm())) { |
78 return false; | 78 return false; |
79 } | 79 } |
80 | 80 |
81 const int x0 = bounds.left(); | 81 const int x0 = bounds.left(); |
82 const int y0 = bounds.top(); | 82 const int y0 = bounds.top(); |
83 | 83 |
84 SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.he
ight())); | 84 SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.he
ight())); |
85 if (NULL == dst) { | 85 if (NULL == dst) { |
86 return false; | 86 return false; |
87 } | 87 } |
88 SkCanvas canvas(dst); | 88 SkCanvas canvas(dst); |
89 SkPaint paint; | 89 SkPaint paint; |
90 | 90 |
91 int inputCount = countInputs(); | 91 int inputCount = countInputs(); |
92 for (int i = 0; i < inputCount; ++i) { | 92 for (int i = 0; i < inputCount; ++i) { |
93 SkBitmap tmp; | 93 SkBitmap tmp; |
94 const SkBitmap* srcPtr; | 94 const SkBitmap* srcPtr; |
95 SkIPoint pos = SkIPoint::Make(0, 0); | 95 SkIPoint pos = SkIPoint::Make(0, 0); |
96 SkImageFilter* filter = getInput(i); | 96 SkImageFilter* filter = getInput(i); |
97 if (filter) { | 97 if (filter) { |
98 if (!filter->filterImage(proxy, src, ctm, &tmp, &pos)) { | 98 if (!filter->filterImage(proxy, src, ctx, &tmp, &pos)) { |
99 return false; | 99 return false; |
100 } | 100 } |
101 srcPtr = &tmp; | 101 srcPtr = &tmp; |
102 } else { | 102 } else { |
103 srcPtr = &src; | 103 srcPtr = &src; |
104 } | 104 } |
105 | 105 |
106 if (fModes) { | 106 if (fModes) { |
107 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); | 107 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); |
108 } else { | 108 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
137 if (buffer.validate(buffer.getArrayCount() == size) && | 137 if (buffer.validate(buffer.getArrayCount() == size) && |
138 buffer.readByteArray(fModes, size)) { | 138 buffer.readByteArray(fModes, size)) { |
139 for (int i = 0; i < nbInputs; ++i) { | 139 for (int i = 0; i < nbInputs; ++i) { |
140 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); | 140 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); |
141 } | 141 } |
142 } | 142 } |
143 } else { | 143 } else { |
144 fModes = 0; | 144 fModes = 0; |
145 } | 145 } |
146 } | 146 } |
OLD | NEW |