| 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 "SkResizeImageFilter.h" | 8 #include "SkResizeImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 buffer.writeScalar(fSx); | 35 buffer.writeScalar(fSx); |
| 36 buffer.writeScalar(fSy); | 36 buffer.writeScalar(fSy); |
| 37 buffer.writeInt(fFilterLevel); | 37 buffer.writeInt(fFilterLevel); |
| 38 } | 38 } |
| 39 | 39 |
| 40 SkResizeImageFilter::~SkResizeImageFilter() { | 40 SkResizeImageFilter::~SkResizeImageFilter() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool SkResizeImageFilter::onFilterImage(Proxy* proxy, | 43 bool SkResizeImageFilter::onFilterImage(Proxy* proxy, |
| 44 const SkBitmap& source, | 44 const SkBitmap& source, |
| 45 const SkMatrix& ctm, | 45 const Context& ctx, |
| 46 SkBitmap* result, | 46 SkBitmap* result, |
| 47 SkIPoint* offset) const { | 47 SkIPoint* offset) const { |
| 48 SkBitmap src = source; | 48 SkBitmap src = source; |
| 49 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 49 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 50 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, &srcO
ffset)) { | 50 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcO
ffset)) { |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 SkRect dstRect; | 54 SkRect dstRect; |
| 55 SkIRect srcBounds, dstBounds; | 55 SkIRect srcBounds, dstBounds; |
| 56 src.getBounds(&srcBounds); | 56 src.getBounds(&srcBounds); |
| 57 srcBounds.offset(srcOffset); | 57 srcBounds.offset(srcOffset); |
| 58 SkRect srcRect = SkRect::Make(srcBounds); | 58 SkRect srcRect = SkRect::Make(srcBounds); |
| 59 SkMatrix matrix; | 59 SkMatrix matrix; |
| 60 if (!ctm.invert(&matrix)) { | 60 if (!ctx.ctm().invert(&matrix)) { |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 matrix.postScale(fSx, fSy); | 63 matrix.postScale(fSx, fSy); |
| 64 matrix.postConcat(ctm); | 64 matrix.postConcat(ctx.ctm()); |
| 65 matrix.mapRect(&dstRect, srcRect); | 65 matrix.mapRect(&dstRect, srcRect); |
| 66 dstRect.roundOut(&dstBounds); | 66 dstRect.roundOut(&dstBounds); |
| 67 | 67 |
| 68 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dst
Bounds.height())); | 68 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dst
Bounds.height())); |
| 69 if (NULL == device.get()) { | 69 if (NULL == device.get()) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 SkCanvas canvas(device.get()); | 73 SkCanvas canvas(device.get()); |
| 74 canvas.scale(fSx, fSy); | 74 canvas.scale(fSx, fSy); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 104 matrix.mapRect(&floatBounds, SkRect::Make(src)); | 104 matrix.mapRect(&floatBounds, SkRect::Make(src)); |
| 105 SkIRect bounds; | 105 SkIRect bounds; |
| 106 floatBounds.roundOut(&bounds); | 106 floatBounds.roundOut(&bounds); |
| 107 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { | 107 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 *dst = bounds; | 111 *dst = bounds; |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| OLD | NEW |