diff options
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 |