blob: 6b5e004e2143039845d40a8624dd92f6803770bc [file] [log] [blame]
Lingfeng Yangee4aea32020-10-29 08:52:13 -07001/*
2* Copyright (C) 2011-2015 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#ifndef _LIBRENDER_HWC2_H
17#define _LIBRENDER_HWC2_H
18
Jason Macnak4516b942022-05-05 10:57:15 -070019#include <memory>
Lingfeng Yangee4aea32020-10-29 08:52:13 -070020#include <stdint.h>
Jason Macnak4516b942022-05-05 10:57:15 -070021#include <vector>
Lingfeng Yangee4aea32020-10-29 08:52:13 -070022
Jason Macnaked0c9e62023-03-30 15:58:24 -070023namespace gfxstream {
24
Lingfeng Yangee4aea32020-10-29 08:52:13 -070025/* Copied from Android source */
26
27// Should be identical to graphics-base-v1.0.h
28typedef enum {
Lingfeng Yanga5b50bb2021-05-24 10:03:29 -070029 HAL_TRANSFORM_NONE = 0,
Lingfeng Yangee4aea32020-10-29 08:52:13 -070030 HAL_TRANSFORM_FLIP_H = 1, // (1 << 0)
31 HAL_TRANSFORM_FLIP_V = 2, // (1 << 1)
32 HAL_TRANSFORM_ROT_90 = 4, // (1 << 2)
33 HAL_TRANSFORM_ROT_180 = 3, // (FLIP_H | FLIP_V)
34 HAL_TRANSFORM_ROT_270 = 7, // ((FLIP_H | FLIP_V) | ROT_90)
35} android_transform_t;
36
37// Should be identical to hwcomposer_defs.h
38typedef struct hwc_color {
39 uint8_t r;
40 uint8_t g;
41 uint8_t b;
42 uint8_t a;
43} hwc_color_t;
44typedef struct hwc_frect {
45 float left;
46 float top;
47 float right;
48 float bottom;
49} hwc_frect_t;
50typedef struct hwc_rect {
51 int left;
52 int top;
53 int right;
54 int bottom;
55} hwc_rect_t;
56
57typedef enum {
Lingfeng Yanga5b50bb2021-05-24 10:03:29 -070058 /* No transform */
59 HWC_TRANSFORM_NONE = HAL_TRANSFORM_NONE,
Lingfeng Yangee4aea32020-10-29 08:52:13 -070060 /* flip source image horizontally */
61 HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
62 /* flip source image vertically */
63 HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
64 /* rotate source image 90 degrees clock-wise */
65 HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
66 /* rotate source image 180 degrees */
67 HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
68 /* rotate source image 270 degrees clock-wise */
69 HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
70 /* flip source image horizontally, the rotate 90 degrees clock-wise */
71 HWC_TRANSFORM_FLIP_H_ROT_90 = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90,
72 /* flip source image vertically, the rotate 90 degrees clock-wise */
73 HWC_TRANSFORM_FLIP_V_ROT_90 = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90,
74} hwc_transform_t;
75
76// Should be identical to hwcomposer2.h
77typedef enum {
78 HWC2_COMPOSITION_INVALID = 0,
79 HWC2_COMPOSITION_CLIENT = 1,
80 HWC2_COMPOSITION_DEVICE = 2,
81 HWC2_COMPOSITION_SOLID_COLOR = 3,
82 HWC2_COMPOSITION_CURSOR = 4,
83 HWC2_COMPOSITION_SIDEBAND = 5,
84} hwc2_composition_t;
85typedef enum {
86 HWC2_BLEND_MODE_INVALID = 0,
87 HWC2_BLEND_MODE_NONE = 1,
88 HWC2_BLEND_MODE_PREMULTIPLIED = 2,
89 HWC2_BLEND_MODE_COVERAGE = 3,
90} hwc2_blend_mode_t;
91
92// Should be identical to EmuHwc2.h
93typedef struct compose_layer {
94 uint32_t cbHandle;
95 hwc2_composition_t composeMode;
96 hwc_rect_t displayFrame;
97 hwc_frect_t crop;
98 int32_t blendMode;
99 float alpha;
100 hwc_color_t color;
101 hwc_transform_t transform;
102} ComposeLayer;
103typedef struct compose_device {
104 uint32_t version;
105 uint32_t targetHandle;
106 uint32_t numLayers;
107 struct compose_layer layer[0];
108} ComposeDevice;
109typedef struct compose_device_v2 {
110 uint32_t version;
111 uint32_t displayId;
112 uint32_t targetHandle;
113 uint32_t numLayers;
114 struct compose_layer layer[0];
115} ComposeDevice_v2;
116
Jason Macnak4516b942022-05-05 10:57:15 -0700117typedef struct FlatComposeRequest {
118 uint32_t displayId;
119 uint32_t targetHandle;
120 std::vector<ComposeLayer> layers;
121} FlatComposeRequest;
122std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(const ComposeDevice* in);
123std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(const ComposeDevice_v2* in);
124
Jason Macnaked0c9e62023-03-30 15:58:24 -0700125} // namespace gfxstream
126
Lingfeng Yangee4aea32020-10-29 08:52:13 -0700127#endif