aboutsummaryrefslogtreecommitdiff
path: root/layer.h
diff options
context:
space:
mode:
Diffstat (limited to 'layer.h')
-rw-r--r--layer.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/layer.h b/layer.h
new file mode 100644
index 0000000..ce9a417
--- /dev/null
+++ b/layer.h
@@ -0,0 +1,76 @@
+#ifndef __HAVE_LAYER_H
+#define __HAVE_LAYER_H
+
+#include <string.h>
+
+#include <SDL.h>
+#include <SDL_thread.h>
+
+class Layer {
+ SDL_mutex *mutex;
+
+public:
+ Layer *next;
+
+ char *name;
+
+ Layer(const char *name)
+ {
+ mutex = SDL_CreateMutex();
+ Layer::name = strdup(name);
+ }
+ ~Layer()
+ {
+ free(name);
+ SDL_DestroyMutex(mutex);
+ }
+
+ inline void
+ lock()
+ {
+ SDL_LockMutex(mutex);
+ }
+ inline void
+ unlock()
+ {
+ SDL_UnlockMutex(mutex);
+ }
+
+ virtual void geo(SDL_Rect geo) = 0;
+ virtual void alpha(float opacity) = 0;
+
+ virtual void frame(SDL_Surface *target) = 0;
+};
+
+class LayerList {
+ Layer *head;
+
+ SDL_mutex *mutex;
+
+ inline void
+ lock()
+ {
+ SDL_LockMutex(mutex);
+ }
+ inline void
+ unlock()
+ {
+ SDL_UnlockMutex(mutex);
+ }
+
+public:
+ LayerList() : head(NULL)
+ {
+ mutex = SDL_CreateMutex();
+ }
+ ~LayerList()
+ {
+ SDL_DestroyMutex(mutex);
+ }
+
+ void insert(int pos, Layer *layer);
+ bool delete_by_name(const char *name);
+ void render(SDL_Surface *target);
+};
+
+#endif \ No newline at end of file