Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c65d006

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
streamline ReadOpAndSize()
Inlining SkPicturePlayback::ReadOpAndSize() simplifies it, as does removing support for the old op encoding, which was the "old format" even back in 2014. Change-Id: I304a777618403667b7b6c11110e3a781a5a29df3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261594 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Reed <reed@google.com>
1 parent ad28486 commit c65d006

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

src/core/SkPicturePlayback.cpp

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,6 @@ SkCanvas::SaveLayerFlags SkCanvasPriv::LegacySaveFlagsToSaveLayerFlags(uint32_t
3535
return layerFlags;
3636
}
3737

38-
/*
39-
* Read the next op code and chunk size from 'reader'. The returned size
40-
* is the entire size of the chunk (including the opcode). Thus, the
41-
* offset just prior to calling ReadOpAndSize + 'size' is the offset
42-
* to the next chunk's op code. This also means that the size of a chunk
43-
* with no arguments (just an opcode) will be 4.
44-
*/
45-
uint32_t SkPicturePlayback::ReadOpAndSize(SkReadBuffer* reader, uint32_t* size) {
46-
uint32_t temp = reader->readInt();
47-
uint32_t op;
48-
if ((temp & 0xFF) == temp) {
49-
// old skp file - no size information
50-
op = temp;
51-
*size = 0;
52-
} else {
53-
UNPACK_8_24(temp, op, *size);
54-
if (MASK_24 == *size) {
55-
*size = reader->readInt();
56-
}
57-
}
58-
return op;
59-
}
60-
61-
6238
static const SkRect* get_rect_ptr(SkReadBuffer* reader, SkRect* storage) {
6339
if (reader->readBool()) {
6440
reader->readRect(storage);
@@ -88,9 +64,15 @@ void SkPicturePlayback::draw(SkCanvas* canvas,
8864
}
8965

9066
fCurOffset = reader.offset();
91-
uint32_t size;
92-
uint32_t op = ReadOpAndSize(&reader, &size);
93-
if (!reader.validate(op > UNUSED && op <= LAST_DRAWTYPE_ENUM)) {
67+
68+
uint32_t bits = reader.readInt();
69+
uint32_t op = bits >> 24,
70+
size = bits & 0xffffff;
71+
if (size == 0xffffff) {
72+
size = reader.readInt();
73+
}
74+
75+
if (!reader.validate(size > 0 && op > UNUSED && op <= LAST_DRAWTYPE_ENUM)) {
9476
return;
9577
}
9678

src/core/SkPicturePlayback.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class SkPicturePlayback final : SkNoncopyable {
4343
SkCanvas* canvas,
4444
const SkMatrix& initialMatrix);
4545

46-
static uint32_t ReadOpAndSize(SkReadBuffer* reader, uint32_t* size);
47-
4846
class AutoResetOpID {
4947
public:
5048
AutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { }

0 commit comments

Comments
 (0)