blob: 38455dc932742ecc99043344390c914e96683392 [file] [log] [blame]
Romain Guyf7f93552010-07-08 19:17:03 -07001/*
2 * Copyright (C) 2010 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
Romain Guy5b3b3522010-10-27 18:57:51 -070017#ifndef ANDROID_HWUI_VERTEX_H
18#define ANDROID_HWUI_VERTEX_H
Romain Guyf7f93552010-07-08 19:17:03 -070019
20namespace android {
21namespace uirenderer {
22
23/**
Romain Guyf7f93552010-07-08 19:17:03 -070024 * Simple structure to describe a vertex with a position and a texture.
25 */
Chet Haase5b0200b2011-04-13 17:58:08 -070026struct Vertex {
27 float position[2];
28
29 static inline void set(Vertex* vertex, float x, float y) {
30 vertex[0].position[0] = x;
31 vertex[0].position[1] = y;
32 }
33}; // struct Vertex
34
35/**
36 * Simple structure to describe a vertex with a position and a texture.
37 */
Romain Guyf7f93552010-07-08 19:17:03 -070038struct TextureVertex {
39 float position[2];
40 float texture[2];
41
42 static inline void set(TextureVertex* vertex, float x, float y, float u, float v) {
43 vertex[0].position[0] = x;
44 vertex[0].position[1] = y;
45 vertex[0].texture[0] = u;
46 vertex[0].texture[1] = v;
47 }
Romain Guy82ba8142010-07-09 13:25:56 -070048
49 static inline void setUV(TextureVertex* vertex, float u, float v) {
50 vertex[0].texture[0] = u;
51 vertex[0].texture[1] = v;
52 }
Romain Guyf7f93552010-07-08 19:17:03 -070053}; // struct TextureVertex
54
Chet Haase5b0200b2011-04-13 17:58:08 -070055/**
56 * Simple structure to describe a vertex with a position and an alpha value.
57 */
58struct AlphaVertex : Vertex {
59 float alpha;
60
61 static inline void set(AlphaVertex* vertex, float x, float y, float alpha) {
62 Vertex::set(vertex, x, y);
63 vertex[0].alpha = alpha;
64 }
65
66 static inline void setColor(AlphaVertex* vertex, float alpha) {
67 vertex[0].alpha = alpha;
68 }
69}; // struct AlphaVertex
70
Chet Haase99585ad2011-05-02 15:00:16 -070071/**
72 * Simple structure to describe a vertex with a position and an alpha value.
73 */
74struct AAVertex : Vertex {
75 float width;
76 float length;
77
78 static inline void set(AAVertex* vertex, float x, float y, float width, float length) {
79 Vertex::set(vertex, x, y);
80 vertex[0].width = width;
81 vertex[0].length = length;
82 }
83
84 static inline void setColor(AAVertex* vertex, float width, float length) {
85 vertex[0].width = width;
86 vertex[0].length = length;
87 }
88}; // struct AlphaVertex
89
Romain Guyf7f93552010-07-08 19:17:03 -070090}; // namespace uirenderer
91}; // namespace android
92
Romain Guy5b3b3522010-10-27 18:57:51 -070093#endif // ANDROID_HWUI_VERTEX_H