Add android:hardwareAccelerated to Activity.
Hardware acceleration can now be enabled/disabled locally on each activity declared in the manifest. It can also be enabled/disabled directly on a window through the WindowManager.LayoutParams. Change-Id: I91dd0b26c4e7eb8cd7288e523ed6b7bda6d0990b
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import com.android.internal.view.BaseSurfaceHolder;
|
||||
import com.android.internal.view.IInputMethodCallback;
|
||||
import com.android.internal.view.IInputMethodSession;
|
||||
@@ -329,7 +328,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
|
||||
mWindowAttributes.copyFrom(attrs);
|
||||
attrs = mWindowAttributes;
|
||||
|
||||
enableHardwareAcceleration(view, attrs);
|
||||
enableHardwareAcceleration(attrs);
|
||||
|
||||
if (view instanceof RootViewSurfaceTaker) {
|
||||
mSurfaceHolderCallback =
|
||||
@@ -460,14 +459,14 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
|
||||
}
|
||||
}
|
||||
|
||||
private void enableHardwareAcceleration(View view, WindowManager.LayoutParams attrs) {
|
||||
private void enableHardwareAcceleration(WindowManager.LayoutParams attrs) {
|
||||
// Only enable hardware acceleration if we are not in the system process
|
||||
// The window manager creates ViewRoots to display animated preview windows
|
||||
// of launching apps and we don't want those to be hardware accelerated
|
||||
if (Process.myUid() != Process.SYSTEM_UID) {
|
||||
// Try to enable hardware acceleration if requested
|
||||
if ((view.getContext().getApplicationInfo().flags &
|
||||
ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
|
||||
if (attrs != null &&
|
||||
(attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0) {
|
||||
final boolean translucent = attrs.format != PixelFormat.OPAQUE;
|
||||
mHwRenderer = HardwareRenderer.createGlRenderer(2, translucent);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ public abstract class Window {
|
||||
* If overlay is enabled, the action mode UI will be allowed to cover existing window content.
|
||||
*/
|
||||
public static final int FEATURE_ACTION_MODE_OVERLAY = 9;
|
||||
/**
|
||||
* Flag for requesting this window to be hardware accelerated, if possible.
|
||||
*/
|
||||
public static final int FEATURE_HARDWARE_ACCELERATED = 10;
|
||||
/** Flag for setting the progress bar's visibility to VISIBLE */
|
||||
public static final int PROGRESS_VISIBILITY_ON = -1;
|
||||
/** Flag for setting the progress bar's visibility to GONE */
|
||||
@@ -375,21 +379,35 @@ public abstract class Window {
|
||||
*
|
||||
* @param wm The ViewManager for adding new windows.
|
||||
*/
|
||||
public void setWindowManager(WindowManager wm,
|
||||
IBinder appToken, String appName) {
|
||||
public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
|
||||
setWindowManager(wm, appToken, appName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the window manager for use by this Window to, for example,
|
||||
* display panels. This is <em>not</em> used for displaying the
|
||||
* Window itself -- that must be done by the client.
|
||||
*
|
||||
* @param wm The ViewManager for adding new windows.
|
||||
*/
|
||||
public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
|
||||
boolean hardwareAccelerated) {
|
||||
mAppToken = appToken;
|
||||
mAppName = appName;
|
||||
if (wm == null) {
|
||||
wm = WindowManagerImpl.getDefault();
|
||||
}
|
||||
mWindowManager = new LocalWindowManager(wm);
|
||||
mWindowManager = new LocalWindowManager(wm, hardwareAccelerated);
|
||||
}
|
||||
|
||||
private class LocalWindowManager implements WindowManager {
|
||||
LocalWindowManager(WindowManager wm) {
|
||||
private boolean mHardwareAccelerated;
|
||||
|
||||
LocalWindowManager(WindowManager wm, boolean hardwareAccelerated) {
|
||||
mWindowManager = wm;
|
||||
mDefaultDisplay = mContext.getResources().getDefaultDisplay(
|
||||
mWindowManager.getDefaultDisplay());
|
||||
mHardwareAccelerated = hardwareAccelerated;
|
||||
}
|
||||
|
||||
public final void addView(View view, ViewGroup.LayoutParams params) {
|
||||
@@ -436,6 +454,9 @@ public abstract class Window {
|
||||
if (wp.packageName == null) {
|
||||
wp.packageName = mContext.getPackageName();
|
||||
}
|
||||
if (mHardwareAccelerated) {
|
||||
wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
|
||||
}
|
||||
mWindowManager.addView(view, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public interface WindowManager extends ViewManager {
|
||||
* When using {@link Gravity#LEFT} or {@link Gravity#RIGHT} it provides
|
||||
* an offset from the given edge.
|
||||
*/
|
||||
@ViewDebug.ExportedProperty
|
||||
public int x;
|
||||
|
||||
/**
|
||||
@@ -79,6 +80,7 @@ public interface WindowManager extends ViewManager {
|
||||
* When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
|
||||
* an offset from the given edge.
|
||||
*/
|
||||
@ViewDebug.ExportedProperty
|
||||
public int y;
|
||||
|
||||
/**
|
||||
@@ -87,6 +89,7 @@ public interface WindowManager extends ViewManager {
|
||||
* should not be stretched. Otherwise the extra pixels will be pro-rated
|
||||
* among all views whose weight is greater than 0.
|
||||
*/
|
||||
@ViewDebug.ExportedProperty
|
||||
public float horizontalWeight;
|
||||
|
||||
/**
|
||||
@@ -95,8 +98,9 @@ public interface WindowManager extends ViewManager {
|
||||
* should not be stretched. Otherwise the extra pixels will be pro-rated
|
||||
* among all views whose weight is greater than 0.
|
||||
*/
|
||||
@ViewDebug.ExportedProperty
|
||||
public float verticalWeight;
|
||||
|
||||
|
||||
/**
|
||||
* The general type of window. There are three main classes of
|
||||
* window types:
|
||||
@@ -389,6 +393,7 @@ public interface WindowManager extends ViewManager {
|
||||
* @see #FLAG_FULLSCREEN
|
||||
* @see #FLAG_FORCE_NOT_FULLSCREEN
|
||||
* @see #FLAG_IGNORE_CHEEK_PRESSES
|
||||
* @see #FLAG_HARDWARE_ACCELERATED
|
||||
*/
|
||||
@ViewDebug.ExportedProperty(flagMapping = {
|
||||
@ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
|
||||
@@ -420,7 +425,9 @@ public interface WindowManager extends ViewManager {
|
||||
@ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN,
|
||||
equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"),
|
||||
@ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES,
|
||||
equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES")
|
||||
equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"),
|
||||
@ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED,
|
||||
equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED")
|
||||
})
|
||||
public int flags;
|
||||
|
||||
@@ -603,6 +610,12 @@ public interface WindowManager extends ViewManager {
|
||||
* it is created.
|
||||
* {@hide} */
|
||||
public static final int FLAG_SYSTEM_ERROR = 0x40000000;
|
||||
|
||||
/**
|
||||
* Indicates whether this window should be hardware accelerated.
|
||||
* Requesting hardware acceleration does not guarantee it will happen.
|
||||
*/
|
||||
public static final int FLAG_HARDWARE_ACCELERATED = 0x80000000;
|
||||
|
||||
/**
|
||||
* Given a particular set of window manager flags, determine whether
|
||||
@@ -1075,6 +1088,7 @@ public interface WindowManager extends ViewManager {
|
||||
screenOrientation = o.screenOrientation;
|
||||
changes |= SCREEN_ORIENTATION_CHANGED;
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user