| 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 "SkRecordDraw.h" | 8 #include "SkRecordDraw.h" |
| 9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); | 101 DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint)); |
| 102 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); | 102 DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint)); |
| 103 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); | 103 DRAW(DrawRRect, drawRRect(r.rrect, r.paint)); |
| 104 DRAW(DrawRect, drawRect(r.rect, r.paint)); | 104 DRAW(DrawRect, drawRect(r.rect, r.paint)); |
| 105 DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); | 105 DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint)); |
| 106 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); | 106 DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint)); |
| 107 DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); | 107 DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint)); |
| 108 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.pa
int)); | 108 DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.pa
int)); |
| 109 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
lors, | 109 DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.co
lors, |
| 110 r.xmode.get(), r.indices, r.indexCount, r.paint)
); | 110 r.xmode.get(), r.indices, r.indexCount, r.paint)
); |
| 111 DRAW(DrawData, drawData(r.data, r.length)); |
| 111 #undef DRAW | 112 #undef DRAW |
| 112 | 113 |
| 113 | 114 |
| 114 // This is an SkRecord visitor that fills an SkBBoxHierarchy. | 115 // This is an SkRecord visitor that fills an SkBBoxHierarchy. |
| 115 // | 116 // |
| 116 // The interesting part here is how to calculate bounds for ops which don't | 117 // The interesting part here is how to calculate bounds for ops which don't |
| 117 // have intrinsic bounds. What is the bounds of a Save or a Translate? | 118 // have intrinsic bounds. What is the bounds of a Save or a Translate? |
| 118 // | 119 // |
| 119 // We answer this by thinking about a particular definition of bounds: if I | 120 // We answer this by thinking about a particular definition of bounds: if I |
| 120 // don't execute this op, pixels in this rectangle might draw incorrectly. So | 121 // don't execute this op, pixels in this rectangle might draw incorrectly. So |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 void trackBounds(const SetMatrix&) { this->pushControl(); } | 206 void trackBounds(const SetMatrix&) { this->pushControl(); } |
| 206 void trackBounds(const ClipRect&) { this->pushControl(); } | 207 void trackBounds(const ClipRect&) { this->pushControl(); } |
| 207 void trackBounds(const ClipRRect&) { this->pushControl(); } | 208 void trackBounds(const ClipRRect&) { this->pushControl(); } |
| 208 void trackBounds(const ClipPath&) { this->pushControl(); } | 209 void trackBounds(const ClipPath&) { this->pushControl(); } |
| 209 void trackBounds(const ClipRegion&) { this->pushControl(); } | 210 void trackBounds(const ClipRegion&) { this->pushControl(); } |
| 210 void trackBounds(const PushCull&) { this->pushControl(); } | 211 void trackBounds(const PushCull&) { this->pushControl(); } |
| 211 void trackBounds(const PopCull&) { this->pushControl(); } | 212 void trackBounds(const PopCull&) { this->pushControl(); } |
| 212 void trackBounds(const BeginCommentGroup&) { this->pushControl(); } | 213 void trackBounds(const BeginCommentGroup&) { this->pushControl(); } |
| 213 void trackBounds(const AddComment&) { this->pushControl(); } | 214 void trackBounds(const AddComment&) { this->pushControl(); } |
| 214 void trackBounds(const EndCommentGroup&) { this->pushControl(); } | 215 void trackBounds(const EndCommentGroup&) { this->pushControl(); } |
| 216 void trackBounds(const DrawData&) { this->pushControl(); } |
| 215 | 217 |
| 216 // For all other ops, we can calculate and store the bounds directly now. | 218 // For all other ops, we can calculate and store the bounds directly now. |
| 217 template <typename T> void trackBounds(const T& op) { | 219 template <typename T> void trackBounds(const T& op) { |
| 218 fBounds[fCurrentOp] = this->bounds(op); | 220 fBounds[fCurrentOp] = this->bounds(op); |
| 219 this->updateSaveBounds(fBounds[fCurrentOp]); | 221 this->updateSaveBounds(fBounds[fCurrentOp]); |
| 220 } | 222 } |
| 221 | 223 |
| 222 void pushSaveBlock(const SkPaint* paint) { | 224 void pushSaveBlock(const SkPaint* paint) { |
| 223 // Starting a new Save block. Push a new entry to represent that. | 225 // Starting a new Save block. Push a new entry to represent that. |
| 224 SaveBounds sb = { 0, Bounds::MakeEmpty(), paint }; | 226 SaveBounds sb = { 0, Bounds::MakeEmpty(), paint }; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 472 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
| 471 SkTDArray<SaveBounds> fSaveStack; | 473 SkTDArray<SaveBounds> fSaveStack; |
| 472 SkTDArray<unsigned> fControlIndices; | 474 SkTDArray<unsigned> fControlIndices; |
| 473 }; | 475 }; |
| 474 | 476 |
| 475 } // namespace SkRecords | 477 } // namespace SkRecords |
| 476 | 478 |
| 477 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 479 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
| 478 SkRecords::FillBounds(record, bbh); | 480 SkRecords::FillBounds(record, bbh); |
| 479 } | 481 } |
| OLD | NEW |