Skip to content

Commit 436e270

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Disable hardware acceleration for apps in compatibility mode"
2 parents 708fd1a + 856d4e1 commit 436e270

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,20 +425,17 @@ public void setView(View view, WindowManager.LayoutParams attrs, View panelParen
425425
}
426426
}
427427

428-
// If the application owns the surface, don't enable hardware acceleration
429-
if (mSurfaceHolder == null) {
430-
enableHardwareAcceleration(attrs);
431-
}
432-
433428
CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get();
434429
mTranslator = compatibilityInfo.getTranslator();
435430

436-
if (mTranslator != null) {
437-
mSurface.setCompatibilityTranslator(mTranslator);
431+
// If the application owns the surface, don't enable hardware acceleration
432+
if (mSurfaceHolder == null) {
433+
enableHardwareAcceleration(attrs);
438434
}
439435

440436
boolean restore = false;
441437
if (mTranslator != null) {
438+
mSurface.setCompatibilityTranslator(mTranslator);
442439
restore = true;
443440
attrs.backup();
444441
mTranslator.translateWindowLayout(attrs);
@@ -590,6 +587,9 @@ private void enableHardwareAcceleration(WindowManager.LayoutParams attrs) {
590587
mAttachInfo.mHardwareAccelerated = false;
591588
mAttachInfo.mHardwareAccelerationRequested = false;
592589

590+
// Don't enable hardware acceleration when the application is in compatibility mode
591+
if (mTranslator != null) return;
592+
593593
// Try to enable hardware acceleration if requested
594594
final boolean hardwareAccelerated =
595595
(attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;

0 commit comments

Comments
 (0)