Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 1211583003: add drawImageNine (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments from #9 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkImage_Base.h" 10 #include "SkImage_Base.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 0, // END_GROUP - no paint 94 0, // END_GROUP - no paint
95 1, // DRAWDRRECT - right after op code 95 1, // DRAWDRRECT - right after op code
96 0, // PUSH_CULL - no paint 96 0, // PUSH_CULL - no paint
97 0, // POP_CULL - no paint 97 0, // POP_CULL - no paint
98 1, // DRAW_PATCH - right after op code 98 1, // DRAW_PATCH - right after op code
99 1, // DRAW_PICTURE_MATRIX_PAINT - right after op code 99 1, // DRAW_PICTURE_MATRIX_PAINT - right after op code
100 1, // DRAW_TEXT_BLOB- right after op code 100 1, // DRAW_TEXT_BLOB- right after op code
101 1, // DRAW_IMAGE - right after op code 101 1, // DRAW_IMAGE - right after op code
102 1, // DRAW_IMAGE_RECT - right after op code 102 1, // DRAW_IMAGE_RECT - right after op code
103 1, // DRAW_ATLAS - right after op code 103 1, // DRAW_ATLAS - right after op code
104 1, // DRAW_IMAGE_NINE - right after op code
104 }; 105 };
105 106
106 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, 107 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
107 need_to_be_in_sync); 108 need_to_be_in_sync);
108 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); 109 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
109 110
110 int overflow = 0; 111 int overflow = 0;
111 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { 112 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) {
112 // This op's size overflows so an extra uint32_t will be written 113 // This op's size overflows so an extra uint32_t will be written
113 // after the op code 114 // after the op code
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE, size) == fWriter.bytesWr itten()); 578 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE, size) == fWriter.bytesWr itten());
578 this->addPaintPtr(paint); 579 this->addPaintPtr(paint);
579 this->addImage(image); 580 this->addImage(image);
580 this->addScalar(x); 581 this->addScalar(x);
581 this->addScalar(y); 582 this->addScalar(y);
582 this->validate(initialOffset, size); 583 this->validate(initialOffset, size);
583 } 584 }
584 585
585 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c onst SkRect& dst, 586 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c onst SkRect& dst,
586 const SkPaint* paint) { 587 const SkPaint* paint) {
587 // id + paint_index + bitmap_index + bool_for_src 588 // id + paint_index + image_index + bool_for_src
588 size_t size = 4 * kUInt32Size; 589 size_t size = 4 * kUInt32Size;
589 if (src) { 590 if (src) {
590 size += sizeof(*src); // + rect 591 size += sizeof(*src); // + rect
591 } 592 }
592 size += sizeof(dst); // + rect 593 size += sizeof(dst); // + rect
593 594
594 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size); 595 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size);
595 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_RECT, size) 596 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_RECT, size)
596 == fWriter.bytesWritten()); 597 == fWriter.bytesWritten());
597 this->addPaintPtr(paint); 598 this->addPaintPtr(paint);
598 this->addImage(image); 599 this->addImage(image);
599 this->addRectPtr(src); // may be null 600 this->addRectPtr(src); // may be null
600 this->addRect(dst); 601 this->addRect(dst);
601 this->validate(initialOffset, size); 602 this->validate(initialOffset, size);
602 } 603 }
603 604
605 void SkPictureRecord::onDrawImageNine(const SkImage* img, const SkIRect& center, const SkRect& dst,
606 const SkPaint* paint) {
607 // id + paint_index + image_index + center + dst
608 size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect);
609
610 size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size);
611 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_NINE, size) == fWriter.by tesWritten());
612 this->addPaintPtr(paint);
613 this->addImage(img);
614 this->addIRect(center);
615 this->addRect(dst);
616 this->validate(initialOffset, size);
617 }
618
604 void SkPictureRecord::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& ce nter, 619 void SkPictureRecord::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& ce nter,
605 const SkRect& dst, const SkPaint* paint) { 620 const SkRect& dst, const SkPaint* paint) {
606 // op + paint index + bitmap id + center + dst rect 621 // op + paint index + bitmap id + center + dst rect
607 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); 622 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
608 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); 623 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
609 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.b ytesWritten()); 624 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.b ytesWritten());
610 this->addPaintPtr(paint); 625 this->addPaintPtr(paint);
611 this->addBitmap(bitmap); 626 this->addBitmap(bitmap);
612 this->addIRect(center); 627 this->addIRect(center);
613 this->addRect(dst); 628 this->addRect(dst);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 1063 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
1049 int index = fTextBlobRefs.count(); 1064 int index = fTextBlobRefs.count();
1050 *fTextBlobRefs.append() = blob; 1065 *fTextBlobRefs.append() = blob;
1051 blob->ref(); 1066 blob->ref();
1052 // follow the convention of recording a 1-based index 1067 // follow the convention of recording a 1-based index
1053 this->addInt(index + 1); 1068 this->addInt(index + 1);
1054 } 1069 }
1055 1070
1056 /////////////////////////////////////////////////////////////////////////////// 1071 ///////////////////////////////////////////////////////////////////////////////
1057 1072
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698