SF: Introduce LayerCompositionState
This moves the remaining display-independent state from LayerBE.h to a
new LayerFECompositionState state structure.
LayerFECompositionState is also set up as a subset of a new
LayerCompositionState structure, which is owned by each
compositionengine::Layer.
The existing front-end SurfaceFlinger code is minimally adjusted to
store the state in the new structures.
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: I20e4aa1a51b2ccbb19d5a1f0a1fad42ee9b7f41a
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
new file mode 100644
index 0000000..2201bdd
--- /dev/null
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2019 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.
+ */
+
+#pragma once
+
+#include <cstdint>
+
+#include <gui/BufferQueue.h>
+#include <gui/HdrMetadata.h>
+#include <math/mat4.h>
+#include <ui/FloatRect.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicTypes.h>
+#include <ui/Rect.h>
+#include <ui/Region.h>
+#include <ui/Transform.h>
+
+#include "DisplayHardware/ComposerHal.h"
+
+namespace android::compositionengine {
+
+/*
+ * Used by LayerFE::getCompositionState
+ */
+struct LayerFECompositionState {
+ /*
+ * Presentation
+ */
+
+ // The blend mode for this layer
+ Hwc2::IComposerClient::BlendMode blendMode{Hwc2::IComposerClient::BlendMode::INVALID};
+
+ // The alpha value for this layer
+ float alpha{1.f};
+
+ /*
+ * Extra metadata
+ */
+
+ // The type for this layer
+ int type{0};
+
+ // The appId for this layer
+ int appId{0};
+
+ /*
+ * Per-frame content
+ */
+
+ // The type of composition for this layer
+ Hwc2::IComposerClient::Composition compositionType{Hwc2::IComposerClient::Composition::INVALID};
+
+ // The buffer and related state
+ sp<GraphicBuffer> buffer;
+ int bufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
+ sp<Fence> acquireFence;
+ Region surfaceDamage;
+
+ // The handle to use for a sideband stream for this layer
+ sp<NativeHandle> sidebandStream;
+
+ // The color for this layer
+ Hwc2::IComposerClient::Color color;
+
+ /*
+ * Per-frame presentation state
+ */
+
+ // The dataspace for this layer
+ ui::Dataspace dataspace{ui::Dataspace::UNKNOWN};
+
+ // The metadata for this layer
+ HdrMetadata hdrMetadata;
+
+ // The color transform
+ mat4 colorTransform;
+};
+
+} // namespace android::compositionengine