diff options
author | 2013-10-29 20:29:38 +0000 | |
---|---|---|
committer | 2013-10-29 20:29:38 +0000 | |
commit | 89ff3dd5af99fb31931a63298617d9a91bff2ca6 (patch) | |
tree | 633d77d995d4f6829ac05e5f1bb38aad80a0e1b4 /src/pipe/SkGPipeWrite.cpp | |
parent | 7585479202f1fe0b6a0a9dcd27697b56154706f4 (diff) |
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
Diffstat (limited to 'src/pipe/SkGPipeWrite.cpp')
-rw-r--r-- | src/pipe/SkGPipeWrite.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp index 53b0ae55d4..50043c6a2d 100644 --- a/src/pipe/SkGPipeWrite.cpp +++ b/src/pipe/SkGPipeWrite.cpp @@ -1128,18 +1128,17 @@ void SkGPipeCanvas::writePaint(const SkPaint& paint) { 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()); } |