src/openvg/qpixmapdata_vg_p.h
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    53 // We mean it.
    53 // We mean it.
    54 //
    54 //
    55 
    55 
    56 #include <QtGui/private/qpixmap_raster_p.h>
    56 #include <QtGui/private/qpixmap_raster_p.h>
    57 #include <private/qvg_p.h>
    57 #include <private/qvg_p.h>
    58 #if !defined(QT_NO_EGL)
       
    59 #endif
       
    60 
    58 
    61 #if defined(Q_OS_SYMBIAN)
    59 #if defined(Q_OS_SYMBIAN)
    62 class RSGImage;
    60 class RSGImage;
    63 #endif
    61 #endif
    64 
    62 
    65 QT_BEGIN_NAMESPACE
    63 QT_BEGIN_NAMESPACE
    66 
    64 
    67 class QEglContext;
    65 class QEglContext;
       
    66 class QVGImagePool;
       
    67 
       
    68 #if !defined(QT_NO_EGL)
       
    69 class QVGPixmapData;
       
    70 class QVGSharedContext;
       
    71 
       
    72 void qt_vg_register_pixmap(QVGPixmapData *pd);
       
    73 void qt_vg_unregister_pixmap(QVGPixmapData *pd);
       
    74 void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
       
    75 #endif
    68 
    76 
    69 class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData
    77 class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData
    70 {
    78 {
    71 public:
    79 public:
    72     QVGPixmapData(PixelType type);
    80     QVGPixmapData(PixelType type);
    87     QImage *buffer();
    95     QImage *buffer();
    88     QPaintEngine* paintEngine() const;
    96     QPaintEngine* paintEngine() const;
    89 
    97 
    90     // Return the VGImage form of this pixmap, creating it if necessary.
    98     // Return the VGImage form of this pixmap, creating it if necessary.
    91     // This assumes that there is a VG context current.
    99     // This assumes that there is a VG context current.
    92     VGImage toVGImage();
   100     virtual VGImage toVGImage();
    93 
   101 
    94     // Return the VGImage form for a specific opacity setting.
   102     // Return the VGImage form for a specific opacity setting.
    95     VGImage toVGImage(qreal opacity);
   103     virtual VGImage toVGImage(qreal opacity);
       
   104 
       
   105     // Detach this image from the image pool.
       
   106     virtual void detachImageFromPool();
       
   107 
       
   108     // Release the VG resources associated with this pixmap and copy
       
   109     // the pixmap's contents out of the GPU back into main memory.
       
   110     // The VG resource will be automatically recreated the next time
       
   111     // toVGImage() is called.  Does nothing if the pixmap cannot be
       
   112     // hibernated for some reason (e.g. VGImage is shared with another
       
   113     // process via a SgImage).
       
   114     virtual void hibernate();
       
   115 
       
   116     // Called when the QVGImagePool wants to reclaim this pixmap's
       
   117     // VGImage objects to reuse storage.
       
   118     virtual void reclaimImages();
    96 
   119 
    97     QSize size() const { return QSize(w, h); }
   120     QSize size() const { return QSize(w, h); }
    98 
   121 
    99 #if defined(Q_OS_SYMBIAN)
   122 #if defined(Q_OS_SYMBIAN)
   100     void* toNativeType(NativeType type);
   123     void* toNativeType(NativeType type);
   107 #if defined(Q_OS_SYMBIAN)
   130 #if defined(Q_OS_SYMBIAN)
   108     void cleanup();
   131     void cleanup();
   109 #endif
   132 #endif
   110 
   133 
   111 private:
   134 private:
       
   135     QVGPixmapData *nextLRU;
       
   136     QVGPixmapData *prevLRU;
       
   137     bool inLRU;
       
   138     friend class QVGImagePool;
       
   139 
       
   140 #if !defined(QT_NO_EGL)
       
   141     QVGPixmapData *next;
       
   142     QVGPixmapData *prev;
       
   143 
       
   144     friend void qt_vg_register_pixmap(QVGPixmapData *pd);
       
   145     friend void qt_vg_unregister_pixmap(QVGPixmapData *pd);
       
   146     friend void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
       
   147 #endif
       
   148 
       
   149 protected:
       
   150     QSize prevSize;
   112     VGImage vgImage;
   151     VGImage vgImage;
   113     VGImage vgImageOpacity;
   152     VGImage vgImageOpacity;
   114     qreal cachedOpacity;
   153     qreal cachedOpacity;
   115     mutable QImage source;
   154     mutable QImage source;
   116     mutable bool recreate;
   155     mutable bool recreate;
       
   156     bool inImagePool;
   117 #if !defined(QT_NO_EGL)
   157 #if !defined(QT_NO_EGL)
   118     mutable QEglContext *context;
   158     mutable QEglContext *context;
   119 #endif
   159 #endif
   120 
   160 
   121     void forceToImage();
   161     void forceToImage();
   122     QImage::Format sourceFormat() const;
   162     QImage::Format sourceFormat() const;
       
   163 
       
   164     void destroyImageAndContext();
       
   165     void destroyImages();
   123 };
   166 };
   124 
   167 
   125 QT_END_NAMESPACE
   168 QT_END_NAMESPACE
   126 
   169 
   127 #endif
   170 #endif