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

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

Issue 13957009: First pass at Comment API (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 1, // DRAW_VERTICES - right after op code 98 1, // DRAW_VERTICES - right after op code
99 0, // RESTORE - no paint 99 0, // RESTORE - no paint
100 0, // ROTATE - no paint 100 0, // ROTATE - no paint
101 0, // SAVE - no paint 101 0, // SAVE - no paint
102 0, // SAVE_LAYER - see below - this paint's location varies 102 0, // SAVE_LAYER - see below - this paint's location varies
103 0, // SCALE - no paint 103 0, // SCALE - no paint
104 0, // SET_MATRIX - no paint 104 0, // SET_MATRIX - no paint
105 0, // SKEW - no paint 105 0, // SKEW - no paint
106 0, // TRANSLATE - no paint 106 0, // TRANSLATE - no paint
107 0, // NOOP - no paint 107 0, // NOOP - no paint
108 0, // BEGIN_GROUP - no paint
109 0, // COMMENT - no paint
110 0, // END_GROUP - no paint
108 }; 111 };
109 112
110 SkASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1); 113 SkASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1);
111 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM); 114 SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
112 115
113 int overflow = 0; 116 int overflow = 0;
114 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) { 117 if (0 != (opSize & ~MASK_24) || opSize == MASK_24) {
115 // This op's size overflows so an extra uint32_t will be written 118 // This op's size overflows so an extra uint32_t will be written
116 // after the op code 119 // after the op code
117 overflow = sizeof(uint32_t); 120 overflow = sizeof(uint32_t);
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 1210
1208 void SkPictureRecord::drawData(const void* data, size_t length) { 1211 void SkPictureRecord::drawData(const void* data, size_t length) {
1209 // op + length + 'length' worth of data 1212 // op + length + 'length' worth of data
1210 uint32_t size = 2 * kUInt32Size + SkAlign4(length); 1213 uint32_t size = 2 * kUInt32Size + SkAlign4(length);
1211 uint32_t initialOffset = this->addDraw(DRAW_DATA, &size); 1214 uint32_t initialOffset = this->addDraw(DRAW_DATA, &size);
1212 addInt(length); 1215 addInt(length);
1213 fWriter.writePad(data, length); 1216 fWriter.writePad(data, length);
1214 validate(initialOffset, size); 1217 validate(initialOffset, size);
1215 } 1218 }
1216 1219
1220 void SkPictureRecord::beginGroup(const char* description) {
1221 // op/size + length of string + \0 terminated chars
1222 int length = strlen(description);
1223 uint32_t size = 2 * kUInt32Size + SkAlign4(length + 1);
1224 uint32_t initialOffset = this->addDraw(BEGIN_GROUP, &size);
1225 fWriter.writeString(description, length);
1226 validate(initialOffset, size);
1227 }
1228
1229 void SkPictureRecord::addComment(const char* kywd, const char* value) {
1230 // op/size + 2x length of string + 2x \0 terminated chars
1231 int kywdLen = strlen(kywd);
1232 int valueLen = strlen(value);
1233 uint32_t size = 3 * kUInt32Size + SkAlign4(kywdLen + 1) + SkAlign4(valueLen + 1);
1234 uint32_t initialOffset = this->addDraw(COMMENT, &size);
1235 fWriter.writeString(kywd, kywdLen);
1236 fWriter.writeString(value, valueLen);
1237 validate(initialOffset, size);
1238 }
1239
1240 void SkPictureRecord::endGroup() {
1241 // op/size
1242 uint32_t size = 1 * kUInt32Size;
1243 uint32_t initialOffset = this->addDraw(END_GROUP, &size);
1244 validate(initialOffset, size);
1245 }
1246
1217 /////////////////////////////////////////////////////////////////////////////// 1247 ///////////////////////////////////////////////////////////////////////////////
1218 1248
1219 void SkPictureRecord::addBitmap(const SkBitmap& bitmap) { 1249 void SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
1220 const int index = fBitmapHeap->insert(bitmap); 1250 const int index = fBitmapHeap->insert(bitmap);
1221 // In debug builds, a bad return value from insert() will crash, allowing fo r debugging. In 1251 // In debug builds, a bad return value from insert() will crash, allowing fo r debugging. In
1222 // release builds, the invalid value will be recorded so that the reader wil l know that there 1252 // release builds, the invalid value will be recorded so that the reader wil l know that there
1223 // was a problem. 1253 // was a problem.
1224 SkASSERT(index != SkBitmapHeap::INVALID_SLOT); 1254 SkASSERT(index != SkBitmapHeap::INVALID_SLOT);
1225 addInt(index); 1255 addInt(index);
1226 } 1256 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 void SkPictureRecord::validateRegions() const { 1480 void SkPictureRecord::validateRegions() const {
1451 int count = fRegions.count(); 1481 int count = fRegions.count();
1452 SkASSERT((unsigned) count < 0x1000); 1482 SkASSERT((unsigned) count < 0x1000);
1453 for (int index = 0; index < count; index++) { 1483 for (int index = 0; index < count; index++) {
1454 const SkFlatData* region = fRegions[index]; 1484 const SkFlatData* region = fRegions[index];
1455 SkASSERT(region); 1485 SkASSERT(region);
1456 // region->validate(); 1486 // region->validate();
1457 } 1487 }
1458 } 1488 }
1459 #endif 1489 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698