| 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkPictureData.h" | 9 #include "SkPictureData.h" |
| 10 #include "SkPicturePlayback.h" | 10 #include "SkPicturePlayback.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 text->fText = (const char*)reader->skip(length); | 59 text->fText = (const char*)reader->skip(length); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip
le threads. | 62 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip
le threads. |
| 63 static SkBitmap shallow_copy(const SkBitmap& bitmap) { | 63 static SkBitmap shallow_copy(const SkBitmap& bitmap) { |
| 64 return bitmap; | 64 return bitmap; |
| 65 } | 65 } |
| 66 | 66 |
| 67 const SkPicture::OperationList* SkPicturePlayback::getActiveOps(const SkCanvas*
canvas) { | 67 const SkPicture::OperationList* SkPicturePlayback::getActiveOps(const SkCanvas*
canvas) { |
| 68 | 68 |
| 69 if (fUseBBH && NULL != fPictureData->fStateTree && NULL != fPictureData->fBo
undingHierarchy) { | 69 if (fUseBBH) { |
| 70 SkRect clipBounds; | 70 SkRect clipBounds; |
| 71 if (canvas->getClipBounds(&clipBounds)) { | 71 if (canvas->getClipBounds(&clipBounds)) { |
| 72 SkIRect query; | 72 SkIRect query; |
| 73 clipBounds.roundOut(&query); | 73 clipBounds.roundOut(&query); |
| 74 | 74 |
| 75 return fPictureData->getActiveOps(query); | 75 return fPictureData->getActiveOps(query); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 return NULL; | 79 return NULL; |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Initialize the state tree iterator. Return false if there is nothing left to
draw. | 82 // Initialize the state tree iterator. Return false if there is nothing left to
draw. |
| 83 bool SkPicturePlayback::initIterator(SkPictureStateTree::Iterator* iter, | 83 bool SkPicturePlayback::initIterator(SkPictureStateTree::Iterator* iter, |
| 84 SkCanvas* canvas, | 84 SkCanvas* canvas, |
| 85 const SkPicture::OperationList *activeOpsLi
st) { | 85 const SkPicture::OperationList *activeOpsLi
st) { |
| 86 | 86 |
| 87 if (NULL != activeOpsList) { | 87 if (NULL != activeOpsList) { |
| 88 if (0 == activeOpsList->numOps()) { | 88 if (0 == activeOpsList->numOps()) { |
| 89 return false; // nothing to draw | 89 return false; // nothing to draw |
| 90 } | 90 } |
| 91 | 91 |
| 92 fPictureData->fStateTree->initIterator(iter, activeOpsList->fOps, canvas
); | 92 fPictureData->initIterator(iter, activeOpsList->fOps, canvas); |
| 93 } | 93 } |
| 94 | 94 |
| 95 return true; | 95 return true; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // If 'iter' is valid use it to skip forward through the picture. | 98 // If 'iter' is valid use it to skip forward through the picture. |
| 99 void SkPicturePlayback::StepIterator(SkPictureStateTree::Iterator* iter, SkReade
r32* reader) { | 99 void SkPicturePlayback::StepIterator(SkPictureStateTree::Iterator* iter, SkReade
r32* reader) { |
| 100 if (iter->isValid()) { | 100 if (iter->isValid()) { |
| 101 uint32_t skipTo = iter->nextDraw(); | 101 uint32_t skipTo = iter->nextDraw(); |
| 102 if (SkPictureStateTree::Iterator::kDrawComplete == skipTo) { | 102 if (SkPictureStateTree::Iterator::kDrawComplete == skipTo) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 case TRANSLATE: { | 477 case TRANSLATE: { |
| 478 SkScalar dx = reader->readScalar(); | 478 SkScalar dx = reader->readScalar(); |
| 479 SkScalar dy = reader->readScalar(); | 479 SkScalar dy = reader->readScalar(); |
| 480 canvas->translate(dx, dy); | 480 canvas->translate(dx, dy); |
| 481 } break; | 481 } break; |
| 482 default: | 482 default: |
| 483 SkASSERT(0); | 483 SkASSERT(0); |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 | 486 |
| OLD | NEW |