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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 // don't modify dst until now, so we don't accidentally change it in the | 93 // don't modify dst until now, so we don't accidentally change it in the |
94 // loop, but then return false on the next filter. | 94 // loop, but then return false on the next filter. |
95 *dst = totalBounds; | 95 *dst = totalBounds; |
96 return true; | 96 return true; |
97 } | 97 } |
98 | 98 |
99 bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, | 99 bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
100 const SkMatrix& ctm, | 100 const SkMatrix& ctm, |
101 SkBitmap* result, SkIPoint* loc) { | 101 SkBitmap* result, SkIPoint* offset) { |
102 if (countInputs() < 1) { | 102 if (countInputs() < 1) { |
103 return false; | 103 return false; |
104 } | 104 } |
105 | 105 |
106 SkIRect bounds; | 106 SkIRect bounds; |
107 src.getBounds(&bounds); | 107 src.getBounds(&bounds); |
108 if (!this->applyCropRect(&bounds, ctm)) { | 108 if (!this->applyCropRect(&bounds, ctm)) { |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
(...skipping 23 matching lines...) Expand all Loading... |
135 } | 135 } |
136 | 136 |
137 if (fModes) { | 137 if (fModes) { |
138 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); | 138 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); |
139 } else { | 139 } else { |
140 paint.setXfermode(NULL); | 140 paint.setXfermode(NULL); |
141 } | 141 } |
142 canvas.drawSprite(*srcPtr, pos.x() - x0, pos.y() - y0, &paint); | 142 canvas.drawSprite(*srcPtr, pos.x() - x0, pos.y() - y0, &paint); |
143 } | 143 } |
144 | 144 |
145 loc->fX += bounds.left(); | 145 offset->fX = bounds.left(); |
146 loc->fY += bounds.top(); | 146 offset->fY = bounds.top(); |
147 *result = dst->accessBitmap(false); | 147 *result = dst->accessBitmap(false); |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 151 void SkMergeImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
152 this->INHERITED::flatten(buffer); | 152 this->INHERITED::flatten(buffer); |
153 | 153 |
154 buffer.writeBool(fModes != NULL); | 154 buffer.writeBool(fModes != NULL); |
155 if (fModes) { | 155 if (fModes) { |
156 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); | 156 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); |
(...skipping 11 matching lines...) Expand all Loading... |
168 if (buffer.validate(buffer.getArrayCount() == size) && | 168 if (buffer.validate(buffer.getArrayCount() == size) && |
169 buffer.readByteArray(fModes, size)) { | 169 buffer.readByteArray(fModes, size)) { |
170 for (int i = 0; i < nbInputs; ++i) { | 170 for (int i = 0; i < nbInputs; ++i) { |
171 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); | 171 buffer.validate(SkIsValidMode((SkXfermode::Mode)fModes[i])); |
172 } | 172 } |
173 } | 173 } |
174 } else { | 174 } else { |
175 fModes = 0; | 175 fModes = 0; |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |