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 "SkColorFilterImageFilter.h" | 8 #include "SkColorFilterImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 SkColorFilterImageFilter::~SkColorFilterImageFilter() { | 93 SkColorFilterImageFilter::~SkColorFilterImageFilter() { |
94 SkSafeUnref(fColorFilter); | 94 SkSafeUnref(fColorFilter); |
95 } | 95 } |
96 | 96 |
97 bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
e, | 97 bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
e, |
98 const SkMatrix& matrix, | 98 const SkMatrix& matrix, |
99 SkBitmap* result, | 99 SkBitmap* result, |
100 SkIPoint* loc) { | 100 SkIPoint* loc) { |
101 SkBitmap src = this->getInputResult(0, proxy, source, matrix, loc); | 101 SkBitmap src = source; |
| 102 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) { |
| 103 return false; |
| 104 } |
| 105 |
102 SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height())
); | 106 SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height())
); |
103 SkCanvas canvas(device.get()); | 107 SkCanvas canvas(device.get()); |
104 SkPaint paint; | 108 SkPaint paint; |
105 | 109 |
106 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 110 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
107 paint.setColorFilter(fColorFilter); | 111 paint.setColorFilter(fColorFilter); |
108 canvas.drawSprite(src, 0, 0, &paint); | 112 canvas.drawSprite(src, 0, 0, &paint); |
109 | 113 |
110 *result = device.get()->accessBitmap(false); | 114 *result = device.get()->accessBitmap(false); |
111 return true; | 115 return true; |
112 } | 116 } |
113 | 117 |
114 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { | 118 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { |
115 if (filter) { | 119 if (filter) { |
116 *filter = fColorFilter; | 120 *filter = fColorFilter; |
117 fColorFilter->ref(); | 121 fColorFilter->ref(); |
118 } | 122 } |
119 return true; | 123 return true; |
120 } | 124 } |
OLD | NEW |