StelTextureMgr.hpp   StelTextureMgr.hpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELTEXTUREMGR_HPP_ #ifndef _STELTEXTUREMGR_HPP_
#define _STELTEXTUREMGR_HPP_ #define _STELTEXTUREMGR_HPP_
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include <QObject> #include <QObject>
#include <QMap>
#include <QWeakPointer>
#include <QMutex>
class QNetworkReply; class QNetworkReply;
class QThread; class QThread;
class QThreadPool;
//! @class StelTextureMgr //! @class StelTextureMgr
//! Manage textures loading. //! Manage textures loading.
//! It provides method for loading images in a separate thread. //! It provides method for loading images in a separate thread.
class StelTextureMgr : QObject class StelTextureMgr : QObject
{ {
Q_OBJECT
public: public:
//! Load an image from a file and create a new texture from it //! Load an image from a file and create a new texture from it
//! @param filename the texture file name, can be absolute path if s tarts with '/' otherwise //! @param filename the texture file name, can be absolute path if s tarts with '/' otherwise
//! the file will be looked for in Stellarium's standard textures directories. //! the file will be looked for in Stellarium's standard textures directories.
//! @param params the texture creation parameters. //! @param params the texture creation parameters.
StelTextureSP createTexture(const QString& filename, const StelTextu re::StelTextureParams& params=StelTexture::StelTextureParams()); StelTextureSP createTexture(const QString& filename, const StelTextu re::StelTextureParams& params=StelTexture::StelTextureParams());
//! Load an image from a file and create a new texture from it in a new thread. //! Load an image from a file and create a new texture from it in a new thread.
//! @note This method is safe to be called from threads other than t he main thread.
//! @param url the texture file name or URL, can be absolute path if starts with '/' otherwise //! @param url the texture file name or URL, can be absolute path if starts with '/' otherwise
//! the file will be looked for in Stellarium's standard textures directories. //! the file will be looked for in Stellarium's standard textures directories.
//! @param params the texture creation parameters. //! @param params the texture creation parameters.
//! @param lazyLoading define whether the texture should be actually loaded only when needed, i.e. when bind() is called the first time. //! @param lazyLoading define whether the texture should be actually loaded only when needed, i.e. when bind() is called the first time.
StelTextureSP createTextureThread(const QString& url, const StelText ure::StelTextureParams& params=StelTexture::StelTextureParams(), bool lazyL oading=true); StelTextureSP createTextureThread(const QString& url, const StelText ure::StelTextureParams& params=StelTexture::StelTextureParams(), bool lazyL oading=true);
//! Creates or finds a StelTexture wrapper for the specified OpenGL
texture object.
//! The wrapper takes ownership of the texture and will delete it if
it is destroyed.
//! @param texID The OpenGL texture ID which should be wrapped. If t
his is already a StelTexture, the existing wrapper will be returned.
//! @returns the existing or new wrapper for the texture with the gi
ven GL name. Returns a null pointer if the texture name is invalid.
StelTextureSP wrapperForGLTexture(GLuint texId);
//! Returns the estimated memory usage of all textures currently loa ded through StelTexture //! Returns the estimated memory usage of all textures currently loa ded through StelTexture
int getGLMemoryUsage(); int getGLMemoryUsage();
private: private:
friend class StelTexture; friend class StelTexture;
friend class ImageLoader; friend class ImageLoader;
friend class StelApp; friend class StelApp;
//! Private constructor, use StelApp::getTextureManager for the corr ect instance //! Private constructor, use StelApp::getTextureManager for the corr ect instance
StelTextureMgr(); StelTextureMgr(QObject* parent = Q_NULLPTR);
//! Initialize some variable from the openGL context.
//! Must be called after the creation of the GLContext.
void init();
unsigned int glMemoryUsage; unsigned int glMemoryUsage;
//! We use our own thread pool to ensure only 1 texture is being loa
ded at a time
QThreadPool* loaderThreadPool;
StelTextureSP lookupCache(const QString& file);
typedef QMap<QString,QWeakPointer<StelTexture> > TexCache;
typedef QMap<GLuint,QWeakPointer<StelTexture> > IdMap;
QMutex mutex;
TexCache textureCache;
IdMap idMap;
}; };
#endif // _STELTEXTUREMGR_HPP_ #endif // _STELTEXTUREMGR_HPP_
 End of changes. 7 change blocks. 
5 lines changed or deleted 28 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/