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

Unified Diff: src/core/SkPictureRecord.cpp

Issue 13957009: First pass at Comment API (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Addressed code review issues Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecord.cpp
===================================================================
--- src/core/SkPictureRecord.cpp (revision 9288)
+++ src/core/SkPictureRecord.cpp (working copy)
@@ -106,6 +106,9 @@
0, // SKEW - no paint
0, // TRANSLATE - no paint
0, // NOOP - no paint
+ 0, // BEGIN_GROUP - no paint
+ 0, // COMMENT - no paint
+ 0, // END_GROUP - no paint
};
SkASSERT(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1);
@@ -1276,6 +1279,33 @@
validate(initialOffset, size);
}
+void SkPictureRecord::beginCommentGroup(const char* description) {
+ // op/size + length of string + \0 terminated chars
+ int length = strlen(description);
+ uint32_t size = 2 * kUInt32Size + SkAlign4(length + 1);
+ uint32_t initialOffset = this->addDraw(BEGIN_COMMENT_GROUP, &size);
+ fWriter.writeString(description, length);
+ validate(initialOffset, size);
+}
+
+void SkPictureRecord::addComment(const char* kywd, const char* value) {
+ // op/size + 2x length of string + 2x \0 terminated chars
+ int kywdLen = strlen(kywd);
+ int valueLen = strlen(value);
+ uint32_t size = 3 * kUInt32Size + SkAlign4(kywdLen + 1) + SkAlign4(valueLen + 1);
+ uint32_t initialOffset = this->addDraw(COMMENT, &size);
+ fWriter.writeString(kywd, kywdLen);
+ fWriter.writeString(value, valueLen);
+ validate(initialOffset, size);
+}
+
+void SkPictureRecord::endCommentGroup() {
+ // op/size
+ uint32_t size = 1 * kUInt32Size;
+ uint32_t initialOffset = this->addDraw(END_COMMENT_GROUP, &size);
+ validate(initialOffset, size);
+}
+
///////////////////////////////////////////////////////////////////////////////
void SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698