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