blob: bbeb19ebe438ecf567bb164169182a2f8ff51013 [file] [log] [blame]
Chris Craik6c15ffa2015-02-02 13:50:55 -08001/*
2 * Copyright (C) 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
17#ifndef ANDROID_HWUI_GLOP_H
18#define ANDROID_HWUI_GLOP_H
19
20#include "Matrix.h"
21#include "Rect.h"
22#include "utils/Macros.h"
23
24#include <GLES2/gl2.h>
25#include <GLES2/gl2ext.h>
Chris Craik03188872015-02-02 18:39:33 -080026#include <SkXfermode.h>
Chris Craik6c15ffa2015-02-02 13:50:55 -080027
28namespace android {
29namespace uirenderer {
30
Chris Craik03188872015-02-02 18:39:33 -080031class Program;
32
Chris Craik6c15ffa2015-02-02 13:50:55 -080033/*
34 * Enumerates optional vertex attributes
35 *
36 * Position is always enabled by MeshState, these other attributes
37 * are enabled/disabled dynamically based on mesh content.
38 */
39enum VertexAttribFlags {
40 // NOTE: position attribute always enabled
41 kTextureCoord_Attrib = 1 << 0,
42 kColor_Attrib = 1 << 1,
43 kAlpha_Attrib = 1 << 2,
44};
45
46/**
47 * Structure containing all data required to issue a single OpenGL draw
48 *
49 * Includes all of the mesh, fill, and GL state required to perform
50 * the operation. Pieces of data are either directly copied into the
51 * structure, or stored as a pointer or GL object reference to data
52 * managed
53 */
54// TODO: PREVENT_COPY_AND_ASSIGN(...) or similar
55struct Glop {
56 Rect bounds;
57
58 struct Mesh {
Chris Craik03188872015-02-02 18:39:33 -080059 VertexAttribFlags vertexFlags;
Chris Craik6c15ffa2015-02-02 13:50:55 -080060 GLuint primitiveMode; // GL_TRIANGLES and GL_TRIANGLE_STRIP supported
Chris Craik03188872015-02-02 18:39:33 -080061 GLuint vertexBufferObject;
62 GLuint indexBufferObject;
Chris Craik6c15ffa2015-02-02 13:50:55 -080063 int vertexCount;
64 GLsizei stride;
65 } mesh;
66
67 struct Fill {
68 Program* program;
Chris Craik6c15ffa2015-02-02 13:50:55 -080069
70 struct Color {
71 float a, r, g, b;
72 } color;
73
74 /* TODO
75 union shader {
76 //...
77 }; TODO
78 union filter {
79 //color
80 //matrix + vector
81 };
82 */
83 } fill;
84
85 struct Transform {
86 Matrix4 ortho; // TODO: out of op, since this is static per FBO
87 Matrix4 modelView;
88 Matrix4 canvas;
89 bool offset;
90 } transform;
91
92 struct Blend {
Chris Craik03188872015-02-02 18:39:33 -080093 GLenum src;
94 GLenum dst;
Chris Craik6c15ffa2015-02-02 13:50:55 -080095 } blend;
96
97 /**
98 * Additional render state to enumerate:
99 * - scissor + (bits for whether each of LTRB needed?)
100 * - stencil mode (draw into, mask, count, etc)
101 */
102};
103
104} /* namespace uirenderer */
105} /* namespace android */
106
107#endif // ANDROID_HWUI_GLOP_H