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