| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBBoxHierarchyRecord.h" | 9 #include "SkBBoxHierarchyRecord.h" |
| 10 #include "SkPictureStateTree.h" | 10 #include "SkPictureStateTree.h" |
| 11 | 11 |
| 12 SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags, | 12 SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags, |
| 13 SkBBoxHierarchy* h, | 13 SkBBoxHierarchy* h, |
| 14 SkDevice* device) | 14 SkDevice* device) |
| 15 : INHERITED(recordFlags, device) { | 15 : INHERITED(recordFlags, device) { |
| 16 fStateTree = SkNEW(SkPictureStateTree); | 16 fStateTree = SkNEW(SkPictureStateTree); |
| 17 fBoundingHierarchy = h; | 17 fBoundingHierarchy = h; |
| 18 fBoundingHierarchy->ref(); | 18 fBoundingHierarchy->ref(); |
| 19 fBoundingHierarchy->setClient(this); | 19 fBoundingHierarchy->setClient(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 #if SK_RECORD_BOUNDS_IN_PICTURE |
| 23 void SkBBoxHierarchyRecord::handleBBox(uint32_t offset) { |
| 24 if (!fLastDrawBounds.isEmpty()) { |
| 25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(offset); |
| 26 fBoundingHierarchy->insert(draw, fLastDrawBounds, true); |
| 27 } |
| 28 } |
| 29 #else |
| 22 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) { | 30 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) { |
| 23 SkIRect r; | 31 SkIRect r; |
| 24 bounds.roundOut(&r); | 32 bounds.roundOut(&r); |
| 25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
size()); | 33 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
size()); |
| 26 fBoundingHierarchy->insert(draw, r, true); | 34 fBoundingHierarchy->insert(draw, r, true); |
| 27 } | 35 } |
| 36 #endif |
| 28 | 37 |
| 29 int SkBBoxHierarchyRecord::save(SaveFlags flags) { | 38 int SkBBoxHierarchyRecord::save(SaveFlags flags) { |
| 30 fStateTree->appendSave(); | 39 fStateTree->appendSave(); |
| 31 return INHERITED::save(flags); | 40 return INHERITED::save(flags); |
| 32 } | 41 } |
| 33 | 42 |
| 34 int SkBBoxHierarchyRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, | 43 int SkBBoxHierarchyRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 35 SaveFlags flags) { | 44 SaveFlags flags) { |
| 36 fStateTree->appendSaveLayer(this->writeStream().size()); | 45 fStateTree->appendSaveLayer(this->writeStream().size()); |
| 37 return INHERITED::saveLayer(bounds, paint, flags); | 46 return INHERITED::saveLayer(bounds, paint, flags); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 115 |
| 107 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { | 116 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { |
| 108 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the | 117 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the |
| 109 // SkPicture has rewound its command stream. To match that rewind in the | 118 // SkPicture has rewound its command stream. To match that rewind in the |
| 110 // BBH, we rewind all draws that reference commands that were recorded | 119 // BBH, we rewind all draws that reference commands that were recorded |
| 111 // past the point to which the SkPicture has rewound, which is given by | 120 // past the point to which the SkPicture has rewound, which is given by |
| 112 // writeStream().size(). | 121 // writeStream().size(). |
| 113 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); | 122 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); |
| 114 return draw->fOffset >= writeStream().size(); | 123 return draw->fOffset >= writeStream().size(); |
| 115 } | 124 } |
| OLD | NEW |