| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 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 "SkPictureImageFilter.h" | 8 #include "SkPictureImageFilter.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 void SkPictureImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 40 void SkPictureImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
| 41 this->INHERITED::flatten(buffer); | 41 this->INHERITED::flatten(buffer); |
| 42 // FIXME: flatten picture here. | 42 // FIXME: flatten picture here. |
| 43 buffer.writeRect(fRect); | 43 buffer.writeRect(fRect); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk
Matrix& matrix, | 46 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk
Matrix& matrix, |
| 47 SkBitmap* result, SkIPoint* offset) { | 47 SkBitmap* result, SkIPoint* offset) { |
| 48 if (!fPicture) { | 48 if (!fPicture) { |
| 49 offset->fX = offset->fY = 0; |
| 49 return true; | 50 return true; |
| 50 } | 51 } |
| 51 | 52 |
| 52 SkRect floatBounds; | 53 SkRect floatBounds; |
| 53 SkIRect bounds; | 54 SkIRect bounds; |
| 54 matrix.mapRect(&floatBounds, fRect); | 55 matrix.mapRect(&floatBounds, fRect); |
| 55 floatBounds.roundOut(&bounds); | 56 floatBounds.roundOut(&bounds); |
| 56 | 57 |
| 57 if (bounds.isEmpty()) { | 58 if (bounds.isEmpty()) { |
| 59 offset->fX = offset->fY = 0; |
| 58 return true; | 60 return true; |
| 59 } | 61 } |
| 60 | 62 |
| 61 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 63 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 62 if (NULL == device.get()) { | 64 if (NULL == device.get()) { |
| 63 return false; | 65 return false; |
| 64 } | 66 } |
| 65 | 67 |
| 66 SkCanvas canvas(device.get()); | 68 SkCanvas canvas(device.get()); |
| 67 SkPaint paint; | 69 SkPaint paint; |
| 68 | 70 |
| 69 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 71 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
| 70 canvas.concat(matrix); | 72 canvas.concat(matrix); |
| 71 canvas.drawPicture(*fPicture); | 73 canvas.drawPicture(*fPicture); |
| 72 | 74 |
| 73 *result = device.get()->accessBitmap(false); | 75 *result = device.get()->accessBitmap(false); |
| 74 offset->fX += bounds.fLeft; | 76 offset->fX = bounds.fLeft; |
| 75 offset->fY += bounds.fTop; | 77 offset->fY = bounds.fTop; |
| 76 return true; | 78 return true; |
| 77 } | 79 } |
| OLD | NEW |