@@ -1935,4 +1935,54 @@ TEST_F(LayerSnapshotTest, shouldUpdateInputWhenNoInputInfo) {
19351935 EXPECT_FALSE (getSnapshot (2 )->hasInputInfo ());
19361936}
19371937
1938+ // content dirty test
1939+ TEST_F (LayerSnapshotTest, contentDirtyWhenParentAlphaChanges) {
1940+ setAlpha (1 , 0.5 );
1941+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1942+ EXPECT_TRUE (getSnapshot (1 )->contentDirty );
1943+ EXPECT_TRUE (getSnapshot (11 )->contentDirty );
1944+ EXPECT_TRUE (getSnapshot (111 )->contentDirty );
1945+
1946+ // subsequent updates clear the dirty bit
1947+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1948+ EXPECT_FALSE (getSnapshot (1 )->contentDirty );
1949+ EXPECT_FALSE (getSnapshot (11 )->contentDirty );
1950+ EXPECT_FALSE (getSnapshot (111 )->contentDirty );
1951+ }
1952+
1953+ TEST_F (LayerSnapshotTest, contentDirtyWhenAutoRefresh) {
1954+ setAutoRefresh (1 , true );
1955+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1956+ EXPECT_TRUE (getSnapshot (1 )->contentDirty );
1957+
1958+ // subsequent updates don't clear the dirty bit
1959+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1960+ EXPECT_TRUE (getSnapshot (1 )->contentDirty );
1961+
1962+ // second update after removing auto refresh will clear content dirty
1963+ setAutoRefresh (1 , false );
1964+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1965+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1966+ EXPECT_FALSE (getSnapshot (1 )->contentDirty );
1967+ }
1968+
1969+ TEST_F (LayerSnapshotTest, contentDirtyWhenColorChanges) {
1970+ setColor (1 , {1 , 2 , 3 });
1971+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1972+ EXPECT_TRUE (getSnapshot (1 )->contentDirty );
1973+
1974+ // subsequent updates clear the dirty bit
1975+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1976+ EXPECT_FALSE (getSnapshot (1 )->contentDirty );
1977+ }
1978+
1979+ TEST_F (LayerSnapshotTest, contentDirtyWhenParentGeometryChanges) {
1980+ setPosition (1 , 2 , 3 );
1981+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1982+ EXPECT_TRUE (getSnapshot (1 )->contentDirty );
1983+
1984+ // subsequent updates clear the dirty bit
1985+ UPDATE_AND_VERIFY (mSnapshotBuilder , STARTING_ZORDER);
1986+ EXPECT_FALSE (getSnapshot (1 )->contentDirty );
1987+ }
19381988} // namespace android::surfaceflinger::frontend
0 commit comments