| 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" |
| 11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
| 12 #include "SkSurfaceProps.h" |
| 12 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
| 13 #include "SkValidationUtils.h" | 14 #include "SkValidationUtils.h" |
| 14 | 15 |
| 15 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, uint32_t un
iqueID) | 16 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, uint32_t un
iqueID) |
| 16 : INHERITED(0, 0, NULL, uniqueID) | 17 : INHERITED(0, 0, NULL, uniqueID) |
| 17 , fPicture(SkSafeRef(picture)) | 18 , fPicture(SkSafeRef(picture)) |
| 18 , fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty()) { | 19 , fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty()) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRec
t& cropRect, | 22 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRec
t& cropRect, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (bounds.isEmpty()) { | 91 if (bounds.isEmpty()) { |
| 91 offset->fX = offset->fY = 0; | 92 offset->fX = offset->fY = 0; |
| 92 return true; | 93 return true; |
| 93 } | 94 } |
| 94 | 95 |
| 95 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 96 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 96 if (NULL == device.get()) { | 97 if (NULL == device.get()) { |
| 97 return false; | 98 return false; |
| 98 } | 99 } |
| 99 | 100 |
| 100 SkCanvas canvas(device.get()); | 101 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. |
| 101 SkPaint paint; | 102 // FIXME: switch back to the public constructor (and unfriend) after |
| 103 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. |
| 104 SkCanvas canvas(device.get(), proxy->surfaceProps(), SkCanvas::kDefault_Init
Flags); |
| 102 | 105 |
| 103 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 106 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
| 104 canvas.concat(ctx.ctm()); | 107 canvas.concat(ctx.ctm()); |
| 105 canvas.drawPicture(fPicture); | 108 canvas.drawPicture(fPicture); |
| 106 | 109 |
| 107 *result = device.get()->accessBitmap(false); | 110 *result = device.get()->accessBitmap(false); |
| 108 offset->fX = bounds.fLeft; | 111 offset->fX = bounds.fLeft; |
| 109 offset->fY = bounds.fTop; | 112 offset->fY = bounds.fTop; |
| 110 return true; | 113 return true; |
| 111 } | 114 } |
| OLD | NEW |