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

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

Issue 174243003: add SkCanvas::drawDRRect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipePriv.h » ('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 "SkTSearch.h" 9 #include "SkTSearch.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 0, // SAVE - no paint 104 0, // SAVE - no paint
105 0, // SAVE_LAYER - see below - this paint's location varies 105 0, // SAVE_LAYER - see below - this paint's location varies
106 0, // SCALE - no paint 106 0, // SCALE - no paint
107 0, // SET_MATRIX - no paint 107 0, // SET_MATRIX - no paint
108 0, // SKEW - no paint 108 0, // SKEW - no paint
109 0, // TRANSLATE - no paint 109 0, // TRANSLATE - no paint
110 0, // NOOP - no paint 110 0, // NOOP - no paint
111 0, // BEGIN_GROUP - no paint 111 0, // BEGIN_GROUP - no paint
112 0, // COMMENT - no paint 112 0, // COMMENT - no paint
113 0, // END_GROUP - no paint 113 0, // END_GROUP - no paint
114 1, // DRAWDRRECT - right after op code
114 }; 115 };
115 116
116 SkASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1); 117 SK_COMPILE_ASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1,
118 need_to_be_in_sync);
117 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); 119 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
118 120
119 int overflow = 0; 121 int overflow = 0;
120 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { 122 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) {
121 // This op's size overflows so an extra uint32_t will be written 123 // This op's size overflows so an extra uint32_t will be written
122 // after the op code 124 // after the op code
123 overflow = sizeof(uint32_t); 125 overflow = sizeof(uint32_t);
124 } 126 }
125 127
126 if (SAVE_LAYER == op) { 128 if (SAVE_LAYER == op) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 458
457 if (kSaveLayerWithBoundsSize == result[0].fSize) { 459 if (kSaveLayerWithBoundsSize == result[0].fSize) {
458 // The saveLayer's bound can offset where the dbm is drawn 460 // The saveLayer's bound can offset where the dbm is drawn
459 return false; 461 return false;
460 } 462 }
461 463
462 return merge_savelayer_paint_into_drawbitmp(writer, paintDict, 464 return merge_savelayer_paint_into_drawbitmp(writer, paintDict,
463 result[0], result[3]); 465 result[0], result[3]);
464 } 466 }
465 467
468 static bool is_drawing_op(DrawType op) {
469 return (op > CONCAT && op < ROTATE) || DRAW_DRRECT == op;
470 }
471
466 /* 472 /*
467 * Restore has just been called (but not recorded), so look back at the 473 * Restore has just been called (but not recorded), so look back at the
468 * matching save(), and see if we can eliminate the pair of them, due to no 474 * matching save(), and see if we can eliminate the pair of them, due to no
469 * intervening matrix/clip calls. 475 * intervening matrix/clip calls.
470 * 476 *
471 * If so, update the writer and return true, in which case we won't even record 477 * If so, update the writer and return true, in which case we won't even record
472 * the restore() call. If we still need the restore(), return false. 478 * the restore() call. If we still need the restore(), return false.
473 */ 479 */
474 static bool collapse_save_clip_restore(SkWriter32* writer, int32_t offset, 480 static bool collapse_save_clip_restore(SkWriter32* writer, int32_t offset,
475 SkPaintDictionary* paintDict) { 481 SkPaintDictionary* paintDict) {
(...skipping 28 matching lines...) Expand all
504 return false; 510 return false;
505 } 511 }
506 512
507 // Walk forward until we get back to either a draw-verb (abort) or we hit 513 // Walk forward until we get back to either a draw-verb (abort) or we hit
508 // our restore (success). 514 // our restore (success).
509 int32_t saveOffset = offset; 515 int32_t saveOffset = offset;
510 516
511 offset += opSize; 517 offset += opSize;
512 while (offset < restoreOffset) { 518 while (offset < restoreOffset) {
513 op = peek_op_and_size(writer, offset, &opSize); 519 op = peek_op_and_size(writer, offset, &opSize);
514 if ((op > CONCAT && op < ROTATE) || (SAVE_LAYER == op)) { 520 if (is_drawing_op(op) || (SAVE_LAYER == op)) {
515 // drawing verb, abort 521 // drawing verb, abort
516 return false; 522 return false;
517 } 523 }
518 offset += opSize; 524 offset += opSize;
519 } 525 }
520 526
521 #ifdef TRACK_COLLAPSE_STATS 527 #ifdef TRACK_COLLAPSE_STATS
522 gCollapseCount += 1; 528 gCollapseCount += 1;
523 SkDebugf("Collapse [%d out of %d] %g%spn", gCollapseCount, gCollapseCalls, 529 SkDebugf("Collapse [%d out of %d] %g%spn", gCollapseCount, gCollapseCalls,
524 (double)gCollapseCount / gCollapseCalls, "%"); 530 (double)gCollapseCount / gCollapseCalls, "%");
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 uint32_t initialOffset, size; 1067 uint32_t initialOffset, size;
1062 size = 2 * kUInt32Size + SkRRect::kSizeInMemory; 1068 size = 2 * kUInt32Size + SkRRect::kSizeInMemory;
1063 initialOffset = this->addDraw(DRAW_RRECT, &size); 1069 initialOffset = this->addDraw(DRAW_RRECT, &size);
1064 SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.bytes Written()); 1070 SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.bytes Written());
1065 this->addPaint(paint); 1071 this->addPaint(paint);
1066 this->addRRect(rrect); 1072 this->addRRect(rrect);
1067 this->validate(initialOffset, size); 1073 this->validate(initialOffset, size);
1068 } 1074 }
1069 } 1075 }
1070 1076
1077 void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
1078 const SkPaint& paint) {
1079
1080 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1081 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1082 #endif
1083
1084 // op + paint index + rrects
1085 uint32_t initialOffset, size;
1086 size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2;
1087 initialOffset = this->addDraw(DRAW_DRRECT, &size);
1088 SkASSERT(initialOffset+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWri tten());
1089 this->addPaint(paint);
1090 this->addRRect(outer);
1091 this->addRRect(inner);
1092 this->validate(initialOffset, size);
1093 }
1094
1071 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { 1095 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) {
1072 1096
1073 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1097 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1074 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1098 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1075 #endif 1099 #endif
1076 1100
1077 // op + paint index + path index 1101 // op + paint index + path index
1078 uint32_t size = 3 * kUInt32Size; 1102 uint32_t size = 3 * kUInt32Size;
1079 size_t initialOffset = this->addDraw(DRAW_PATH, &size); 1103 size_t initialOffset = this->addDraw(DRAW_PATH, &size);
1080 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt en()); 1104 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt en());
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 void SkPictureRecord::validateRegions() const { 1796 void SkPictureRecord::validateRegions() const {
1773 int count = fRegions.count(); 1797 int count = fRegions.count();
1774 SkASSERT((unsigned) count < 0x1000); 1798 SkASSERT((unsigned) count < 0x1000);
1775 for (int index = 0; index < count; index++) { 1799 for (int index = 0; index < count; index++) {
1776 const SkFlatData* region = fRegions[index]; 1800 const SkFlatData* region = fRegions[index];
1777 SkASSERT(region); 1801 SkASSERT(region);
1778 // region->validate(); 1802 // region->validate();
1779 } 1803 }
1780 } 1804 }
1781 #endif 1805 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698