Kaydet (Commit) 878cea91 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

windows opengl: Provide the context to textures everywhere where we have it.

Change-Id: Ib820326fdc752d0893840bad3eb7f1369469f796
üst fef950f8
/* -*- 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: */
......@@ -52,7 +52,7 @@ private:
int mnBufHeight;
std::deque< OpenGLSalBitmapOp* > maPendingOps;
bool makeCurrent();
void makeCurrent();
public:
OpenGLSalBitmap();
......
......@@ -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; }
......
......@@ -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;
......
......@@ -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() )
......
......@@ -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 */,
......
......@@ -173,15 +173,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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment