diff options
| -rw-r--r-- | cmds/cmd/Android.bp | 3 | ||||
| -rw-r--r-- | cmds/cmd/cmd.cpp | 7 | ||||
| -rw-r--r-- | cmds/installd/otapreopt.cpp | 3 | ||||
| -rw-r--r-- | services/surfaceflinger/FrontEnd/RequestedLayerState.cpp | 3 | ||||
| -rw-r--r-- | services/surfaceflinger/Scheduler/LayerHistory.cpp | 4 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp | 88 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp | 13 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp | 2 | ||||
| -rw-r--r-- | vulkan/libvulkan/swapchain.cpp | 36 |
9 files changed, 142 insertions, 17 deletions
diff --git a/cmds/cmd/Android.bp b/cmds/cmd/Android.bp index c3d2601444..27ef78854c 100644 --- a/cmds/cmd/Android.bp +++ b/cmds/cmd/Android.bp @@ -27,6 +27,9 @@ cc_library_static { "libselinux", "libbinder", ], + whole_static_libs: [ + "libc++fs", + ], cflags: [ "-Wall", diff --git a/cmds/cmd/cmd.cpp b/cmds/cmd/cmd.cpp index b7273987b6..0ce7711574 100644 --- a/cmds/cmd/cmd.cpp +++ b/cmds/cmd/cmd.cpp @@ -27,6 +27,7 @@ #include <utils/Mutex.h> #include <utils/Vector.h> +#include <filesystem> #include <getopt.h> #include <stdlib.h> #include <stdio.h> @@ -69,10 +70,8 @@ public: virtual int openFile(const String16& path, const String16& seLinuxContext, const String16& mode) { String8 path8(path); - char cwd[256]; - getcwd(cwd, 256); - String8 fullPath(cwd); - fullPath.appendPath(path8); + auto fullPath = std::filesystem::current_path(); + fullPath /= path8.c_str(); if (!mActive) { mErrorLog << "Open attempt after active for: " << fullPath << endl; return -EPERM; diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp index 27ae8f6e6f..a447cda492 100644 --- a/cmds/installd/otapreopt.cpp +++ b/cmds/installd/otapreopt.cpp @@ -422,7 +422,8 @@ private: bool IsAotCompilation() const { if (std::find(std::begin(kAotCompilerFilters), std::end(kAotCompilerFilters), - parameters_.compiler_filter) == std::end(kAotCompilerFilters)) { + std::string_view(parameters_.compiler_filter)) == + std::end(kAotCompilerFilters)) { return false; } diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp index de3295130a..57ebee92d4 100644 --- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp +++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp @@ -491,6 +491,9 @@ aidl::android::hardware::graphics::composer3::Composition RequestedLayerState::g if (flags & layer_state_t::eLayerIsDisplayDecoration) { return Composition::DISPLAY_DECORATION; } + if (flags & layer_state_t::eLayerIsRefreshRateIndicator) { + return Composition::REFRESH_RATE_INDICATOR; + } if (potentialCursor) { return Composition::CURSOR; } diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp index c92e670aa9..23eb31f1de 100644 --- a/services/surfaceflinger/Scheduler/LayerHistory.cpp +++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp @@ -188,8 +188,8 @@ auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) - const float layerArea = transformed.getWidth() * transformed.getHeight(); float weight = mDisplayArea ? layerArea / mDisplayArea : 0.0f; const std::string categoryString = vote.category == FrameRateCategory::Default - ? base::StringPrintf("category=%s", ftl::enum_string(vote.category).c_str()) - : ""; + ? "" + : base::StringPrintf("category=%s", ftl::enum_string(vote.category).c_str()); ATRACE_FORMAT_INSTANT("%s %s %s (%d%)", ftl::enum_string(vote.type).c_str(), to_string(vote.fps).c_str(), categoryString.c_str(), weight * 100); diff --git a/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp b/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp index d65277a999..1fde9b8efa 100644 --- a/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerLifecycleManagerTest.cpp @@ -17,6 +17,8 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> +#include <renderengine/mock/FakeExternalTexture.h> + #include "FrontEnd/LayerLifecycleManager.h" #include "LayerHierarchyTest.h" #include "TransactionState.h" @@ -25,6 +27,8 @@ using namespace android::surfaceflinger; namespace android::surfaceflinger::frontend { +using namespace ftl::flag_operators; + // To run test: /** mp :libsurfaceflinger_unittest && adb sync; adb shell \ @@ -437,4 +441,88 @@ TEST_F(LayerLifecycleManagerTest, colorSetsVisibilityChangeFlag) { mLifecycleManager.commitChanges(); } +TEST_F(LayerLifecycleManagerTest, layerOpacityChangesSetsVisibilityChangeFlag) { + // add a default buffer and make the layer opaque + setFlags(1, layer_state_t::eLayerOpaque, layer_state_t::eLayerOpaque); + setBuffer(1, + std::make_shared< + renderengine::mock::FakeExternalTexture>(1U /*width*/, 1U /*height*/, + 1ULL /* bufferId */, + HAL_PIXEL_FORMAT_RGBA_8888, + GRALLOC_USAGE_PROTECTED /*usage*/)); + + mLifecycleManager.commitChanges(); + + // set new buffer but layer opacity doesn't change + setBuffer(1, + std::make_shared< + renderengine::mock::FakeExternalTexture>(1U /*width*/, 1U /*height*/, + 2ULL /* bufferId */, + HAL_PIXEL_FORMAT_RGBA_8888, + GRALLOC_USAGE_PROTECTED /*usage*/)); + EXPECT_EQ(mLifecycleManager.getGlobalChanges().get(), + ftl::Flags<RequestedLayerState::Changes>(RequestedLayerState::Changes::Buffer | + RequestedLayerState::Changes::Content) + .get()); + mLifecycleManager.commitChanges(); + + // change layer flags and confirm visibility flag is set + setFlags(1, layer_state_t::eLayerOpaque, 0); + EXPECT_TRUE( + mLifecycleManager.getGlobalChanges().test(RequestedLayerState::Changes::Visibility)); + mLifecycleManager.commitChanges(); +} + +TEST_F(LayerLifecycleManagerTest, bufferFormatChangesSetsVisibilityChangeFlag) { + // add a default buffer and make the layer opaque + setFlags(1, layer_state_t::eLayerOpaque, layer_state_t::eLayerOpaque); + setBuffer(1, + std::make_shared< + renderengine::mock::FakeExternalTexture>(1U /*width*/, 1U /*height*/, + 1ULL /* bufferId */, + HAL_PIXEL_FORMAT_RGBA_8888, + GRALLOC_USAGE_PROTECTED /*usage*/)); + + mLifecycleManager.commitChanges(); + + // set new buffer with an opaque buffer format + setBuffer(1, + std::make_shared< + renderengine::mock::FakeExternalTexture>(1U /*width*/, 1U /*height*/, + 2ULL /* bufferId */, + HAL_PIXEL_FORMAT_RGB_888, + GRALLOC_USAGE_PROTECTED /*usage*/)); + EXPECT_EQ(mLifecycleManager.getGlobalChanges().get(), + ftl::Flags<RequestedLayerState::Changes>(RequestedLayerState::Changes::Buffer | + RequestedLayerState::Changes::Content | + RequestedLayerState::Changes::VisibleRegion | + RequestedLayerState::Changes::Visibility) + .get()); + mLifecycleManager.commitChanges(); +} + +TEST_F(LayerLifecycleManagerTest, roundedCornerChangesSetsVisibilityChangeFlag) { + // add a default buffer and make the layer opaque + setFlags(1, layer_state_t::eLayerOpaque, layer_state_t::eLayerOpaque); + setBuffer(1, + std::make_shared< + renderengine::mock::FakeExternalTexture>(1U /*width*/, 1U /*height*/, + 1ULL /* bufferId */, + HAL_PIXEL_FORMAT_RGBA_8888, + GRALLOC_USAGE_PROTECTED /*usage*/)); + + mLifecycleManager.commitChanges(); + + // add rounded corners which should make the layer translucent + setRoundedCorners(1, 5.f); + EXPECT_EQ(mLifecycleManager.getGlobalChanges().get(), + ftl::Flags<RequestedLayerState::Changes>( + RequestedLayerState::Changes::AffectsChildren | + RequestedLayerState::Changes::Content | + RequestedLayerState::Changes::Geometry | + RequestedLayerState::Changes::VisibleRegion) + .get()); + mLifecycleManager.commitChanges(); +} + } // namespace android::surfaceflinger::frontend diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp index 80d913c812..72ed4c801e 100644 --- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp @@ -770,4 +770,17 @@ TEST_F(LayerSnapshotTest, skipRoundCornersWhenProtected) { EXPECT_EQ(getSnapshot({.id = 1})->roundedCorner.radius.x, 42.f); } +TEST_F(LayerSnapshotTest, setRefreshRateIndicatorCompositionType) { + setFlags(1, layer_state_t::eLayerIsRefreshRateIndicator, + layer_state_t::eLayerIsRefreshRateIndicator); + setBuffer(1, + std::make_shared<renderengine::mock::FakeExternalTexture>(1U /*width*/, 1U /*height*/, + 42ULL /* bufferId */, + HAL_PIXEL_FORMAT_RGBA_8888, + 0 /*usage*/)); + UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER); + EXPECT_EQ(getSnapshot({.id = 1})->compositionType, + aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR); +} + } // namespace android::surfaceflinger::frontend diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp index dbf0cd8772..28162f4d6b 100644 --- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp +++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_CreateDisplayTest.cpp @@ -47,7 +47,7 @@ public: const auto& display = getCurrentDisplayState(displayToken); EXPECT_TRUE(display.isVirtual()); EXPECT_EQ(display.requestedRefreshRate, Fps::fromValue(requestedRefreshRate)); - EXPECT_EQ(name.string(), display.displayName); + EXPECT_EQ(name.c_str(), display.displayName); std::optional<VirtualDisplayId> vid = DisplayId::fromValue<VirtualDisplayId>(displayId | DisplayId::FLAG_VIRTUAL); diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index bffbe9d8d5..7159d83e61 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -944,16 +944,34 @@ VkResult GetPhysicalDeviceSurfaceCapabilities2KHR( return VK_ERROR_SURFACE_LOST_KHR; } - if (pPresentMode && IsSharedPresentMode(pPresentMode->presentMode)) { - capabilities->minImageCount = 1; - capabilities->maxImageCount = 1; - } else if (pPresentMode && pPresentMode->presentMode == VK_PRESENT_MODE_MAILBOX_KHR) { - capabilities->minImageCount = - std::min(max_buffer_count, min_undequeued_buffers + 2); - capabilities->maxImageCount = static_cast<uint32_t>(max_buffer_count); + if(pPresentMode != nullptr) { + switch (pPresentMode->presentMode) { + case VK_PRESENT_MODE_IMMEDIATE_KHR: + ALOGE("Swapchain present mode VK_PRESENT_MODE_IMMEDIATE_KHR is not supported"); + break; + case VK_PRESENT_MODE_MAILBOX_KHR: + case VK_PRESENT_MODE_FIFO_KHR: + capabilities->minImageCount = + std::min(max_buffer_count, min_undequeued_buffers + 2); + capabilities->maxImageCount = static_cast<uint32_t>(max_buffer_count); + break; + case VK_PRESENT_MODE_FIFO_RELAXED_KHR: + ALOGE("Swapchain present mode VK_PRESENT_MODE_FIFO_RELEAXED_KHR " + "is not supported"); + break; + case VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR: + case VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR: + capabilities->minImageCount = 1; + capabilities->maxImageCount = 1; + break; + + default: + ALOGE("Unrecognized swapchain present mode %u is not supported", + pPresentMode->presentMode); + break; + } } else { - capabilities->minImageCount = - std::min(max_buffer_count, min_undequeued_buffers + 1); + capabilities->minImageCount = std::min(max_buffer_count, min_undequeued_buffers + 2); capabilities->maxImageCount = static_cast<uint32_t>(max_buffer_count); } } |