| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 buffer.writeBool(hasPicture); | 51 buffer.writeBool(hasPicture); |
| 52 if (hasPicture) { | 52 if (hasPicture) { |
| 53 fPicture->flatten(buffer); | 53 fPicture->flatten(buffer); |
| 54 } | 54 } |
| 55 #else | 55 #else |
| 56 buffer.writeBool(false); | 56 buffer.writeBool(false); |
| 57 #endif | 57 #endif |
| 58 buffer.writeRect(fCropRect); | 58 buffer.writeRect(fCropRect); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk
Matrix& matrix, | 61 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, |
| 62 SkBitmap* result, SkIPoint* offset) const { | 62 SkBitmap* result, SkIPoint* offset) con
st { |
| 63 if (!fPicture) { | 63 if (!fPicture) { |
| 64 offset->fX = offset->fY = 0; | 64 offset->fX = offset->fY = 0; |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 SkRect floatBounds; | 68 SkRect floatBounds; |
| 69 SkIRect bounds; | 69 SkIRect bounds; |
| 70 matrix.mapRect(&floatBounds, fCropRect); | 70 ctx.ctm().mapRect(&floatBounds, fCropRect); |
| 71 floatBounds.roundOut(&bounds); | 71 floatBounds.roundOut(&bounds); |
| 72 | 72 |
| 73 if (bounds.isEmpty()) { | 73 if (bounds.isEmpty()) { |
| 74 offset->fX = offset->fY = 0; | 74 offset->fX = offset->fY = 0; |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 78 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 79 if (NULL == device.get()) { | 79 if (NULL == device.get()) { |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 | 82 |
| 83 SkCanvas canvas(device.get()); | 83 SkCanvas canvas(device.get()); |
| 84 SkPaint paint; | 84 SkPaint paint; |
| 85 | 85 |
| 86 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 86 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
| 87 canvas.concat(matrix); | 87 canvas.concat(ctx.ctm()); |
| 88 canvas.drawPicture(*fPicture); | 88 canvas.drawPicture(*fPicture); |
| 89 | 89 |
| 90 *result = device.get()->accessBitmap(false); | 90 *result = device.get()->accessBitmap(false); |
| 91 offset->fX = bounds.fLeft; | 91 offset->fX = bounds.fLeft; |
| 92 offset->fY = bounds.fTop; | 92 offset->fY = bounds.fTop; |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| OLD | NEW |