Loading aidl/gui/android/view/LayerMetadataKey.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -26,4 +26,5 @@ enum LayerMetadataKey { METADATA_ACCESSIBILITY_ID = 5, METADATA_OWNER_PID = 6, METADATA_DEQUEUE_TIME = 7, METADATA_GAME_MODE = 8, } libs/gui/LayerMetadata.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,8 @@ std::string LayerMetadata::itemToString(uint32_t key, const char* separator) con return StringPrintf("ownerPID%s%d", separator, getInt32(key, 0)); case view::LayerMetadataKey::METADATA_DEQUEUE_TIME: return StringPrintf("dequeueTime%s%" PRId64, separator, *getInt64(key)); case view::LayerMetadataKey::METADATA_GAME_MODE: return StringPrintf("gameMode%s%d", separator, getInt32(key, 0)); default: return StringPrintf("%d%s%dbytes", key, separator, static_cast<int>(mMap.at(key).size())); Loading libs/gui/include/gui/LayerMetadata.h +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ enum { METADATA_MOUSE_CURSOR = 4, METADATA_ACCESSIBILITY_ID = 5, METADATA_OWNER_PID = 6, METADATA_DEQUEUE_TIME = 7 METADATA_DEQUEUE_TIME = 7, METADATA_GAME_MODE = 8 }; struct LayerMetadata : public Parcelable { Loading services/surfaceflinger/Layer.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -1652,12 +1652,25 @@ size_t Layer::getChildrenCount() const { return count; } void Layer::setGameModeForTree(int parentGameMode) { int gameMode = parentGameMode; auto& currentState = getCurrentState(); if (currentState.metadata.has(METADATA_GAME_MODE)) { gameMode = currentState.metadata.getInt32(METADATA_GAME_MODE, 0); } setGameMode(gameMode); for (const sp<Layer>& child : mCurrentChildren) { child->setGameModeForTree(gameMode); } } void Layer::addChild(const sp<Layer>& layer) { mChildrenChanged = true; setTransactionFlags(eTransactionNeeded); mCurrentChildren.add(layer); layer->setParent(this); layer->setGameModeForTree(mGameMode); updateTreeHasFrameRateVote(); } Loading @@ -1669,6 +1682,7 @@ ssize_t Layer::removeChild(const sp<Layer>& layer) { const auto removeResult = mCurrentChildren.remove(layer); updateTreeHasFrameRateVote(); layer->setGameModeForTree(0); layer->updateTreeHasFrameRateVote(); return removeResult; Loading services/surfaceflinger/Layer.h +11 −0 Original line number Diff line number Diff line Loading @@ -847,6 +847,13 @@ public: */ bool hasInputInfo() const; // Sets the parent's gameMode for this layer and all its children. Parent's gameMode is applied // only to layers that do not have the GAME_MODE_METADATA set by WMShell. Any layer(along with // its children) that has the metadata set will use the gameMode from the metadata. void setGameModeForTree(int parentGameMode); void setGameMode(int gameMode) { mGameMode = gameMode; }; int getGameMode() const { return mGameMode; } virtual uid_t getOwnerUid() const { return mOwnerUid; } pid_t getOwnerPid() { return mOwnerPid; } Loading Loading @@ -1089,6 +1096,10 @@ private: // shadow radius is the set shadow radius, otherwise its the parent's shadow radius. float mEffectiveShadowRadius = 0.f; // Game mode for the layer. Set by WindowManagerShell, game mode is used in // metrics(SurfaceFlingerStats). int mGameMode = 0; // A list of regions on this layer that should have blurs. const std::vector<BlurRegion> getBlurRegions() const; }; Loading Loading
aidl/gui/android/view/LayerMetadataKey.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -26,4 +26,5 @@ enum LayerMetadataKey { METADATA_ACCESSIBILITY_ID = 5, METADATA_OWNER_PID = 6, METADATA_DEQUEUE_TIME = 7, METADATA_GAME_MODE = 8, }
libs/gui/LayerMetadata.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,8 @@ std::string LayerMetadata::itemToString(uint32_t key, const char* separator) con return StringPrintf("ownerPID%s%d", separator, getInt32(key, 0)); case view::LayerMetadataKey::METADATA_DEQUEUE_TIME: return StringPrintf("dequeueTime%s%" PRId64, separator, *getInt64(key)); case view::LayerMetadataKey::METADATA_GAME_MODE: return StringPrintf("gameMode%s%d", separator, getInt32(key, 0)); default: return StringPrintf("%d%s%dbytes", key, separator, static_cast<int>(mMap.at(key).size())); Loading
libs/gui/include/gui/LayerMetadata.h +2 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,8 @@ enum { METADATA_MOUSE_CURSOR = 4, METADATA_ACCESSIBILITY_ID = 5, METADATA_OWNER_PID = 6, METADATA_DEQUEUE_TIME = 7 METADATA_DEQUEUE_TIME = 7, METADATA_GAME_MODE = 8 }; struct LayerMetadata : public Parcelable { Loading
services/surfaceflinger/Layer.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -1652,12 +1652,25 @@ size_t Layer::getChildrenCount() const { return count; } void Layer::setGameModeForTree(int parentGameMode) { int gameMode = parentGameMode; auto& currentState = getCurrentState(); if (currentState.metadata.has(METADATA_GAME_MODE)) { gameMode = currentState.metadata.getInt32(METADATA_GAME_MODE, 0); } setGameMode(gameMode); for (const sp<Layer>& child : mCurrentChildren) { child->setGameModeForTree(gameMode); } } void Layer::addChild(const sp<Layer>& layer) { mChildrenChanged = true; setTransactionFlags(eTransactionNeeded); mCurrentChildren.add(layer); layer->setParent(this); layer->setGameModeForTree(mGameMode); updateTreeHasFrameRateVote(); } Loading @@ -1669,6 +1682,7 @@ ssize_t Layer::removeChild(const sp<Layer>& layer) { const auto removeResult = mCurrentChildren.remove(layer); updateTreeHasFrameRateVote(); layer->setGameModeForTree(0); layer->updateTreeHasFrameRateVote(); return removeResult; Loading
services/surfaceflinger/Layer.h +11 −0 Original line number Diff line number Diff line Loading @@ -847,6 +847,13 @@ public: */ bool hasInputInfo() const; // Sets the parent's gameMode for this layer and all its children. Parent's gameMode is applied // only to layers that do not have the GAME_MODE_METADATA set by WMShell. Any layer(along with // its children) that has the metadata set will use the gameMode from the metadata. void setGameModeForTree(int parentGameMode); void setGameMode(int gameMode) { mGameMode = gameMode; }; int getGameMode() const { return mGameMode; } virtual uid_t getOwnerUid() const { return mOwnerUid; } pid_t getOwnerPid() { return mOwnerPid; } Loading Loading @@ -1089,6 +1096,10 @@ private: // shadow radius is the set shadow radius, otherwise its the parent's shadow radius. float mEffectiveShadowRadius = 0.f; // Game mode for the layer. Set by WindowManagerShell, game mode is used in // metrics(SurfaceFlingerStats). int mGameMode = 0; // A list of regions on this layer that should have blurs. const std::vector<BlurRegion> getBlurRegions() const; }; Loading