Optimizing DisplayList properties

DisplayList properties are still disabled default (flags in View.java
and DisplayListRenderer.h). When they are enabled, and when a View has
a DisplayList, invalidations due to property changes are now optimized
to avoid causing DisplayList recreation. This eliminates the drawing step
of invalidation (due to changes in these properties), only requiring
issuing the previously-created DisplayList to the GL renderer. Invalidation
is slightly faster (less overhead as we walk up the hierarchy), getDisplayList()
is potentially much faster (going down to ~0ms), depending on the complexity
of the View being redrawn and the size of the invalidated hierarchy.

Change-Id: I57587d5b810c3595bdd72a6c52349c2a3d1bdf25
This commit is contained in:
Chet Haase
2012-03-13 11:03:25 -07:00
parent f63c52ac87
commit 9d1992deae
5 changed files with 243 additions and 122 deletions

View File

@ -671,18 +671,6 @@ void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
if (mLeft != 0 || mTop != 0) {
ALOGD("%s%s %d, %d", indent, "Translate", mLeft, mTop);
}
if (mAlpha < 1) {
// TODO: should be able to store the size of a DL at record time and not
// have to pass it into this call. In fact, this information might be in the
// location/size info that we store with the new native transform data.
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
if (mClipChildren) {
flags |= SkCanvas::kClipToLayer_SaveFlag;
}
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
mMultipliedAlpha, flags);
}
if (mMatrixFlags != 0) {
if (mMatrixFlags == TRANSLATION) {
ALOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
@ -696,6 +684,18 @@ void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
mTransformMatrix->get(8));
}
}
if (mAlpha < 1) {
// TODO: should be able to store the size of a DL at record time and not
// have to pass it into this call. In fact, this information might be in the
// location/size info that we store with the new native transform data.
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
if (mClipChildren) {
flags |= SkCanvas::kClipToLayer_SaveFlag;
}
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
mMultipliedAlpha, flags);
}
if (mClipChildren) {
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
(float) mRight - mLeft, (float) mBottom - mTop);
@ -724,20 +724,6 @@ void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t width, ui
mApplicationScale, mApplicationScale);
renderer.scale(mApplicationScale, mApplicationScale);
}
if (mAlpha < 1 && !mCaching) {
// TODO: should be able to store the size of a DL at record time and not
// have to pass it into this call. In fact, this information might be in the
// location/size info that we store with the new native transform data.
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
if (mClipChildren) {
flags |= SkCanvas::kClipToLayer_SaveFlag;
}
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
mMultipliedAlpha, flags);
renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
mMultipliedAlpha, flags);
}
if (mMatrixFlags != 0) {
if (mMatrixFlags == TRANSLATION) {
DISPLAY_LIST_LOGD("%s%s %f, %f", indent, "Translate", mTranslationX, mTranslationY);
@ -754,6 +740,20 @@ void DisplayList::setViewProperties(OpenGLRenderer& renderer, uint32_t width, ui
renderer.concatMatrix(mTransformMatrix);
}
}
if (mAlpha < 1 && !mCaching) {
// TODO: should be able to store the size of a DL at record time and not
// have to pass it into this call. In fact, this information might be in the
// location/size info that we store with the new native transform data.
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
if (mClipChildren) {
flags |= SkCanvas::kClipToLayer_SaveFlag;
}
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
mMultipliedAlpha, flags);
renderer.saveLayerAlpha(0, 0, mRight - mLeft, mBottom - mTop,
mMultipliedAlpha, flags);
}
if (mClipChildren) {
DISPLAY_LIST_LOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,
(float) mRight - mLeft, (float) mBottom - mTop);