Merge "SF: explicitly mark surface frame without a composite as non janky" into main
diff --git a/cmds/cmd/fuzzer/cmd_fuzzer.cpp b/cmds/cmd/fuzzer/cmd_fuzzer.cpp
index ab514a1..72b295b 100644
--- a/cmds/cmd/fuzzer/cmd_fuzzer.cpp
+++ b/cmds/cmd/fuzzer/cmd_fuzzer.cpp
@@ -58,6 +58,12 @@
while (mFDP->remaining_bytes() > 0) {
size_t sizestr = mFDP->ConsumeIntegralInRange<size_t>(1, mFDP->remaining_bytes());
string argument = mFDP->ConsumeBytesAsString(sizestr);
+ /**
+ * Filtering out strings based on "-w" argument. Since it leads to timeout.
+ */
+ if(strcmp(argument.c_str(), "-w") == 0) {
+ continue;
+ }
arguments.emplace_back(argument);
}
}
diff --git a/libs/binder/tests/binderSafeInterfaceTest.cpp b/libs/binder/tests/binderSafeInterfaceTest.cpp
index 41cb552..0aa678d 100644
--- a/libs/binder/tests/binderSafeInterfaceTest.cpp
+++ b/libs/binder/tests/binderSafeInterfaceTest.cpp
@@ -723,7 +723,7 @@
ASSERT_EQ(a.getValue() + 1, aPlusOne.getValue());
}
-TEST_F(SafeInterfaceTest, TestIncremementParcelableVector) {
+TEST_F(SafeInterfaceTest, TestIncrementParcelableVector) {
const std::vector<TestParcelable> a{TestParcelable{1}, TestParcelable{2}};
std::vector<TestParcelable> aPlusOne;
status_t result = mSafeInterfaceTest->increment(a, &aPlusOne);
diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp
index 704ea46..476b5cf 100644
--- a/libs/input/tests/InputEvent_test.cpp
+++ b/libs/input/tests/InputEvent_test.cpp
@@ -858,11 +858,10 @@
pointerCoords.back().setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, dy);
nsecs_t eventTime = systemTime(SYSTEM_TIME_MONOTONIC);
MotionEvent event;
- event.initialize(InputEvent::nextId(), /* deviceId */ 1, source, ui::LogicalDisplayId::DEFAULT,
- INVALID_HMAC, action,
- /* actionButton */ 0, /* flags */ 0, /* edgeFlags */ 0, AMETA_NONE,
- /* buttonState */ 0, MotionClassification::NONE, transform,
- /* xPrecision */ 0, /* yPrecision */ 0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
+ event.initialize(InputEvent::nextId(), /*deviceId=*/1, source, ui::LogicalDisplayId::DEFAULT,
+ INVALID_HMAC, action, /*actionButton=*/0, /*flags=*/0, /*edgeFlags=*/0,
+ AMETA_NONE, /*buttonState=*/0, MotionClassification::NONE, transform,
+ /*xPrecision=*/0, /*yPrecision=*/0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
AMOTION_EVENT_INVALID_CURSOR_POSITION, rawTransform, eventTime, eventTime,
pointerCoords.size(), pointerProperties.data(), pointerCoords.data());
return event;
diff --git a/libs/renderengine/skia/filters/KawaseBlurFilter.cpp b/libs/renderengine/skia/filters/KawaseBlurFilter.cpp
index 2d68840..7a070d7 100644
--- a/libs/renderengine/skia/filters/KawaseBlurFilter.cpp
+++ b/libs/renderengine/skia/filters/KawaseBlurFilter.cpp
@@ -120,7 +120,7 @@
surfaceTwo = surface->makeSurface(scaledInfo);
LOG_ALWAYS_FATAL_IF(!surfaceTwo, "%s: Failed to create second blur surface!", __func__);
- for (auto i = 2; i <= numberOfPasses; i++) {
+ for (auto i = 1; i < numberOfPasses; i++) {
LOG_ALWAYS_FATAL_IF(tmpBlur == nullptr, "%s: tmpBlur is null for pass %d", __func__, i);
blurBuilder.child("child") =
tmpBlur->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, linear);
diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp
index 30c1430..cb8b016 100644
--- a/libs/renderengine/tests/RenderEngineTest.cpp
+++ b/libs/renderengine/tests/RenderEngineTest.cpp
@@ -1066,7 +1066,7 @@
template <typename SourceVariant>
void RenderEngineTest::fillBufferAndBlurBackground() {
- auto blurRadius = 30;
+ auto blurRadius = 50;
auto center = DEFAULT_DISPLAY_WIDTH / 2;
renderengine::DisplaySettings settings;
diff --git a/libs/ui/include/ui/LogicalDisplayId.h b/libs/ui/include/ui/LogicalDisplayId.h
index d745758..fd84b12 100644
--- a/libs/ui/include/ui/LogicalDisplayId.h
+++ b/libs/ui/include/ui/LogicalDisplayId.h
@@ -43,13 +43,6 @@
constexpr inline LogicalDisplayId LogicalDisplayId::INVALID{-1};
constexpr inline LogicalDisplayId LogicalDisplayId::DEFAULT{0};
-/**
- * Deprecated! Use LogicalDisplayId::INVALID / LogicalDisplayId::DEFAULT instead.
- * TODO(b/339106983): remove these.
- */
-[[deprecated]] constexpr LogicalDisplayId ADISPLAY_ID_NONE{-1};
-[[deprecated]] constexpr LogicalDisplayId ADISPLAY_ID_DEFAULT{0};
-
inline std::ostream& operator<<(std::ostream& stream, LogicalDisplayId displayId) {
return stream << displayId.val();
}
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index 2a580c9..b8911db 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -183,7 +183,6 @@
static AStatsManager_PullAtomCallbackReturn pullAtomCallback(int32_t atomTag,
AStatsEventList* outEventList,
void* cookie) {
- ALOGI("Received pull request for touchpad usage atom");
LOG_ALWAYS_FATAL_IF(atomTag != android::util::TOUCHPAD_USAGE);
MetricsAccumulator& accumulator = MetricsAccumulator::getInstance();
accumulator.produceAtomsAndReset(*outEventList);
@@ -191,14 +190,12 @@
}
void produceAtomsAndReset(AStatsEventList& outEventList) {
- ALOGI("Acquiring lock for touchpad usage metrics...");
std::scoped_lock lock(mLock);
produceAtomsLocked(outEventList);
resetCountersLocked();
}
void produceAtomsLocked(AStatsEventList& outEventList) const REQUIRES(mLock) {
- ALOGI("Producing touchpad usage atoms for %zu counters", mCounters.size());
for (auto& [id, counters] : mCounters) {
auto [busId, vendorId, productId, versionId] = id;
addAStatsEvent(&outEventList, android::util::TOUCHPAD_USAGE, vendorId, productId,
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index ff95857..e8e7376 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -331,6 +331,7 @@
out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
+ coords.clear();
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
NotifyMotionArgs args =
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index 2f9036f..d0cd677 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -441,6 +441,43 @@
EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), WithGestureScrollDistance(0, 0, EPSILON));
}
+TEST_F(GestureConverterTest, Scroll_ClearsFakeFingerPositionOnSubsequentScrollGestures) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+ converter.setDisplayId(ui::LogicalDisplayId::DEFAULT);
+
+ Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 15, -10);
+ std::list<NotifyArgs> args =
+ converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
+
+ Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -2, -5);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
+
+ Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
+ GESTURES_FLING_START);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
+ Gesture flingGestureEnd(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, 0,
+ GESTURES_FLING_TAP_DOWN);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGestureEnd);
+
+ // Start a second scoll gesture, and ensure the fake finger is reset to (0, 0), instead of
+ // continuing from the position where the last scroll gesture's fake finger ended.
+ Gesture secondScrollStart(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 2,
+ 14);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, secondScrollStart);
+ ASSERT_THAT(args,
+ ElementsAre(VariantWith<NotifyMotionArgs>(
+ WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT)),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
+ WithCoords(0, 0),
+ WithGestureScrollDistance(0, 0, EPSILON))),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
+ WithCoords(2, 14),
+ WithGestureScrollDistance(-2, -14, EPSILON)))));
+}
+
TEST_F(GestureConverterTest, ThreeFingerSwipe_ClearsClassificationAfterGesture) {
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
diff --git a/services/surfaceflinger/Effects/Daltonizer.cpp b/services/surfaceflinger/Effects/Daltonizer.cpp
index a7090c5..65f2605 100644
--- a/services/surfaceflinger/Effects/Daltonizer.cpp
+++ b/services/surfaceflinger/Effects/Daltonizer.cpp
@@ -37,6 +37,18 @@
}
}
+void Daltonizer::setLevel(int32_t level) {
+ if (level < 0 || level > 10) {
+ return;
+ }
+
+ float newLevel = level / 10.0f;
+ if (std::fabs(mLevel - newLevel) > 0.09f) {
+ mDirty = true;
+ }
+ mLevel = newLevel;
+}
+
const mat4& Daltonizer::operator()() {
if (mDirty) {
mDirty = false;
@@ -117,25 +129,24 @@
// a color blind user and "spread" this error onto the healthy cones.
// The matrices below perform this last step and have been chosen arbitrarily.
- // The amount of correction can be adjusted here.
-
+ // Scale 0 represents no change (mColorTransform is identical matrix).
// error spread for protanopia
- const mat4 errp( 1.0, 0.7, 0.7, 0,
- 0.0, 1.0, 0.0, 0,
- 0.0, 0.0, 1.0, 0,
- 0, 0, 0, 1);
+ const mat4 errp(1.0, mLevel, mLevel, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
// error spread for deuteranopia
- const mat4 errd( 1.0, 0.0, 0.0, 0,
- 0.7, 1.0, 0.7, 0,
- 0.0, 0.0, 1.0, 0,
- 0, 0, 0, 1);
+ const mat4 errd( 1.0, 0.0, 0.0, 0.0,
+ mLevel, 1.0, mLevel, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
// error spread for tritanopia
- const mat4 errt( 1.0, 0.0, 0.0, 0,
- 0.0, 1.0, 0.0, 0,
- 0.7, 0.7, 1.0, 0,
- 0, 0, 0, 1);
+ const mat4 errt( 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ mLevel, mLevel, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
// And the magic happens here...
// We construct the matrix that will perform the whole correction.
diff --git a/services/surfaceflinger/Effects/Daltonizer.h b/services/surfaceflinger/Effects/Daltonizer.h
index 2fb60e9..f5eaae7 100644
--- a/services/surfaceflinger/Effects/Daltonizer.h
+++ b/services/surfaceflinger/Effects/Daltonizer.h
@@ -21,6 +21,9 @@
namespace android {
+// Forward declare test class
+class DaltonizerTest;
+
enum class ColorBlindnessType {
None, // Disables the Daltonizer
Protanomaly, // L (red) cone deficient
@@ -37,10 +40,15 @@
public:
void setType(ColorBlindnessType type);
void setMode(ColorBlindnessMode mode);
+ // sets level for correction saturation, [0-10].
+ void setLevel(int32_t level);
// returns the color transform to apply in the shader
const mat4& operator()();
+ // For testing.
+ friend class DaltonizerTest;
+
private:
void update();
@@ -48,6 +56,8 @@
ColorBlindnessMode mMode = ColorBlindnessMode::Simulation;
bool mDirty = true;
mat4 mColorTransform;
+ // level of error spreading, [0.0-1.0].
+ float mLevel = 0.7f;
};
} /* namespace android */
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index e40c79c..f2497d4 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -362,6 +362,7 @@
snapshot.gameMode = gui::GameMode::Unsupported;
snapshot.frameRate = {};
snapshot.fixedTransformHint = ui::Transform::ROT_INVALID;
+ snapshot.ignoreLocalTransform = false;
return snapshot;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 410c420..33dbab0 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -7143,6 +7143,7 @@
Mutex::Autolock _l(mStateLock);
// daltonize
n = data.readInt32();
+ mDaltonizer.setLevel(data.readInt32());
switch (n % 10) {
case 1:
mDaltonizer.setType(ColorBlindnessType::Protanomaly);
diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp
index 0ea0824..d97d433 100644
--- a/services/surfaceflinger/tests/MirrorLayer_test.cpp
+++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp
@@ -19,6 +19,7 @@
#pragma clang diagnostic ignored "-Wconversion"
#include <android-base/properties.h>
+#include <common/FlagManager.h>
#include <private/android_filesystem_config.h>
#include "LayerTransactionTest.h"
#include "utils/TransactionUtils.h"
@@ -78,6 +79,10 @@
.show(mirrorLayer)
.apply();
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 550, 550).apply();
+ }
+
{
SCOPED_TRACE("Initial Mirror");
auto shot = screenshot();
@@ -172,6 +177,9 @@
.show(mirrorLayer)
.apply();
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 550, 550).apply();
+ }
{
SCOPED_TRACE("Initial Mirror BufferQueueLayer");
auto shot = screenshot();
@@ -263,6 +271,9 @@
.setLayer(mirrorLayer, INT32_MAX - 1)
.apply();
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 550, 550).apply();
+ }
{
SCOPED_TRACE("Offscreen Mirror");
auto shot = screenshot();
@@ -313,8 +324,15 @@
ASSERT_NE(mirrorLayer, nullptr);
}
+ sp<SurfaceControl> mirrorParent =
+ createLayer("Grandchild layer", 50, 50, ISurfaceComposerClient::eFXSurfaceBufferState);
+
// Show the mirror layer, but don't reparent to a layer on screen.
- Transaction().show(mirrorLayer).apply();
+ Transaction().reparent(mirrorLayer, mirrorParent).show(mirrorLayer).apply();
+
+ if (FlagManager::getInstance().detached_mirror()) {
+ Transaction().setPosition(mirrorLayer, 50, 50).apply();
+ }
{
SCOPED_TRACE("Offscreen Mirror");
@@ -331,7 +349,7 @@
SCOPED_TRACE("Capture Mirror");
// Capture just the mirror layer and child.
LayerCaptureArgs captureArgs;
- captureArgs.layerHandle = mirrorLayer->getHandle();
+ captureArgs.layerHandle = mirrorParent->getHandle();
captureArgs.sourceCrop = childBounds;
std::unique_ptr<ScreenCapture> shot;
ScreenCapture::captureLayers(&shot, captureArgs);
diff --git a/services/surfaceflinger/tests/unittests/Android.bp b/services/surfaceflinger/tests/unittests/Android.bp
index 0c13db3..5145e11 100644
--- a/services/surfaceflinger/tests/unittests/Android.bp
+++ b/services/surfaceflinger/tests/unittests/Android.bp
@@ -66,6 +66,7 @@
"BackgroundExecutorTest.cpp",
"CommitTest.cpp",
"CompositionTest.cpp",
+ "DaltonizerTest.cpp",
"DisplayIdGeneratorTest.cpp",
"DisplayTransactionTest.cpp",
"DisplayDevice_GetBestColorModeTest.cpp",
diff --git a/services/surfaceflinger/tests/unittests/DaltonizerTest.cpp b/services/surfaceflinger/tests/unittests/DaltonizerTest.cpp
new file mode 100644
index 0000000..9f632a1
--- /dev/null
+++ b/services/surfaceflinger/tests/unittests/DaltonizerTest.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <math/mat4.h>
+#include <cmath>
+#include "Effects/Daltonizer.h"
+
+namespace android {
+
+class DaltonizerTest {
+private:
+ Daltonizer& mDaltonizer;
+
+public:
+ DaltonizerTest(Daltonizer& daltonizer) : mDaltonizer(daltonizer) {}
+
+ bool isDirty() const { return mDaltonizer.mDirty; }
+
+ float getLevel() const { return mDaltonizer.mLevel; }
+
+ ColorBlindnessType getType() const { return mDaltonizer.mType; }
+};
+
+constexpr float TOLERANCE = 0.01f;
+
+static bool isIdentityMatrix(mat4& matrix) {
+ for (size_t i = 0; i < 4; ++i) {
+ for (size_t j = 0; j < 4; ++j) {
+ if (i == j) {
+ // Check diagonal elements
+ if (std::fabs(matrix[i][j] - 1.0f) > TOLERANCE) {
+ return false;
+ }
+ } else {
+ // Check off-diagonal elements
+ if (std::fabs(matrix[i][j]) > TOLERANCE) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+// Test Suite Name : DaltonizerTest, Test name: ConstructionDefaultValues
+TEST(DaltonizerTest, ConstructionDefaultValues) {
+ Daltonizer daltonizer;
+ DaltonizerTest test(daltonizer);
+
+ EXPECT_EQ(test.getLevel(), 0.7f);
+ ASSERT_TRUE(test.isDirty());
+ EXPECT_EQ(test.getType(), ColorBlindnessType::None);
+ mat4 matrix = daltonizer();
+ ASSERT_TRUE(isIdentityMatrix(matrix));
+}
+
+TEST(DaltonizerTest, NotDirtyAfterColorMatrixReturned) {
+ Daltonizer daltonizer;
+
+ mat4 matrix = daltonizer();
+ DaltonizerTest test(daltonizer);
+
+ ASSERT_FALSE(test.isDirty());
+ ASSERT_TRUE(isIdentityMatrix(matrix));
+}
+
+TEST(DaltonizerTest, LevelOutOfRangeTooLowIgnored) {
+ Daltonizer daltonizer;
+ // Get matrix to reset isDirty == false.
+ mat4 matrix = daltonizer();
+
+ daltonizer.setLevel(-1);
+ DaltonizerTest test(daltonizer);
+
+ EXPECT_EQ(test.getLevel(), 0.7f);
+ ASSERT_FALSE(test.isDirty());
+}
+
+TEST(DaltonizerTest, LevelOutOfRangeTooHighIgnored) {
+ Daltonizer daltonizer;
+ // Get matrix to reset isDirty == false.
+ mat4 matrix = daltonizer();
+
+ daltonizer.setLevel(11);
+ DaltonizerTest test(daltonizer);
+
+ EXPECT_EQ(test.getLevel(), 0.7f);
+ ASSERT_FALSE(test.isDirty());
+}
+
+TEST(DaltonizerTest, ColorCorrectionMatrixNonIdentical) {
+ Daltonizer daltonizer;
+ daltonizer.setType(ColorBlindnessType::Protanomaly);
+ daltonizer.setMode(ColorBlindnessMode::Correction);
+
+ mat4 matrix = daltonizer();
+
+ ASSERT_FALSE(isIdentityMatrix(matrix));
+}
+
+TEST(DaltonizerTest, LevelZeroColorMatrixEqIdentityMatrix) {
+ Daltonizer daltonizer;
+ daltonizer.setType(ColorBlindnessType::Protanomaly);
+ daltonizer.setMode(ColorBlindnessMode::Correction);
+ daltonizer.setLevel(0);
+
+ mat4 matrix = daltonizer();
+
+ ASSERT_TRUE(isIdentityMatrix(matrix));
+}
+
+} /* namespace android */