From 7c290476afd877cf4be48f458a6d2666a2562c8c Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 17 Sep 2012 01:37:56 +0200 Subject: menu/background_*: vertices are only recalculated if the size changed The size of the parent component is cached by the backgrounds and the vertices to draw the backgrounds are only calculated again, if the size of the parent component changed. --- src/menu/background_image.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/menu/background_image.hpp') diff --git a/src/menu/background_image.hpp b/src/menu/background_image.hpp index 23b1a68e..8b28a2e3 100644 --- a/src/menu/background_image.hpp +++ b/src/menu/background_image.hpp @@ -31,6 +31,7 @@ #include "background.hpp" #include "texture.hpp" #include "utils/disposer.hpp" +#include "utils/dimension.hpp" namespace usdx { @@ -46,8 +47,26 @@ namespace usdx */ Disposer* texture; + /** + * Vertices to draw the background rectangle filled with the + * texture. Cached until size of the parent component changes. + * + * @see updateVertices() + */ GLint vertices[8]; + /** + * Cache for the size of the parent component, to be able to detect + * changes. + */ + Dimension size; + + /** + * Update the vertices for drawing the background, if the size if the + * parent component changes. + */ + void updateVertices(); + protected: void draw(void); -- cgit v1.2.3