diff options
Diffstat (limited to 'src/adaptationlayers/adaptationinterfaces.h')
-rw-r--r-- | src/adaptationlayers/adaptationinterfaces.h | 97 |
1 files changed, 75 insertions, 22 deletions
diff --git a/src/adaptationlayers/adaptationinterfaces.h b/src/adaptationlayers/adaptationinterfaces.h index 4b15647..b5fa295 100644 --- a/src/adaptationlayers/adaptationinterfaces.h +++ b/src/adaptationlayers/adaptationinterfaces.h @@ -52,9 +52,8 @@ #include "node.h" class Node; -class QPixmap; -class QGLTexture2D; class QImage; +class TextureReference; // TODO: Rename from XInterface to AbstractX. @@ -83,6 +82,7 @@ public: virtual void setRadius(qreal radius) = 0; qreal radius() const { return m_radius; } + protected: QRectF m_rect; QGradientStops m_gradient_stops; @@ -93,10 +93,10 @@ protected: int m_pen_width; }; -class PixmapNodeInterface : public GeometryNode +class TextureNodeInterface : public GeometryNode { public: - PixmapNodeInterface() : m_opacity(1), m_clamp_to_edge(true), m_linear_filtering(false) { } + TextureNodeInterface() : m_texture(0), m_opacity(1), m_clamp_to_edge(true), m_linear_filtering(false) { } virtual void setRect(const QRectF &rect) = 0; QRectF rect() const { return m_rect; } @@ -107,45 +107,98 @@ public: virtual void setOpacity(qreal opacity) = 0; qreal opacity() const { return m_opacity; } - virtual void setPixmap(const QPixmap &pixmap, bool dynamic) = 0; - void setPixmap(const QPixmap &pixmap) { setPixmap(pixmap, true); } + virtual void setTexture(TextureReference *ref) = 0; + TextureReference *texture() const; virtual void setClampToEdge(bool clampToEdge) = 0; bool clampToEdge() const { return m_clamp_to_edge; } virtual void setLinearFiltering(bool linearFiltering) = 0; bool linearFiltering() const { return m_linear_filtering; } + protected: + TextureReference *m_texture; QRectF m_rect; QRectF m_source_rect; qreal m_opacity; bool m_clamp_to_edge; bool m_linear_filtering; -}; -typedef QSharedPointer<const QGLTexture2D> QGLTexture2DConstPtr; -typedef QSharedPointer<QGLTexture2D> QGLTexture2DPtr; +}; -class TextureAtlasInterface +class TextureReference : public QObject { + Q_OBJECT public: - enum Flag - { - DynamicFlag = 0x01 // Set if images are added to the texture atlas every few frames. + enum Status { + Null, + Ready, + Loading, + Error }; - TextureAtlasInterface(uint flags) : m_flags(flags) { } - virtual ~TextureAtlasInterface() { } + TextureReference(); + TextureReference(int id, const QRectF &rect, bool hasAlpha); + + virtual int textureId() const { return m_texture_id; } + virtual QRectF textureRect() const { return m_texture_rect; } + + bool hasAlphaChannel() const { return m_has_alpha; } - virtual QGLTexture2DConstPtr texture() = 0; - virtual QRect allocate(const QImage &image, bool clampToEdge) = 0; - virtual void deallocate(const QRect &rect) = 0; + Status status() const { return m_status; } + +signals: + void statusChanged(Status status); - uint flags() const { return m_flags; } protected: - uint m_flags; + Status m_status; + int m_texture_id; + QRectF m_texture_rect; + + uint m_has_alpha : 1; }; +class TextureManager +{ +public: + enum UploadHint { + SynchronousUploadHint = 0x0001, + CanUseAtlasUploadHint = 0x0002, + + DefaultUploadHints = 0 + }; + Q_DECLARE_FLAGS(UploadHints, UploadHint); + + virtual ~TextureManager() { }; + + virtual TextureReference *requestUploadedTexture(const QImage &image, UploadHints hints = DefaultUploadHints) = 0; +}; + + +//typedef QSharedPointer<const QGLTexture2D> QGLTexture2DConstPtr; +//typedef QSharedPointer<QGLTexture2D> QGLTexture2DPtr; + +//class TextureAtlasInterface +//{ +//public: +// enum Flag +// { +// DynamicFlag = 0x01 // Set if images are added to the texture atlas every few frames. +// }; + +// TextureAtlasInterface(uint flags) : m_flags(flags) { } +// virtual ~TextureAtlasInterface() { } + +// virtual QGLTexture2DConstPtr texture() = 0; +// virtual QRect allocate(const QImage &image, bool clampToEdge) = 0; +// virtual void deallocate(const QRect &rect) = 0; + +// uint flags() const { return m_flags; } +//protected: +// uint m_flags; +//}; + + class GlyphNodeInterface: public GeometryNode { public: @@ -174,10 +227,10 @@ class AdaptationLayerInterface { public: virtual RectangleNodeInterface *createRectangleNode() = 0; - virtual PixmapNodeInterface *createPixmapNode() = 0; - virtual TextureAtlasInterface *createTextureAtlas(uint flags) = 0; + virtual TextureNodeInterface *createTextureNode() = 0; virtual GlyphNodeInterface *createGlyphNode() = 0; virtual Renderer *createRenderer() = 0; + virtual TextureManager *textureManager() = 0; }; #endif |