summaryrefslogtreecommitdiff
path: root/vcl/inc/opengl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-11-13 21:37:54 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-11-15 12:17:43 +0100
commitdce9610afed674ecec23497a1a004193a6cf3bf1 (patch)
tree7b0e2063667645ae3a4259a08c0ab1d2fce0eaf1 /vcl/inc/opengl
parent330b7b310193f3290cbd4c340659f72d12c352e1 (diff)
vcl: Improve OpenGLTexture implementation by allowing implicit sharing
Conflicts: vcl/opengl/gdiimpl.cxx Change-Id: I6421265325e72023d1affe671d75488185772786
Diffstat (limited to 'vcl/inc/opengl')
-rw-r--r--vcl/inc/opengl/salbmp.hxx7
-rw-r--r--vcl/inc/opengl/texture.hxx67
2 files changed, 49 insertions, 25 deletions
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index c1f0cdb817ad..dbb29d80f802 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -40,7 +40,7 @@ class VCL_PLUGIN_PUBLIC OpenGLSalBitmap : public SalBitmap
{
private:
OpenGLContext* mpContext;
- OpenGLTextureSharedPtr mpTexture;
+ OpenGLTexture maTexture;
bool mbDirtyTexture;
BitmapPalette maPalette;
basebmp::RawMemorySharedArray maUserBuffer;
@@ -81,9 +81,8 @@ public:
public:
- bool Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pTex, long nX, long nY, long nWidth, long nHeight );
- bool Draw( OpenGLContext& rContext, const SalTwoRect& rPosAry );
- GLuint GetTexture( OpenGLContext& rContext ) const;
+ bool Create( OpenGLContext& rContext, const OpenGLTexture& rTex, long nX, long nY, long nWidth, long nHeight );
+ OpenGLTexture& GetTexture( OpenGLContext& rContext ) const;
private:
diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx
index c0b6541d7700..eb003cfe5b96 100644
--- a/vcl/inc/opengl/texture.hxx
+++ b/vcl/inc/opengl/texture.hxx
@@ -20,37 +20,62 @@
#ifndef INCLUDED_VCL_INC_OPENGL_TEXTURE_H
#define INCLUDED_VCL_INC_OPENGL_TEXTURE_H
-#include <boost/shared_ptr.hpp>
#include <GL/glew.h>
+#include <vcl/dllapi.h>
-class OpenGLTexture
+class ImplOpenGLTexture
{
-private:
+public:
+ int mnRefCount;
GLuint mnTexture;
int mnWidth;
int mnHeight;
GLenum mnFilter;
-public:
- OpenGLTexture();
- OpenGLTexture( int nWidth, int nHeight );
- OpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData );
- OpenGLTexture( int nX, int nY, int nWidth, int nHeight );
- virtual ~OpenGLTexture();
-
- GLuint Id() const;
- int GetWidth() const;
- int GetHeight() const;
-
- void Bind();
- void Unbind();
- bool Draw();
-
- GLenum GetFilter() const;
- void SetFilter( GLenum nFilter );
+ ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate );
+ ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData );
+ ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight );
+ ~ImplOpenGLTexture();
};
-typedef boost::shared_ptr< OpenGLTexture > OpenGLTextureSharedPtr;
+class VCL_PLUGIN_PUBLIC OpenGLTexture
+{
+private:
+ // if the rect size doesn't match the mpImpl one, this instance
+ // is a sub-area from the real OpenGL texture
+ Rectangle maRect;
+
+ ImplOpenGLTexture* mpImpl;
+
+public:
+ OpenGLTexture();
+ OpenGLTexture( int nWidth, int nHeight, bool bAllocate = true );
+ OpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData );
+ OpenGLTexture( int nX, int nY, int nWidth, int nHeight );
+ OpenGLTexture( const OpenGLTexture& rTexture );
+ OpenGLTexture( const OpenGLTexture& rTexture, int nX, int nY, int nWidth, int nHeight );
+ virtual ~OpenGLTexture();
+
+ bool IsUnique() const;
+
+ GLuint Id() const;
+ int GetWidth() const;
+ int GetHeight() const;
+ void GetCoord( GLfloat* pCoord, const SalTwoRect& rPosAry, bool bInverted=false ) const;
+
+ void Bind();
+ void Unbind();
+ bool Draw();
+ void Read( GLenum nFormat, GLenum nType, sal_uInt8* pData );
+
+ GLenum GetFilter() const;
+ void SetFilter( GLenum nFilter );
+
+ operator bool() const;
+ OpenGLTexture& operator=( const OpenGLTexture& rTexture );
+ bool operator==( const OpenGLTexture& rTexture ) const;
+ bool operator!=( const OpenGLTexture& rTexture ) const;
+};
#endif // INCLUDED_VCL_INC_OPENGL_TEXTURE_H