Loading libs/gui/include/gui/LayerMetadata.h +10 −0 Original line number Diff line number Diff line Loading @@ -59,4 +59,14 @@ struct LayerMetadata : public Parcelable { std::string itemToString(uint32_t key, const char* separator) const; }; // Keep in sync with the GameManager.java constants. enum class GameMode : int32_t { Unsupported = 0, Standard = 1, Performance = 2, Battery = 3, ftl_last = Battery }; } // namespace android services/surfaceflinger/BufferLayer.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -401,12 +401,13 @@ void BufferLayer::onPostComposition(const DisplayDevice* display, const Fps refreshRate = display->refreshRateConfigs().getCurrentRefreshRate().getFps(); const std::optional<Fps> renderRate = mFlinger->mScheduler->getFrameRateOverride(getOwnerUid()); const auto vote = frameRateToSetFrameRateVotePayload(mDrawingState.frameRate); const auto gameMode = getGameMode(); if (presentFence->isValid()) { mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate), getGameMode()); refreshRate, renderRate, vote, gameMode); mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber, presentFence, FrameTracer::FrameEvent::PRESENT_FENCE); Loading @@ -417,10 +418,7 @@ void BufferLayer::onPostComposition(const DisplayDevice* display, // timestamp instead. const nsecs_t actualPresentTime = display->getRefreshTimestamp(); mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate), getGameMode()); refreshRate, renderRate, vote, gameMode); mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber, actualPresentTime, FrameTracer::FrameEvent::PRESENT_FENCE); Loading services/surfaceflinger/CompositionEngine/include/compositionengine/DisplaySurface.h +4 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #pragma once #include <cinttypes> #include <ui/Size.h> #include <utils/Errors.h> #include <utils/RefBase.h> Loading Loading @@ -47,13 +49,8 @@ public: // before composition takes place. The DisplaySurface can use the // composition type to decide how to manage the flow of buffers between // GPU and HWC for this frame. enum CompositionType { COMPOSITION_UNKNOWN = 0, COMPOSITION_GPU = 1, COMPOSITION_HWC = 2, COMPOSITION_MIXED = COMPOSITION_GPU | COMPOSITION_HWC }; virtual status_t prepareFrame(CompositionType compositionType) = 0; enum class CompositionType : uint8_t { Unknown = 0, Gpu = 0b1, Hwc = 0b10, Mixed = Gpu | Hwc }; virtual status_t prepareFrame(CompositionType) = 0; // Inform the surface that GPU composition is complete for this frame, and // the surface should make sure that HWComposer has the correct buffer for Loading services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp +9 −10 Original line number Diff line number Diff line Loading @@ -127,19 +127,18 @@ status_t RenderSurface::beginFrame(bool mustRecompose) { } void RenderSurface::prepareFrame(bool usesClientComposition, bool usesDeviceComposition) { DisplaySurface::CompositionType compositionType; if (usesClientComposition && usesDeviceComposition) { compositionType = DisplaySurface::COMPOSITION_MIXED; } else if (usesClientComposition) { compositionType = DisplaySurface::COMPOSITION_GPU; } else if (usesDeviceComposition) { compositionType = DisplaySurface::COMPOSITION_HWC; } else { const auto compositionType = [=] { using CompositionType = DisplaySurface::CompositionType; if (usesClientComposition && usesDeviceComposition) return CompositionType::Mixed; if (usesClientComposition) return CompositionType::Gpu; if (usesDeviceComposition) return CompositionType::Hwc; // Nothing to do -- when turning the screen off we get a frame like // this. Call it a HWC frame since we won't be doing any GPU work but // will do a prepare/set cycle. compositionType = DisplaySurface::COMPOSITION_HWC; } return CompositionType::Hwc; }(); if (status_t result = mDisplaySurface->prepareFrame(compositionType); result != NO_ERROR) { ALOGE("updateCompositionType failed for %s: %d (%s)", mDisplay.getName().c_str(), result, Loading services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -201,28 +201,28 @@ TEST_F(RenderSurfaceTest, beginFrameAppliesChange) { */ TEST_F(RenderSurfaceTest, prepareFrameHandlesMixedComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_MIXED)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Mixed)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(true, true); } TEST_F(RenderSurfaceTest, prepareFrameHandlesOnlyGpuComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_GPU)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Gpu)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(true, false); } TEST_F(RenderSurfaceTest, prepareFrameHandlesOnlyHwcComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_HWC)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Hwc)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(false, true); } TEST_F(RenderSurfaceTest, prepareFrameHandlesNoComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_HWC)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Hwc)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(false, false); Loading Loading
libs/gui/include/gui/LayerMetadata.h +10 −0 Original line number Diff line number Diff line Loading @@ -59,4 +59,14 @@ struct LayerMetadata : public Parcelable { std::string itemToString(uint32_t key, const char* separator) const; }; // Keep in sync with the GameManager.java constants. enum class GameMode : int32_t { Unsupported = 0, Standard = 1, Performance = 2, Battery = 3, ftl_last = Battery }; } // namespace android
services/surfaceflinger/BufferLayer.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -401,12 +401,13 @@ void BufferLayer::onPostComposition(const DisplayDevice* display, const Fps refreshRate = display->refreshRateConfigs().getCurrentRefreshRate().getFps(); const std::optional<Fps> renderRate = mFlinger->mScheduler->getFrameRateOverride(getOwnerUid()); const auto vote = frameRateToSetFrameRateVotePayload(mDrawingState.frameRate); const auto gameMode = getGameMode(); if (presentFence->isValid()) { mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate), getGameMode()); refreshRate, renderRate, vote, gameMode); mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber, presentFence, FrameTracer::FrameEvent::PRESENT_FENCE); Loading @@ -417,10 +418,7 @@ void BufferLayer::onPostComposition(const DisplayDevice* display, // timestamp instead. const nsecs_t actualPresentTime = display->getRefreshTimestamp(); mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate), getGameMode()); refreshRate, renderRate, vote, gameMode); mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber, actualPresentTime, FrameTracer::FrameEvent::PRESENT_FENCE); Loading
services/surfaceflinger/CompositionEngine/include/compositionengine/DisplaySurface.h +4 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #pragma once #include <cinttypes> #include <ui/Size.h> #include <utils/Errors.h> #include <utils/RefBase.h> Loading Loading @@ -47,13 +49,8 @@ public: // before composition takes place. The DisplaySurface can use the // composition type to decide how to manage the flow of buffers between // GPU and HWC for this frame. enum CompositionType { COMPOSITION_UNKNOWN = 0, COMPOSITION_GPU = 1, COMPOSITION_HWC = 2, COMPOSITION_MIXED = COMPOSITION_GPU | COMPOSITION_HWC }; virtual status_t prepareFrame(CompositionType compositionType) = 0; enum class CompositionType : uint8_t { Unknown = 0, Gpu = 0b1, Hwc = 0b10, Mixed = Gpu | Hwc }; virtual status_t prepareFrame(CompositionType) = 0; // Inform the surface that GPU composition is complete for this frame, and // the surface should make sure that HWComposer has the correct buffer for Loading
services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp +9 −10 Original line number Diff line number Diff line Loading @@ -127,19 +127,18 @@ status_t RenderSurface::beginFrame(bool mustRecompose) { } void RenderSurface::prepareFrame(bool usesClientComposition, bool usesDeviceComposition) { DisplaySurface::CompositionType compositionType; if (usesClientComposition && usesDeviceComposition) { compositionType = DisplaySurface::COMPOSITION_MIXED; } else if (usesClientComposition) { compositionType = DisplaySurface::COMPOSITION_GPU; } else if (usesDeviceComposition) { compositionType = DisplaySurface::COMPOSITION_HWC; } else { const auto compositionType = [=] { using CompositionType = DisplaySurface::CompositionType; if (usesClientComposition && usesDeviceComposition) return CompositionType::Mixed; if (usesClientComposition) return CompositionType::Gpu; if (usesDeviceComposition) return CompositionType::Hwc; // Nothing to do -- when turning the screen off we get a frame like // this. Call it a HWC frame since we won't be doing any GPU work but // will do a prepare/set cycle. compositionType = DisplaySurface::COMPOSITION_HWC; } return CompositionType::Hwc; }(); if (status_t result = mDisplaySurface->prepareFrame(compositionType); result != NO_ERROR) { ALOGE("updateCompositionType failed for %s: %d (%s)", mDisplay.getName().c_str(), result, Loading
services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -201,28 +201,28 @@ TEST_F(RenderSurfaceTest, beginFrameAppliesChange) { */ TEST_F(RenderSurfaceTest, prepareFrameHandlesMixedComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_MIXED)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Mixed)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(true, true); } TEST_F(RenderSurfaceTest, prepareFrameHandlesOnlyGpuComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_GPU)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Gpu)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(true, false); } TEST_F(RenderSurfaceTest, prepareFrameHandlesOnlyHwcComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_HWC)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Hwc)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(false, true); } TEST_F(RenderSurfaceTest, prepareFrameHandlesNoComposition) { EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::COMPOSITION_HWC)) EXPECT_CALL(*mDisplaySurface, prepareFrame(DisplaySurface::CompositionType::Hwc)) .WillOnce(Return(NO_ERROR)); mSurface.prepareFrame(false, false); Loading