Little changes to SkAnnotation in pipe:
- store size in the op data field rather than separately (saves 4 bytes);
- trim out a malloc/memcpy in each of read and write;
- remove unused enum value;
- use the right _unpackOp function;
- make sure we call needOpBytes().
BUG=
R=reed@google.com, scroggo@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/50523004
git-svn-id: http://skia.googlecode.com/svn/trunk@12007 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 53b0ae5..50043c6 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -1128,18 +1128,17 @@
if (base.getAnnotation() != paint.getAnnotation()) {
if (NULL == paint.getAnnotation()) {
- this->writeOp(kSetAnnotation_DrawOp, 0, 0);
+ if (this->needOpBytes()) {
+ this->writeOp(kSetAnnotation_DrawOp, 0, 0);
+ }
} else {
SkOrderedWriteBuffer buffer(1024);
paint.getAnnotation()->writeToBuffer(buffer);
- size = buffer.bytesWritten();
-
- SkAutoMalloc storage(size);
- buffer.writeToMemory(storage.get());
-
- this->writeOp(kSetAnnotation_DrawOp, 0, 1);
- fWriter.write32(size);
- fWriter.write(storage.get(), size);
+ const size_t size = buffer.bytesWritten();
+ if (this->needOpBytes(size)) {
+ this->writeOp(kSetAnnotation_DrawOp, 0, size);
+ buffer.writeToMemory(fWriter.reserve(size));
+ }
}
base.setAnnotation(paint.getAnnotation());
}