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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 offset->fY = bounds.fTop; | 126 offset->fY = bounds.fTop; |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 void SkPictureImageFilter::drawPictureAtDeviceResolution(Proxy* proxy, SkBaseDev
ice* device, | 130 void SkPictureImageFilter::drawPictureAtDeviceResolution(Proxy* proxy, SkBaseDev
ice* device, |
131 const SkIRect& deviceBo
unds, | 131 const SkIRect& deviceBo
unds, |
132 const Context& ctx) con
st { | 132 const Context& ctx) con
st { |
133 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. | 133 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. |
134 // FIXME: switch back to the public constructor (and unfriend) after | 134 // FIXME: switch back to the public constructor (and unfriend) after |
135 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. | 135 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. |
136 SkCanvas canvas(device, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags)
; | 136 SkCanvas canvas(device, &proxy->surfaceProps(), SkCanvas::kDefault_InitFlags
); |
137 | 137 |
138 canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBo
unds.fTop)); | 138 canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBo
unds.fTop)); |
139 canvas.concat(ctx.ctm()); | 139 canvas.concat(ctx.ctm()); |
140 canvas.drawPicture(fPicture); | 140 canvas.drawPicture(fPicture); |
141 } | 141 } |
142 | 142 |
143 void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
ce* device, | 143 void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
ce* device, |
144 const SkIRect& deviceBou
nds, | 144 const SkIRect& deviceBou
nds, |
145 const Context& ctx) cons
t { | 145 const Context& ctx) cons
t { |
146 SkMatrix inverseCtm; | 146 SkMatrix inverseCtm; |
147 if (!ctx.ctm().invert(&inverseCtm)) | 147 if (!ctx.ctm().invert(&inverseCtm)) |
148 return; | 148 return; |
149 SkRect localBounds = SkRect::Make(ctx.clipBounds()); | 149 SkRect localBounds = SkRect::Make(ctx.clipBounds()); |
150 inverseCtm.mapRect(&localBounds); | 150 inverseCtm.mapRect(&localBounds); |
151 if (!localBounds.intersect(fCropRect)) | 151 if (!localBounds.intersect(fCropRect)) |
152 return; | 152 return; |
153 SkIRect localIBounds = localBounds.roundOut(); | 153 SkIRect localIBounds = localBounds.roundOut(); |
154 SkAutoTUnref<SkBaseDevice> localDevice(proxy->createDevice(localIBounds.widt
h(), localIBounds.height())); | 154 SkAutoTUnref<SkBaseDevice> localDevice(proxy->createDevice(localIBounds.widt
h(), localIBounds.height())); |
155 | 155 |
156 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. | 156 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. |
157 // FIXME: switch back to the public constructor (and unfriend) after | 157 // FIXME: switch back to the public constructor (and unfriend) after |
158 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. | 158 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. |
159 SkCanvas localCanvas(localDevice, proxy->surfaceProps(), SkCanvas::kDefault_
InitFlags); | 159 SkCanvas localCanvas(localDevice, &proxy->surfaceProps(), SkCanvas::kDefault
_InitFlags); |
160 localCanvas.translate(-SkIntToScalar(localIBounds.fLeft), -SkIntToScalar(loc
alIBounds.fTop)); | 160 localCanvas.translate(-SkIntToScalar(localIBounds.fLeft), -SkIntToScalar(loc
alIBounds.fTop)); |
161 localCanvas.drawPicture(fPicture); | 161 localCanvas.drawPicture(fPicture); |
162 | 162 |
163 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. | 163 // Pass explicit surface props, as the simplified canvas constructor discard
s device properties. |
164 // FIXME: switch back to the public constructor (and unfriend) after | 164 // FIXME: switch back to the public constructor (and unfriend) after |
165 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. | 165 // https://code.google.com/p/skia/issues/detail?id=3142 is fixed. |
166 SkCanvas canvas(device, proxy->surfaceProps(), SkCanvas::kDefault_InitFlags)
; | 166 SkCanvas canvas(device, &proxy->surfaceProps(), SkCanvas::kDefault_InitFlags
); |
167 | 167 |
168 canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBo
unds.fTop)); | 168 canvas.translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBo
unds.fTop)); |
169 canvas.concat(ctx.ctm()); | 169 canvas.concat(ctx.ctm()); |
170 SkPaint paint; | 170 SkPaint paint; |
171 paint.setFilterQuality(fFilterQuality); | 171 paint.setFilterQuality(fFilterQuality); |
172 canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(loca
lIBounds.fLeft), | 172 canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(loca
lIBounds.fLeft), |
173 SkIntToScalar(localIBounds.fTop), &paint); | 173 SkIntToScalar(localIBounds.fTop), &paint); |
174 //canvas.drawPicture(fPicture); | 174 //canvas.drawPicture(fPicture); |
175 } | 175 } |
176 | 176 |
177 #ifndef SK_IGNORE_TO_STRING | 177 #ifndef SK_IGNORE_TO_STRING |
178 void SkPictureImageFilter::toString(SkString* str) const { | 178 void SkPictureImageFilter::toString(SkString* str) const { |
179 str->appendf("SkPictureImageFilter: ("); | 179 str->appendf("SkPictureImageFilter: ("); |
180 str->appendf("crop: (%f,%f,%f,%f) ", | 180 str->appendf("crop: (%f,%f,%f,%f) ", |
181 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); | 181 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); |
182 if (fPicture) { | 182 if (fPicture) { |
183 str->appendf("picture: (%f,%f,%f,%f)", | 183 str->appendf("picture: (%f,%f,%f,%f)", |
184 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, | 184 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, |
185 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); | 185 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); |
186 } | 186 } |
187 str->append(")"); | 187 str->append(")"); |
188 } | 188 } |
189 #endif | 189 #endif |
OLD | NEW |