aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu/background_image.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-09-17 01:37:56 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-13 22:41:06 +0100
commit7c290476afd877cf4be48f458a6d2666a2562c8c (patch)
treeb662247e94851cb66d005e64b7c6db062f2fef02 /src/menu/background_image.cpp
parent618926293ca497ff8e31d048e34d10954cb0e059 (diff)
downloadusdx-7c290476afd877cf4be48f458a6d2666a2562c8c.tar.gz
usdx-7c290476afd877cf4be48f458a6d2666a2562c8c.tar.xz
usdx-7c290476afd877cf4be48f458a6d2666a2562c8c.zip
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.
Diffstat (limited to 'src/menu/background_image.cpp')
-rw-r--r--src/menu/background_image.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/menu/background_image.cpp b/src/menu/background_image.cpp
index bb398304..451587f7 100644
--- a/src/menu/background_image.cpp
+++ b/src/menu/background_image.cpp
@@ -30,7 +30,7 @@ namespace usdx
{
BackgroundImage::BackgroundImage(const DrawableControl &control,
boost::filesystem::wpath filename) :
- Background(control)
+ Background(control), texture(NULL), size(0,0)
{
texture = new Disposer<Texture>(new Texture(filename));
}
@@ -42,18 +42,24 @@ namespace usdx
texture = NULL;
}
}
+
+ void BackgroundImage::updateVertices() {
+ vertices[0] = 0;
+ vertices[1] = get_parent().get_height();
+ vertices[2] = get_parent().get_width();
+ vertices[3] = get_parent().get_height();
+ vertices[4] = get_parent().get_width();
+ vertices[5] = 0;
+ vertices[6] = 0;
+ vertices[7] = 0;
}
void BackgroundImage::draw(void)
{
- this->vertices[0] = 0;
- this->vertices[1] = get_parent().get_height();
- this->vertices[2] = get_parent().get_width();
- this->vertices[3] = get_parent().get_height();
- this->vertices[4] = get_parent().get_width();
- this->vertices[5] = 0;
- this->vertices[6] = 0;
- this->vertices[7] = 0;
+ if (size != get_parent().get_size()) {
+ this->updateVertices();
+ size = get_parent().get_size();
+ }
Activator<Texture> t(texture->get());