1 /*
2  * Copyright (C) 2011 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 #ifndef ANDROID_HWUI_DRAW_GL_INFO_H
18 #define ANDROID_HWUI_DRAW_GL_INFO_H
19 
20 #include <SkColorSpace.h>
21 #include <SkColorType.h>
22 
23 namespace android {
24 namespace uirenderer {
25 
26 /**
27  * Structure used by OpenGLRenderer::callDrawGLFunction() to pass and
28  * receive data from OpenGL functors.
29  */
30 struct DrawGlInfo {
31     // Input: current clip rect
32     int clipLeft;
33     int clipTop;
34     int clipRight;
35     int clipBottom;
36 
37     // Input: current width/height of destination surface
38     int width;
39     int height;
40 
41     // Input: is the render target an FBO
42     bool isLayer;
43 
44     // Input: current transform matrix, in OpenGL format
45     float transform[16];
46 
47     // Input: Color space.
48     const SkColorSpace* color_space_ptr;
49 
50     // Output: dirty region to redraw
51     float dirtyLeft;
52     float dirtyTop;
53     float dirtyRight;
54     float dirtyBottom;
55 
56     /**
57      * Values used as the "what" parameter of the functor.
58      */
59     enum Mode {
60         // Indicates that the functor is called to perform a draw
61         kModeDraw,
62         // Indicates the the functor is called only to perform
63         // processing and that no draw should be attempted
64         kModeProcess,
65         // Same as kModeProcess, however there is no GL context because it was
66         // lost or destroyed
67         kModeProcessNoContext,
68         // Invoked every time the UI thread pushes over a frame to the render thread
69         // *and the owning view has a dirty display list*. This is a signal to sync
70         // any data that needs to be shared between the UI thread and the render thread.
71         // During this time the UI thread is blocked.
72         kModeSync
73     };
74 
75     /**
76      * Values used by OpenGL functors to tell the framework
77      * what to do next.
78      */
79     enum Status {
80         // The functor is done
81         kStatusDone = 0x0,
82         // DisplayList actually issued GL drawing commands.
83         // This is used to signal the HardwareRenderer that the
84         // buffers should be flipped - otherwise, there were no
85         // changes to the buffer, so no need to flip. Some hardware
86         // has issues with stale buffer contents when no GL
87         // commands are issued.
88         kStatusDrew = 0x4
89     };
90 
91     // The current HDR/SDR ratio that we are rendering to. The transform to SDR will already
92     // be baked into the color_space_ptr, so this is just to indicate the amount of extended
93     // range is available if desired
94     float currentHdrSdrRatio;
95 
96     // Whether or not dithering is globally enabled
97     bool shouldDither;
98 
99     // The color type of the destination framebuffer
100     SkColorType fboColorType;
101 };  // struct DrawGlInfo
102 
103 }  // namespace uirenderer
104 }  // namespace android
105 
106 #endif  // ANDROID_HWUI_DRAW_GL_INFO_H
107