summaryrefslogtreecommitdiff
path: root/vcl/opengl/win/gdiimpl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/opengl/win/gdiimpl.cxx')
-rw-r--r--vcl/opengl/win/gdiimpl.cxx85
1 files changed, 85 insertions, 0 deletions
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index ee53c8a7695b..cd7dc87b6e8c 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -7,6 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <o3tl/lru_map.hxx>
+
+
#include "opengl/win/gdiimpl.hxx"
#include <win/wincomp.hxx>
@@ -43,4 +46,86 @@ bool WinOpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
return ( pContext->getOpenGLWindow().hWnd == mrParent.mhWnd );
}
+namespace
+{
+
+typedef std::pair<ControlCacheKey, std::unique_ptr<TextureCombo>> ControlCachePair;
+typedef o3tl::lru_map<ControlCacheKey, std::unique_ptr<TextureCombo>, ControlCacheHashFunction> ControlCacheType;
+
+ControlCacheType gTextureCache(200);
+
+}
+
+bool WinOpenGLSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey& rControlCacheKey, int nX, int nY)
+{
+ static bool gbCacheEnabled = !getenv("SAL_WITHOUT_WIDGET_CACHE");
+
+ if (!gbCacheEnabled)
+ return false;
+
+ ControlCacheType::const_iterator iterator = gTextureCache.find(rControlCacheKey);
+
+ if (iterator == gTextureCache.end())
+ return false;
+
+ const std::unique_ptr<TextureCombo>& pCombo = iterator->second;
+
+ PreDraw();
+
+ OpenGLTexture& rTexture = *pCombo->mpTexture;
+
+ SalTwoRect aPosAry(0, 0, rTexture.GetWidth(), rTexture.GetHeight(),
+ nX, nY, rTexture.GetWidth(), rTexture.GetHeight());
+
+ if (pCombo->mpMask)
+ DrawTextureDiff(rTexture, *pCombo->mpMask, aPosAry, true);
+ else
+ DrawTexture(rTexture, aPosAry, true);
+
+ PostDraw();
+
+ return true;
+}
+
+bool WinOpenGLSalGraphicsImpl::RenderCompatibleDC(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack,
+ int nX, int nY, TextureCombo& rCombo)
+{
+ PreDraw();
+
+ rCombo.mpTexture.reset(rWhite.getTexture());
+ rCombo.mpMask.reset(rBlack.getTexture());
+
+
+ if (rCombo.mpTexture && rCombo.mpMask)
+ {
+ OpenGLTexture& rTexture = *rCombo.mpTexture;
+
+ SalTwoRect aPosAry(0, 0, rTexture.GetWidth(), rTexture.GetHeight(),
+ nX, nY, rTexture.GetWidth(), rTexture.GetHeight());
+
+ DrawTextureDiff(*rCombo.mpTexture, *rCombo.mpMask, aPosAry);
+ }
+
+ PostDraw();
+ return true;
+}
+
+bool WinOpenGLSalGraphicsImpl::RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack,
+ int nX, int nY , ControlCacheKey& aControlCacheKey)
+{
+ std::unique_ptr<TextureCombo> pCombo(new TextureCombo);
+
+ bool bResult = RenderCompatibleDC(rWhite, rBlack, nX, nY, *pCombo);
+ if (!bResult)
+ return false;
+
+ if (aControlCacheKey.mnType == CTRL_CHECKBOX)
+ return true;
+
+ ControlCachePair pair(aControlCacheKey, std::move(pCombo));
+ gTextureCache.insert(std::move(pair));
+
+ return bResult;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */