Loading libs/hwui/Vertex.h +27 −16 Original line number Diff line number Diff line Loading @@ -19,6 +19,12 @@ #include "Vector.h" #include <type_traits> #define REQUIRE_COMPATIBLE_LAYOUT(TARGET_TYPE) \ static_assert(std::is_standard_layout<TARGET_TYPE>::value, \ #TARGET_TYPE " must have standard layout") namespace android { namespace uirenderer { Loading Loading @@ -53,6 +59,8 @@ struct Vertex { }; // struct Vertex REQUIRE_COMPATIBLE_LAYOUT(Vertex); /** * Simple structure to describe a vertex with a position and texture UV. */ Loading @@ -61,10 +69,7 @@ struct TextureVertex { float u, v; static inline void set(TextureVertex* vertex, float x, float y, float u, float v) { vertex[0].x = x; vertex[0].y = y; vertex[0].u = u; vertex[0].v = v; *vertex = { x, y, u, v }; } static inline void setUV(TextureVertex* vertex, float u, float v) { Loading @@ -73,39 +78,43 @@ struct TextureVertex { } }; // struct TextureVertex REQUIRE_COMPATIBLE_LAYOUT(TextureVertex); /** * Simple structure to describe a vertex with a position, texture UV and ARGB color. */ struct ColorTextureVertex : TextureVertex { struct ColorTextureVertex { float x, y; float u, v; float r, g, b, a; static inline void set(ColorTextureVertex* vertex, float x, float y, float u, float v, int color) { TextureVertex::set(vertex, x, y, u, v); const float a = ((color >> 24) & 0xff) / 255.0f; vertex[0].r = a * ((color >> 16) & 0xff) / 255.0f; vertex[0].g = a * ((color >> 8) & 0xff) / 255.0f; vertex[0].b = a * ((color ) & 0xff) / 255.0f; vertex[0].a = a; float a = ((color >> 24) & 0xff) / 255.0f; float r = a * ((color >> 16) & 0xff) / 255.0f; float g = a * ((color >> 8) & 0xff) / 255.0f; float b = a * ((color) & 0xff) / 255.0f; *vertex = { x, y, u, v, r, g, b, a }; } }; // struct ColorTextureVertex REQUIRE_COMPATIBLE_LAYOUT(ColorTextureVertex); /** * Simple structure to describe a vertex with a position and an alpha value. */ struct AlphaVertex : Vertex { struct AlphaVertex { float x, y; float alpha; static inline void set(AlphaVertex* vertex, float x, float y, float alpha) { Vertex::set(vertex, x, y); vertex[0].alpha = alpha; *vertex = { x, y, alpha }; } static inline void copyWithOffset(AlphaVertex* vertex, const AlphaVertex& src, float x, float y) { Vertex::set(vertex, src.x + x, src.y + y); vertex[0].alpha = src.alpha; AlphaVertex::set(vertex, src.x + x, src.y + y, src.alpha); } static inline void setColor(AlphaVertex* vertex, float alpha) { Loading @@ -113,6 +122,8 @@ struct AlphaVertex : Vertex { } }; // struct AlphaVertex REQUIRE_COMPATIBLE_LAYOUT(AlphaVertex); }; // namespace uirenderer }; // namespace android Loading Loading
libs/hwui/Vertex.h +27 −16 Original line number Diff line number Diff line Loading @@ -19,6 +19,12 @@ #include "Vector.h" #include <type_traits> #define REQUIRE_COMPATIBLE_LAYOUT(TARGET_TYPE) \ static_assert(std::is_standard_layout<TARGET_TYPE>::value, \ #TARGET_TYPE " must have standard layout") namespace android { namespace uirenderer { Loading Loading @@ -53,6 +59,8 @@ struct Vertex { }; // struct Vertex REQUIRE_COMPATIBLE_LAYOUT(Vertex); /** * Simple structure to describe a vertex with a position and texture UV. */ Loading @@ -61,10 +69,7 @@ struct TextureVertex { float u, v; static inline void set(TextureVertex* vertex, float x, float y, float u, float v) { vertex[0].x = x; vertex[0].y = y; vertex[0].u = u; vertex[0].v = v; *vertex = { x, y, u, v }; } static inline void setUV(TextureVertex* vertex, float u, float v) { Loading @@ -73,39 +78,43 @@ struct TextureVertex { } }; // struct TextureVertex REQUIRE_COMPATIBLE_LAYOUT(TextureVertex); /** * Simple structure to describe a vertex with a position, texture UV and ARGB color. */ struct ColorTextureVertex : TextureVertex { struct ColorTextureVertex { float x, y; float u, v; float r, g, b, a; static inline void set(ColorTextureVertex* vertex, float x, float y, float u, float v, int color) { TextureVertex::set(vertex, x, y, u, v); const float a = ((color >> 24) & 0xff) / 255.0f; vertex[0].r = a * ((color >> 16) & 0xff) / 255.0f; vertex[0].g = a * ((color >> 8) & 0xff) / 255.0f; vertex[0].b = a * ((color ) & 0xff) / 255.0f; vertex[0].a = a; float a = ((color >> 24) & 0xff) / 255.0f; float r = a * ((color >> 16) & 0xff) / 255.0f; float g = a * ((color >> 8) & 0xff) / 255.0f; float b = a * ((color) & 0xff) / 255.0f; *vertex = { x, y, u, v, r, g, b, a }; } }; // struct ColorTextureVertex REQUIRE_COMPATIBLE_LAYOUT(ColorTextureVertex); /** * Simple structure to describe a vertex with a position and an alpha value. */ struct AlphaVertex : Vertex { struct AlphaVertex { float x, y; float alpha; static inline void set(AlphaVertex* vertex, float x, float y, float alpha) { Vertex::set(vertex, x, y); vertex[0].alpha = alpha; *vertex = { x, y, alpha }; } static inline void copyWithOffset(AlphaVertex* vertex, const AlphaVertex& src, float x, float y) { Vertex::set(vertex, src.x + x, src.y + y); vertex[0].alpha = src.alpha; AlphaVertex::set(vertex, src.x + x, src.y + y, src.alpha); } static inline void setColor(AlphaVertex* vertex, float alpha) { Loading @@ -113,6 +122,8 @@ struct AlphaVertex : Vertex { } }; // struct AlphaVertex REQUIRE_COMPATIBLE_LAYOUT(AlphaVertex); }; // namespace uirenderer }; // namespace android Loading