• 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 #ifdef _MSC_VER
20 #include <stdint.h>
21 #endif
22 
23 /* Copied from Android source */
24 
25 // Should be identical to graphics-base-v1.0.h
26 typedef enum {
27     HAL_TRANSFORM_NONE = 0,
28     HAL_TRANSFORM_FLIP_H = 1,   // (1 << 0)
29     HAL_TRANSFORM_FLIP_V = 2,   // (1 << 1)
30     HAL_TRANSFORM_ROT_90 = 4,   // (1 << 2)
31     HAL_TRANSFORM_ROT_180 = 3,  // (FLIP_H | FLIP_V)
32     HAL_TRANSFORM_ROT_270 = 7,  // ((FLIP_H | FLIP_V) | ROT_90)
33 } android_transform_t;
34 
35 // Should be identical to hwcomposer_defs.h
36 typedef struct hwc_color {
37     uint8_t r;
38     uint8_t g;
39     uint8_t b;
40     uint8_t a;
41 } hwc_color_t;
42 typedef struct hwc_frect {
43     float left;
44     float top;
45     float right;
46     float bottom;
47 } hwc_frect_t;
48 typedef struct hwc_rect {
49     int left;
50     int top;
51     int right;
52     int bottom;
53 } hwc_rect_t;
54 
55 typedef enum {
56     /* No transform */
57     HWC_TRANSFORM_NONE = HAL_TRANSFORM_NONE,
58     /* flip source image horizontally */
59     HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
60     /* flip source image vertically */
61     HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
62     /* rotate source image 90 degrees clock-wise */
63     HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
64     /* rotate source image 180 degrees */
65     HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
66     /* rotate source image 270 degrees clock-wise */
67     HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
68     /* flip source image horizontally, the rotate 90 degrees clock-wise */
69     HWC_TRANSFORM_FLIP_H_ROT_90 = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90,
70     /* flip source image vertically, the rotate 90 degrees clock-wise */
71     HWC_TRANSFORM_FLIP_V_ROT_90 = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90,
72 } hwc_transform_t;
73 
74 // Should be identical to hwcomposer2.h
75 typedef enum {
76     HWC2_COMPOSITION_INVALID = 0,
77     HWC2_COMPOSITION_CLIENT = 1,
78     HWC2_COMPOSITION_DEVICE = 2,
79     HWC2_COMPOSITION_SOLID_COLOR = 3,
80     HWC2_COMPOSITION_CURSOR = 4,
81     HWC2_COMPOSITION_SIDEBAND = 5,
82 } hwc2_composition_t;
83 typedef enum {
84     HWC2_BLEND_MODE_INVALID = 0,
85     HWC2_BLEND_MODE_NONE = 1,
86     HWC2_BLEND_MODE_PREMULTIPLIED = 2,
87     HWC2_BLEND_MODE_COVERAGE = 3,
88 } hwc2_blend_mode_t;
89 
90 // Should be identical to EmuHwc2.h
91 typedef struct compose_layer {
92     uint32_t cbHandle;
93     hwc2_composition_t composeMode;
94     hwc_rect_t displayFrame;
95     hwc_frect_t crop;
96     int32_t blendMode;
97     float alpha;
98     hwc_color_t color;
99     hwc_transform_t transform;
100 } ComposeLayer;
101 typedef struct compose_device {
102     uint32_t version;
103     uint32_t targetHandle;
104     uint32_t numLayers;
105     struct compose_layer layer[0];
106 } ComposeDevice;
107 typedef struct compose_device_v2 {
108     uint32_t version;
109     uint32_t displayId;
110     uint32_t targetHandle;
111     uint32_t numLayers;
112     struct compose_layer layer[0];
113 } ComposeDevice_v2;
114 
115 #endif
116