summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-01 19:49:34 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-01 22:58:18 +0300
commitd418537e26ec75bc656518dab293ff6313998682 (patch)
tree3c705f29207814276c2f036dc9b703b3b64cb7ed
parent5238a8fd782d5dc703aa788126748050f0cd604e (diff)
downloadplus-d418537e26ec75bc656518dab293ff6313998682.tar.gz
plus-d418537e26ec75bc656518dab293ff6313998682.tar.bz2
plus-d418537e26ec75bc656518dab293ff6313998682.tar.xz
plus-d418537e26ec75bc656518dab293ff6313998682.zip
Add batch drawing to touch manager.
-rw-r--r--src/touchmanager.cpp50
-rw-r--r--src/touchmanager.h6
2 files changed, 42 insertions, 14 deletions
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 7675cfb9b..f2c91f867 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -22,6 +22,7 @@
#include "configuration.h"
#include "graphics.h"
+#include "graphicsvertexes.h"
#include "touchactions.h"
#include "gui/theme.h"
@@ -30,9 +31,13 @@
TouchManager touchManager;
+extern int openGLMode;
+
TouchManager::TouchManager() :
mKeyboard(nullptr),
- mPad(nullptr)
+ mPad(nullptr),
+ mVertexes(new ImageCollection),
+ mRedraw(true)
{
for (int f = 0;f < actionsSize; f ++)
mActions[f] = false;
@@ -85,6 +90,7 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name, bool type,
}
theme->unload(skin);
}
+ mRedraw = true;
}
void TouchManager::clear()
@@ -104,6 +110,7 @@ void TouchManager::clear()
}
}
mObjects.clear();
+ mRedraw = true;
}
void TouchManager::unloadTouchItem(TouchItem **item0)
@@ -116,23 +123,42 @@ void TouchManager::unloadTouchItem(TouchItem **item0)
delete item;
*item0 = nullptr;
}
+ mRedraw = true;
}
void TouchManager::draw()
{
-// drawTouchItem(mPad);
- for (TouchItemVectorCIter it = mObjects.begin(), it_end = mObjects.end();
- it != it_end; ++ it)
+ if (openGLMode != 2)
+ {
+ if (mRedraw)
+ {
+ mRedraw = false;
+ mVertexes->clear();
+ for (TouchItemVectorCIter it = mObjects.begin(),
+ it_end = mObjects.end();
+ it != it_end; ++ it)
+ {
+ const TouchItem *const item = *it;
+ if (item && item->image)
+ {
+ mainGraphics->calcTile(mVertexes, item->image,
+ item->x, item->y);
+ }
+ }
+ }
+ mainGraphics->drawTile(mVertexes);
+ }
+ else
{
- drawTouchItem(*it);
+ for (TouchItemVectorCIter it = mObjects.begin(),
+ it_end = mObjects.end();
+ it != it_end; ++ it)
+ {
+ const TouchItem *const item = *it;
+ if (item && item->image)
+ mainGraphics->drawImage(item->image, item->x, item->y);
+ }
}
-// drawTouchItem(mKeyboard);
-}
-
-void TouchManager::drawTouchItem(const TouchItem *const item) const
-{
- if (item && item->image)
- mainGraphics->drawImage(item->image, item->x, item->y);
}
bool TouchManager::processEvent(const gcn::MouseInput &mouseInput)
diff --git a/src/touchmanager.h b/src/touchmanager.h
index ae25d9a8c..43eaf65d1 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -32,6 +32,8 @@
#include "localconsts.h"
+class ImageCollection;
+
typedef void (*TouchFuncPtr) (const gcn::MouseInput &mouseInput);
const int actionsSize = 10;
@@ -88,8 +90,6 @@ class TouchManager final
void draw();
- void drawTouchItem(const TouchItem *const item) const;
-
bool processEvent(const gcn::MouseInput &mouseInput);
bool isActionActive(const int index) const;
@@ -104,7 +104,9 @@ class TouchManager final
TouchItem *mKeyboard;
TouchItem *mPad;
TouchItemVector mObjects;
+ ImageCollection *mVertexes;
bool mActions[actionsSize];
+ bool mRedraw;
};
extern TouchManager touchManager;