From ce480b07335d8f7d380ac302a1a6422c4fa3742b Mon Sep 17 00:00:00 2001 From: Yaniv Kamay Date: Mon, 28 Dec 2009 00:31:35 +0200 Subject: client: add soft renderer and cegui --- client/gui/softrenderer.h | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 client/gui/softrenderer.h (limited to 'client/gui/softrenderer.h') 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 +#include +#include + +#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 QuadQueue; + QuadQueue _queue; + + typedef std::list TexturesList; + TexturesList _textures; + }; +} + +#endif + + -- cgit