Loading core/java/android/view/DisplayList.java +24 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.graphics.Matrix; * @hide */ public abstract class DisplayList { private boolean mDirty; /** * Flag used when calling * {@link HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)} Loading Loading @@ -95,6 +97,28 @@ public abstract class DisplayList { */ public abstract void clear(); /** * Sets the dirty flag. When a display list is dirty, both * {@link #invalidate()} and {@link #clear()} should be invoked whenever * possible. * * @param dirty True to mark the display list dirty, false otherwise * * @see #isDirty() */ public void setDirty(boolean dirty) { mDirty = dirty; } /** * Indicates whether the display list is dirty. * * @see #setDirty(boolean) */ public boolean isDirty() { return mDirty; } /** * Returns whether the display list is currently usable. If this returns false, * the display list should be re-recorded prior to replaying it. Loading core/java/android/view/View.java +3 −2 Original line number Diff line number Diff line Loading @@ -11562,8 +11562,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, imm.focusIn(this); } if (mAttachInfo != null && mDisplayList != null) { mAttachInfo.mViewRootImpl.dequeueDisplayList(mDisplayList); if (mDisplayList != null) { mDisplayList.setDirty(false); } } Loading Loading @@ -11843,6 +11843,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (mAttachInfo != null) { if (mDisplayList != null) { mDisplayList.setDirty(true); mAttachInfo.mViewRootImpl.enqueueDisplayList(mDisplayList); } mAttachInfo.mViewRootImpl.cancelInvalidate(this); Loading core/java/android/view/ViewRootImpl.java +15 −28 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public final class ViewRootImpl implements ViewParent, private long mFpsPrevTime = -1; private int mFpsNumFrames; private final ArrayList<DisplayList> mDisplayLists = new ArrayList<DisplayList>(24); private final ArrayList<DisplayList> mDisplayLists = new ArrayList<DisplayList>(); /** * see {@link #playSoundEffect(int)} Loading Loading @@ -2128,7 +2128,7 @@ public final class ViewRootImpl implements ViewParent, private void draw(boolean fullRedrawNeeded) { Surface surface = mSurface; if (surface == null || !surface.isValid()) { if (!surface.isValid()) { return; } Loading Loading @@ -2209,6 +2209,8 @@ public final class ViewRootImpl implements ViewParent, appScale + ", width=" + mWidth + ", height=" + mHeight); } invalidateDisplayLists(); attachInfo.mTreeObserver.dispatchOnDraw(); if (!dirty.isEmpty() || mIsAnimating) { Loading Loading @@ -2419,8 +2421,11 @@ public final class ViewRootImpl implements ViewParent, for (int i = 0; i < count; i++) { final DisplayList displayList = displayLists.get(i); if (displayList.isDirty()) { displayList.invalidate(); displayList.clear(); displayList.setDirty(false); } } displayLists.clear(); Loading Loading @@ -2794,11 +2799,10 @@ public final class ViewRootImpl implements ViewParent, private final static int MSG_UPDATE_CONFIGURATION = 18; private final static int MSG_PROCESS_INPUT_EVENTS = 19; private final static int MSG_DISPATCH_SCREEN_STATE = 20; private final static int MSG_INVALIDATE_DISPLAY_LIST = 21; private final static int MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST = 22; private final static int MSG_DISPATCH_DONE_ANIMATING = 23; private final static int MSG_INVALIDATE_WORLD = 24; private final static int MSG_WINDOW_MOVED = 25; private final static int MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST = 21; private final static int MSG_DISPATCH_DONE_ANIMATING = 22; private final static int MSG_INVALIDATE_WORLD = 23; private final static int MSG_WINDOW_MOVED = 24; final class ViewRootHandler extends Handler { @Override Loading Loading @@ -2844,8 +2848,6 @@ public final class ViewRootImpl implements ViewParent, return "MSG_PROCESS_INPUT_EVENTS"; case MSG_DISPATCH_SCREEN_STATE: return "MSG_DISPATCH_SCREEN_STATE"; case MSG_INVALIDATE_DISPLAY_LIST: return "MSG_INVALIDATE_DISPLAY_LIST"; case MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST: return "MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST"; case MSG_DISPATCH_DONE_ANIMATING: Loading Loading @@ -3066,9 +3068,6 @@ public final class ViewRootImpl implements ViewParent, handleScreenStateChange(msg.arg1 == 1); } } break; case MSG_INVALIDATE_DISPLAY_LIST: { invalidateDisplayLists(); } break; case MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST: { setAccessibilityFocus(null, null); } break; Loading Loading @@ -4153,6 +4152,7 @@ public final class ViewRootImpl implements ViewParent, } if (mAdded && !mFirst) { invalidateDisplayLists(); destroyHardwareRenderer(); if (mView != null) { Loading Loading @@ -4572,19 +4572,6 @@ public final class ViewRootImpl implements ViewParent, public void enqueueDisplayList(DisplayList displayList) { mDisplayLists.add(displayList); mHandler.removeMessages(MSG_INVALIDATE_DISPLAY_LIST); Message msg = mHandler.obtainMessage(MSG_INVALIDATE_DISPLAY_LIST); mHandler.sendMessage(msg); } public void dequeueDisplayList(DisplayList displayList) { if (mDisplayLists.remove(displayList)) { displayList.invalidate(); if (mDisplayLists.size() == 0) { mHandler.removeMessages(MSG_INVALIDATE_DISPLAY_LIST); } } } public void cancelInvalidate(View view) { Loading Loading
core/java/android/view/DisplayList.java +24 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.graphics.Matrix; * @hide */ public abstract class DisplayList { private boolean mDirty; /** * Flag used when calling * {@link HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)} Loading Loading @@ -95,6 +97,28 @@ public abstract class DisplayList { */ public abstract void clear(); /** * Sets the dirty flag. When a display list is dirty, both * {@link #invalidate()} and {@link #clear()} should be invoked whenever * possible. * * @param dirty True to mark the display list dirty, false otherwise * * @see #isDirty() */ public void setDirty(boolean dirty) { mDirty = dirty; } /** * Indicates whether the display list is dirty. * * @see #setDirty(boolean) */ public boolean isDirty() { return mDirty; } /** * Returns whether the display list is currently usable. If this returns false, * the display list should be re-recorded prior to replaying it. Loading
core/java/android/view/View.java +3 −2 Original line number Diff line number Diff line Loading @@ -11562,8 +11562,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, imm.focusIn(this); } if (mAttachInfo != null && mDisplayList != null) { mAttachInfo.mViewRootImpl.dequeueDisplayList(mDisplayList); if (mDisplayList != null) { mDisplayList.setDirty(false); } } Loading Loading @@ -11843,6 +11843,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (mAttachInfo != null) { if (mDisplayList != null) { mDisplayList.setDirty(true); mAttachInfo.mViewRootImpl.enqueueDisplayList(mDisplayList); } mAttachInfo.mViewRootImpl.cancelInvalidate(this); Loading
core/java/android/view/ViewRootImpl.java +15 −28 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public final class ViewRootImpl implements ViewParent, private long mFpsPrevTime = -1; private int mFpsNumFrames; private final ArrayList<DisplayList> mDisplayLists = new ArrayList<DisplayList>(24); private final ArrayList<DisplayList> mDisplayLists = new ArrayList<DisplayList>(); /** * see {@link #playSoundEffect(int)} Loading Loading @@ -2128,7 +2128,7 @@ public final class ViewRootImpl implements ViewParent, private void draw(boolean fullRedrawNeeded) { Surface surface = mSurface; if (surface == null || !surface.isValid()) { if (!surface.isValid()) { return; } Loading Loading @@ -2209,6 +2209,8 @@ public final class ViewRootImpl implements ViewParent, appScale + ", width=" + mWidth + ", height=" + mHeight); } invalidateDisplayLists(); attachInfo.mTreeObserver.dispatchOnDraw(); if (!dirty.isEmpty() || mIsAnimating) { Loading Loading @@ -2419,8 +2421,11 @@ public final class ViewRootImpl implements ViewParent, for (int i = 0; i < count; i++) { final DisplayList displayList = displayLists.get(i); if (displayList.isDirty()) { displayList.invalidate(); displayList.clear(); displayList.setDirty(false); } } displayLists.clear(); Loading Loading @@ -2794,11 +2799,10 @@ public final class ViewRootImpl implements ViewParent, private final static int MSG_UPDATE_CONFIGURATION = 18; private final static int MSG_PROCESS_INPUT_EVENTS = 19; private final static int MSG_DISPATCH_SCREEN_STATE = 20; private final static int MSG_INVALIDATE_DISPLAY_LIST = 21; private final static int MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST = 22; private final static int MSG_DISPATCH_DONE_ANIMATING = 23; private final static int MSG_INVALIDATE_WORLD = 24; private final static int MSG_WINDOW_MOVED = 25; private final static int MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST = 21; private final static int MSG_DISPATCH_DONE_ANIMATING = 22; private final static int MSG_INVALIDATE_WORLD = 23; private final static int MSG_WINDOW_MOVED = 24; final class ViewRootHandler extends Handler { @Override Loading Loading @@ -2844,8 +2848,6 @@ public final class ViewRootImpl implements ViewParent, return "MSG_PROCESS_INPUT_EVENTS"; case MSG_DISPATCH_SCREEN_STATE: return "MSG_DISPATCH_SCREEN_STATE"; case MSG_INVALIDATE_DISPLAY_LIST: return "MSG_INVALIDATE_DISPLAY_LIST"; case MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST: return "MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST"; case MSG_DISPATCH_DONE_ANIMATING: Loading Loading @@ -3066,9 +3068,6 @@ public final class ViewRootImpl implements ViewParent, handleScreenStateChange(msg.arg1 == 1); } } break; case MSG_INVALIDATE_DISPLAY_LIST: { invalidateDisplayLists(); } break; case MSG_CLEAR_ACCESSIBILITY_FOCUS_HOST: { setAccessibilityFocus(null, null); } break; Loading Loading @@ -4153,6 +4152,7 @@ public final class ViewRootImpl implements ViewParent, } if (mAdded && !mFirst) { invalidateDisplayLists(); destroyHardwareRenderer(); if (mView != null) { Loading Loading @@ -4572,19 +4572,6 @@ public final class ViewRootImpl implements ViewParent, public void enqueueDisplayList(DisplayList displayList) { mDisplayLists.add(displayList); mHandler.removeMessages(MSG_INVALIDATE_DISPLAY_LIST); Message msg = mHandler.obtainMessage(MSG_INVALIDATE_DISPLAY_LIST); mHandler.sendMessage(msg); } public void dequeueDisplayList(DisplayList displayList) { if (mDisplayLists.remove(displayList)) { displayList.invalidate(); if (mDisplayLists.size() == 0) { mHandler.removeMessages(MSG_INVALIDATE_DISPLAY_LIST); } } } public void cancelInvalidate(View view) { Loading