From 80d0b2916db81a7f47bb1d368677016bbb870df6 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 4 Apr 2016 19:29:27 +0900 Subject: opengl: use packed texture atlas for glyph cache in win. backend Change-Id: I6a627699d49bad47213788877fa3947ad2ef83f4 --- vcl/inc/opengl/AccumulatedTextures.hxx | 17 +++++++++-------- vcl/inc/opengl/texture.hxx | 6 ++++-- vcl/inc/openglgdiimpl.hxx | 2 +- vcl/inc/win/salgdi.h | 5 +++++ 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'vcl/inc') diff --git a/vcl/inc/opengl/AccumulatedTextures.hxx b/vcl/inc/opengl/AccumulatedTextures.hxx index 9ce170c2a0af..e74c06535f69 100644 --- a/vcl/inc/opengl/AccumulatedTextures.hxx +++ b/vcl/inc/opengl/AccumulatedTextures.hxx @@ -11,6 +11,8 @@ #ifndef INCLUDED_VCL_INC_OPENGL_ACCUMULATEDTEXTURES_H #define INCLUDED_VCL_INC_OPENGL_ACCUMULATEDTEXTURES_H +#include + #include #include "opengl/texture.hxx" #include @@ -34,10 +36,10 @@ struct AccumulatedTexturesEntry : maTexture(rTexture) {} - void insert(const SalColor& aColor, const SalTwoRect& r2Rect) + void insert(const OpenGLTexture& rTexture, const SalColor& aColor, const SalTwoRect& r2Rect) { TextureDrawParameters& aDrawParameters = maColorTextureDrawParametersMap[aColor]; - maTexture.FillCoords(aDrawParameters.maTextureCoords, r2Rect, false); + rTexture.FillCoords(aDrawParameters.maTextureCoords, r2Rect, false); GLfloat nX1 = r2Rect.mnDestX; GLfloat nY1 = r2Rect.mnDestY; @@ -86,19 +88,18 @@ public: maEntries.clear(); } - void insert(const OpenGLTexture& rTexture, const SalColor& aColor, const SalTwoRect& r2Rect) + void insert(OpenGLTexture& rTexture, const SalColor& aColor, const SalTwoRect& r2Rect) { GLuint nTextureId = rTexture.Id(); - auto iterator = maEntries.find(nTextureId); - - if (iterator == maEntries.end()) + if (maEntries.find(nTextureId) == maEntries.end()) { - maEntries[nTextureId] = o3tl::make_unique(rTexture); + OpenGLTexture aWholeTexture(rTexture.GetWholeTexture()); + maEntries[nTextureId] = o3tl::make_unique(aWholeTexture); } std::unique_ptr& rEntry = maEntries[nTextureId]; - rEntry->insert(aColor, r2Rect); + rEntry->insert(rTexture, aColor, r2Rect); } AccumulatedTexturesMap& getAccumulatedTexturesMap() diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx index f48a1a166b03..a220875ba1ac 100644 --- a/vcl/inc/opengl/texture.hxx +++ b/vcl/inc/opengl/texture.hxx @@ -96,7 +96,7 @@ private: public: OpenGLTexture(); - OpenGLTexture(ImplOpenGLTexture* pImpl, Rectangle aRectangle, int nSlotNumber = 0); + OpenGLTexture(ImplOpenGLTexture* pImpl, Rectangle aRectangle, int nSlotNumber); OpenGLTexture( int nWidth, int nHeight, bool bAllocate = true ); OpenGLTexture( int nWidth, int nHeight, int nFormat, int nType, void const * pData ); @@ -113,13 +113,15 @@ public: void GetCoord( GLfloat* pCoord, const SalTwoRect& rPosAry, bool bInverted=false ) const; void GetWholeCoord( GLfloat* pCoord ) const; - + OpenGLTexture GetWholeTexture(); void Bind(); void Unbind(); void Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ); GLuint AddStencil(); GLuint StencilId() const; + bool CopyData(int nWidth, int nHeight, int nFormat, int nType, sal_uInt8* pData); + void SaveToFile(const OUString& rFileName); GLenum GetFilter() const; diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 0fb2941ace9c..756190135daa 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -147,7 +147,7 @@ public: void DrawLinearGradient( const Gradient& rGradient, const Rectangle& rRect ); void DrawAxialGradient( const Gradient& rGradient, const Rectangle& rRect ); void DrawRadialGradient( const Gradient& rGradient, const Rectangle& rRect ); - void DeferredTextDraw(const OpenGLTexture& rTexture, const SalColor nMaskColor, const SalTwoRect& rPosAry); + void DeferredTextDraw(OpenGLTexture& rTexture, const SalColor nMaskColor, const SalTwoRect& rPosAry); void FlushDeferredDrawing(bool bInDraw = false); public: diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index ffd83ab251ad..8866dcfbc289 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -172,11 +172,16 @@ public: SalTwoRect getTwoRect() { return maRects; } + Size getBitmapSize() { return Size(maRects.mnSrcWidth, maRects.mnSrcHeight); } + /// Reset the DC with the defined color. void fill(sal_uInt32 color); /// Obtain the texture; the caller must delete it after use. OpenGLTexture* getTexture(); + + /// Copy bitmap data to the texture. Texutre must be initialized and the correct size to hold the bitmap. + bool copyToTexture(OpenGLTexture& aTexture); }; class WinSalGraphics : public SalGraphics -- cgit