surfaceflinger: Add support for extension lib
* Supports changed z fod order
* Supports changed fod usage bits
TheScarastic: Adapt to extension lib
Co-authored-by: TheScarastic <warabhishek@gmail.com>
Change-Id: Id95aa73e06b4223a6b4f05c69fa2fc494f9a97b1
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index f35a4fd..062f927 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "BufferQueueLayer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <compositionengine/Display.h>
+#include <compositionengine/FodExtension.h>
#include <compositionengine/Layer.h>
#include <compositionengine/OutputLayer.h>
#include <compositionengine/impl/LayerCompositionState.h>
@@ -560,11 +561,19 @@
return BAD_VALUE;
}
+ uint32_t usageBits = 0;
+
+ if (mName == FOD_LAYER_NAME) {
+ usageBits = getFodUsageBits(usageBits, false);
+ } else if (mName == FOD_TOUCHED_LAYER_NAME) {
+ usageBits = getFodUsageBits(usageBits, true);
+ }
+
mFormat = format;
setDefaultBufferSize(w, h);
mConsumer->setDefaultBufferFormat(format);
- mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
+ mConsumer->setConsumerUsageBits(getEffectiveUsage(usageBits));
return NO_ERROR;
}
diff --git a/services/surfaceflinger/CompositionEngine/Android.bp b/services/surfaceflinger/CompositionEngine/Android.bp
index 6f076ad..fd1c369 100644
--- a/services/surfaceflinger/CompositionEngine/Android.bp
+++ b/services/surfaceflinger/CompositionEngine/Android.bp
@@ -45,6 +45,7 @@
"src/DisplayColorProfile.cpp",
"src/DisplaySurface.cpp",
"src/DumpHelpers.cpp",
+ "src/FodExtension.cpp",
"src/HwcBufferCache.cpp",
"src/Layer.cpp",
"src/LayerCompositionState.cpp",
@@ -56,6 +57,15 @@
],
local_include_dirs: ["include"],
export_include_dirs: ["include"],
+ product_variables: {
+ lineage: {
+ target_surfaceflinger_fod_lib: {
+ cflags: ["-DTARGET_PROVIDES_FOD_LIB"],
+ whole_static_libs: ["%s"],
+ },
+ },
+ },
+
}
cc_library {
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/FodExtension.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/FodExtension.h
new file mode 100644
index 0000000..816a059
--- /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 uint32_t getFodUsageBits(uint32_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 0000000..780db4b
--- /dev/null
+++ b/services/surfaceflinger/CompositionEngine/src/FodExtension.cpp
@@ -0,0 +1,29 @@
+/*
+ * 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, bool touched) {
+ (void) touched;
+ return z;
+}
+
+uint32_t getFodUsageBits(uint32_t usageBits, bool touched) {
+ (void) touched;
+ return usageBits;
+}
+#endif
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 5ce72b0..985b598 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/CompositionEngine.h>
+#include <compositionengine/FodExtension.h>
#include <compositionengine/Layer.h>
#include <compositionengine/LayerFE.h>
#include <compositionengine/Output.h>
@@ -335,7 +336,14 @@
static_cast<int32_t>(error));
}
- if (auto error = hwcLayer->setZOrder(mState.z); error != HWC2::Error::None) {
+ uint32_t z = mState.z;
+ if (strcmp(mLayerFE->getDebugName(), FOD_LAYER_NAME) == 0) {
+ z = getFodZOrder(z, false);
+ } else if (strcmp(mLayerFE->getDebugName(), FOD_TOUCHED_LAYER_NAME) == 0) {
+ z = getFodZOrder(z, true);
+ }
+
+ if (auto error = hwcLayer->setZOrder(z); error != HWC2::Error::None) {
ALOGE("[%s] Failed to set Z %u: %s (%d)", mLayerFE->getDebugName(), mState.z,
to_string(error).c_str(), static_cast<int32_t>(error));
}