blob: e41632ca3483836edbf60e519f25b7828fe81f7a [file] [log] [blame]
David Sodmanaf8bab12017-12-14 15:30:55 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <stdint.h>
20#include <sys/types.h>
21
Peiyong Lincbc184f2018-08-22 13:24:10 -070022#include <renderengine/Mesh.h>
David Sodmanfb95bcc2017-12-22 15:45:30 -080023#include <renderengine/RenderEngine.h>
Peiyong Lincbc184f2018-08-22 13:24:10 -070024#include <renderengine/Texture.h>
David Sodmanaf8bab12017-12-14 15:30:55 -080025#include <ui/Region.h>
26
Dominik Laskowski075d3172018-05-24 15:50:06 -070027#include "DisplayHardware/DisplayIdentification.h"
David Sodmanaf8bab12017-12-14 15:30:55 -080028#include "DisplayHardware/HWComposer.h"
Peiyong Lincbc184f2018-08-22 13:24:10 -070029#include "SurfaceFlinger.h"
David Sodmanaf8bab12017-12-14 15:30:55 -080030
31namespace android {
32
David Sodmanb8af7922017-12-21 15:17:55 -080033class LayerBE;
34
David Sodmanaf8bab12017-12-14 15:30:55 -080035struct CompositionInfo {
David Sodmanb8af7922017-12-21 15:17:55 -080036 std::string layerName;
David Sodman15094112018-10-11 09:39:37 -070037 HWC2::Composition compositionType;
David Sodmanfb95bcc2017-12-22 15:45:30 -080038 bool firstClear = false;
David Sodmanaf8bab12017-12-14 15:30:55 -080039 sp<GraphicBuffer> mBuffer = nullptr;
40 int mBufferSlot = BufferQueue::INVALID_BUFFER_SLOT;
David Sodman40a3a5a2018-05-16 11:55:52 -070041 std::shared_ptr<LayerBE> layer;
David Sodmanaf8bab12017-12-14 15:30:55 -080042 struct {
Dominik Laskowski075d3172018-05-24 15:50:06 -070043 DisplayId displayId;
David Sodmanaf8bab12017-12-14 15:30:55 -080044 sp<Fence> fence;
45 HWC2::BlendMode blendMode = HWC2::BlendMode::Invalid;
David Sodmanaf8bab12017-12-14 15:30:55 -080046 float alpha;
David Sodmanaf8bab12017-12-14 15:30:55 -080047 HWC2::Transform transform = HWC2::Transform::None;
David Sodmanaf8bab12017-12-14 15:30:55 -080048 int type;
49 int appId;
David Sodmanaf8bab12017-12-14 15:30:55 -080050 Region surfaceDamage;
51 sp<NativeHandle> sidebandStream;
David Sodmanca10ed22018-04-16 14:10:25 -070052 ui::Dataspace dataspace;
David Sodmanaf8bab12017-12-14 15:30:55 -080053 hwc_color_t color;
David Sodmanba340492018-08-05 21:51:33 -070054 bool supportedPerFrameMetadata = false;
55 HdrMetadata hdrMetadata;
Peiyong Lind3788632018-09-18 16:01:31 -070056 mat4 colorTransform;
David Sodmanaf8bab12017-12-14 15:30:55 -080057 } hwc;
58 struct {
David Sodman8725e812018-01-06 15:18:35 -080059 bool blackoutLayer = false;
60 bool clearArea = false;
61 bool preMultipliedAlpha = false;
62 bool opaque = false;
David Sodmanca10ed22018-04-16 14:10:25 -070063 bool disableTexture = false;
David Sodman8725e812018-01-06 15:18:35 -080064 half4 color;
David Sodman8725e812018-01-06 15:18:35 -080065 bool useIdentityTransform = false;
David Sodmanca10ed22018-04-16 14:10:25 -070066 bool Y410BT2020 = false;
David Sodman839d41b2017-12-31 18:44:09 -080067 } re;
David Sodmanb8af7922017-12-21 15:17:55 -080068
69 void dump(const char* tag) const;
David Sodman7e4ae112018-02-09 15:02:28 -080070 void dump(std::string& result, const char* tag = nullptr) const;
71 void dumpHwc(std::string& result, const char* tag = nullptr) const;
72 void dumpRe(std::string& result, const char* tag = nullptr) const;
David Sodmanaf8bab12017-12-14 15:30:55 -080073};
74
75class LayerBE {
76public:
David Sodmanb8af7922017-12-21 15:17:55 -080077 friend class Layer;
78 friend class BufferLayer;
Marissa Wallfd668622018-05-10 10:21:13 -070079 friend class BufferQueueLayer;
Marissa Wall61c58622018-07-18 10:12:20 -070080 friend class BufferStateLayer;
David Sodmanb8af7922017-12-21 15:17:55 -080081 friend class ColorLayer;
82 friend class SurfaceFlinger;
David Sodmanaf8bab12017-12-14 15:30:55 -080083
Lloyd Piqued6b579f2018-04-06 15:29:10 -070084 // For unit tests
85 friend class TestableSurfaceFlinger;
86
David Sodman2b727ac2017-12-21 14:28:08 -080087 LayerBE(Layer* layer, std::string layerName);
David Sodman40a3a5a2018-05-16 11:55:52 -070088 explicit LayerBE(const LayerBE& layer);
David Sodmanb8af7922017-12-21 15:17:55 -080089
90 void onLayerDisplayed(const sp<Fence>& releaseFence);
Peiyong Lin833074a2018-08-28 11:53:54 -070091 void clear(renderengine::RenderEngine& renderEngine);
92 renderengine::Mesh& getMesh() { return mMesh; }
David Sodmanb8af7922017-12-21 15:17:55 -080093
David Sodman10a41ff2018-08-05 12:14:17 -070094 Layer*const mLayer;
David Sodmanc1498e62018-09-12 14:36:26 -070095private:
David Sodmanaf8bab12017-12-14 15:30:55 -080096 // The mesh used to draw the layer in GLES composition mode
Peiyong Lin833074a2018-08-28 11:53:54 -070097 renderengine::Mesh mMesh;
David Sodmanaf8bab12017-12-14 15:30:55 -080098
David Sodmanaf8bab12017-12-14 15:30:55 -080099 CompositionInfo compositionInfo;
100};
101
102}; // namespace android
103