| 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 "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
| 11 #include "SkPaintPriv.h" | 11 #include "SkPaintPriv.h" |
| 12 #include "SkPicturePlayback.h" |
| 12 | 13 |
| 13 // The GrGather device performs GPU-backend-specific preprocessing on | 14 // The GrGather device performs GPU-backend-specific preprocessing on |
| 14 // a picture. The results are stored in a GPUAccelData. | 15 // a picture. The results are stored in a GPUAccelData. |
| 15 // | 16 // |
| 16 // Currently the only interesting work is done in drawDevice (i.e., when a | 17 // Currently the only interesting work is done in drawDevice (i.e., when a |
| 17 // saveLayer is collapsed back into its parent) and, maybe, in onCreateDevice. | 18 // saveLayer is collapsed back into its parent) and, maybe, in onCreateDevice. |
| 18 // All the current work could be done much more efficiently by just traversing t
he | 19 // All the current work could be done much more efficiently by just traversing t
he |
| 19 // raw op codes in the SkPicture (although we would still need to replay all the | 20 // raw op codes in the SkPicture (although we would still need to replay all the |
| 20 // clip calls). | 21 // clip calls). |
| 21 class GrGatherDevice : public SkBaseDevice { | 22 class GrGatherDevice : public SkBaseDevice { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 return; | 237 return; |
| 237 } | 238 } |
| 238 | 239 |
| 239 this->clipRect(SkRect::MakeWH(SkIntToScalar(fPicture->width()), | 240 this->clipRect(SkRect::MakeWH(SkIntToScalar(fPicture->width()), |
| 240 SkIntToScalar(fPicture->height())), | 241 SkIntToScalar(fPicture->height())), |
| 241 SkRegion::kIntersect_Op, false); | 242 SkRegion::kIntersect_Op, false); |
| 242 this->drawPicture(*fPicture); | 243 this->drawPicture(*fPicture); |
| 243 } | 244 } |
| 244 | 245 |
| 245 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE { | 246 virtual void drawPicture(SkPicture& picture) SK_OVERRIDE { |
| 247 // BBH-based rendering doesn't re-issue many of the operations the gathe
r |
| 248 // process cares about (e.g., saves and restores) so it must be disabled
. |
| 249 if (NULL != picture.fPlayback) { |
| 250 picture.fPlayback->setUseBBH(false); |
| 251 } |
| 246 picture.draw(this); | 252 picture.draw(this); |
| 253 if (NULL != picture.fPlayback) { |
| 254 picture.fPlayback->setUseBBH(true); |
| 255 } |
| 247 } | 256 } |
| 248 protected: | 257 protected: |
| 249 // disable aa for speed | 258 // disable aa for speed |
| 250 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle)
SK_OVERRIDE { | 259 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle)
SK_OVERRIDE { |
| 251 this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle); | 260 this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle); |
| 252 } | 261 } |
| 253 | 262 |
| 254 // for speed, just respect the bounds, and disable AA. May give us a few | 263 // for speed, just respect the bounds, and disable AA. May give us a few |
| 255 // false positives and negatives. | 264 // false positives and negatives. |
| 256 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle)
SK_OVERRIDE { | 265 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle)
SK_OVERRIDE { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 272 void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData) { | 281 void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData) { |
| 273 if (0 == pict->width() || 0 == pict->height()) { | 282 if (0 == pict->width() || 0 == pict->height()) { |
| 274 return ; | 283 return ; |
| 275 } | 284 } |
| 276 | 285 |
| 277 GrGatherDevice device(pict->width(), pict->height(), pict, accelData, 0); | 286 GrGatherDevice device(pict->width(), pict->height(), pict, accelData, 0); |
| 278 GrGatherCanvas canvas(&device, pict); | 287 GrGatherCanvas canvas(&device, pict); |
| 279 | 288 |
| 280 canvas.gather(); | 289 canvas.gather(); |
| 281 } | 290 } |
| OLD | NEW |