113837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi/* 213837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * Copyright (C) 2010 The Android Open Source Project 313837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * 413837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * Licensed under the Apache License, Version 2.0 (the "License"); 513837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * you may not use this file except in compliance with the License. 613837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * You may obtain a copy of the License at 713837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * 813837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * http://www.apache.org/licenses/LICENSE-2.0 913837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * 1013837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * Unless required by applicable law or agreed to in writing, software 1113837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * distributed under the License is distributed on an "AS IS" BASIS, 1213837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1313837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * See the License for the specific language governing permissions and 1413837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * limitations under the License. 1513837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi */ 1613837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 17bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#ifndef ANDROID_HWUI_VERTEX_H 18bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi#define ANDROID_HWUI_VERTEX_H 19bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi 202b06e20ae32388f6e1dfd088d9773c34e6b1cb45Jean-Michel Trivinamespace android { 2113837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivinamespace uirenderer { 2213837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 2313837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi/** 2413837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * Simple structure to describe a vertex with a position and a texture. 2513837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi */ 2613837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivistruct Vertex { 2713837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi float position[2]; 2813837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 2913837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi static inline void set(Vertex* vertex, float x, float y) { 3013837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].position[0] = x; 3113837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].position[1] = y; 32f4b45a37248899ae2d27bb172f8387fbf1edff8eGlenn Kasten } 3313837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi}; // struct Vertex 3413837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 3513837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi/** 3613837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * Simple structure to describe a vertex with a position and a texture. 3713837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi */ 3813837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivistruct TextureVertex { 3913837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi float position[2]; 4013837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi float texture[2]; 4113837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 4213837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi static inline void set(TextureVertex* vertex, float x, float y, float u, float v) { 4313837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].position[0] = x; 4413837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].position[1] = y; 4513837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].texture[0] = u; 4613837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].texture[1] = v; 4713837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi } 4813837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 49f4b45a37248899ae2d27bb172f8387fbf1edff8eGlenn Kasten static inline void setUV(TextureVertex* vertex, float u, float v) { 5013837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].texture[0] = u; 5113837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi vertex[0].texture[1] = v; 5213837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi } 5313837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi}; // struct TextureVertex 5413837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi 5513837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi/** 5613837cf3f7be0eb8b1a9552bd99a89f98c987720Jean-Michel Trivi * Simple structure to describe a vertex with a position and an alpha value. 57bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivi */ 58bb832e853d4afb11b0a3287b2eb0cad87696d631Jean-Michel Trivistruct 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 71/** 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 90}; // namespace uirenderer 91}; // namespace android 92 93#endif // ANDROID_HWUI_VERTEX_H 94