| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 static inline size_t get_paint_offset(DrawType op, size_t opSize) { | 50 static inline size_t get_paint_offset(DrawType op, size_t opSize) { |
| 51 // These offsets are where the paint would be if the op size doesn't overflo
w | 51 // These offsets are where the paint would be if the op size doesn't overflo
w |
| 52 static const uint8_t gPaintOffsets[] = { | 52 static const uint8_t gPaintOffsets[] = { |
| 53 0, // UNUSED - no paint | 53 0, // UNUSED - no paint |
| 54 0, // CLIP_PATH - no paint | 54 0, // CLIP_PATH - no paint |
| 55 0, // CLIP_REGION - no paint | 55 0, // CLIP_REGION - no paint |
| 56 0, // CLIP_RECT - no paint | 56 0, // CLIP_RECT - no paint |
| 57 0, // CLIP_RRECT - no paint | 57 0, // CLIP_RRECT - no paint |
| 58 0, // CONCAT - no paint | 58 0, // CONCAT - no paint |
| 59 1, // DRAW_BITMAP - right after op code | 59 1, // DRAW_BITMAP - right after op code |
| 60 1, // DRAW_BITMAP_MATRIX - right after op code | 60 1, // DRAW_BITMAP_MATRIX - right after op code, deprecated |
| 61 1, // DRAW_BITMAP_NINE - right after op code | 61 1, // DRAW_BITMAP_NINE - right after op code |
| 62 1, // DRAW_BITMAP_RECT_TO_RECT - right after op code | 62 1, // DRAW_BITMAP_RECT_TO_RECT - right after op code |
| 63 0, // DRAW_CLEAR - no paint | 63 0, // DRAW_CLEAR - no paint |
| 64 0, // DRAW_DATA - no paint | 64 0, // DRAW_DATA - no paint |
| 65 1, // DRAW_OVAL - right after op code | 65 1, // DRAW_OVAL - right after op code |
| 66 1, // DRAW_PAINT - right after op code | 66 1, // DRAW_PAINT - right after op code |
| 67 1, // DRAW_PATH - right after op code | 67 1, // DRAW_PATH - right after op code |
| 68 0, // DRAW_PICTURE - no paint | 68 0, // DRAW_PICTURE - no paint |
| 69 1, // DRAW_POINTS - right after op code | 69 1, // DRAW_POINTS - right after op code |
| 70 1, // DRAW_POS_TEXT - right after op code | 70 1, // DRAW_POS_TEXT - right after op code |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT_TO_RECT, size) | 566 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT_TO_RECT, size) |
| 567 == fWriter.bytesWritten()); | 567 == fWriter.bytesWritten()); |
| 568 this->addPaintPtr(paint); | 568 this->addPaintPtr(paint); |
| 569 this->addBitmap(bitmap); | 569 this->addBitmap(bitmap); |
| 570 this->addRectPtr(src); // may be null | 570 this->addRectPtr(src); // may be null |
| 571 this->addRect(dst); | 571 this->addRect(dst); |
| 572 this->addInt(flags); | 572 this->addInt(flags); |
| 573 this->validate(initialOffset, size); | 573 this->validate(initialOffset, size); |
| 574 } | 574 } |
| 575 | 575 |
| 576 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
atrix, | |
| 577 const SkPaint* paint) { | |
| 578 // id + paint index + bitmap index + matrix | |
| 579 size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL); | |
| 580 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); | |
| 581 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_MATRIX, size) == fWriter
.bytesWritten()); | |
| 582 this->addPaintPtr(paint); | |
| 583 this->addBitmap(bitmap); | |
| 584 this->addMatrix(matrix); | |
| 585 this->validate(initialOffset, size); | |
| 586 } | |
| 587 | |
| 588 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
er, | 576 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
er, |
| 589 const SkRect& dst, const SkPaint* paint) { | 577 const SkRect& dst, const SkPaint* paint) { |
| 590 // op + paint index + bitmap id + center + dst rect | 578 // op + paint index + bitmap id + center + dst rect |
| 591 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); | 579 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); |
| 592 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); | 580 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); |
| 593 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.b
ytesWritten()); | 581 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.b
ytesWritten()); |
| 594 this->addPaintPtr(paint); | 582 this->addPaintPtr(paint); |
| 595 this->addBitmap(bitmap); | 583 this->addBitmap(bitmap); |
| 596 this->addIRect(center); | 584 this->addIRect(center); |
| 597 this->addRect(dst); | 585 this->addRect(dst); |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1040 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
| 1053 int index = fTextBlobRefs.count(); | 1041 int index = fTextBlobRefs.count(); |
| 1054 *fTextBlobRefs.append() = blob; | 1042 *fTextBlobRefs.append() = blob; |
| 1055 blob->ref(); | 1043 blob->ref(); |
| 1056 // follow the convention of recording a 1-based index | 1044 // follow the convention of recording a 1-based index |
| 1057 this->addInt(index + 1); | 1045 this->addInt(index + 1); |
| 1058 } | 1046 } |
| 1059 | 1047 |
| 1060 /////////////////////////////////////////////////////////////////////////////// | 1048 /////////////////////////////////////////////////////////////////////////////// |
| 1061 | 1049 |
| OLD | NEW |