| 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; | 23 SkIRect r; |
| 24 bounds.roundOut(&r); | 24 bounds.roundOut(&r); |
| 25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().
bytesWritten()); | 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 void SkBBoxHierarchyRecord::willSave(SaveFlags flags) { |
| 30 fStateTree->appendSave(); | 30 fStateTree->appendSave(); |
| 31 return INHERITED::save(flags); | 31 this->INHERITED::willSave(flags); |
| 32 } | 32 } |
| 33 | 33 |
| 34 int SkBBoxHierarchyRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, | 34 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* b
ounds, |
| 35 SaveFlags flags) { | 35 const SkPaint*
paint, |
| 36 SaveFlags flags
) { |
| 36 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); | 37 fStateTree->appendSaveLayer(this->writeStream().bytesWritten()); |
| 37 return INHERITED::saveLayer(bounds, paint, flags); | 38 return this->INHERITED::willSaveLayer(bounds, paint, flags); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void SkBBoxHierarchyRecord::restore() { | 41 void SkBBoxHierarchyRecord::willRestore() { |
| 41 fStateTree->appendRestore(); | 42 fStateTree->appendRestore(); |
| 42 INHERITED::restore(); | 43 this->INHERITED::willRestore(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 bool SkBBoxHierarchyRecord::translate(SkScalar dx, SkScalar dy) { | 46 bool SkBBoxHierarchyRecord::translate(SkScalar dx, SkScalar dy) { |
| 46 bool result = INHERITED::translate(dx, dy); | 47 bool result = INHERITED::translate(dx, dy); |
| 47 fStateTree->appendTransform(getTotalMatrix()); | 48 fStateTree->appendTransform(getTotalMatrix()); |
| 48 return result; | 49 return result; |
| 49 } | 50 } |
| 50 | 51 |
| 51 bool SkBBoxHierarchyRecord::scale(SkScalar sx, SkScalar sy) { | 52 bool SkBBoxHierarchyRecord::scale(SkScalar sx, SkScalar sy) { |
| 52 bool result = INHERITED::scale(sx, sy); | 53 bool result = INHERITED::scale(sx, sy); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 107 |
| 107 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { | 108 bool SkBBoxHierarchyRecord::shouldRewind(void* data) { |
| 108 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the | 109 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the |
| 109 // SkPicture has rewound its command stream. To match that rewind in the | 110 // SkPicture has rewound its command stream. To match that rewind in the |
| 110 // BBH, we rewind all draws that reference commands that were recorded | 111 // 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 | 112 // past the point to which the SkPicture has rewound, which is given by |
| 112 // writeStream().bytesWritten(). | 113 // writeStream().bytesWritten(). |
| 113 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); | 114 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data
); |
| 114 return draw->fOffset >= writeStream().bytesWritten(); | 115 return draw->fOffset >= writeStream().bytesWritten(); |
| 115 } | 116 } |
| OLD | NEW |