| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) { | 104 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) { |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 | 107 |
| 108 SkIRect bounds; | 108 SkIRect bounds; |
| 109 src.getBounds(&bounds); | 109 src.getBounds(&bounds); |
| 110 if (!this->applyCropRect(&bounds, matrix)) { | 110 if (!this->applyCropRect(&bounds, matrix)) { |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 | 113 |
| 114 SkAutoTUnref<SkDevice> device(proxy->createDevice(bounds.width(), bounds.hei
ght())); | 114 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 115 SkCanvas canvas(device.get()); | 115 SkCanvas canvas(device.get()); |
| 116 SkPaint paint; | 116 SkPaint paint; |
| 117 | 117 |
| 118 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 118 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 119 paint.setColorFilter(fColorFilter); | 119 paint.setColorFilter(fColorFilter); |
| 120 canvas.drawSprite(src, -bounds.fLeft, -bounds.fTop, &paint); | 120 canvas.drawSprite(src, -bounds.fLeft, -bounds.fTop, &paint); |
| 121 | 121 |
| 122 *result = device.get()->accessBitmap(false); | 122 *result = device.get()->accessBitmap(false); |
| 123 loc->fX += bounds.fLeft; | 123 loc->fX += bounds.fLeft; |
| 124 loc->fY += bounds.fTop; | 124 loc->fY += bounds.fTop; |
| 125 return true; | 125 return true; |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { | 128 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { |
| 129 if (cropRect().isLargest()) { | 129 if (cropRect().isLargest()) { |
| 130 if (filter) { | 130 if (filter) { |
| 131 *filter = fColorFilter; | 131 *filter = fColorFilter; |
| 132 fColorFilter->ref(); | 132 fColorFilter->ref(); |
| 133 } | 133 } |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| OLD | NEW |