diff options
author | Romain Guy <romainguy@android.com> | 2009-05-11 11:50:46 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-05-11 11:50:46 -0700 |
commit | 263e019baafb3b6cbcfdef9c81d74a4bea769180 (patch) | |
tree | c1bfc76310bf056120b1e43c18e27d6ad90ba997 /src/com/android/launcher/Workspace.java | |
parent | 82d94d9e9ee4eb6b14db3c8df2f47dcae5ce4ab0 (diff) | |
download | android_packages_apps_Trebuchet-263e019baafb3b6cbcfdef9c81d74a4bea769180.tar.gz android_packages_apps_Trebuchet-263e019baafb3b6cbcfdef9c81d74a4bea769180.tar.bz2 android_packages_apps_Trebuchet-263e019baafb3b6cbcfdef9c81d74a4bea769180.zip |
Fixes #1596240. Optimize invalidate/draw passes by marking opaque views and avoiding drawing them. Whenever a View requests an invalidate its parent check whether the view is opaque or not. When the view is not opaque, the framework behaves as it used to. However, when a view is opaque, the parent marks itself as being dirty because of an opaque view. Its parent then does the same, and so on. When the framework then starts drawing the views, it does not draw views marked as dirty opaque. If a view is dirty opaque and receives an invalidate request from a non-opaque view, it then clears the dirty opaque flag and behaves as before.
Diffstat (limited to 'src/com/android/launcher/Workspace.java')
-rw-r--r-- | src/com/android/launcher/Workspace.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/com/android/launcher/Workspace.java b/src/com/android/launcher/Workspace.java index f20572e82..b246ddb9d 100644 --- a/src/com/android/launcher/Workspace.java +++ b/src/com/android/launcher/Workspace.java @@ -457,6 +457,11 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag } @Override + public boolean isOpaque() { + return !mWallpaper.hasAlpha(); + } + + @Override protected void dispatchDraw(Canvas canvas) { boolean restore = false; @@ -915,7 +920,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag originalCellLayout.removeView(cell); cellLayout.addView(cell); } - mTargetCell = estimateDropCell(source, x - xOffset, y - yOffset, + mTargetCell = estimateDropCell(x - xOffset, y - yOffset, mDragInfo.spanX, mDragInfo.spanY, cell, cellLayout, mTargetCell); cellLayout.onDropChild(cell, mTargetCell); @@ -972,7 +977,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag cellLayout.addView(view, insertAtFirst ? 0 : -1); view.setOnLongClickListener(mLongClickListener); - mTargetCell = estimateDropCell(null, x, y, 1, 1, view, cellLayout, mTargetCell); + mTargetCell = estimateDropCell(x, y, 1, 1, view, cellLayout, mTargetCell); cellLayout.onDropChild(view, mTargetCell); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams(); @@ -1015,7 +1020,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag final Rect location = recycle != null ? recycle : new Rect(); // Find drop cell and convert into rectangle - int[] dropCell = estimateDropCell(source, x - xOffset, y - yOffset, + int[] dropCell = estimateDropCell(x - xOffset, y - yOffset, spanX, spanY, ignoreView, layout, mTempCell); if (dropCell == null) { @@ -1036,7 +1041,7 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag /** * Calculate the nearest cell where the given object would be dropped. */ - private int[] estimateDropCell(DragSource source, int pixelX, int pixelY, + private int[] estimateDropCell(int pixelX, int pixelY, int spanX, int spanY, View ignoreView, CellLayout layout, int[] recycle) { // Create vacant cell cache if none exists if (mVacantCache == null) { |