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 SkBaseDevice* device) | 14 SkBaseDevice* 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 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) { | 22 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) { |
23 SkIRect r; | 23 SkIRect r; |
24 bounds.roundOut(&r); | 24 bounds.roundOut(&r); |
25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
size()); | 25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
bytesWritten()); |
26 fBoundingHierarchy->insert(draw, r, true); | 26 fBoundingHierarchy->insert(draw, r, true); |
27 } | 27 } |
28 | 28 |
29 int SkBBoxHierarchyRecord::save(SaveFlags flags) { | 29 int SkBBoxHierarchyRecord::save(SaveFlags flags) { |
30 fStateTree->appendSave(); | 30 fStateTree->appendSave(); |
31 return INHERITED::save(flags); | 31 return INHERITED::save(flags); |
32 } | 32 } |
33 | 33 |
34 int SkBBoxHierarchyRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, | 34 int SkBBoxHierarchyRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, |
35 SaveFlags flags) { | 35 SaveFlags flags) { |
36 fStateTree->appendSaveLayer(this->writeStream().size()); | 36 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); |
37 return INHERITED::saveLayer(bounds, paint, flags); | 37 return INHERITED::saveLayer(bounds, paint, flags); |
38 } | 38 } |
39 | 39 |
40 void SkBBoxHierarchyRecord::restore() { | 40 void SkBBoxHierarchyRecord::restore() { |
41 fStateTree->appendRestore(); | 41 fStateTree->appendRestore(); |
42 INHERITED::restore(); | 42 INHERITED::restore(); |
43 } | 43 } |
44 | 44 |
45 bool SkBBoxHierarchyRecord::translate(SkScalar dx, SkScalar dy) { | 45 bool SkBBoxHierarchyRecord::translate(SkScalar dx, SkScalar dy) { |
46 bool result = INHERITED::translate(dx, dy); | 46 bool result = INHERITED::translate(dx, dy); |
(...skipping 26 matching lines...) Expand all Loading... |
73 } | 73 } |
74 | 74 |
75 void SkBBoxHierarchyRecord::setMatrix(const SkMatrix& matrix) { | 75 void SkBBoxHierarchyRecord::setMatrix(const SkMatrix& matrix) { |
76 INHERITED::setMatrix(matrix); | 76 INHERITED::setMatrix(matrix); |
77 fStateTree->appendTransform(getTotalMatrix()); | 77 fStateTree->appendTransform(getTotalMatrix()); |
78 } | 78 } |
79 | 79 |
80 bool SkBBoxHierarchyRecord::clipRect(const SkRect& rect, | 80 bool SkBBoxHierarchyRecord::clipRect(const SkRect& rect, |
81 SkRegion::Op op, | 81 SkRegion::Op op, |
82 bool doAntiAlias) { | 82 bool doAntiAlias) { |
83 fStateTree->appendClip(this->writeStream().size()); | 83 fStateTree->appendClip(this->writeStream().bytesWritten()); |
84 return INHERITED::clipRect(rect, op, doAntiAlias); | 84 return INHERITED::clipRect(rect, op, doAntiAlias); |
85 } | 85 } |
86 | 86 |
87 bool SkBBoxHierarchyRecord::clipRegion(const SkRegion& region, | 87 bool SkBBoxHierarchyRecord::clipRegion(const SkRegion& region, |
88 SkRegion::Op op) { | 88 SkRegion::Op op) { |
89 fStateTree->appendClip(this->writeStream().size()); | 89 fStateTree->appendClip(this->writeStream().bytesWritten()); |
90 return INHERITED::clipRegion(region, op); | 90 return INHERITED::clipRegion(region, op); |
91 } | 91 } |
92 | 92 |
93 bool SkBBoxHierarchyRecord::clipPath(const SkPath& path, | 93 bool SkBBoxHierarchyRecord::clipPath(const SkPath& path, |
94 SkRegion::Op op, | 94 SkRegion::Op op, |
95 bool doAntiAlias) { | 95 bool doAntiAlias) { |
96 fStateTree->appendClip(this->writeStream().size()); | 96 fStateTree->appendClip(this->writeStream().bytesWritten()); |
97 return INHERITED::clipPath(path, op, doAntiAlias); | 97 return INHERITED::clipPath(path, op, doAntiAlias); |
98 } | 98 } |
99 | 99 |
100 bool SkBBoxHierarchyRecord::clipRRect(const SkRRect& rrect, | 100 bool SkBBoxHierarchyRecord::clipRRect(const SkRRect& rrect, |
101 SkRegion::Op op, | 101 SkRegion::Op op, |
102 bool doAntiAlias) { | 102 bool doAntiAlias) { |
103 fStateTree->appendClip(this->writeStream().size()); | 103 fStateTree->appendClip(this->writeStream().bytesWritten()); |
104 return INHERITED::clipRRect(rrect, op, doAntiAlias); | 104 return INHERITED::clipRRect(rrect, op, doAntiAlias); |
105 } | 105 } |
106 | 106 |
107 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { | 107 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { |
108 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the | 108 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the |
109 // SkPicture has rewound its command stream. To match that rewind in the | 109 // SkPicture has rewound its command stream. To match that rewind in the |
110 // BBH, we rewind all draws that reference commands that were recorded | 110 // 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 | 111 // past the point to which the SkPicture has rewound, which is given by |
112 // writeStream().size(). | 112 // writeStream().bytesWritten(). |
113 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); | 113 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); |
114 return draw->fOffset >= writeStream().size(); | 114 return draw->fOffset >= writeStream().bytesWritten(); |
115 } | 115 } |
OLD | NEW |