diff options
author | Dennis Kasprzyk <onestone@opencompositing.org> | 2008-08-12 21:00:32 +0200 |
---|---|---|
committer | Dennis kasprzyk <onestone@opencompositing.org> | 2008-08-12 21:00:32 +0200 |
commit | 27b751990b322da19ac1ca0f91f8e632b850d107 (patch) | |
tree | 0a579c2b1a91c8892e7614e51dfe4e0b49caf618 /src/icon.cpp | |
parent | 1ed4c1a382fa17c6bfbb195ac6836e5c5bff04da (diff) | |
download | unity-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.cpp | 49 |
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 |