diff options
author | Yaniv Kamay <ykamay@redhat.com> | 2009-12-28 00:31:35 +0200 |
---|---|---|
committer | Yaniv Kamay <ykamay@redhat.com> | 2009-12-28 12:37:01 +0200 |
commit | ce480b07335d8f7d380ac302a1a6422c4fa3742b (patch) | |
tree | c60f73f0887ee0e66a11cc6d3fd723427eb19c99 /client/gui/softrenderer.h | |
parent | 2dbaf8c00c28770e48cbfc6ab3300000118d22ec (diff) | |
download | spice-ce480b07335d8f7d380ac302a1a6422c4fa3742b.tar.gz spice-ce480b07335d8f7d380ac302a1a6422c4fa3742b.tar.xz spice-ce480b07335d8f7d380ac302a1a6422c4fa3742b.zip |
client: add soft renderer and cegui
Diffstat (limited to 'client/gui/softrenderer.h')
-rw-r--r-- | client/gui/softrenderer.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/client/gui/softrenderer.h b/client/gui/softrenderer.h new file mode 100644 index 00000000..939eb38b --- /dev/null +++ b/client/gui/softrenderer.h @@ -0,0 +1,131 @@ +#ifndef _directfbrenderer_h_ +#define _directfbrenderer_h_ + +#include <stdint.h> +#include <list> +#include <set> + +#include "CEGUIRenderer.h" +#include "CEGUIColourRect.h" +#include "CEGUIRect.h" + + +namespace CEGUI +{ + class SoftTexture; + class ImageCodec; + + class SoftRenderer : public Renderer + { + public: + SoftRenderer(uint8_t* surface, uint width, uint height, uint stride, + ImageCodec* codec = NULL); + virtual ~SoftRenderer(); + + void reset_surface(uint8_t* surface, uint width, uint height, uint stride); + + virtual void addQuad(const Rect& dest_rect, float z, const Texture* tex, + const Rect& texture_rect, const ColourRect& colours, + QuadSplitMode quad_split_mode); + virtual void doRender(); + virtual void clearRenderList(); + virtual void setQueueingEnabled(bool setting); + virtual bool isQueueingEnabled() const; + + virtual Texture* createTexture(); + virtual Texture* createTexture(const String& filename, + const String& resourceGroup); + virtual Texture* createTexture(float size); + virtual void destroyTexture(Texture* texture); + virtual void destroyAllTextures(); + virtual uint getMaxTextureSize() const; + + virtual float getWidth() const; + virtual float getHeight() const; + virtual Size getSize() const; + virtual Rect getRect() const; + + virtual uint getHorzScreenDPI() const; + virtual uint getVertScreenDPI() const; + + ImageCodec* getImageCodec() { return _image_codec;} + + private: + void setupImageCodec(); + void cleanupImageCodec(); + struct QuadInfo; + void renderQuad(const QuadInfo& quad); + void renderQuadWithColourRect(const QuadInfo& quad); + + class ColourI { + public: + + bool isSameColour(const ColourI& other) const + { + return other.r == r && other.g == g && other.b == b && other.a == a; + } + + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + }; + + static inline void setRGB(ColourI& dest, const colour& src); + static inline void componnentAtPoint(int x_pos, int y_pos, + int top_left, int top_right, + int bottom_left, int bottom_right, + uint64_t& comp); + + struct ColourIRect { + ColourI top_left; + ColourI top_right; + ColourI bottom_left; + ColourI bottom_right; + }; + + static void colourAtPoint(int x, int x_max, int y, int y_max, + const ColourIRect& colours, + uint64_t& r, uint64_t& g, + uint64_t& b, uint64_t& a); + + private: + uint8_t* _surface; + int _width; + int _height; + ImageCodec* _image_codec; + DynamicModule* _image_codec_module; + void (*_destroy_image_codec)(ImageCodec*); + bool _queueing; + + struct RectI { + int left; + int top; + int right; + int bottom; + }; + + struct QuadInfo { + RectI dest; + const SoftTexture* tex; + RectI tex_src; + ColourIRect colors; + float z; + + bool operator < (const QuadInfo& other) const + { + return z > other.z; + } + }; + + typedef std::multiset<QuadInfo> QuadQueue; + QuadQueue _queue; + + typedef std::list<SoftTexture *> TexturesList; + TexturesList _textures; + }; +} + +#endif + + |