• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
19 #include <memory>
20 #include <stdint.h>
21 #include <vector>
22 
23 namespace gfxstream {
24 
25 /* Copied from Android source */
26 
27 // Should be identical to graphics-base-v1.0.h
28 typedef enum {
29     HAL_TRANSFORM_NONE = 0,
30     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
38 typedef struct hwc_color {
39     uint8_t r;
40     uint8_t g;
41     uint8_t b;
42     uint8_t a;
43 } hwc_color_t;
44 typedef struct hwc_frect {
45     float left;
46     float top;
47     float right;
48     float bottom;
49 } hwc_frect_t;
50 typedef struct hwc_rect {
51     int left;
52     int top;
53     int right;
54     int bottom;
55 } hwc_rect_t;
56 
57 typedef enum {
58     /* No transform */
59     HWC_TRANSFORM_NONE = HAL_TRANSFORM_NONE,
60     /* 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
77 typedef 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;
85 typedef 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
93 typedef 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;
103 typedef struct compose_device {
104     uint32_t version;
105     uint32_t targetHandle;
106     uint32_t numLayers;
107     struct compose_layer layer[0];
108 } ComposeDevice;
109 typedef 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 
117 typedef struct FlatComposeRequest {
118     uint32_t displayId;
119     uint32_t targetHandle;
120     std::vector<ComposeLayer> layers;
121 } FlatComposeRequest;
122 std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(const ComposeDevice* in);
123 std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(const ComposeDevice_v2* in);
124 
125 }  // namespace gfxstream
126 
127 #endif
128