Skip to content

Commit 390f882

Browse files
author
Romain Guy
committed
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
1 parent 6810a24 commit 390f882

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

libs/hwui/DisplayListRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, uint32_t width,
826826
while (!mReader.eof()) {
827827
int op = mReader.readInt();
828828
if (op & OP_MAY_BE_SKIPPED_MASK) {
829-
int32_t skip = mReader.readInt() * 4;
829+
int32_t skip = mReader.readInt();
830830
if (CC_LIKELY(flags & kReplayFlag_ClipChildren)) {
831831
mReader.skip(skip);
832832
DISPLAY_LIST_LOGD("%s%s skipping %d bytes", (char*) indent,

libs/hwui/DisplayListRenderer.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,18 +656,16 @@ class DisplayListRenderer: public OpenGLRenderer {
656656
if (reject) {
657657
mWriter.writeInt(OP_MAY_BE_SKIPPED_MASK | drawOp);
658658
mWriter.writeInt(0xdeaddead);
659-
uint32_t* location = reject ?
660-
mWriter.peek32(mWriter.size() - sizeof(int32_t)) : NULL;
661-
return location;
659+
mBufferSize = mWriter.size();
660+
return mWriter.peek32(mBufferSize - sizeof(int32_t));
662661
}
663662
mWriter.writeInt(drawOp);
664663
return NULL;
665664
}
666665

667666
inline void addSkip(uint32_t* location) {
668667
if (location) {
669-
*location = (int32_t) (mWriter.peek32(
670-
mWriter.size() - sizeof(int32_t)) - location);
668+
*location = (int32_t) (mWriter.size() - mBufferSize);
671669
}
672670
}
673671

@@ -822,6 +820,7 @@ class DisplayListRenderer: public OpenGLRenderer {
822820
Vector<SkMatrix*> mMatrices;
823821

824822
SkWriter32 mWriter;
823+
uint32_t mBufferSize;
825824

826825
int mRestoreSaveCount;
827826

0 commit comments

Comments
 (0)