| 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 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 SkRect floatBounds; | 112 SkRect floatBounds; |
| 113 ctx.ctm().mapRect(&floatBounds, fCropRect); | 113 ctx.ctm().mapRect(&floatBounds, fCropRect); |
| 114 SkIRect bounds = floatBounds.roundOut(); | 114 SkIRect bounds = floatBounds.roundOut(); |
| 115 if (!bounds.intersect(ctx.clipBounds())) { | 115 if (!bounds.intersect(ctx.clipBounds())) { |
| 116 return nullptr; | 116 return nullptr; |
| 117 } | 117 } |
| 118 | 118 |
| 119 SkASSERT(!bounds.isEmpty()); | 119 SkASSERT(!bounds.isEmpty()); |
| 120 | 120 |
| 121 SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), kPr
emul_SkAlphaType); | 121 sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bou
nds.size())); |
| 122 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); | |
| 123 if (!surf) { | 122 if (!surf) { |
| 124 return nullptr; | 123 return nullptr; |
| 125 } | 124 } |
| 126 | 125 |
| 127 SkCanvas* canvas = surf->getCanvas(); | 126 SkCanvas* canvas = surf->getCanvas(); |
| 128 SkASSERT(canvas); | 127 SkASSERT(canvas); |
| 129 | 128 |
| 130 canvas->clear(0x0); | 129 canvas->clear(0x0); |
| 131 | 130 |
| 132 if (kDeviceSpace_PictureResolution == fPictureResolution || | 131 if (kDeviceSpace_PictureResolution == fPictureResolution || |
| (...skipping 27 matching lines...) Expand all Loading... |
| 160 | 159 |
| 161 SkRect localBounds = SkRect::Make(ctx.clipBounds()); | 160 SkRect localBounds = SkRect::Make(ctx.clipBounds()); |
| 162 inverseCtm.mapRect(&localBounds); | 161 inverseCtm.mapRect(&localBounds); |
| 163 if (!localBounds.intersect(fCropRect)) { | 162 if (!localBounds.intersect(fCropRect)) { |
| 164 return; | 163 return; |
| 165 } | 164 } |
| 166 SkIRect localIBounds = localBounds.roundOut(); | 165 SkIRect localIBounds = localBounds.roundOut(); |
| 167 | 166 |
| 168 sk_sp<SkSpecialImage> localImg; | 167 sk_sp<SkSpecialImage> localImg; |
| 169 { | 168 { |
| 170 const SkImageInfo info = SkImageInfo::MakeN32(localIBounds.width(), loca
lIBounds.height(), | 169 sk_sp<SkSpecialSurface> localSurface(source->makeSurface(ctx.outputPrope
rties(), |
| 171 kPremul_SkAlphaType); | 170 localIBounds.si
ze())); |
| 172 | |
| 173 sk_sp<SkSpecialSurface> localSurface(source->makeSurface(info)); | |
| 174 if (!localSurface) { | 171 if (!localSurface) { |
| 175 return; | 172 return; |
| 176 } | 173 } |
| 177 | 174 |
| 178 SkCanvas* localCanvas = localSurface->getCanvas(); | 175 SkCanvas* localCanvas = localSurface->getCanvas(); |
| 179 SkASSERT(localCanvas); | 176 SkASSERT(localCanvas); |
| 180 | 177 |
| 181 localCanvas->clear(0x0); | 178 localCanvas->clear(0x0); |
| 182 | 179 |
| 183 localCanvas->translate(-SkIntToScalar(localIBounds.fLeft), | 180 localCanvas->translate(-SkIntToScalar(localIBounds.fLeft), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 207 str->appendf("crop: (%f,%f,%f,%f) ", | 204 str->appendf("crop: (%f,%f,%f,%f) ", |
| 208 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); | 205 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); |
| 209 if (fPicture) { | 206 if (fPicture) { |
| 210 str->appendf("picture: (%f,%f,%f,%f)", | 207 str->appendf("picture: (%f,%f,%f,%f)", |
| 211 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, | 208 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, |
| 212 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); | 209 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); |
| 213 } | 210 } |
| 214 str->append(")"); | 211 str->append(")"); |
| 215 } | 212 } |
| 216 #endif | 213 #endif |
| OLD | NEW |