summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-18 09:07:31 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-18 09:14:26 +0100
commitd09f827b1d33ca001ebfa55bdecca1b3437e53ec (patch)
treee6318096d9435f30a6a32f03d9ac69d60b7a5774
parent2195500d40055a182c573da074e61ddf0a2b4d5a (diff)
windows opengl: Provide the context to textures everywhere where we have it.
Change-Id: Ib820326fdc752d0893840bad3eb7f1369469f796
-rw-r--r--vcl/inc/opengl/contextprovider.hxx28
-rw-r--r--vcl/inc/opengl/salbmp.hxx2
-rw-r--r--vcl/inc/salgdi.hxx4
-rw-r--r--vcl/inc/unx/salgdi.h2
-rw-r--r--vcl/opengl/salbmp.cxx23
-rw-r--r--vcl/source/gdi/salgdilayout.cxx13
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx9
7 files changed, 24 insertions, 57 deletions
diff --git a/vcl/inc/opengl/contextprovider.hxx b/vcl/inc/opengl/contextprovider.hxx
deleted file mode 100644
index 47eb98cd92e7..000000000000
--- a/vcl/inc/opengl/contextprovider.hxx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX
-#define INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX
-
-#include "vclpluginapi.h"
-
-#include <vcl/opengl/OpenGLContext.hxx>
-
-class VCLPLUG_GEN_PUBLIC OpenGLContextProvider
-{
-public:
- virtual ~OpenGLContextProvider() {};
-
- /* Get the OpenGL context provided by this instance */
- virtual OpenGLContext* GetOpenGLContext() const = 0;
-};
-
-#endif // INCLUDED_VCL_INC_OPENGL_CONTEXTPROVIDER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 98fc2feb6e2b..c8626729a63c 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -52,7 +52,7 @@ private:
int mnBufHeight;
std::deque< OpenGLSalBitmapOp* > maPendingOps;
- bool makeCurrent();
+ void makeCurrent();
public:
OpenGLSalBitmap();
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 4a567f5b7f57..95920a050157 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -44,6 +44,7 @@ class SalLayout;
class ImplLayoutArgs;
class Rectangle;
class FontSubsetInfo;
+class OpenGLContext;
class OutputDevice;
class ServerFontLayout;
struct SystemGraphicsData;
@@ -85,6 +86,9 @@ public:
virtual SalGraphicsImpl* GetImpl() const = 0;
+ /// Check that our mpImpl is OpenGL and return the context, otherwise NULL.
+ virtual OpenGLContext* GetOpenGLContext() const;
+
void setAntiAliasB2DDraw(bool bNew) { m_bAntiAliasB2DDraw = bNew; }
bool getAntiAliasB2DDraw() const { return m_bAntiAliasB2DDraw; }
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 6b0e2be8a035..6bf4c04542de 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -62,7 +62,7 @@ namespace basegfx {
class B2DTrapezoid;
}
-class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics, public OpenGLContextProvider
+class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
{
friend class ServerFontLayout;
friend class X11SalGraphicsImpl;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 78bcf07b1594..c664d7e7e8fd 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -27,7 +27,6 @@
#include "svdata.hxx"
#include "salgdi.hxx"
-#include "opengl/contextprovider.hxx"
#include "opengl/salbmp.hxx"
static bool isValidBitCount( sal_uInt16 nBitCount )
@@ -407,8 +406,7 @@ GLuint OpenGLSalBitmap::CreateTexture()
}
}
- if( !makeCurrent() )
- return 0;
+ makeCurrent();
maTexture = OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData );
SAL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
@@ -470,21 +468,13 @@ sal_uInt16 OpenGLSalBitmap::GetBitCount() const
return mnBits;
}
-bool OpenGLSalBitmap::makeCurrent()
+void OpenGLSalBitmap::makeCurrent()
{
if (!mpContext || !mpContext->isInitialized())
- {
- OpenGLContextProvider *pProvider;
- pProvider = dynamic_cast< OpenGLContextProvider* >( ImplGetDefaultWindow()->GetGraphics() );
- if( pProvider == NULL )
- {
- SAL_WARN( "vcl.opengl", "Couldn't get default OpenGL context provider" );
- return false;
- }
- mpContext = pProvider->GetOpenGLContext();
- }
+ mpContext = ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
+
+ assert(mpContext && "Couldn't get default OpenGL context provider");
mpContext->makeCurrent();
- return true;
}
BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
@@ -499,8 +489,7 @@ BitmapBuffer* OpenGLSalBitmap::AcquireBuffer( bool /*bReadOnly*/ )
if( !maPendingOps.empty() )
{
- if (!makeCurrent())
- return NULL;
+ makeCurrent();
SAL_INFO( "vcl.opengl", "** Creating texture and reading it back immediatly" );
if( !CreateTexture() || !AllocateUserData() || !ReadTexture() )
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 599500bc9ff3..da020434f24c 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -27,11 +27,13 @@
#include <vcl/metaact.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/print.hxx>
+#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/outdev.hxx>
#include <vcl/unowrap.hxx>
#include <vcl/settings.hxx>
#include <window.h>
+#include <openglgdiimpl.hxx>
#include <outdev.h>
#include <sallayout.hxx>
#include <salgdi.hxx>
@@ -43,7 +45,7 @@
#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
-#include "basegfx/polygon/b2dpolygon.hxx"
+#include <basegfx/polygon/b2dpolygon.hxx>
// The only common SalFrame method
@@ -75,6 +77,15 @@ SalGraphics::~SalGraphics()
{
}
+OpenGLContext* SalGraphics::GetOpenGLContext() const
+{
+ OpenGLSalGraphicsImpl *pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(GetImpl());
+ if (pImpl)
+ return &pImpl->GetOpenGLContext();
+
+ return NULL;
+}
+
bool SalGraphics::drawTransformedBitmap(
const basegfx::B2DPoint& /* rNull */,
const basegfx::B2DPoint& /* rX */,
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index fc2ca5080e6f..34df86ddd770 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -172,15 +172,6 @@ void X11SalGraphics::DeInit()
SetDrawable( None, m_nXScreen );
}
-OpenGLContext* X11SalGraphics::GetOpenGLContext() const
-{
- OpenGLSalGraphicsImpl *pImpl;
- pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(mpImpl.get());
- if( pImpl )
- return &pImpl->GetOpenGLContext();
- return NULL;
-}
-
void X11SalGraphics::SetClipRegion( GC pGC, Region pXReg ) const
{
Display *pDisplay = GetXDisplay();