2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_HWUI_GLOP_H
18 #define ANDROID_HWUI_GLOP_H
20 #include "FloatColor.h"
24 #include "SkiaShader.h"
25 #include "utils/Macros.h"
27 #include <GLES2/gl2.h>
28 #include <GLES2/gl2ext.h>
29 #include <SkXfermode.h>
32 namespace uirenderer {
35 class RoundRectClipState;
39 * Enumerates optional vertex attributes
41 * Position is always enabled by MeshState, these other attributes
42 * are enabled/disabled dynamically based on mesh content.
45 namespace VertexAttribFlags {
47 // Mesh is pure x,y vertex pairs
49 // Mesh has texture coordinates embedded. Note that texture can exist without this flag
50 // being set, if coordinates passed to sampler are determined another way.
51 TextureCoord = 1 << 0,
52 // Mesh has color embedded (to export to varying)
54 // Mesh has alpha embedded (to export to varying)
60 * Enumerates transform features
62 namespace TransformFlags {
66 // offset the eventual drawing matrix by a tiny amount to
67 // disambiguate sampling patterns with non-AA rendering
68 OffsetByFudgeFactor = 1 << 0,
70 // Canvas transform isn't applied to the mesh at draw time,
71 //since it's already built in.
72 MeshIgnoresCanvasTransform = 1 << 1, // TODO: remove for HWUI_NEW_OPS
77 * Structure containing all data required to issue an OpenGL draw
79 * Includes all of the mesh, fill, and GL state required to perform
80 * the operation. Pieces of data are either directly copied into the
81 * structure, or stored as a pointer or GL object reference to data
84 * Eventually, a Glop should be able to be drawn multiple times from
85 * a single construction, up until GL context destruction. Currently,
86 * vertex/index/Texture/RoundRectClipState pointers prevent this from
90 PREVENT_COPY_AND_ASSIGN(Glop);
94 GLuint primitiveMode; // GL_TRIANGLES and GL_TRIANGLE_STRIP supported
96 // buffer object and void* are mutually exclusive.
97 // Only GL_UNSIGNED_SHORT supported.
103 // buffer object and void*s are mutually exclusive.
104 // TODO: enforce mutual exclusion with restricted setters and/or unions
108 const void* position;
109 const void* texCoord;
115 TextureVertex mappedVertices[4];
126 Matrix4* textureTransform;
132 ProgramDescription::ColorFilterMode filterMode;
141 SkiaShaderData skiaShaderData;
145 // modelView transform, accounting for delta between mesh transform and content of the mesh
146 // often represents x/y offsets within command, or scaling for mesh unit size
149 // Canvas transform of Glop - not necessarily applied to geometry (see flags)
153 const Matrix4& meshTransform() const {
154 return (transformFlags & TransformFlags::MeshIgnoresCanvasTransform)
155 ? Matrix4::identity() : canvas;
159 const RoundRectClipState* roundRectClipState = nullptr;
162 * Blending to be used by this draw - both GL_NONE if blending is disabled.
164 * Defined by fill step, but can be force-enabled by presence of kAlpha_Attrib
173 * Bounds of the drawing command in layer space. Only mapped into layer
174 * space once GlopBuilder::build() is called.
176 Rect bounds; // TODO: remove for HWUI_NEW_OPS
180 * Additional render state to enumerate:
181 * - scissor + (bits for whether each of LTRB needed?)
182 * - stencil mode (draw into, mask, count, etc)
186 } /* namespace uirenderer */
187 } /* namespace android */
189 #endif // ANDROID_HWUI_GLOP_H