diff options
Diffstat (limited to 'libs')
17 files changed, 97 insertions, 154 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java index ef93a336305f..be1b9b1227de 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java @@ -16,6 +16,7 @@ package com.android.wm.shell.common.split; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; @@ -60,7 +61,8 @@ public class SplitScreenConstants { public static final int[] CONTROLLED_WINDOWING_MODES = {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED}; public static final int[] CONTROLLED_WINDOWING_MODES_WHEN_ACTIVE = - {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED, WINDOWING_MODE_MULTI_WINDOW}; + {WINDOWING_MODE_FULLSCREEN, WINDOWING_MODE_UNDEFINED, WINDOWING_MODE_MULTI_WINDOW, + WINDOWING_MODE_FREEFORM}; /** Flag applied to a transition change to identify it as a divider bar for animation. */ public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index 1d46e755ec9d..633f627e8e71 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -18,6 +18,7 @@ package com.android.wm.shell.desktopmode import android.R import android.app.ActivityManager.RunningTaskInfo +import android.app.WindowConfiguration import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM @@ -301,6 +302,24 @@ class DesktopTasksController( } } + /** Move a desktop app to split screen. */ + fun moveToSplit(task: RunningTaskInfo) { + KtProtoLog.v( + WM_SHELL_DESKTOP_MODE, + "DesktopTasksController: moveToSplit taskId=%d", + task.taskId + ) + val wct = WindowContainerTransaction() + wct.setWindowingMode(task.token, WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW) + wct.setBounds(task.token, null) + wct.setDensityDpi(task.token, getDefaultDensityDpi()) + if (Transitions.ENABLE_SHELL_TRANSITIONS) { + transitions.startTransition(TRANSIT_CHANGE, wct, null /* handler */) + } else { + shellTaskOrganizer.applyTransaction(wct) + } + } + /** * The second part of the animated move to desktop transition, called after * {@link startMoveToDesktop}. Move a task to fullscreen after being dragged from fullscreen diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index b872267947dc..f25110ac3257 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java @@ -123,14 +123,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb private static final long PIP_KEEP_CLEAR_AREAS_DELAY = SystemProperties.getLong("persist.wm.debug.pip_keep_clear_areas_delay", 200); - private boolean mEnablePipKeepClearAlgorithm = - SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", true); - - @VisibleForTesting - void setEnablePipKeepClearAlgorithm(boolean value) { - mEnablePipKeepClearAlgorithm = value; - } - private Context mContext; protected ShellExecutor mMainExecutor; private DisplayController mDisplayController; @@ -166,10 +158,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb // early bail out if the change was caused by keyguard showing up return; } - if (!mEnablePipKeepClearAlgorithm) { - // early bail out if the keep clear areas feature is disabled - return; - } if (mPipBoundsState.isStashed()) { // don't move when stashed return; @@ -187,10 +175,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb } private void updatePipPositionForKeepClearAreas() { - if (!mEnablePipKeepClearAlgorithm) { - // early bail out if the keep clear areas feature is disabled - return; - } if (mIsKeyguardShowingOrAnimating) { // early bail out if the change was caused by keyguard showing up return; @@ -343,19 +327,17 @@ public class PipController implements PipTransitionController.PipTransitionCallb public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted, Set<Rect> unrestricted) { if (mPipDisplayLayoutState.getDisplayId() == displayId) { - if (mEnablePipKeepClearAlgorithm) { - mPipBoundsState.setKeepClearAreas(restricted, unrestricted); - - mMainExecutor.removeCallbacks( - mMovePipInResponseToKeepClearAreasChangeCallback); - mMainExecutor.executeDelayed( - mMovePipInResponseToKeepClearAreasChangeCallback, - PIP_KEEP_CLEAR_AREAS_DELAY); - - ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, - "onKeepClearAreasChanged: restricted=%s, unrestricted=%s", - restricted, unrestricted); - } + mPipBoundsState.setKeepClearAreas(restricted, unrestricted); + + mMainExecutor.removeCallbacks( + mMovePipInResponseToKeepClearAreasChangeCallback); + mMainExecutor.executeDelayed( + mMovePipInResponseToKeepClearAreasChangeCallback, + PIP_KEEP_CLEAR_AREAS_DELAY); + + ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, + "onKeepClearAreasChanged: restricted=%s, unrestricted=%s", + restricted, unrestricted); } } }; @@ -660,25 +642,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb // there's a keyguard present return; } - int oldMaxMovementBound = mPipBoundsState.getMovementBounds().bottom; onDisplayChangedUncheck(mDisplayController .getDisplayLayout(mPipDisplayLayoutState.getDisplayId()), false /* saveRestoreSnapFraction */); - int newMaxMovementBound = mPipBoundsState.getMovementBounds().bottom; - if (!mEnablePipKeepClearAlgorithm) { - // offset PiP to adjust for bottom inset change - int pipTop = mPipBoundsState.getBounds().top; - int diff = newMaxMovementBound - oldMaxMovementBound; - if (diff < 0 && pipTop > newMaxMovementBound) { - // bottom inset has increased, move PiP up if it is too low - mPipMotionHelper.animateToOffset(mPipBoundsState.getBounds(), - newMaxMovementBound - pipTop); - } - if (diff > 0 && oldMaxMovementBound == pipTop) { - // bottom inset has decreased, move PiP down if it was by the edge - mPipMotionHelper.animateToOffset(mPipBoundsState.getBounds(), diff); - } - } } }); @@ -947,14 +913,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb * Sets both shelf visibility and its height. */ private void setShelfHeight(boolean visible, int height) { - if (mEnablePipKeepClearAlgorithm) { - // turn this into Launcher keep clear area registration instead - setLauncherKeepClearAreaHeight(visible, height); - return; - } - if (!mIsKeyguardShowingOrAnimating) { - setShelfHeightLocked(visible, height); - } + // turn this into Launcher keep clear area registration instead + setLauncherKeepClearAreaHeight(visible, height); } private void setLauncherKeepClearAreaHeight(boolean visible, int height) { @@ -1015,16 +975,10 @@ public class PipController implements PipTransitionController.PipTransitionCallb private Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo, PictureInPictureParams pictureInPictureParams, int launcherRotation, Rect hotseatKeepClearArea) { - - if (mEnablePipKeepClearAlgorithm) { - // preemptively add the keep clear area for Hotseat, so that it is taken into account - // when calculating the entry destination bounds of PiP window - mPipBoundsState.addNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG, - hotseatKeepClearArea); - } else { - int shelfHeight = hotseatKeepClearArea.height(); - setShelfHeightLocked(shelfHeight > 0 /* visible */, shelfHeight); - } + // preemptively add the keep clear area for Hotseat, so that it is taken into account + // when calculating the entry destination bounds of PiP window + mPipBoundsState.addNamedUnrestrictedKeepClearArea(LAUNCHER_KEEP_CLEAR_AREA_TAG, + hotseatKeepClearArea); onDisplayRotationChangedNotInPip(mContext, launcherRotation); final Rect entryBounds = mPipTaskOrganizer.startSwipePipToHome(componentName, activityInfo, pictureInPictureParams); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java index 3e95498a832b..9f7dee74d06e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java @@ -34,7 +34,6 @@ import android.content.res.Resources; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; -import android.os.SystemProperties; import android.provider.DeviceConfig; import android.util.Size; import android.view.DisplayCutout; @@ -73,14 +72,6 @@ public class PipTouchHandler { private static final String TAG = "PipTouchHandler"; private static final float DEFAULT_STASH_VELOCITY_THRESHOLD = 18000.f; - private boolean mEnablePipKeepClearAlgorithm = - SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", true); - - @VisibleForTesting - void setEnablePipKeepClearAlgorithm(boolean value) { - mEnablePipKeepClearAlgorithm = value; - } - // Allow PIP to resize to a slightly bigger state upon touch private boolean mEnableResize; private final Context mContext; @@ -430,48 +421,6 @@ public class PipTouchHandler { mIsImeShowing ? mImeOffset : 0, !mIsImeShowing && mIsShelfShowing ? mShelfHeight : 0); - // If this is from an IME or shelf adjustment, then we should move the PiP so that it is not - // occluded by the IME or shelf. - if (fromImeAdjustment || fromShelfAdjustment) { - if (mTouchState.isUserInteracting() && mTouchState.isDragging()) { - // Defer the update of the current movement bounds until after the user finishes - // touching the screen - } else if (mEnablePipKeepClearAlgorithm) { - // Ignore moving PiP if keep clear algorithm is enabled, since IME and shelf height - // now are accounted for in the keep clear algorithm calculations - } else { - final boolean isExpanded = mMenuState == MENU_STATE_FULL && willResizeMenu(); - final Rect toMovementBounds = new Rect(); - mPipBoundsAlgorithm.getMovementBounds(curBounds, insetBounds, - toMovementBounds, mIsImeShowing ? mImeHeight : 0); - final int prevBottom = mPipBoundsState.getMovementBounds().bottom - - mMovementBoundsExtraOffsets; - // This is to handle landscape fullscreen IMEs, don't apply the extra offset in this - // case - final int toBottom = toMovementBounds.bottom < toMovementBounds.top - ? toMovementBounds.bottom - : toMovementBounds.bottom - extraOffset; - - if (isExpanded) { - curBounds.set(mPipBoundsState.getExpandedBounds()); - mPipBoundsAlgorithm.getSnapAlgorithm().applySnapFraction(curBounds, - toMovementBounds, mSavedSnapFraction); - } - - if (prevBottom < toBottom) { - // The movement bounds are expanding - if (curBounds.top > prevBottom - mBottomOffsetBufferPx) { - mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top); - } - } else if (prevBottom > toBottom) { - // The movement bounds are shrinking - if (curBounds.top > toBottom - mBottomOffsetBufferPx) { - mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top); - } - } - } - } - // Update the movement bounds after doing the calculations based on the old movement bounds // above mPipBoundsState.setNormalMovementBounds(normalMovementBounds); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java index 2be7a491fdf2..29fff03500a5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java @@ -71,6 +71,7 @@ import com.android.wm.shell.desktopmode.DesktopModeController; import com.android.wm.shell.desktopmode.DesktopModeStatus; import com.android.wm.shell.desktopmode.DesktopTasksController; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; +import com.android.wm.shell.splitscreen.SplitScreen; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.KeyguardChangeListener; import com.android.wm.shell.sysui.ShellController; @@ -200,6 +201,19 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { @Override public void setSplitScreenController(SplitScreenController splitScreenController) { mSplitScreenController = splitScreenController; + mSplitScreenController.registerSplitScreenListener(new SplitScreen.SplitScreenListener() { + @Override + public void onTaskStageChanged(int taskId, int stage, boolean visible) { + if (visible) { + DesktopModeWindowDecoration decor = mWindowDecorByTaskId.get(taskId); + if (decor != null && DesktopModeStatus.isActive(mContext) + && decor.mTaskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) { + mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); + mDesktopTasksController.ifPresent(c -> c.moveToSplit(decor.mTaskInfo)); + } + } + } + }); } @Override diff --git a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/service/Utils.kt b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/service/Utils.kt index 610cedefe594..fa723e3110e0 100644 --- a/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/service/Utils.kt +++ b/libs/WindowManager/Shell/tests/flicker/src/com/android/wm/shell/flicker/service/Utils.kt @@ -23,6 +23,7 @@ import android.platform.test.rule.UnlockScreenRule import android.tools.common.NavBar import android.tools.common.Rotation import android.tools.device.apphelpers.MessagingAppHelper +import android.tools.device.flicker.rules.ArtifactSaverRule import android.tools.device.flicker.rules.ChangeDisplayOrientationRule import android.tools.device.flicker.rules.LaunchAppRule import android.tools.device.flicker.rules.RemoveAllTasksButHomeRule @@ -33,9 +34,10 @@ object Utils { private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation() fun testSetupRule(navigationMode: NavBar, rotation: Rotation): RuleChain { - return RuleChain.outerRule(UnlockScreenRule()) + return RuleChain.outerRule(ArtifactSaverRule()) + .around(UnlockScreenRule()) .around( - NavigationModeRule(navigationMode.value, /* changeNavigationModeAfterTest */ false) + NavigationModeRule(navigationMode.value, false) ) .around( LaunchAppRule(MessagingAppHelper(instrumentation), clearCacheAfterParsing = false) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java index 0ae290847644..05c6ba9f0897 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java @@ -76,7 +76,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import java.util.Optional; @@ -329,21 +328,7 @@ public class PipControllerTest extends ShellTestCase { } @Test - public void onKeepClearAreasChanged_featureDisabled_pipBoundsStateDoesntChange() { - mPipController.setEnablePipKeepClearAlgorithm(false); - final int displayId = 1; - final Rect keepClearArea = new Rect(0, 0, 10, 10); - when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId); - - mPipController.mDisplaysChangedListener.onKeepClearAreasChanged( - displayId, Set.of(keepClearArea), Set.of()); - - verify(mMockPipBoundsState, never()).setKeepClearAreas(Mockito.anySet(), Mockito.anySet()); - } - - @Test - public void onKeepClearAreasChanged_featureEnabled_updatesPipBoundsState() { - mPipController.setEnablePipKeepClearAlgorithm(true); + public void onKeepClearAreasChanged_updatesPipBoundsState() { final int displayId = 1; final Rect keepClearArea = new Rect(0, 0, 10, 10); when(mMockPipDisplayLayoutState.getDisplayId()).thenReturn(displayId); diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java index 852183cbcbac..f65d7af70f49 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java @@ -18,7 +18,6 @@ package com.android.wm.shell.pip.phone; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -174,16 +173,4 @@ public class PipTouchHandlerTest extends ShellTestCase { verify(mPipResizeGestureHandler, times(1)) .updateMaxSize(expectedMaxSize.getWidth(), expectedMaxSize.getHeight()); } - - @Test - public void updateMovementBounds_withImeAdjustment_movesPip() { - mPipTouchHandler.setEnablePipKeepClearAlgorithm(false); - mFromImeAdjustment = true; - mPipTouchHandler.onImeVisibilityChanged(true /* imeVisible */, mImeHeight); - - mPipTouchHandler.onMovementBoundsChanged(mInsetBounds, mPipBounds, mCurBounds, - mFromImeAdjustment, mFromShelfAdjustment, mDisplayRotation); - - verify(mMotionHelper, times(1)).animateToOffset(any(), anyInt()); - } } diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h index eb5878d95561..8c180da9c84f 100644 --- a/libs/hwui/DisplayList.h +++ b/libs/hwui/DisplayList.h @@ -54,6 +54,8 @@ public: mImpl->updateChildren(std::move(updateFn)); } + void visit(std::function<void(const RenderNode&)> func) const { mImpl->visit(std::move(func)); } + [[nodiscard]] explicit operator bool() const { return mImpl.get() != nullptr; } diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 1dd22cf43c5c..eee93c153b9a 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -109,6 +109,13 @@ void RenderNode::output(std::ostream& output, uint32_t level) { output << std::endl; } +void RenderNode::visit(std::function<void(const RenderNode&)> func) const { + func(*this); + if (mDisplayList) { + mDisplayList.visit(func); + } +} + int RenderNode::getUsageSize() { int size = sizeof(RenderNode); size += mStagingDisplayList.getUsedSize(); diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index d1e04adcb642..529a49e9277e 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -114,7 +114,7 @@ public: return mDisplayList.containsProjectionReceiver(); } - const char* getName() const { return mName.string(); } + const char* getName() const { return mName.c_str(); } void setName(const char* name) { if (name) { @@ -129,10 +129,6 @@ public: StretchMask& getStretchMask() { return mStretchMask; } - VirtualLightRefBase* getUserContext() const { return mUserContext.get(); } - - void setUserContext(VirtualLightRefBase* context) { mUserContext = context; } - bool isPropertyFieldDirty(DirtyPropertyMask field) const { return mDirtyPropertyFields & field; } @@ -215,6 +211,8 @@ public: void output(std::ostream& output, uint32_t level); + void visit(std::function<void(const RenderNode&)>) const; + void setUsageHint(UsageHint usageHint) { mUsageHint = usageHint; } UsageHint usageHint() const { return mUsageHint; } @@ -222,6 +220,7 @@ public: int64_t uniqueId() const { return mUniqueId; } void setIsTextureView() { mIsTextureView = true; } + bool isTextureView() const { return mIsTextureView; } void markDrawStart(SkCanvas& canvas); void markDrawEnd(SkCanvas& canvas); @@ -248,7 +247,6 @@ private: const int64_t mUniqueId; String8 mName; - sp<VirtualLightRefBase> mUserContext; uint32_t mDirtyPropertyFields; RenderProperties mProperties; diff --git a/libs/hwui/pipeline/skia/SkiaDisplayList.cpp b/libs/hwui/pipeline/skia/SkiaDisplayList.cpp index af2d3b34bac7..5c8285a8e1e9 100644 --- a/libs/hwui/pipeline/skia/SkiaDisplayList.cpp +++ b/libs/hwui/pipeline/skia/SkiaDisplayList.cpp @@ -66,6 +66,12 @@ void SkiaDisplayList::updateChildren(std::function<void(RenderNode*)> updateFn) } } +void SkiaDisplayList::visit(std::function<void(const RenderNode&)> func) const { + for (auto& child : mChildNodes) { + child.getRenderNode()->visit(func); + } +} + static bool intersects(const SkISize screenSize, const Matrix4& mat, const SkRect& bounds) { Vector3 points[] = { Vector3 {bounds.fLeft, bounds.fTop, 0}, Vector3 {bounds.fRight, bounds.fTop, 0}, diff --git a/libs/hwui/pipeline/skia/SkiaDisplayList.h b/libs/hwui/pipeline/skia/SkiaDisplayList.h index 7af31a4dc4c6..e5bd5c9b2a3b 100644 --- a/libs/hwui/pipeline/skia/SkiaDisplayList.h +++ b/libs/hwui/pipeline/skia/SkiaDisplayList.h @@ -145,6 +145,8 @@ public: */ void updateChildren(std::function<void(RenderNode*)> updateFn); + void visit(std::function<void(const RenderNode&)> func) const; + /** * Returns true if there is a child render node that is a projection receiver. */ diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp index 3d77877cf6eb..6679f8ff4f24 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp @@ -201,7 +201,7 @@ bool SkiaPipeline::createOrUpdateLayer(RenderNode* node, const DamageAccumulator String8 cachesOutput; mRenderThread.cacheManager().dumpMemoryUsage(cachesOutput, &mRenderThread.renderState()); - ALOGE("%s", cachesOutput.string()); + ALOGE("%s", cachesOutput.c_str()); if (errorHandler) { std::ostringstream err; err << "Unable to create layer for " << node->getName(); diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 2e0de3f8f590..4064bb933491 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -1132,6 +1132,12 @@ bool CanvasContext::shouldDither() { return self->mColorMode != ColorMode::Default; } +void CanvasContext::visitAllRenderNodes(std::function<void(const RenderNode&)> func) const { + for (auto node : mRenderNodes) { + node->visit(func); + } +} + } /* namespace renderthread */ } /* namespace uirenderer */ } /* namespace android */ diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index 3f02674d3b53..241f8dd879d9 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -238,6 +238,8 @@ public: static bool shouldDither(); + void visitAllRenderNodes(std::function<void(const RenderNode&)>) const; + private: CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode, IContextFactory* contextFactory, std::unique_ptr<IRenderPipeline> renderPipeline, diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index eb28c080c056..94ed06c806e5 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -357,7 +357,15 @@ void RenderThread::dumpGraphicsMemory(int fd, bool includeProfileData) { String8 cachesOutput; mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState); - dprintf(fd, "\nPipeline=%s\n%s\n", pipelineToString(), cachesOutput.string()); + dprintf(fd, "\nPipeline=%s\n%s", pipelineToString(), cachesOutput.c_str()); + for (auto&& context : mCacheManager->mCanvasContexts) { + context->visitAllRenderNodes([&](const RenderNode& node) { + if (node.isTextureView()) { + dprintf(fd, "TextureView: %dx%d\n", node.getWidth(), node.getHeight()); + } + }); + } + dprintf(fd, "\n"); } void RenderThread::getMemoryUsage(size_t* cpuUsage, size_t* gpuUsage) { |