Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52828486 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Automerger Merge Worker
Browse files

Merge "SF - plumbing game mode for metrics (Part 1)" into sc-dev am: dc63047b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14684892

Change-Id: I08f54a2a7f65754cda8d7b569cff1f02a3bc6783
parents 51882e97 dc63047b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,4 +26,5 @@ enum LayerMetadataKey {
    METADATA_ACCESSIBILITY_ID = 5,
    METADATA_OWNER_PID = 6,
    METADATA_DEQUEUE_TIME = 7,
    METADATA_GAME_MODE = 8,
}
+2 −0
Original line number Diff line number Diff line
@@ -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()));
+2 −1
Original line number Diff line number Diff line
@@ -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 {
+14 −0
Original line number Diff line number Diff line
@@ -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();
}

@@ -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;
+11 −0
Original line number Diff line number Diff line
@@ -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; }
@@ -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