diff options
author | Pierre-Hugues Husson <phh@phh.me> | 2020-05-25 10:12:24 +0000 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2020-12-12 02:28:19 +0200 |
commit | 381416d540ea92dca5f64cd48fd8c9dc887cac7b (patch) | |
tree | 2c81966718acc90627b727e396953a376b4637e3 | |
parent | ff2caa1755a75d235a5bc7768677355515b3c62b (diff) |
surfaceflinger: Add support for extension lib
* Supports changed z fod order
* Supports changed fod usage bits
TheScarastic: Adapt to extension lib
Pig: Convert lineage product variables to soong config variables
Co-authored-by: TheScarastic <warabhishek@gmail.com>
Change-Id: Id95aa73e06b4223a6b4f05c69fa2fc494f9a97b1
5 files changed, 86 insertions, 3 deletions
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp index 6e4235e409..87be9a821d 100644 --- a/services/surfaceflinger/BufferQueueLayer.cpp +++ b/services/surfaceflinger/BufferQueueLayer.cpp @@ -24,6 +24,7 @@ #include "BufferQueueLayer.h" #include <compositionengine/LayerFECompositionState.h> +#include <compositionengine/FodExtension.h> #include <gui/BufferQueueConsumer.h> #include <system/window.h> @@ -514,9 +515,17 @@ status_t BufferQueueLayer::setDefaultBufferProperties(uint32_t w, uint32_t h, Pi return BAD_VALUE; } + uint64_t usageBits = getEffectiveUsage(0); + + if (mName == FOD_LAYER_NAME) { + usageBits = getFodUsageBits(usageBits, false); + } else if (mName == FOD_TOUCHED_LAYER_NAME) { + usageBits = getFodUsageBits(usageBits, true); + } + setDefaultBufferSize(w, h); mConsumer->setDefaultBufferFormat(format); - mConsumer->setConsumerUsageBits(getEffectiveUsage(0)); + mConsumer->setConsumerUsageBits(usageBits); return NO_ERROR; } diff --git a/services/surfaceflinger/CompositionEngine/Android.bp b/services/surfaceflinger/CompositionEngine/Android.bp index b3b9fe5981..d205a19df9 100644 --- a/services/surfaceflinger/CompositionEngine/Android.bp +++ b/services/surfaceflinger/CompositionEngine/Android.bp @@ -41,7 +41,10 @@ cc_defaults { cc_library { name: "libcompositionengine", - defaults: ["libcompositionengine_defaults"], + defaults: [ + "libcompositionengine_defaults", + "surfaceflinger_fod_lib_defaults", + ], srcs: [ "src/ClientCompositionRequestCache.cpp", "src/CompositionEngine.cpp", @@ -84,6 +87,14 @@ cc_library { export_include_dirs: ["include"], } +cc_library_static { + name: "surfaceflinger_fod_lib", + srcs: [ + "src/FodExtension.cpp", + ], + export_include_dirs: ["include"], +} + cc_test { name: "libcompositionengine_test", test_suites: ["device-tests"], diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/FodExtension.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/FodExtension.h new file mode 100644 index 0000000000..3585f63d9a --- /dev/null +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/FodExtension.h @@ -0,0 +1,28 @@ +/* + * Copyright 2020 The LineageOS 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 <stdint.h> + +#ifndef __FOD_EXTENSION__H__ +#define __FOD_EXTENSION__H__ + +#define FOD_LAYER_NAME "Fingerprint on display#0" +#define FOD_TOUCHED_LAYER_NAME "Fingerprint on display.touched#0" + +extern uint32_t getFodZOrder(uint32_t z, bool touched); +extern uint64_t getFodUsageBits(uint64_t usageBits, bool touched); + +#endif /* __FOD_EXTENSION__H__ */ diff --git a/services/surfaceflinger/CompositionEngine/src/FodExtension.cpp b/services/surfaceflinger/CompositionEngine/src/FodExtension.cpp new file mode 100644 index 0000000000..dff24c2c67 --- /dev/null +++ b/services/surfaceflinger/CompositionEngine/src/FodExtension.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2020 The LineageOS 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. + */ + +#ifndef TARGET_PROVIDES_FOD_LIB +#include <compositionengine/FodExtension.h> + +uint32_t getFodZOrder(uint32_t z, __unused bool touched) { + return z; +} + +uint64_t getFodUsageBits(uint64_t usageBits, __unused bool touched) { + return usageBits; +} +#endif diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp index 1faf775ed3..ebf651ee8a 100644 --- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp +++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp @@ -16,6 +16,7 @@ #include <android-base/stringprintf.h> #include <compositionengine/DisplayColorProfile.h> +#include <compositionengine/FodExtension.h> #include <compositionengine/LayerFE.h> #include <compositionengine/LayerFECompositionState.h> #include <compositionengine/Output.h> @@ -370,7 +371,14 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC( static_cast<int32_t>(error)); } - if (auto error = hwcLayer->setZOrder(outputDependentState.z); error != hal::Error::NONE) { + uint32_t z = outputDependentState.z; + if (strcmp(getLayerFE().getDebugName(), FOD_LAYER_NAME) == 0) { + z = getFodZOrder(z, false); + } else if (strcmp(getLayerFE().getDebugName(), FOD_TOUCHED_LAYER_NAME) == 0) { + z = getFodZOrder(z, true); + } + + if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) { ALOGE("[%s] Failed to set Z %u: %s (%d)", getLayerFE().getDebugName(), outputDependentState.z, to_string(error).c_str(), static_cast<int32_t>(error)); } |