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
This commit is contained in:
parent
7585479202
commit
89ff3dd5af
@ -236,8 +236,6 @@ enum PaintOps {
|
||||
kTextSkewX_PaintOp, // arg scalar - text
|
||||
kTypeface_PaintOp, // arg inline (index) - text
|
||||
|
||||
kAnnotation_PaintOp,// arg SkAnnotation_flat, data=bool-has-size
|
||||
|
||||
kFlatIndex_PaintOp, // flags=paintflat, data=index
|
||||
};
|
||||
|
||||
|
@ -691,13 +691,11 @@ static void annotation_rp(SkCanvas*, SkReader32* reader, uint32_t op32,
|
||||
SkGPipeState* state) {
|
||||
SkPaint* p = state->editPaint();
|
||||
|
||||
if (SkToBool(PaintOp_unpackData(op32))) {
|
||||
const size_t size = reader->readU32();
|
||||
SkAutoMalloc storage(size);
|
||||
|
||||
reader->read(storage.get(), size);
|
||||
SkOrderedReadBuffer buffer(storage.get(), size);
|
||||
const size_t size = DrawOp_unpackData(op32);
|
||||
if (size > 0) {
|
||||
SkOrderedReadBuffer buffer(reader->skip(size), size);
|
||||
p->setAnnotation(SkNEW_ARGS(SkAnnotation, (buffer)))->unref();
|
||||
SkASSERT(buffer.offset() == size);
|
||||
} else {
|
||||
p->setAnnotation(NULL);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user