summaryrefslogtreecommitdiff
path: root/src/icon.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-08-12 21:00:32 +0200
committerDennis kasprzyk <onestone@opencompositing.org>2008-08-12 21:00:32 +0200
commit27b751990b322da19ac1ca0f91f8e632b850d107 (patch)
tree0a579c2b1a91c8892e7614e51dfe4e0b49caf618 /src/icon.cpp
parent1ed4c1a382fa17c6bfbb195ac6836e5c5bff04da (diff)
downloadunity-window-decorator-27b751990b322da19ac1ca0f91f8e632b850d107.tar.gz
unity-window-decorator-27b751990b322da19ac1ca0f91f8e632b850d107.tar.bz2
CompIcon class and CompTexture cleanup.
Diffstat (limited to 'src/icon.cpp')
-rw-r--r--src/icon.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/icon.cpp b/src/icon.cpp
new file mode 100644
index 0000000..856ceaf
--- /dev/null
+++ b/src/icon.cpp
@@ -0,0 +1,49 @@
+#include <compicon.h>
+
+CompIcon::CompIcon (CompScreen *screen, unsigned int width,
+ unsigned int height) :
+ mTexture (screen),
+ mWidth (width),
+ mHeight (height),
+ mData (new unsigned char[width * height * 4]),
+ mUpdateTex (true)
+{
+}
+
+CompIcon::~CompIcon ()
+{
+ free (mData);
+}
+
+CompTexture &
+CompIcon::texture ()
+{
+ if (mUpdateTex)
+ {
+ mUpdateTex = false;
+ mTexture.reset ();
+ if (!mTexture.imageBufferToTexture (&mTexture,
+ reinterpret_cast<const char *> (mData), mWidth, mHeight))
+ mTexture.reset ();
+ }
+ return mTexture;
+}
+
+unsigned int
+CompIcon::width ()
+{
+ return mWidth;
+}
+
+unsigned int
+CompIcon::height ()
+{
+ return mHeight;
+}
+
+unsigned char*
+CompIcon::data ()
+{
+ mUpdateTex = true;
+ return mData;
+} \ No newline at end of file