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

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

Issue 1228083004: add src-rect-constraint to drawImageRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 5 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 static const uint8_t gPaintOffsets[] = { 54 static const uint8_t gPaintOffsets[] = {
55 0, // UNUSED - no paint 55 0, // UNUSED - no paint
56 0, // CLIP_PATH - no paint 56 0, // CLIP_PATH - no paint
57 0, // CLIP_REGION - no paint 57 0, // CLIP_REGION - no paint
58 0, // CLIP_RECT - no paint 58 0, // CLIP_RECT - no paint
59 0, // CLIP_RRECT - no paint 59 0, // CLIP_RRECT - no paint
60 0, // CONCAT - no paint 60 0, // CONCAT - no paint
61 1, // DRAW_BITMAP - right after op code 61 1, // DRAW_BITMAP - right after op code
62 1, // DRAW_BITMAP_MATRIX - right after op code, deprecated 62 1, // DRAW_BITMAP_MATRIX - right after op code, deprecated
63 1, // DRAW_BITMAP_NINE - right after op code 63 1, // DRAW_BITMAP_NINE - right after op code
64 1, // DRAW_BITMAP_RECT_TO_RECT - right after op code 64 1, // DRAW_BITMAP_RECT - right after op code
65 0, // DRAW_CLEAR - no paint 65 0, // DRAW_CLEAR - no paint
66 0, // DRAW_DATA - no paint 66 0, // DRAW_DATA - no paint
67 1, // DRAW_OVAL - right after op code 67 1, // DRAW_OVAL - right after op code
68 1, // DRAW_PAINT - right after op code 68 1, // DRAW_PAINT - right after op code
69 1, // DRAW_PATH - right after op code 69 1, // DRAW_PATH - right after op code
70 0, // DRAW_PICTURE - no paint 70 0, // DRAW_PICTURE - no paint
71 1, // DRAW_POINTS - right after op code 71 1, // DRAW_POINTS - right after op code
72 1, // DRAW_POS_TEXT - right after op code 72 1, // DRAW_POS_TEXT - right after op code
73 1, // DRAW_POS_TEXT_TOP_BOTTOM - right after op code 73 1, // DRAW_POS_TEXT_TOP_BOTTOM - right after op code
74 1, // DRAW_POS_TEXT_H - right after op code 74 1, // DRAW_POS_TEXT_H - right after op code
(...skipping 17 matching lines...) Expand all
92 0, // BEGIN_GROUP - no paint 92 0, // BEGIN_GROUP - no paint
93 0, // COMMENT - no paint 93 0, // COMMENT - no paint
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_STRICT - 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 1, // DRAW_IMAGE_NINE - right after op code
105 1, // DRAW_IMAGE_RECT - right after op code
105 }; 106 };
106 107
107 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, 108 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
108 need_to_be_in_sync); 109 need_to_be_in_sync);
109 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); 110 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
110 111
111 int overflow = 0; 112 int overflow = 0;
112 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { 113 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) {
113 // This op's size overflows so an extra uint32_t will be written 114 // This op's size overflows so an extra uint32_t will be written
114 // after the op code 115 // after the op code
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); 545 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
545 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP, size) == fWriter.bytesW ritten()); 546 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP, size) == fWriter.bytesW ritten());
546 this->addPaintPtr(paint); 547 this->addPaintPtr(paint);
547 this->addBitmap(bitmap); 548 this->addBitmap(bitmap);
548 this->addScalar(left); 549 this->addScalar(left);
549 this->addScalar(top); 550 this->addScalar(top);
550 this->validate(initialOffset, size); 551 this->validate(initialOffset, size);
551 } 552 }
552 553
553 void SkPictureRecord::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src , const SkRect& dst, 554 void SkPictureRecord::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src , const SkRect& dst,
554 const SkPaint* paint, DrawBitmapRectFlags flags) { 555 const SkPaint* paint,
556 SK_VIRTUAL_CONSTRAINT_TYPE constraint) {
555 // id + paint index + bitmap index + bool for 'src' + flags 557 // id + paint index + bitmap index + bool for 'src' + flags
556 size_t size = 5 * kUInt32Size; 558 size_t size = 5 * kUInt32Size;
557 if (src) { 559 if (src) {
558 size += sizeof(*src); // + rect 560 size += sizeof(*src); // + rect
559 } 561 }
560 size += sizeof(dst); // + rect 562 size += sizeof(dst); // + rect
561 563
562 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); 564 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT, &size);
563 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT_TO_RECT, size) 565 SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT, size) == fWriter.b ytesWritten());
564 == fWriter.bytesWritten());
565 this->addPaintPtr(paint); 566 this->addPaintPtr(paint);
566 this->addBitmap(bitmap); 567 this->addBitmap(bitmap);
567 this->addRectPtr(src); // may be null 568 this->addRectPtr(src); // may be null
568 this->addRect(dst); 569 this->addRect(dst);
569 this->addInt(flags); 570 this->addInt(constraint);
570 this->validate(initialOffset, size); 571 this->validate(initialOffset, size);
571 } 572 }
572 573
573 void SkPictureRecord::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, 574 void SkPictureRecord::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
574 const SkPaint* paint) { 575 const SkPaint* paint) {
575 // op + paint_index + image_index + x + y 576 // op + paint_index + image_index + x + y
576 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); 577 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
577 size_t initialOffset = this->addDraw(DRAW_IMAGE, &size); 578 size_t initialOffset = this->addDraw(DRAW_IMAGE, &size);
578 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE, size) == fWriter.bytesWr itten()); 579 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE, size) == fWriter.bytesWr itten());
579 this->addPaintPtr(paint); 580 this->addPaintPtr(paint);
580 this->addImage(image); 581 this->addImage(image);
581 this->addScalar(x); 582 this->addScalar(x);
582 this->addScalar(y); 583 this->addScalar(y);
583 this->validate(initialOffset, size); 584 this->validate(initialOffset, size);
584 } 585 }
585 586
586 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c onst SkRect& dst, 587 void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c onst SkRect& dst,
587 const SkPaint* paint) { 588 const SkPaint* paint SRC_RECT_CONSTRAINT_P ARAM(constraint)) {
588 // id + paint_index + image_index + bool_for_src 589 SRC_RECT_CONSTRAINT_LOCAL_DEFAULT(constraint)
589 size_t size = 4 * kUInt32Size; 590 // id + paint_index + image_index + bool_for_src + constraint
591 size_t size = 5 * kUInt32Size;
590 if (src) { 592 if (src) {
591 size += sizeof(*src); // + rect 593 size += sizeof(*src); // + rect
592 } 594 }
593 size += sizeof(dst); // + rect 595 size += sizeof(dst); // + rect
594 596
595 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size); 597 size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size);
596 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_RECT, size) 598 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_RECT, size)
597 == fWriter.bytesWritten()); 599 == fWriter.bytesWritten());
598 this->addPaintPtr(paint); 600 this->addPaintPtr(paint);
599 this->addImage(image); 601 this->addImage(image);
600 this->addRectPtr(src); // may be null 602 this->addRectPtr(src); // may be null
601 this->addRect(dst); 603 this->addRect(dst);
604 this->addInt(constraint);
602 this->validate(initialOffset, size); 605 this->validate(initialOffset, size);
603 } 606 }
604 607
605 void SkPictureRecord::onDrawImageNine(const SkImage* img, const SkIRect& center, const SkRect& dst, 608 void SkPictureRecord::onDrawImageNine(const SkImage* img, const SkIRect& center, const SkRect& dst,
606 const SkPaint* paint) { 609 const SkPaint* paint) {
607 // id + paint_index + image_index + center + dst 610 // id + paint_index + image_index + center + dst
608 size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect); 611 size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect);
609 612
610 size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size); 613 size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size);
611 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_NINE, size) == fWriter.by tesWritten()); 614 SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_NINE, size) == fWriter.by tesWritten());
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 1066 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
1064 int index = fTextBlobRefs.count(); 1067 int index = fTextBlobRefs.count();
1065 *fTextBlobRefs.append() = blob; 1068 *fTextBlobRefs.append() = blob;
1066 blob->ref(); 1069 blob->ref();
1067 // follow the convention of recording a 1-based index 1070 // follow the convention of recording a 1-based index
1068 this->addInt(index + 1); 1071 this->addInt(index + 1);
1069 } 1072 }
1070 1073
1071 /////////////////////////////////////////////////////////////////////////////// 1074 ///////////////////////////////////////////////////////////////////////////////
1072 1075
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