Correctly compute the number of bytes written by each op.
Bug #6157792
Previously, DisplayListRenderer would compute the number of bytes
written after a drawing op by looking at the difference between
the start pointer of the command stream and the end pointer of
the command stream. The SkWriter class used to record the commands
stream allocates blocks of storage which would cause a crash when
a command spanned two blocks.
Change-Id: I4d79d3feeb6d72d9d4e6ab05ecebd72d004be56c
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 24f52e0..a884d8e 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -826,7 +826,7 @@
while (!mReader.eof()) {
int op = mReader.readInt();
if (op & OP_MAY_BE_SKIPPED_MASK) {
- int32_t skip = mReader.readInt() * 4;
+ int32_t skip = mReader.readInt();
if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
mReader.skip(skip);
DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index abe8b82..43617e7 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -656,9 +656,8 @@
if (reject) {
mWriter.writeInt(OP_MAY_BE_SKIPPED_MASK | drawOp);
mWriter.writeInt(0xdeaddead);
- uint32_t* location = reject ?
- mWriter.peek32(mWriter.size() - sizeof(int32_t)) : NULL;
- return location;
+ mBufferSize = mWriter.size();
+ return mWriter.peek32(mBufferSize - sizeof(int32_t));
}
mWriter.writeInt(drawOp);
return NULL;
@@ -666,8 +665,7 @@
inline void addSkip(uint32_t* location) {
if (location) {
- *location = (int32_t) (mWriter.peek32(
- mWriter.size() - sizeof(int32_t)) - location);
+ *location = (int32_t) (mWriter.size() - mBufferSize);
}
}
@@ -822,6 +820,7 @@
Vector<SkMatrix*> mMatrices;
SkWriter32 mWriter;
+ uint32_t mBufferSize;
int mRestoreSaveCount;