| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, | 76 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
ntext& ctx, |
| 77 SkBitmap* result, SkIPoint* offset) con
st { | 77 SkBitmap* result, SkIPoint* offset) con
st { |
| 78 if (!fPicture) { | 78 if (!fPicture) { |
| 79 offset->fX = offset->fY = 0; | 79 offset->fX = offset->fY = 0; |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 SkRect floatBounds; | 83 SkRect floatBounds; |
| 84 SkIRect bounds; | |
| 85 ctx.ctm().mapRect(&floatBounds, fCropRect); | 84 ctx.ctm().mapRect(&floatBounds, fCropRect); |
| 86 floatBounds.roundOut(&bounds); | 85 SkIRect bounds = floatBounds.roundOut(); |
| 87 if (!bounds.intersect(ctx.clipBounds())) { | 86 if (!bounds.intersect(ctx.clipBounds())) { |
| 88 return false; | 87 return false; |
| 89 } | 88 } |
| 90 | 89 |
| 91 if (bounds.isEmpty()) { | 90 if (bounds.isEmpty()) { |
| 92 offset->fX = offset->fY = 0; | 91 offset->fX = offset->fY = 0; |
| 93 return true; | 92 return true; |
| 94 } | 93 } |
| 95 | 94 |
| 96 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 95 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 97 if (NULL == device.get()) { | 96 if (NULL == device.get()) { |
| 98 return false; | 97 return false; |
| 99 } | 98 } |
| 100 | 99 |
| 101 SkCanvas canvas(device.get()); | 100 SkCanvas canvas(device.get()); |
| 102 SkPaint paint; | 101 SkPaint paint; |
| 103 | 102 |
| 104 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 103 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
| 105 canvas.concat(ctx.ctm()); | 104 canvas.concat(ctx.ctm()); |
| 106 canvas.drawPicture(fPicture); | 105 canvas.drawPicture(fPicture); |
| 107 | 106 |
| 108 *result = device.get()->accessBitmap(false); | 107 *result = device.get()->accessBitmap(false); |
| 109 offset->fX = bounds.fLeft; | 108 offset->fX = bounds.fLeft; |
| 110 offset->fY = bounds.fTop; | 109 offset->fY = bounds.fTop; |
| 111 return true; | 110 return true; |
| 112 } | 111 } |
| OLD | NEW |