| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
| 9 #include "SkTSearch.h" | 9 #include "SkTSearch.h" |
| 10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 SkBaseDevice* SkPictureRecord::setDevice(SkBaseDevice* device) { | 141 SkBaseDevice* SkPictureRecord::setDevice(SkBaseDevice* device) { |
| 142 SkDEBUGFAIL("eeek, don't try to change the device on a recording canvas"); | 142 SkDEBUGFAIL("eeek, don't try to change the device on a recording canvas"); |
| 143 return this->INHERITED::setDevice(device); | 143 return this->INHERITED::setDevice(device); |
| 144 } | 144 } |
| 145 | 145 |
| 146 int SkPictureRecord::save(SaveFlags flags) { | 146 int SkPictureRecord::save(SaveFlags flags) { |
| 147 // record the offset to us, making it non-positive to distinguish a save | 147 // record the offset to us, making it non-positive to distinguish a save |
| 148 // from a clip entry. | 148 // from a clip entry. |
| 149 fRestoreOffsetStack.push(-(int32_t)fWriter.size()); | 149 fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); |
| 150 | 150 |
| 151 // op + flags | 151 // op + flags |
| 152 uint32_t size = kSaveSize; | 152 uint32_t size = kSaveSize; |
| 153 size_t initialOffset = this->addDraw(SAVE, &size); | 153 size_t initialOffset = this->addDraw(SAVE, &size); |
| 154 addInt(flags); | 154 addInt(flags); |
| 155 | 155 |
| 156 this->validate(initialOffset, size); | 156 this->validate(initialOffset, size); |
| 157 return this->INHERITED::save(flags); | 157 return this->INHERITED::save(flags); |
| 158 } | 158 } |
| 159 | 159 |
| 160 int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, | 160 int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, |
| 161 SaveFlags flags) { | 161 SaveFlags flags) { |
| 162 // record the offset to us, making it non-positive to distinguish a save | 162 // record the offset to us, making it non-positive to distinguish a save |
| 163 // from a clip entry. | 163 // from a clip entry. |
| 164 fRestoreOffsetStack.push(-(int32_t)fWriter.size()); | 164 fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); |
| 165 | 165 |
| 166 // op + bool for 'bounds' | 166 // op + bool for 'bounds' |
| 167 uint32_t size = 2 * kUInt32Size; | 167 uint32_t size = 2 * kUInt32Size; |
| 168 if (NULL != bounds) { | 168 if (NULL != bounds) { |
| 169 size += sizeof(*bounds); // + rect | 169 size += sizeof(*bounds); // + rect |
| 170 } | 170 } |
| 171 // + paint index + flags | 171 // + paint index + flags |
| 172 size += 2 * kUInt32Size; | 172 size += 2 * kUInt32Size; |
| 173 | 173 |
| 174 SkASSERT(kSaveLayerNoBoundsSize == size || kSaveLayerWithBoundsSize == size)
; | 174 SkASSERT(kSaveLayerNoBoundsSize == size || kSaveLayerWithBoundsSize == size)
; |
| 175 | 175 |
| 176 size_t initialOffset = this->addDraw(SAVE_LAYER, &size); | 176 size_t initialOffset = this->addDraw(SAVE_LAYER, &size); |
| 177 addRectPtr(bounds); | 177 addRectPtr(bounds); |
| 178 SkASSERT(initialOffset+getPaintOffset(SAVE_LAYER, size) == fWriter.size()); | 178 SkASSERT(initialOffset+getPaintOffset(SAVE_LAYER, size) == fWriter.bytesWrit
ten()); |
| 179 addPaintPtr(paint); | 179 addPaintPtr(paint); |
| 180 addInt(flags); | 180 addInt(flags); |
| 181 | 181 |
| 182 if (kNoSavedLayerIndex == fFirstSavedLayerIndex) { | 182 if (kNoSavedLayerIndex == fFirstSavedLayerIndex) { |
| 183 fFirstSavedLayerIndex = fRestoreOffsetStack.count(); | 183 fFirstSavedLayerIndex = fRestoreOffsetStack.count(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 this->validate(initialOffset, size); | 186 this->validate(initialOffset, size); |
| 187 /* Don't actually call saveLayer, because that will try to allocate an | 187 /* Don't actually call saveLayer, because that will try to allocate an |
| 188 offscreen device (potentially very big) which we don't actually need | 188 offscreen device (potentially very big) which we don't actually need |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 /* | 242 /* |
| 243 * Attempt to match the provided pattern of commands starting at 'offset' | 243 * Attempt to match the provided pattern of commands starting at 'offset' |
| 244 * in the byte stream and stopping at the end of the stream. Upon success, | 244 * in the byte stream and stopping at the end of the stream. Upon success, |
| 245 * return true with all the pattern information filled out in the result | 245 * return true with all the pattern information filled out in the result |
| 246 * array (i.e., actual ops, offsets and sizes). | 246 * array (i.e., actual ops, offsets and sizes). |
| 247 * Note this method skips any NOOPs seen in the stream | 247 * Note this method skips any NOOPs seen in the stream |
| 248 */ | 248 */ |
| 249 static bool match(SkWriter32* writer, uint32_t offset, | 249 static bool match(SkWriter32* writer, uint32_t offset, |
| 250 int* pattern, CommandInfo* result, int numCommands) { | 250 int* pattern, CommandInfo* result, int numCommands) { |
| 251 SkASSERT(offset < writer->size()); | 251 SkASSERT(offset < writer->bytesWritten()); |
| 252 | 252 |
| 253 uint32_t curOffset = offset; | 253 uint32_t curOffset = offset; |
| 254 uint32_t curSize = 0; | 254 uint32_t curSize = 0; |
| 255 int numMatched; | 255 int numMatched; |
| 256 for (numMatched = 0; numMatched < numCommands && curOffset < writer->size();
++numMatched) { | 256 for (numMatched = 0; numMatched < numCommands && curOffset < writer->bytesWr
itten(); ++numMatched) { |
| 257 DrawType op = peek_op_and_size(writer, curOffset, &curSize); | 257 DrawType op = peek_op_and_size(writer, curOffset, &curSize); |
| 258 while (NOOP == op && curOffset < writer->size()) { | 258 while (NOOP == op && curOffset < writer->bytesWritten()) { |
| 259 curOffset += curSize; | 259 curOffset += curSize; |
| 260 op = peek_op_and_size(writer, curOffset, &curSize); | 260 op = peek_op_and_size(writer, curOffset, &curSize); |
| 261 } | 261 } |
| 262 | 262 |
| 263 if (curOffset >= writer->size()) { | 263 if (curOffset >= writer->bytesWritten()) { |
| 264 return false; // ran out of byte stream | 264 return false; // ran out of byte stream |
| 265 } | 265 } |
| 266 | 266 |
| 267 if (kDRAW_BITMAP_FLAVOR == pattern[numMatched]) { | 267 if (kDRAW_BITMAP_FLAVOR == pattern[numMatched]) { |
| 268 if (DRAW_BITMAP != op && DRAW_BITMAP_MATRIX != op && | 268 if (DRAW_BITMAP != op && DRAW_BITMAP_MATRIX != op && |
| 269 DRAW_BITMAP_NINE != op && DRAW_BITMAP_RECT_TO_RECT != op) { | 269 DRAW_BITMAP_NINE != op && DRAW_BITMAP_RECT_TO_RECT != op) { |
| 270 return false; | 270 return false; |
| 271 } | 271 } |
| 272 } else if (op != pattern[numMatched]) { | 272 } else if (op != pattern[numMatched]) { |
| 273 return false; | 273 return false; |
| 274 } | 274 } |
| 275 | 275 |
| 276 result[numMatched].fActualOp = op; | 276 result[numMatched].fActualOp = op; |
| 277 result[numMatched].fOffset = curOffset; | 277 result[numMatched].fOffset = curOffset; |
| 278 result[numMatched].fSize = curSize; | 278 result[numMatched].fSize = curSize; |
| 279 | 279 |
| 280 curOffset += curSize; | 280 curOffset += curSize; |
| 281 } | 281 } |
| 282 | 282 |
| 283 if (numMatched != numCommands) { | 283 if (numMatched != numCommands) { |
| 284 return false; | 284 return false; |
| 285 } | 285 } |
| 286 | 286 |
| 287 curOffset += curSize; | 287 curOffset += curSize; |
| 288 if (curOffset < writer->size()) { | 288 if (curOffset < writer->bytesWritten()) { |
| 289 // Something else between the last command and the end of the stream | 289 // Something else between the last command and the end of the stream |
| 290 return false; | 290 return false; |
| 291 } | 291 } |
| 292 | 292 |
| 293 return true; | 293 return true; |
| 294 } | 294 } |
| 295 | 295 |
| 296 // temporarily here to make code review easier | 296 // temporarily here to make code review easier |
| 297 static bool merge_savelayer_paint_into_drawbitmp(SkWriter32* writer, | 297 static bool merge_savelayer_paint_into_drawbitmp(SkWriter32* writer, |
| 298 SkPaintDictionary* paintDict, | 298 SkPaintDictionary* paintDict, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 * | 457 * |
| 458 * If so, update the writer and return true, in which case we won't even record | 458 * If so, update the writer and return true, in which case we won't even record |
| 459 * the restore() call. If we still need the restore(), return false. | 459 * the restore() call. If we still need the restore(), return false. |
| 460 */ | 460 */ |
| 461 static bool collapse_save_clip_restore(SkWriter32* writer, int32_t offset, | 461 static bool collapse_save_clip_restore(SkWriter32* writer, int32_t offset, |
| 462 SkPaintDictionary* paintDict) { | 462 SkPaintDictionary* paintDict) { |
| 463 #ifdef TRACK_COLLAPSE_STATS | 463 #ifdef TRACK_COLLAPSE_STATS |
| 464 gCollapseCalls += 1; | 464 gCollapseCalls += 1; |
| 465 #endif | 465 #endif |
| 466 | 466 |
| 467 int32_t restoreOffset = (int32_t)writer->size(); | 467 int32_t restoreOffset = (int32_t)writer->bytesWritten(); |
| 468 | 468 |
| 469 // back up to the save block | 469 // back up to the save block |
| 470 while (offset > 0) { | 470 while (offset > 0) { |
| 471 offset = *writer->peek32(offset); | 471 offset = *writer->peek32(offset); |
| 472 } | 472 } |
| 473 | 473 |
| 474 // now offset points to a save | 474 // now offset points to a save |
| 475 offset = -offset; | 475 offset = -offset; |
| 476 uint32_t opSize; | 476 uint32_t opSize; |
| 477 DrawType op = peek_op_and_size(writer, offset, &opSize); | 477 DrawType op = peek_op_and_size(writer, offset, &opSize); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 fFirstSavedLayerIndex = kNoSavedLayerIndex; | 578 fFirstSavedLayerIndex = kNoSavedLayerIndex; |
| 579 } | 579 } |
| 580 | 580 |
| 581 uint32_t initialOffset, size; | 581 uint32_t initialOffset, size; |
| 582 size_t opt = 0; | 582 size_t opt = 0; |
| 583 if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag))
{ | 583 if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag))
{ |
| 584 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) { | 584 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) { |
| 585 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t
op(), &fPaints)) { | 585 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t
op(), &fPaints)) { |
| 586 // Some optimization fired so don't add the RESTORE | 586 // Some optimization fired so don't add the RESTORE |
| 587 size = 0; | 587 size = 0; |
| 588 initialOffset = fWriter.size(); | 588 initialOffset = fWriter.bytesWritten(); |
| 589 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType, | 589 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType, |
| 590 fStateTree, fBoundingHierarchy); | 590 fStateTree, fBoundingHierarchy); |
| 591 break; | 591 break; |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 if ((fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag) || | 596 if ((fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag) || |
| 597 SK_ARRAY_COUNT(gPictureRecordOpts) == opt) { | 597 SK_ARRAY_COUNT(gPictureRecordOpts) == opt) { |
| 598 // No optimization fired so add the RESTORE | 598 // No optimization fired so add the RESTORE |
| 599 fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.size
()); | 599 fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.byte
sWritten()); |
| 600 size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code | 600 size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code |
| 601 initialOffset = this->addDraw(RESTORE, &size); | 601 initialOffset = this->addDraw(RESTORE, &size); |
| 602 } | 602 } |
| 603 | 603 |
| 604 fRestoreOffsetStack.pop(); | 604 fRestoreOffsetStack.pop(); |
| 605 | 605 |
| 606 this->validate(initialOffset, size); | 606 this->validate(initialOffset, size); |
| 607 return this->INHERITED::restore(); | 607 return this->INHERITED::restore(); |
| 608 } | 608 } |
| 609 | 609 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 640 // op + sx + sy | 640 // op + sx + sy |
| 641 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); | 641 uint32_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); |
| 642 size_t initialOffset = this->addDraw(SKEW, &size); | 642 size_t initialOffset = this->addDraw(SKEW, &size); |
| 643 addScalar(sx); | 643 addScalar(sx); |
| 644 addScalar(sy); | 644 addScalar(sy); |
| 645 this->validate(initialOffset, size); | 645 this->validate(initialOffset, size); |
| 646 return this->INHERITED::skew(sx, sy); | 646 return this->INHERITED::skew(sx, sy); |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool SkPictureRecord::concat(const SkMatrix& matrix) { | 649 bool SkPictureRecord::concat(const SkMatrix& matrix) { |
| 650 this->validate(fWriter.size(), 0); | 650 this->validate(fWriter.bytesWritten(), 0); |
| 651 // op + matrix index | 651 // op + matrix index |
| 652 uint32_t size = 2 * kUInt32Size; | 652 uint32_t size = 2 * kUInt32Size; |
| 653 size_t initialOffset = this->addDraw(CONCAT, &size); | 653 size_t initialOffset = this->addDraw(CONCAT, &size); |
| 654 addMatrix(matrix); | 654 addMatrix(matrix); |
| 655 this->validate(initialOffset, size); | 655 this->validate(initialOffset, size); |
| 656 return this->INHERITED::concat(matrix); | 656 return this->INHERITED::concat(matrix); |
| 657 } | 657 } |
| 658 | 658 |
| 659 void SkPictureRecord::setMatrix(const SkMatrix& matrix) { | 659 void SkPictureRecord::setMatrix(const SkMatrix& matrix) { |
| 660 this->validate(fWriter.size(), 0); | 660 this->validate(fWriter.bytesWritten(), 0); |
| 661 // op + matrix index | 661 // op + matrix index |
| 662 uint32_t size = 2 * kUInt32Size; | 662 uint32_t size = 2 * kUInt32Size; |
| 663 size_t initialOffset = this->addDraw(SET_MATRIX, &size); | 663 size_t initialOffset = this->addDraw(SET_MATRIX, &size); |
| 664 addMatrix(matrix); | 664 addMatrix(matrix); |
| 665 this->validate(initialOffset, size); | 665 this->validate(initialOffset, size); |
| 666 this->INHERITED::setMatrix(matrix); | 666 this->INHERITED::setMatrix(matrix); |
| 667 } | 667 } |
| 668 | 668 |
| 669 static bool regionOpExpands(SkRegion::Op op) { | 669 static bool regionOpExpands(SkRegion::Op op) { |
| 670 switch (op) { | 670 switch (op) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 // be 0, disabling their ability to trigger a jump-to-restore, otherwise | 727 // be 0, disabling their ability to trigger a jump-to-restore, otherwise |
| 728 // they could hide this clips ability to expand the clip (i.e. go from | 728 // they could hide this clips ability to expand the clip (i.e. go from |
| 729 // empty to non-empty). | 729 // empty to non-empty). |
| 730 fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); | 730 fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); |
| 731 | 731 |
| 732 // Reset the pointer back to the previous clip so that subsequent | 732 // Reset the pointer back to the previous clip so that subsequent |
| 733 // restores don't overwrite the offsets we just cleared. | 733 // restores don't overwrite the offsets we just cleared. |
| 734 prevOffset = 0; | 734 prevOffset = 0; |
| 735 } | 735 } |
| 736 | 736 |
| 737 size_t offset = fWriter.size(); | 737 size_t offset = fWriter.bytesWritten(); |
| 738 addInt(prevOffset); | 738 addInt(prevOffset); |
| 739 fRestoreOffsetStack.top() = offset; | 739 fRestoreOffsetStack.top() = offset; |
| 740 } | 740 } |
| 741 | 741 |
| 742 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 742 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
| 743 // id + rect + clip params | 743 // id + rect + clip params |
| 744 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; | 744 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; |
| 745 // recordRestoreOffsetPlaceholder doesn't always write an offset | 745 // recordRestoreOffsetPlaceholder doesn't always write an offset |
| 746 if (!fRestoreOffsetStack.isEmpty()) { | 746 if (!fRestoreOffsetStack.isEmpty()) { |
| 747 // + restore offset | 747 // + restore offset |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 uint32_t size = 2 * kUInt32Size; | 833 uint32_t size = 2 * kUInt32Size; |
| 834 size_t initialOffset = this->addDraw(DRAW_CLEAR, &size); | 834 size_t initialOffset = this->addDraw(DRAW_CLEAR, &size); |
| 835 addInt(color); | 835 addInt(color); |
| 836 this->validate(initialOffset, size); | 836 this->validate(initialOffset, size); |
| 837 } | 837 } |
| 838 | 838 |
| 839 void SkPictureRecord::drawPaint(const SkPaint& paint) { | 839 void SkPictureRecord::drawPaint(const SkPaint& paint) { |
| 840 // op + paint index | 840 // op + paint index |
| 841 uint32_t size = 2 * kUInt32Size; | 841 uint32_t size = 2 * kUInt32Size; |
| 842 size_t initialOffset = this->addDraw(DRAW_PAINT, &size); | 842 size_t initialOffset = this->addDraw(DRAW_PAINT, &size); |
| 843 SkASSERT(initialOffset+getPaintOffset(DRAW_PAINT, size) == fWriter.size()); | 843 SkASSERT(initialOffset+getPaintOffset(DRAW_PAINT, size) == fWriter.bytesWrit
ten()); |
| 844 addPaint(paint); | 844 addPaint(paint); |
| 845 this->validate(initialOffset, size); | 845 this->validate(initialOffset, size); |
| 846 } | 846 } |
| 847 | 847 |
| 848 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
[], | 848 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
[], |
| 849 const SkPaint& paint) { | 849 const SkPaint& paint) { |
| 850 // op + paint index + mode + count + point data | 850 // op + paint index + mode + count + point data |
| 851 uint32_t size = 4 * kUInt32Size + count * sizeof(SkPoint); | 851 uint32_t size = 4 * kUInt32Size + count * sizeof(SkPoint); |
| 852 size_t initialOffset = this->addDraw(DRAW_POINTS, &size); | 852 size_t initialOffset = this->addDraw(DRAW_POINTS, &size); |
| 853 SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.size()); | 853 SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWri
tten()); |
| 854 addPaint(paint); | 854 addPaint(paint); |
| 855 addInt(mode); | 855 addInt(mode); |
| 856 addInt(count); | 856 addInt(count); |
| 857 fWriter.writeMul4(pts, count * sizeof(SkPoint)); | 857 fWriter.writeMul4(pts, count * sizeof(SkPoint)); |
| 858 this->validate(initialOffset, size); | 858 this->validate(initialOffset, size); |
| 859 } | 859 } |
| 860 | 860 |
| 861 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) { | 861 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) { |
| 862 // op + paint index + rect | 862 // op + paint index + rect |
| 863 uint32_t size = 2 * kUInt32Size + sizeof(oval); | 863 uint32_t size = 2 * kUInt32Size + sizeof(oval); |
| 864 size_t initialOffset = this->addDraw(DRAW_OVAL, &size); | 864 size_t initialOffset = this->addDraw(DRAW_OVAL, &size); |
| 865 SkASSERT(initialOffset+getPaintOffset(DRAW_OVAL, size) == fWriter.size()); | 865 SkASSERT(initialOffset+getPaintOffset(DRAW_OVAL, size) == fWriter.bytesWritt
en()); |
| 866 addPaint(paint); | 866 addPaint(paint); |
| 867 addRect(oval); | 867 addRect(oval); |
| 868 this->validate(initialOffset, size); | 868 this->validate(initialOffset, size); |
| 869 } | 869 } |
| 870 | 870 |
| 871 void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) { | 871 void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) { |
| 872 // op + paint index + rect | 872 // op + paint index + rect |
| 873 uint32_t size = 2 * kUInt32Size + sizeof(rect); | 873 uint32_t size = 2 * kUInt32Size + sizeof(rect); |
| 874 size_t initialOffset = this->addDraw(DRAW_RECT, &size); | 874 size_t initialOffset = this->addDraw(DRAW_RECT, &size); |
| 875 SkASSERT(initialOffset+getPaintOffset(DRAW_RECT, size) == fWriter.size()); | 875 SkASSERT(initialOffset+getPaintOffset(DRAW_RECT, size) == fWriter.bytesWritt
en()); |
| 876 addPaint(paint); | 876 addPaint(paint); |
| 877 addRect(rect); | 877 addRect(rect); |
| 878 this->validate(initialOffset, size); | 878 this->validate(initialOffset, size); |
| 879 } | 879 } |
| 880 | 880 |
| 881 void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) { | 881 void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 882 if (rrect.isRect()) { | 882 if (rrect.isRect()) { |
| 883 this->SkPictureRecord::drawRect(rrect.getBounds(), paint); | 883 this->SkPictureRecord::drawRect(rrect.getBounds(), paint); |
| 884 } else if (rrect.isOval()) { | 884 } else if (rrect.isOval()) { |
| 885 this->SkPictureRecord::drawOval(rrect.getBounds(), paint); | 885 this->SkPictureRecord::drawOval(rrect.getBounds(), paint); |
| 886 } else { | 886 } else { |
| 887 // op + paint index + rrect | 887 // op + paint index + rrect |
| 888 uint32_t initialOffset, size; | 888 uint32_t initialOffset, size; |
| 889 size = 2 * kUInt32Size + SkRRect::kSizeInMemory; | 889 size = 2 * kUInt32Size + SkRRect::kSizeInMemory; |
| 890 initialOffset = this->addDraw(DRAW_RRECT, &size); | 890 initialOffset = this->addDraw(DRAW_RRECT, &size); |
| 891 SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.size(
)); | 891 SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.bytes
Written()); |
| 892 addPaint(paint); | 892 addPaint(paint); |
| 893 addRRect(rrect); | 893 addRRect(rrect); |
| 894 this->validate(initialOffset, size); | 894 this->validate(initialOffset, size); |
| 895 } | 895 } |
| 896 } | 896 } |
| 897 | 897 |
| 898 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { | 898 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { |
| 899 // op + paint index + path index | 899 // op + paint index + path index |
| 900 uint32_t size = 3 * kUInt32Size; | 900 uint32_t size = 3 * kUInt32Size; |
| 901 size_t initialOffset = this->addDraw(DRAW_PATH, &size); | 901 size_t initialOffset = this->addDraw(DRAW_PATH, &size); |
| 902 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.size()); | 902 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt
en()); |
| 903 addPaint(paint); | 903 addPaint(paint); |
| 904 addPath(path); | 904 addPath(path); |
| 905 this->validate(initialOffset, size); | 905 this->validate(initialOffset, size); |
| 906 } | 906 } |
| 907 | 907 |
| 908 void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
top, | 908 void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
top, |
| 909 const SkPaint* paint = NULL) { | 909 const SkPaint* paint = NULL) { |
| 910 // op + paint index + bitmap index + left + top | 910 // op + paint index + bitmap index + left + top |
| 911 uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); | 911 uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); |
| 912 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); | 912 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); |
| 913 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.size()); | 913 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri
tten()); |
| 914 addPaintPtr(paint); | 914 addPaintPtr(paint); |
| 915 addBitmap(bitmap); | 915 addBitmap(bitmap); |
| 916 addScalar(left); | 916 addScalar(left); |
| 917 addScalar(top); | 917 addScalar(top); |
| 918 this->validate(initialOffset, size); | 918 this->validate(initialOffset, size); |
| 919 } | 919 } |
| 920 | 920 |
| 921 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
src, | 921 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
src, |
| 922 const SkRect& dst, const SkPaint* pai
nt, | 922 const SkRect& dst, const SkPaint* pai
nt, |
| 923 DrawBitmapRectFlags flags) { | 923 DrawBitmapRectFlags flags) { |
| 924 // id + paint index + bitmap index + bool for 'src' + flags | 924 // id + paint index + bitmap index + bool for 'src' + flags |
| 925 uint32_t size = 5 * kUInt32Size; | 925 uint32_t size = 5 * kUInt32Size; |
| 926 if (NULL != src) { | 926 if (NULL != src) { |
| 927 size += sizeof(*src); // + rect | 927 size += sizeof(*src); // + rect |
| 928 } | 928 } |
| 929 size += sizeof(dst); // + rect | 929 size += sizeof(dst); // + rect |
| 930 | 930 |
| 931 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); | 931 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); |
| 932 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) == fWr
iter.size()); | 932 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) == fWr
iter.bytesWritten()); |
| 933 addPaintPtr(paint); | 933 addPaintPtr(paint); |
| 934 addBitmap(bitmap); | 934 addBitmap(bitmap); |
| 935 addRectPtr(src); // may be null | 935 addRectPtr(src); // may be null |
| 936 addRect(dst); | 936 addRect(dst); |
| 937 addInt(flags); | 937 addInt(flags); |
| 938 this->validate(initialOffset, size); | 938 this->validate(initialOffset, size); |
| 939 } | 939 } |
| 940 | 940 |
| 941 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
atrix, | 941 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
atrix, |
| 942 const SkPaint* paint) { | 942 const SkPaint* paint) { |
| 943 // id + paint index + bitmap index + matrix index | 943 // id + paint index + bitmap index + matrix index |
| 944 uint32_t size = 4 * kUInt32Size; | 944 uint32_t size = 4 * kUInt32Size; |
| 945 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); | 945 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); |
| 946 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.s
ize()); | 946 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b
ytesWritten()); |
| 947 addPaintPtr(paint); | 947 addPaintPtr(paint); |
| 948 addBitmap(bitmap); | 948 addBitmap(bitmap); |
| 949 addMatrix(matrix); | 949 addMatrix(matrix); |
| 950 this->validate(initialOffset, size); | 950 this->validate(initialOffset, size); |
| 951 } | 951 } |
| 952 | 952 |
| 953 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
er, | 953 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
er, |
| 954 const SkRect& dst, const SkPaint* paint) { | 954 const SkRect& dst, const SkPaint* paint) { |
| 955 // op + paint index + bitmap id + center + dst rect | 955 // op + paint index + bitmap id + center + dst rect |
| 956 uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); | 956 uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); |
| 957 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); | 957 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); |
| 958 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.siz
e()); | 958 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt
esWritten()); |
| 959 addPaintPtr(paint); | 959 addPaintPtr(paint); |
| 960 addBitmap(bitmap); | 960 addBitmap(bitmap); |
| 961 addIRect(center); | 961 addIRect(center); |
| 962 addRect(dst); | 962 addRect(dst); |
| 963 this->validate(initialOffset, size); | 963 this->validate(initialOffset, size); |
| 964 } | 964 } |
| 965 | 965 |
| 966 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, | 966 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, |
| 967 const SkPaint* paint = NULL) { | 967 const SkPaint* paint = NULL) { |
| 968 // op + paint index + bitmap index + left + top | 968 // op + paint index + bitmap index + left + top |
| 969 uint32_t size = 5 * kUInt32Size; | 969 uint32_t size = 5 * kUInt32Size; |
| 970 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); | 970 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); |
| 971 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.size()); | 971 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri
tten()); |
| 972 addPaintPtr(paint); | 972 addPaintPtr(paint); |
| 973 addBitmap(bitmap); | 973 addBitmap(bitmap); |
| 974 addInt(left); | 974 addInt(left); |
| 975 addInt(top); | 975 addInt(top); |
| 976 this->validate(initialOffset, size); | 976 this->validate(initialOffset, size); |
| 977 } | 977 } |
| 978 | 978 |
| 979 void SkPictureRecord::ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar
topbot[2]) { | 979 void SkPictureRecord::ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar
topbot[2]) { |
| 980 SkPaint::FontMetrics metrics; | 980 SkPaint::FontMetrics metrics; |
| 981 paint.getFontMetrics(&metrics); | 981 paint.getFontMetrics(&metrics); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1000 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds(); | 1000 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds(); |
| 1001 | 1001 |
| 1002 // op + paint index + length + 'length' worth of chars + x + y | 1002 // op + paint index + length + 'length' worth of chars + x + y |
| 1003 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar
); | 1003 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar
); |
| 1004 if (fast) { | 1004 if (fast) { |
| 1005 size += 2 * sizeof(SkScalar); // + top & bottom | 1005 size += 2 * sizeof(SkScalar); // + top & bottom |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; | 1008 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; |
| 1009 size_t initialOffset = this->addDraw(op, &size); | 1009 size_t initialOffset = this->addDraw(op, &size); |
| 1010 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.size()); | 1010 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); |
| 1011 const SkFlatData* flatPaintData = addPaint(paint); | 1011 const SkFlatData* flatPaintData = addPaint(paint); |
| 1012 SkASSERT(flatPaintData); | 1012 SkASSERT(flatPaintData); |
| 1013 addText(text, byteLength); | 1013 addText(text, byteLength); |
| 1014 addScalar(x); | 1014 addScalar(x); |
| 1015 addScalar(y); | 1015 addScalar(y); |
| 1016 if (fast) { | 1016 if (fast) { |
| 1017 addFontMetricsTopBottom(paint, *flatPaintData, y, y); | 1017 addFontMetricsTopBottom(paint, *flatPaintData, y, y); |
| 1018 } | 1018 } |
| 1019 this->validate(initialOffset, size); | 1019 this->validate(initialOffset, size); |
| 1020 } | 1020 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 if (fast) { | 1066 if (fast) { |
| 1067 op = DRAW_POS_TEXT_H_TOP_BOTTOM; | 1067 op = DRAW_POS_TEXT_H_TOP_BOTTOM; |
| 1068 } else if (canUseDrawH) { | 1068 } else if (canUseDrawH) { |
| 1069 op = DRAW_POS_TEXT_H; | 1069 op = DRAW_POS_TEXT_H; |
| 1070 } else if (fastBounds) { | 1070 } else if (fastBounds) { |
| 1071 op = DRAW_POS_TEXT_TOP_BOTTOM; | 1071 op = DRAW_POS_TEXT_TOP_BOTTOM; |
| 1072 } else { | 1072 } else { |
| 1073 op = DRAW_POS_TEXT; | 1073 op = DRAW_POS_TEXT; |
| 1074 } | 1074 } |
| 1075 size_t initialOffset = this->addDraw(op, &size); | 1075 size_t initialOffset = this->addDraw(op, &size); |
| 1076 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.size()); | 1076 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); |
| 1077 const SkFlatData* flatPaintData = addPaint(paint); | 1077 const SkFlatData* flatPaintData = addPaint(paint); |
| 1078 SkASSERT(flatPaintData); | 1078 SkASSERT(flatPaintData); |
| 1079 addText(text, byteLength); | 1079 addText(text, byteLength); |
| 1080 addInt(points); | 1080 addInt(points); |
| 1081 | 1081 |
| 1082 #ifdef SK_DEBUG_SIZE | 1082 #ifdef SK_DEBUG_SIZE |
| 1083 size_t start = fWriter.size(); | 1083 size_t start = fWriter.bytesWritten(); |
| 1084 #endif | 1084 #endif |
| 1085 if (canUseDrawH) { | 1085 if (canUseDrawH) { |
| 1086 if (fast) { | 1086 if (fast) { |
| 1087 addFontMetricsTopBottom(paint, *flatPaintData, pos[0].fY, pos[0].fY)
; | 1087 addFontMetricsTopBottom(paint, *flatPaintData, pos[0].fY, pos[0].fY)
; |
| 1088 } | 1088 } |
| 1089 addScalar(pos[0].fY); | 1089 addScalar(pos[0].fY); |
| 1090 SkScalar* xptr = (SkScalar*)fWriter.reserve(points * sizeof(SkScalar)); | 1090 SkScalar* xptr = (SkScalar*)fWriter.reserve(points * sizeof(SkScalar)); |
| 1091 for (size_t index = 0; index < points; index++) | 1091 for (size_t index = 0; index < points; index++) |
| 1092 *xptr++ = pos[index].fX; | 1092 *xptr++ = pos[index].fX; |
| 1093 } else { | 1093 } else { |
| 1094 fWriter.writeMul4(pos, points * sizeof(SkPoint)); | 1094 fWriter.writeMul4(pos, points * sizeof(SkPoint)); |
| 1095 if (fastBounds) { | 1095 if (fastBounds) { |
| 1096 addFontMetricsTopBottom(paint, *flatPaintData, minY, maxY); | 1096 addFontMetricsTopBottom(paint, *flatPaintData, minY, maxY); |
| 1097 } | 1097 } |
| 1098 } | 1098 } |
| 1099 #ifdef SK_DEBUG_SIZE | 1099 #ifdef SK_DEBUG_SIZE |
| 1100 fPointBytes += fWriter.size() - start; | 1100 fPointBytes += fWriter.bytesWritten() - start; |
| 1101 fPointWrites += points; | 1101 fPointWrites += points; |
| 1102 #endif | 1102 #endif |
| 1103 this->validate(initialOffset, size); | 1103 this->validate(initialOffset, size); |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, | 1106 void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, |
| 1107 const SkScalar xpos[], SkScalar constY, | 1107 const SkScalar xpos[], SkScalar constY, |
| 1108 const SkPaint& paint) { | 1108 const SkPaint& paint) { |
| 1109 | 1109 |
| 1110 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); | 1110 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1129 size += 1 * kUInt32Size + points * sizeof(SkScalar); | 1129 size += 1 * kUInt32Size + points * sizeof(SkScalar); |
| 1130 size_t initialOffset = this->addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : DRA
W_POS_TEXT_H, | 1130 size_t initialOffset = this->addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : DRA
W_POS_TEXT_H, |
| 1131 &size); | 1131 &size); |
| 1132 SkASSERT(flatPaintData); | 1132 SkASSERT(flatPaintData); |
| 1133 addFlatPaint(flatPaintData); | 1133 addFlatPaint(flatPaintData); |
| 1134 | 1134 |
| 1135 addText(text, byteLength); | 1135 addText(text, byteLength); |
| 1136 addInt(points); | 1136 addInt(points); |
| 1137 | 1137 |
| 1138 #ifdef SK_DEBUG_SIZE | 1138 #ifdef SK_DEBUG_SIZE |
| 1139 size_t start = fWriter.size(); | 1139 size_t start = fWriter.bytesWritten(); |
| 1140 #endif | 1140 #endif |
| 1141 if (fast) { | 1141 if (fast) { |
| 1142 addFontMetricsTopBottom(paint, *flatPaintData, constY, constY); | 1142 addFontMetricsTopBottom(paint, *flatPaintData, constY, constY); |
| 1143 } | 1143 } |
| 1144 addScalar(constY); | 1144 addScalar(constY); |
| 1145 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); | 1145 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); |
| 1146 #ifdef SK_DEBUG_SIZE | 1146 #ifdef SK_DEBUG_SIZE |
| 1147 fPointBytes += fWriter.size() - start; | 1147 fPointBytes += fWriter.bytesWritten() - start; |
| 1148 fPointWrites += points; | 1148 fPointWrites += points; |
| 1149 #endif | 1149 #endif |
| 1150 this->validate(initialOffset, size); | 1150 this->validate(initialOffset, size); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength, | 1153 void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength, |
| 1154 const SkPath& path, const SkMatrix* matrix, | 1154 const SkPath& path, const SkMatrix* matrix, |
| 1155 const SkPaint& paint) { | 1155 const SkPaint& paint) { |
| 1156 // op + paint index + length + 'length' worth of data + path index + matrix
index | 1156 // op + paint index + length + 'length' worth of data + path index + matrix
index |
| 1157 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * kUInt32Size; | 1157 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * kUInt32Size; |
| 1158 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); | 1158 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); |
| 1159 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.si
ze()); | 1159 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by
tesWritten()); |
| 1160 addPaint(paint); | 1160 addPaint(paint); |
| 1161 addText(text, byteLength); | 1161 addText(text, byteLength); |
| 1162 addPath(path); | 1162 addPath(path); |
| 1163 addMatrixPtr(matrix); | 1163 addMatrixPtr(matrix); |
| 1164 this->validate(initialOffset, size); | 1164 this->validate(initialOffset, size); |
| 1165 } | 1165 } |
| 1166 | 1166 |
| 1167 void SkPictureRecord::drawPicture(SkPicture& picture) { | 1167 void SkPictureRecord::drawPicture(SkPicture& picture) { |
| 1168 // op + picture index | 1168 // op + picture index |
| 1169 uint32_t size = 2 * kUInt32Size; | 1169 uint32_t size = 2 * kUInt32Size; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1195 } | 1195 } |
| 1196 if (flags & DRAW_VERTICES_HAS_COLORS) { | 1196 if (flags & DRAW_VERTICES_HAS_COLORS) { |
| 1197 size += vertexCount * sizeof(SkColor); // + vert colors | 1197 size += vertexCount * sizeof(SkColor); // + vert colors |
| 1198 } | 1198 } |
| 1199 if (flags & DRAW_VERTICES_HAS_INDICES) { | 1199 if (flags & DRAW_VERTICES_HAS_INDICES) { |
| 1200 // + num indices + indices | 1200 // + num indices + indices |
| 1201 size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t)); | 1201 size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t)); |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); | 1204 size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); |
| 1205 SkASSERT(initialOffset+getPaintOffset(DRAW_VERTICES, size) == fWriter.size()
); | 1205 SkASSERT(initialOffset+getPaintOffset(DRAW_VERTICES, size) == fWriter.bytesW
ritten()); |
| 1206 addPaint(paint); | 1206 addPaint(paint); |
| 1207 addInt(flags); | 1207 addInt(flags); |
| 1208 addInt(vmode); | 1208 addInt(vmode); |
| 1209 addInt(vertexCount); | 1209 addInt(vertexCount); |
| 1210 addPoints(vertices, vertexCount); | 1210 addPoints(vertices, vertexCount); |
| 1211 if (flags & DRAW_VERTICES_HAS_TEXS) { | 1211 if (flags & DRAW_VERTICES_HAS_TEXS) { |
| 1212 addPoints(texs, vertexCount); | 1212 addPoints(texs, vertexCount); |
| 1213 } | 1213 } |
| 1214 if (flags & DRAW_VERTICES_HAS_COLORS) { | 1214 if (flags & DRAW_VERTICES_HAS_COLORS) { |
| 1215 fWriter.writeMul4(colors, vertexCount * sizeof(SkColor)); | 1215 fWriter.writeMul4(colors, vertexCount * sizeof(SkColor)); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 index = fPictureRefs.count(); | 1304 index = fPictureRefs.count(); |
| 1305 *fPictureRefs.append() = &picture; | 1305 *fPictureRefs.append() = &picture; |
| 1306 picture.ref(); | 1306 picture.ref(); |
| 1307 } | 1307 } |
| 1308 // follow the convention of recording a 1-based index | 1308 // follow the convention of recording a 1-based index |
| 1309 addInt(index + 1); | 1309 addInt(index + 1); |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 void SkPictureRecord::addPoint(const SkPoint& point) { | 1312 void SkPictureRecord::addPoint(const SkPoint& point) { |
| 1313 #ifdef SK_DEBUG_SIZE | 1313 #ifdef SK_DEBUG_SIZE |
| 1314 size_t start = fWriter.size(); | 1314 size_t start = fWriter.bytesWritten(); |
| 1315 #endif | 1315 #endif |
| 1316 fWriter.writePoint(point); | 1316 fWriter.writePoint(point); |
| 1317 #ifdef SK_DEBUG_SIZE | 1317 #ifdef SK_DEBUG_SIZE |
| 1318 fPointBytes += fWriter.size() - start; | 1318 fPointBytes += fWriter.bytesWritten() - start; |
| 1319 fPointWrites++; | 1319 fPointWrites++; |
| 1320 #endif | 1320 #endif |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 void SkPictureRecord::addPoints(const SkPoint pts[], int count) { | 1323 void SkPictureRecord::addPoints(const SkPoint pts[], int count) { |
| 1324 fWriter.writeMul4(pts, count * sizeof(SkPoint)); | 1324 fWriter.writeMul4(pts, count * sizeof(SkPoint)); |
| 1325 #ifdef SK_DEBUG_SIZE | 1325 #ifdef SK_DEBUG_SIZE |
| 1326 fPointBytes += count * sizeof(SkPoint); | 1326 fPointBytes += count * sizeof(SkPoint); |
| 1327 fPointWrites++; | 1327 fPointWrites++; |
| 1328 #endif | 1328 #endif |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 void SkPictureRecord::addRect(const SkRect& rect) { | 1331 void SkPictureRecord::addRect(const SkRect& rect) { |
| 1332 #ifdef SK_DEBUG_SIZE | 1332 #ifdef SK_DEBUG_SIZE |
| 1333 size_t start = fWriter.size(); | 1333 size_t start = fWriter.bytesWritten(); |
| 1334 #endif | 1334 #endif |
| 1335 fWriter.writeRect(rect); | 1335 fWriter.writeRect(rect); |
| 1336 #ifdef SK_DEBUG_SIZE | 1336 #ifdef SK_DEBUG_SIZE |
| 1337 fRectBytes += fWriter.size() - start; | 1337 fRectBytes += fWriter.bytesWritten() - start; |
| 1338 fRectWrites++; | 1338 fRectWrites++; |
| 1339 #endif | 1339 #endif |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 void SkPictureRecord::addRectPtr(const SkRect* rect) { | 1342 void SkPictureRecord::addRectPtr(const SkRect* rect) { |
| 1343 if (fWriter.writeBool(rect != NULL)) { | 1343 if (fWriter.writeBool(rect != NULL)) { |
| 1344 fWriter.writeRect(*rect); | 1344 fWriter.writeRect(*rect); |
| 1345 } | 1345 } |
| 1346 } | 1346 } |
| 1347 | 1347 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1358 void SkPictureRecord::addRRect(const SkRRect& rrect) { | 1358 void SkPictureRecord::addRRect(const SkRRect& rrect) { |
| 1359 fWriter.writeRRect(rrect); | 1359 fWriter.writeRRect(rrect); |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 void SkPictureRecord::addRegion(const SkRegion& region) { | 1362 void SkPictureRecord::addRegion(const SkRegion& region) { |
| 1363 addInt(fRegions.find(region)); | 1363 addInt(fRegions.find(region)); |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 void SkPictureRecord::addText(const void* text, size_t byteLength) { | 1366 void SkPictureRecord::addText(const void* text, size_t byteLength) { |
| 1367 #ifdef SK_DEBUG_SIZE | 1367 #ifdef SK_DEBUG_SIZE |
| 1368 size_t start = fWriter.size(); | 1368 size_t start = fWriter.bytesWritten(); |
| 1369 #endif | 1369 #endif |
| 1370 addInt(byteLength); | 1370 addInt(byteLength); |
| 1371 fWriter.writePad(text, byteLength); | 1371 fWriter.writePad(text, byteLength); |
| 1372 #ifdef SK_DEBUG_SIZE | 1372 #ifdef SK_DEBUG_SIZE |
| 1373 fTextBytes += fWriter.size() - start; | 1373 fTextBytes += fWriter.bytesWritten() - start; |
| 1374 fTextWrites++; | 1374 fTextWrites++; |
| 1375 #endif | 1375 #endif |
| 1376 } | 1376 } |
| 1377 | 1377 |
| 1378 /////////////////////////////////////////////////////////////////////////////// | 1378 /////////////////////////////////////////////////////////////////////////////// |
| 1379 | 1379 |
| 1380 #ifdef SK_DEBUG_SIZE | 1380 #ifdef SK_DEBUG_SIZE |
| 1381 size_t SkPictureRecord::size() const { | 1381 size_t SkPictureRecord::size() const { |
| 1382 size_t result = 0; | 1382 size_t result = 0; |
| 1383 size_t sizeData; | 1383 size_t sizeData; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 void SkPictureRecord::validateRegions() const { | 1501 void SkPictureRecord::validateRegions() const { |
| 1502 int count = fRegions.count(); | 1502 int count = fRegions.count(); |
| 1503 SkASSERT((unsigned) count < 0x1000); | 1503 SkASSERT((unsigned) count < 0x1000); |
| 1504 for (int index = 0; index < count; index++) { | 1504 for (int index = 0; index < count; index++) { |
| 1505 const SkFlatData* region = fRegions[index]; | 1505 const SkFlatData* region = fRegions[index]; |
| 1506 SkASSERT(region); | 1506 SkASSERT(region); |
| 1507 // region->validate(); | 1507 // region->validate(); |
| 1508 } | 1508 } |
| 1509 } | 1509 } |
| 1510 #endif | 1510 #endif |
| OLD | NEW |