Kaydet (Commit) 1b0df37e authored tarafından Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Kaydeden (comit) Markus Mohrhard

vcl: Add OpenGLSalBitmap implementation

Change-Id: I0deebaedf6fe5b23f50a448eea0d5d9e99ebd391
üst 251f9af7
...@@ -123,6 +123,7 @@ $(eval $(call gb_Library_use_externals,vcl,\ ...@@ -123,6 +123,7 @@ $(eval $(call gb_Library_use_externals,vcl,\
$(eval $(call gb_Library_add_exception_objects,vcl,\ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/opengl/gdiimpl \ vcl/opengl/gdiimpl \
vcl/opengl/salbmp \
vcl/source/opengl/OpenGLContext \ vcl/source/opengl/OpenGLContext \
vcl/source/opengl/OpenGLHelper \ vcl/source/opengl/OpenGLHelper \
vcl/source/window/openglwin \ vcl/source/window/openglwin \
......
/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_VCL_INC_OPENGL_SALBMP_H
#define INCLUDED_VCL_INC_OPENGL_SALBMP_H
#include <basebmp/bitmapdevice.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
#include "vcl/salbtype.hxx"
#include <salbmp.hxx>
// - SalBitmap -
struct BitmapBuffer;
class BitmapPalette;
class VCL_PLUGIN_PUBLIC OpenGLSalBitmap : public SalBitmap
{
private:
OpenGLContext* mpContext;
GLuint mnTexture;
bool mbDirtyTexture;
BitmapPalette maPalette;
basebmp::RawMemorySharedArray maUserBuffer;
sal_uInt16 mnBits;
sal_uInt16 mnBytesPerRow;
int mnWidth;
int mnHeight;
public:
OpenGLSalBitmap();
virtual ~OpenGLSalBitmap();
public:
// SalBitmap methods
bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ) SAL_OVERRIDE;
bool Create( const SalBitmap& rSalBmp ) SAL_OVERRIDE;
bool Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics ) SAL_OVERRIDE;
bool Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount ) SAL_OVERRIDE;
virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas,
Size& rSize,
bool bMask = false ) SAL_OVERRIDE;
void Destroy() SAL_OVERRIDE;
Size GetSize() const SAL_OVERRIDE;
sal_uInt16 GetBitCount() const SAL_OVERRIDE;
BitmapBuffer *AcquireBuffer( bool bReadOnly ) SAL_OVERRIDE;
void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) SAL_OVERRIDE;
bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
public:
bool Create( OpenGLContext& rContext, long nX, long nY, long nWidth, long nHeight );
bool Draw( OpenGLContext& rContext, const SalTwoRect& rPosAry );
GLuint GetTexture( OpenGLContext& rContext ) const;
private:
GLuint CreateTexture();
void DeleteTexture();
void DrawTexture( GLuint nTexture, const SalTwoRect& rPosAry );
bool AllocateUserData();
bool ReadTexture();
};
#endif // INCLUDED_VCL_INC_OPENGL_SALBMP_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <basegfx/polygon/b2dpolygontriangulator.hxx> #include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/opengl/OpenGLHelper.hxx>
#include "opengl/salbmp.hxx"
#define GL_ATTRIB_POS 0 #define GL_ATTRIB_POS 0
#define GL_ATTRIB_TEX 1 #define GL_ATTRIB_TEX 1
...@@ -654,8 +655,9 @@ void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* /* ...@@ -654,8 +655,9 @@ void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* /*
void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
{ {
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap); const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
GLuint nTexture = rBitmap.GetTexture(); GLuint nTexture = rBitmap.GetTexture( maContext );
SAL_INFO( "vcl.opengl", "::drawBitmap" );
maContext.makeCurrent(); maContext.makeCurrent();
DrawTexture( nTexture, rPosAry ); DrawTexture( nTexture, rPosAry );
} }
...@@ -675,9 +677,10 @@ void OpenGLSalGraphicsImpl::drawBitmap( ...@@ -675,9 +677,10 @@ void OpenGLSalGraphicsImpl::drawBitmap(
{ {
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap); const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
const OpenGLSalBitmap& rMask = static_cast<const OpenGLSalBitmap&>(rMaskBitmap); const OpenGLSalBitmap& rMask = static_cast<const OpenGLSalBitmap&>(rMaskBitmap);
const GLuint nTexture( rBitmap.GetTexture() ); const GLuint nTexture( rBitmap.GetTexture( maContext ) );
const GLuint nMask( rMask.GetTexture() ); const GLuint nMask( rMask.GetTexture( maContext ) );
SAL_INFO( "vcl.opengl", "::drawBitmap" );
maContext.makeCurrent(); maContext.makeCurrent();
DrawTextureWithMask( nTexture, nMask, rPosAry ); DrawTextureWithMask( nTexture, nMask, rPosAry );
} }
...@@ -688,22 +691,16 @@ void OpenGLSalGraphicsImpl::drawMask( ...@@ -688,22 +691,16 @@ void OpenGLSalGraphicsImpl::drawMask(
SalColor nMaskColor ) SalColor nMaskColor )
{ {
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap); const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
const GLuint nTexture( rBitmap.GetTexture() ); const GLuint nTexture( rBitmap.GetTexture( maContext ) );
maContext.makeCurrent();
DrawMask( nTexture, nMaskColor, rPosAry ); DrawMask( nTexture, nMaskColor, rPosAry );
} }
SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long nHeight ) SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long nHeight )
{ {
GLuint nTexture;
/*glGenTexture( 1, &nTexture );
glBindTexture( GL_TEXTURE_2D, nTexture );
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, nX, nY, nWidth, nHeight, 0 );
glBindTexture( GL_TEXTURE_2D, 0 );*/
OpenGLSalBitmap* pBitmap = new OpenGLSalBitmap; OpenGLSalBitmap* pBitmap = new OpenGLSalBitmap;
if( !pBitmap->Create( nX, nY, nWidth, nHeight ) ) if( !pBitmap->Create( maContext, nX, nY, nWidth, nHeight ) )
{ {
delete pBitmap; delete pBitmap;
pBitmap = NULL; pBitmap = NULL;
...@@ -796,8 +793,8 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap( ...@@ -796,8 +793,8 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
{ {
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap); const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
const OpenGLSalBitmap& rAlpha = static_cast<const OpenGLSalBitmap&>(rAlphaBitmap); const OpenGLSalBitmap& rAlpha = static_cast<const OpenGLSalBitmap&>(rAlphaBitmap);
const GLuint nTexture( rBitmap.GetTexture() ); const GLuint nTexture( rBitmap.GetTexture( maContext ) );
const GLuint nAlpha( rAlpha.GetTexture() ); const GLuint nAlpha( rAlpha.GetTexture( maContext ) );
maContext.makeCurrent(); maContext.makeCurrent();
DrawTextureWithMask( nTexture, nAlpha, rPosAry ); DrawTextureWithMask( nTexture, nAlpha, rPosAry );
......
This diff is collapsed.
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include <unx/salinst.h> #include <unx/salinst.h>
#include <unx/x11/xlimits.hxx> #include <unx/x11/xlimits.hxx>
#include <opengl/salbmp.hxx>
#if defined HAVE_VALGRIND_HEADERS #if defined HAVE_VALGRIND_HEADERS
#include <valgrind/memcheck.h> #include <valgrind/memcheck.h>
#endif #endif
...@@ -53,7 +55,11 @@ ...@@ -53,7 +55,11 @@
SalBitmap* X11SalInstance::CreateSalBitmap() SalBitmap* X11SalInstance::CreateSalBitmap()
{ {
return new X11SalBitmap(); static const char* pOpenGL = getenv("USE_OPENGL");
if (pOpenGL)
return new OpenGLSalBitmap();
else
return new X11SalBitmap();
} }
ImplSalBitmapCache* X11SalBitmap::mpCache = NULL; ImplSalBitmapCache* X11SalBitmap::mpCache = NULL;
......
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