OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
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 "GrPictureUtils.h" | 8 #include "GrPictureUtils.h" |
9 #include "SkCanvasPriv.h" | 9 #include "SkCanvasPriv.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle)
SK_OVERRIDE { | 230 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle)
SK_OVERRIDE { |
231 this->updateClipConservativelyUsingBounds(path.getBounds(), op, | 231 this->updateClipConservativelyUsingBounds(path.getBounds(), op, |
232 path.isInverseFillType()); | 232 path.isInverseFillType()); |
233 } | 233 } |
234 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e) SK_OVERRIDE { | 234 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl
e) SK_OVERRIDE { |
235 this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); | 235 this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); |
236 } | 236 } |
237 | 237 |
238 virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, | 238 virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, |
239 const SkPaint* paint) SK_OVERRIDE { | 239 const SkPaint* paint) SK_OVERRIDE { |
240 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->width(), pict
ure->height()); | 240 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, picture->cullRect()); |
241 | 241 |
242 if (NULL != picture->fData.get()) { | 242 if (NULL != picture->fData.get()) { |
243 // Disable the BBH for the old path so all the draw calls | 243 // Disable the BBH for the old path so all the draw calls |
244 // will be seen. The stock SkPicture::draw method can't be | 244 // will be seen. The stock SkPicture::draw method can't be |
245 // invoked since it just uses a vanilla SkPicturePlayback. | 245 // invoked since it just uses a vanilla SkPicturePlayback. |
246 SkPicturePlayback playback(picture); | 246 SkPicturePlayback playback(picture); |
247 playback.setUseBBH(false); | 247 playback.setUseBBH(false); |
248 playback.draw(this, NULL); | 248 playback.draw(this, NULL); |
249 } else { | 249 } else { |
250 // Since we know this is the SkRecord path we can just call | 250 // Since we know this is the SkRecord path we can just call |
251 // SkPicture::draw. | 251 // SkPicture::draw. |
252 picture->draw(this); | 252 picture->draw(this); |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 private: | 256 private: |
257 typedef SkCanvas INHERITED; | 257 typedef SkCanvas INHERITED; |
258 }; | 258 }; |
259 | 259 |
260 // GatherGPUInfo is only intended to be called within the context of SkGpuDevice
's | 260 // GatherGPUInfo is only intended to be called within the context of SkGpuDevice
's |
261 // EXPERIMENTAL_optimize method. | 261 // EXPERIMENTAL_optimize method. |
262 void GatherGPUInfo(const SkPicture* pict, GrAccelData* accelData) { | 262 void GatherGPUInfo(const SkPicture* pict, GrAccelData* accelData) { |
263 if (NULL == pict || 0 == pict->width() || 0 == pict->height()) { | 263 if (NULL == pict || pict->cullRect().isEmpty()) { |
264 return ; | 264 return ; |
265 } | 265 } |
266 | 266 |
267 // BBH-based rendering doesn't re-issue many of the operations the gather | 267 // BBH-based rendering doesn't re-issue many of the operations the gather |
268 // process cares about (e.g., saves and restores) so it must be disabled. | 268 // process cares about (e.g., saves and restores) so it must be disabled. |
269 SkPicturePlayback playback(pict); | 269 SkPicturePlayback playback(pict); |
270 playback.setUseBBH(false); | 270 playback.setUseBBH(false); |
271 | 271 |
272 GrGatherDevice device(pict->width(), pict->height(), &playback, accelData, 0
); | 272 GrGatherDevice device(SkScalarCeilToInt(pict->cullRect().width()), |
| 273 SkScalarCeilToInt(pict->cullRect().height()), |
| 274 &playback, accelData, 0); |
273 GrGatherCanvas canvas(&device); | 275 GrGatherCanvas canvas(&device); |
274 | 276 |
275 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(pict->width()), | 277 canvas.clipRect(pict->cullRect(), SkRegion::kIntersect_Op, false); |
276 SkIntToScalar(pict->height())), | |
277 SkRegion::kIntersect_Op, false); | |
278 playback.draw(&canvas, NULL); | 278 playback.draw(&canvas, NULL); |
279 } | 279 } |
OLD | NEW |