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(const SkISize& size, | 12 SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(const SkISize& size, |
13 uint32_t recordFlags, | 13 uint32_t recordFlags, |
14 SkBBoxHierarchy* h) | 14 SkBBoxHierarchy* h) |
15 : INHERITED(size, recordFlags) { | 15 : INHERITED(size, recordFlags) { |
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 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) { | 22 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) { |
| 23 SkIRect r; |
| 24 bounds.roundOut(&r); |
23 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
bytesWritten()); | 25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
bytesWritten()); |
24 fBoundingHierarchy->insert(draw, bounds, true); | 26 fBoundingHierarchy->insert(draw, r, true); |
25 } | 27 } |
26 | 28 |
27 void SkBBoxHierarchyRecord::willSave() { | 29 void SkBBoxHierarchyRecord::willSave() { |
28 fStateTree->appendSave(); | 30 fStateTree->appendSave(); |
29 this->INHERITED::willSave(); | 31 this->INHERITED::willSave(); |
30 } | 32 } |
31 | 33 |
32 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, | 34 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, |
33 const SkPaint*
paint, | 35 const SkPaint*
paint, |
34 SaveFlags flags
) { | 36 SaveFlags flags
) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 98 |
97 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { | 99 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { |
98 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the | 100 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the |
99 // SkPicture has rewound its command stream. To match that rewind in the | 101 // SkPicture has rewound its command stream. To match that rewind in the |
100 // BBH, we rewind all draws that reference commands that were recorded | 102 // BBH, we rewind all draws that reference commands that were recorded |
101 // past the point to which the SkPicture has rewound, which is given by | 103 // past the point to which the SkPicture has rewound, which is given by |
102 // writeStream().bytesWritten(). | 104 // writeStream().bytesWritten(). |
103 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); | 105 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); |
104 return draw->fOffset >= writeStream().bytesWritten(); | 106 return draw->fOffset >= writeStream().bytesWritten(); |
105 } | 107 } |
OLD | NEW |