Merge "Optimize display lists"
This commit is contained in:
@@ -9992,8 +9992,6 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
|
|||||||
// The dirty rect should always be null for a display list
|
// The dirty rect should always be null for a display list
|
||||||
canvas.onPreDraw(null);
|
canvas.onPreDraw(null);
|
||||||
|
|
||||||
final int restoreCount = canvas.save();
|
|
||||||
|
|
||||||
computeScroll();
|
computeScroll();
|
||||||
canvas.translate(-mScrollX, -mScrollY);
|
canvas.translate(-mScrollX, -mScrollY);
|
||||||
mPrivateFlags |= DRAWN | DRAWING_CACHE_VALID;
|
mPrivateFlags |= DRAWN | DRAWING_CACHE_VALID;
|
||||||
@@ -10005,8 +10003,6 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
|
|||||||
} else {
|
} else {
|
||||||
draw(canvas);
|
draw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.restoreToCount(restoreCount);
|
|
||||||
} finally {
|
} finally {
|
||||||
canvas.onPostDraw();
|
canvas.onPostDraw();
|
||||||
|
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde
|
|||||||
|
|
||||||
void DisplayList::init() {
|
void DisplayList::init() {
|
||||||
mSize = 0;
|
mSize = 0;
|
||||||
|
mIsRenderable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DisplayList::getSize() {
|
size_t DisplayList::getSize() {
|
||||||
@@ -892,7 +893,7 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level)
|
|||||||
// Base structure
|
// Base structure
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DisplayListRenderer::DisplayListRenderer(): mWriter(MIN_WRITER_SIZE) {
|
DisplayListRenderer::DisplayListRenderer(): mWriter(MIN_WRITER_SIZE), mHasDrawOps(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayListRenderer::~DisplayListRenderer() {
|
DisplayListRenderer::~DisplayListRenderer() {
|
||||||
@@ -926,6 +927,8 @@ void DisplayListRenderer::reset() {
|
|||||||
mPathMap.clear();
|
mPathMap.clear();
|
||||||
|
|
||||||
mMatrices.clear();
|
mMatrices.clear();
|
||||||
|
|
||||||
|
mHasDrawOps = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -938,6 +941,7 @@ DisplayList* DisplayListRenderer::getDisplayList(DisplayList* displayList) {
|
|||||||
} else {
|
} else {
|
||||||
displayList->initFromDisplayListRenderer(*this, true);
|
displayList->initFromDisplayListRenderer(*this, true);
|
||||||
}
|
}
|
||||||
|
displayList->setRenderable(mHasDrawOps);
|
||||||
return displayList;
|
return displayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -982,7 +986,11 @@ int DisplayListRenderer::save(int flags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DisplayListRenderer::restore() {
|
void DisplayListRenderer::restore() {
|
||||||
addOp(DisplayList::Restore);
|
if (mRestoreSaveCount < 0) {
|
||||||
|
addOp(DisplayList::Restore);
|
||||||
|
} else {
|
||||||
|
mRestoreSaveCount--;
|
||||||
|
}
|
||||||
OpenGLRenderer::restore();
|
OpenGLRenderer::restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
// IMPORTANT: Update the intialization of OP_NAMES in the .cpp file
|
// IMPORTANT: Update the intialization of OP_NAMES in the .cpp file
|
||||||
// when modifying this file
|
// when modifying this file
|
||||||
enum Op {
|
enum Op {
|
||||||
|
// Non-drawing operations
|
||||||
Save = 0,
|
Save = 0,
|
||||||
Restore,
|
Restore,
|
||||||
RestoreToCount,
|
RestoreToCount,
|
||||||
@@ -75,6 +76,7 @@ public:
|
|||||||
SetMatrix,
|
SetMatrix,
|
||||||
ConcatMatrix,
|
ConcatMatrix,
|
||||||
ClipRect,
|
ClipRect,
|
||||||
|
// Drawing operations
|
||||||
DrawDisplayList,
|
DrawDisplayList,
|
||||||
DrawLayer,
|
DrawLayer,
|
||||||
DrawBitmap,
|
DrawBitmap,
|
||||||
@@ -113,6 +115,14 @@ public:
|
|||||||
|
|
||||||
static void outputLogBuffer(int fd);
|
static void outputLogBuffer(int fd);
|
||||||
|
|
||||||
|
void setRenderable(bool renderable) {
|
||||||
|
mIsRenderable = renderable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isRenderable() const {
|
||||||
|
return mIsRenderable;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
@@ -207,6 +217,8 @@ private:
|
|||||||
mutable SkFlattenableReadBuffer mReader;
|
mutable SkFlattenableReadBuffer mReader;
|
||||||
|
|
||||||
size_t mSize;
|
size_t mSize;
|
||||||
|
|
||||||
|
bool mIsRenderable;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -328,6 +340,7 @@ private:
|
|||||||
inline void addOp(DisplayList::Op drawOp) {
|
inline void addOp(DisplayList::Op drawOp) {
|
||||||
insertRestoreToCount();
|
insertRestoreToCount();
|
||||||
mWriter.writeInt(drawOp);
|
mWriter.writeInt(drawOp);
|
||||||
|
mHasDrawOps = mHasDrawOps || drawOp >= DisplayList::DrawDisplayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void addInt(int value) {
|
inline void addInt(int value) {
|
||||||
@@ -479,6 +492,7 @@ private:
|
|||||||
SkWriter32 mWriter;
|
SkWriter32 mWriter;
|
||||||
|
|
||||||
int mRestoreSaveCount;
|
int mRestoreSaveCount;
|
||||||
|
bool mHasDrawOps;
|
||||||
|
|
||||||
friend class DisplayList;
|
friend class DisplayList;
|
||||||
|
|
||||||
|
|||||||
@@ -1278,7 +1278,7 @@ bool OpenGLRenderer::drawDisplayList(DisplayList* displayList, uint32_t width, u
|
|||||||
|
|
||||||
// All the usual checks and setup operations (quickReject, setupDraw, etc.)
|
// All the usual checks and setup operations (quickReject, setupDraw, etc.)
|
||||||
// will be performed by the display list itself
|
// will be performed by the display list itself
|
||||||
if (displayList) {
|
if (displayList && displayList->isRenderable()) {
|
||||||
return displayList->replay(*this, dirty, level);
|
return displayList->replay(*this, dirty, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user