[Libreoffice-commits] core.git: 161 commits - avmedia/Library_avmedia.mk avmedia/Library_avmediaogl.mk basegfx/source canvas/Library_oglcanvas.mk chart2/Library_chartcontroller.mk chart2/Library_chartcore.mk chart2/Library_chartopengl.mk chart2/opengl chart2/source include/vcl officecfg/registry Repository.mk sc/CppunitTest_sc_ucalc.mk sc/Library_sc.mk sc/workben shell/source slideshow/Library_OGLTrans.mk slideshow/Library_slideshow.mk slideshow/source solenv/gbuild svx/Library_svxcore.mk vcl/Executable_icontest.mk vcl/Executable_outdevgrind.mk vcl/Executable_vcldemo.mk vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Library_vclopengl.mk vcl/Library_vclplug_gen.mk vcl/Module_vcl.mk vcl/opengl vcl/Package_opengl.mk vcl/quartz vcl/source vcl/unx vcl/win vcl/workben

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sun Nov 9 23:05:54 PST 2014


 Repository.mk                                                          |    4 
 avmedia/Library_avmedia.mk                                             |    1 
 avmedia/Library_avmediaogl.mk                                          |    1 
 basegfx/source/polygon/b2dpolypolygoncutter.cxx                        |    2 
 canvas/Library_oglcanvas.mk                                            |    1 
 chart2/Library_chartcontroller.mk                                      |    1 
 chart2/Library_chartcore.mk                                            |    2 
 chart2/Library_chartopengl.mk                                          |    1 
 chart2/opengl/README.deprecated                                        |   23 
 chart2/source/view/main/GL3DRenderer.cxx                               |    3 
 include/vcl/opengl/OpenGLContext.hxx                                   |   36 
 include/vcl/opengl/OpenGLHelper.hxx                                    |   16 
 include/vcl/outdev.hxx                                                 |    2 
 officecfg/registry/data/org/openoffice/Office/Common.xcu               |    8 
 officecfg/registry/data/org/openoffice/Setup.xcu                       |    2 
 officecfg/registry/schema/org/openoffice/Office/Common.xcs             |   79 
 sc/CppunitTest_sc_ucalc.mk                                             |    1 
 sc/Library_sc.mk                                                       |    1 
 sc/workben/opencl/platform_detect.cxx                                  |   14 
 shell/source/backends/gconfbe/gconfaccess.cxx                          |   16 
 shell/source/backends/gconfbe/gconfaccess.hxx                          |    2 
 slideshow/Library_OGLTrans.mk                                          |    1 
 slideshow/Library_slideshow.mk                                         |    1 
 slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx |    6 
 solenv/gbuild/extensions/pre_MergedLibsList.mk                         |    1 
 svx/Library_svxcore.mk                                                 |    1 
 vcl/Executable_icontest.mk                                             |    1 
 vcl/Executable_outdevgrind.mk                                          |   39 
 vcl/Executable_vcldemo.mk                                              |    4 
 vcl/Library_vcl.mk                                                     |   35 
 vcl/Library_vclopengl.mk                                               |   88 
 vcl/Library_vclplug_gen.mk                                             |   13 
 vcl/Module_vcl.mk                                                      |    9 
 vcl/Package_opengl.mk                                                  |   24 
 vcl/headless/svpbmp.cxx                                                |    5 
 vcl/inc/cairotextrender.hxx                                            |  129 
 vcl/inc/generic/genpspgraphics.h                                       |    2 
 vcl/inc/generic/glyphcache.hxx                                         |    1 
 vcl/inc/graphite_serverfont.hxx                                        |    2 
 vcl/inc/headless/svpbmp.hxx                                            |    2 
 vcl/inc/headless/svpgdi.hxx                                            |    2 
 vcl/inc/impbmp.hxx                                                     |   10 
 vcl/inc/opengl/bmpop.hxx                                               |   35 
 vcl/inc/opengl/salbmp.hxx                                              |  120 
 vcl/inc/opengl/texture.hxx                                             |   54 
 vcl/inc/opengl/win/gdiimpl.hxx                                         |   36 
 vcl/inc/opengl/x11/gdiimpl.hxx                                         |   42 
 vcl/inc/openglgdiimpl.hxx                                              |  259 +
 vcl/inc/quartz/salbmp.h                                                |    2 
 vcl/inc/quartz/salgdi.h                                                |    2 
 vcl/inc/salbmp.hxx                                                     |    2 
 vcl/inc/salgdi.hxx                                                     |    2 
 vcl/inc/salgdiimpl.hxx                                                 |  210 
 vcl/inc/textrender.hxx                                                 |   81 
 vcl/inc/unx/gtk/gtkframe.hxx                                           |    5 
 vcl/inc/unx/gtk/gtkgdi.hxx                                             |    5 
 vcl/inc/unx/pixmap.hxx                                                 |   46 
 vcl/inc/unx/salbmp.h                                                   |    2 
 vcl/inc/unx/salframe.h                                                 |    5 
 vcl/inc/unx/salgdi.h                                                   |  121 
 vcl/inc/unx/x11/x11gdiimpl.h                                           |   27 
 vcl/inc/unx/x11windowprovider.hxx                                      |   28 
 vcl/inc/win/salbmp.h                                                   |    2 
 vcl/inc/win/salgdi.h                                                   |   69 
 vcl/inc/win/svsys.h                                                    |    3 
 vcl/opengl/README.deprecated                                           |   23 
 vcl/opengl/convolutionFragmentShader.glsl                              |   28 
 vcl/opengl/gdiimpl.cxx                                                 | 1000 ++++
 vcl/opengl/maskFragmentShader.glsl                                     |   21 
 vcl/opengl/maskVertexShader.glsl                                       |   19 
 vcl/opengl/maskedTextureFragmentShader.glsl                            |   23 
 vcl/opengl/maskedTextureVertexShader.glsl                              |   19 
 vcl/opengl/salbmp.cxx                                                  |  513 ++
 vcl/opengl/scale.cxx                                                   |  308 +
 vcl/opengl/solidFragmentShader.glsl                                    |   17 
 vcl/opengl/solidVertexShader.glsl                                      |   16 
 vcl/opengl/texture.cxx                                                 |  144 
 vcl/opengl/textureFragmentShader.glsl                                  |   18 
 vcl/opengl/textureVertexShader.glsl                                    |   19 
 vcl/opengl/win/gdiimpl.cxx                                             |   65 
 vcl/opengl/x11/gdiimpl.cxx                                             |  139 
 vcl/quartz/salbmp.cxx                                                  |    5 
 vcl/source/gdi/bitmap.cxx                                              |    3 
 vcl/source/gdi/bitmap3.cxx                                             |   20 
 vcl/source/gdi/impbmp.cxx                                              |   12 
 vcl/source/gdi/salgdiimpl.cxx                                          |   26 
 vcl/source/opengl/OpenGLContext.cxx                                    |  434 +
 vcl/source/opengl/OpenGLHelper.cxx                                     |   83 
 vcl/source/outdev/bitmap.cxx                                           |    3 
 vcl/source/outdev/outdev.cxx                                           |    7 
 vcl/source/outdev/polygon.cxx                                          |    2 
 vcl/source/window/paint.cxx                                            |    2 
 vcl/unx/generic/app/saldisp.cxx                                        |    8 
 vcl/unx/generic/gdi/cairotextrender.cxx                                |  660 ++
 vcl/unx/generic/gdi/gdiimpl.cxx                                        | 1850 +++++++
 vcl/unx/generic/gdi/gdiimpl.hxx                                        |  278 +
 vcl/unx/generic/gdi/openglx11cairotextrender.cxx                       |   50 
 vcl/unx/generic/gdi/openglx11cairotextrender.hxx                       |   26 
 vcl/unx/generic/gdi/pixmap.cxx                                         |   49 
 vcl/unx/generic/gdi/salbmp.cxx                                         |   16 
 vcl/unx/generic/gdi/salgdi.cxx                                         |  913 ---
 vcl/unx/generic/gdi/salgdi2.cxx                                        |  772 ---
 vcl/unx/generic/gdi/salgdi3.cxx                                        |  590 --
 vcl/unx/generic/gdi/salvd.cxx                                          |    6 
 vcl/unx/generic/gdi/x11cairotextrender.cxx                             |  129 
 vcl/unx/generic/gdi/x11cairotextrender.hxx                             |   50 
 vcl/unx/generic/gdi/x11windowprovider.cxx                              |   16 
 vcl/unx/generic/window/salframe.cxx                                    |    5 
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx                               |  236 
 vcl/unx/gtk/window/gtksalframe.cxx                                     |    5 
 vcl/win/source/gdi/gdiimpl.cxx                                         | 2371 ++++++++++
 vcl/win/source/gdi/gdiimpl.hxx                                         |  218 
 vcl/win/source/gdi/salbmp.cxx                                          |    5 
 vcl/win/source/gdi/salgdi.cxx                                          | 1086 ----
 vcl/win/source/gdi/salgdi2.cxx                                         |  728 ---
 vcl/win/source/gdi/salgdi_gdiplus.cxx                                  |  469 -
 vcl/win/source/gdi/salprn.cxx                                          |   21 
 vcl/win/source/gdi/salvd.cxx                                           |   19 
 vcl/win/source/window/salframe.cxx                                     |   78 
 vcl/workben/icontest.cxx                                               |  218 
 vcl/workben/outdevgrind.cxx                                            |  103 
 vcl/workben/vcldemo.cxx                                                |  418 +
 122 files changed, 10831 insertions(+), 5281 deletions(-)

New commits:
commit ea48707a9d13fe94bfe4947aa28d755d19813456
Merge: 06a5b61 730a3ac
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 08:02:18 2014 +0100

    merge initial work on OpenGL vcl backend
    
    The backend builds on Windows, Linux and OSX but still does not render
    everything perfectly. Based on this initial framework the remaining
    improvements can be made incrementally in master.
    
    Whether the OpenGL code or the normal code is used depends on the OpenGL
    configuration variable. It currently defaults to false. Additionally we
    check during runtime if the requirements for running the OpenGL backend
    are fulfilled.

commit 730a3ac2daa9ec5774fc7b9482ed1aa94afab67f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 07:09:59 2014 +0100

    forgot to add the files
    
    Change-Id: I44a7e9bec213514708e4c971479660574508ad1b

diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
new file mode 100644
index 0000000..9b7c49e
--- /dev/null
+++ b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ */
+
+#include "openglx11cairotextrender.hxx"
+
+#include "salbmp.hxx"
+#include <vcl/salbtype.hxx>
+
+#include <cairo-svg.h>
+
+OpenGLX11CairoTextRender::OpenGLX11CairoTextRender(bool bPrinter, X11SalGraphics& rParent):
+    X11CairoTextRender(bPrinter, rParent)
+{
+}
+
+cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface()
+{
+    // static size_t id = 0;
+    // OString aFileName = OString("/tmp/libo_logs/text_rendering") + OString::number(id++) + OString(".svg");
+    // cairo_surface_t* surface = cairo_svg_surface_create(aFileName.getStr(), GetWidth(), GetHeight());
+    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, GetWidth(), GetHeight());
+    return surface;
+}
+
+void OpenGLX11CairoTextRender::drawSurface(cairo_t* cr)
+{
+    cairo_surface_t* surface = cairo_get_target(cr);
+    int width = cairo_image_surface_get_width(surface);
+    int height = cairo_image_surface_get_height(surface);
+    SalBitmap* pBitmap = ImplGetSVData()->mpDefInst->CreateSalBitmap();
+    pBitmap->Create(Size(width, height), 24, BitmapPalette());
+    BitmapBuffer* pBuffer = pBitmap->AcquireBuffer(false);
+    std::memcpy(pBuffer->mpBits, cairo_image_surface_get_data(surface), width*height*3);
+    pBitmap->ReleaseBuffer(pBuffer, false);
+    SalTwoRect aRect;
+    aRect.mnSrcX = 0;
+    aRect.mnSrcY = 0;
+    aRect.mnSrcWidth = width;
+    aRect.mnSrcHeight = height;
+    mrParent.drawBitmap(aRect, *pBitmap);
+    delete pBitmap;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.hxx b/vcl/unx/generic/gdi/openglx11cairotextrender.hxx
new file mode 100644
index 0000000..87ef948
--- /dev/null
+++ b/vcl/unx/generic/gdi/openglx11cairotextrender.hxx
@@ -0,0 +1,26 @@
+/* -*- 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_UNX_GENERIC_GDI_OPENGLX11CAIROTEXTRENDER_HXX
+#define INCLUDED_VCL_UNX_GENERIC_GDI_OPENGLX11CAIROTEXTRENDER_HXX value
+
+#include "x11cairotextrender.hxx"
+
+class OpenGLX11CairoTextRender : public X11CairoTextRender
+{
+public:
+    OpenGLX11CairoTextRender(bool bPrinter, X11SalGraphics& rParent);
+
+    virtual cairo_surface_t* getCairoSurface() SAL_OVERRIDE;
+    virtual void drawSurface(cairo_t* cr) SAL_OVERRIDE;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 7c4ccbc12b1bc732c7255b2c708081ca25bf9cb1
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 05:54:17 2014 +0100

    fix build
    
    Change-Id: I2c5152dfffa8f29502b902fbdcb0eabdb1d31704

diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index b18b630..f4dcc83 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_VCL_INC_UNX_CAIROFONTIMPL_HXX
 #define INCLUDED_VCL_INC_UNX_CAIROFONTIMPL_HXX
 
-#include <tools/rational.hxx>
+#include <sal/types.h>
 #include <vcl/salgtype.hxx>
 #include <vcl/vclenum.hxx>
 #include <vcl/metric.hxx>
commit 6efec7dca078dd92137a69886ca7f2bb8497df86
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 04:30:31 2014 +0100

    fix bad merge conflict resolution
    
    Change-Id: I788d57a5645c00f6bdb66cc14c7fa748bc8b02f2

diff --git a/Repository.mk b/Repository.mk
index 15bc3c9..3d3e35a 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -68,7 +68,8 @@ $(eval $(call gb_Helper_register_executables,NONE, \
         svpclient \
         pixelctl ) \
 	$(if $(and $(ENABLE_GTK), $(filter LINUX,$(OS))), tilebench) \
-	$(if $(filter LINUX MACOSX WNT,$(OS)),icontest) \
+	$(if $(filter LINUX MACOSX WNT,$(OS)),icontest \
+	    outdevgrind) \
 	vcldemo \
 	tiledrendering \
 	$(if $(and $(ENABLE_GTK), $(filter LINUX,$(OS))), gtktiledviewer) \
@@ -146,10 +147,6 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,ooo, \
 	$(if $(filter unx-TRUE,$(GUIBASE)-$(ENABLE_TDE)),tdefilepicker) \
 	$(if $(filter WNT,$(OS)),,uri-encode) \
 	ui-previewer \
-	$(if $(filter LINUX MACOSX WNT,$(OS)), \
-		icontest \
-	    outdevgrind) \
-	vcldemo \
 	$(if $(filter WNT,$(OS)), \
 		senddoc \
 	) \
commit 5d048e11e701aa35d1d466a1e3795bb4bae86163
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 04:28:40 2014 +0100

    disable OpenGL VCL backend for now in master
    
    Change-Id: Ie823c28fdcc742025d2f87a9cc1ca12cc41059b2

diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 42cfaa0..e19df23 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -856,7 +856,7 @@
            <desc>Specifies if OpenGL rendering should be used in VCL backends
                 supporting it.</desc>
         </info>
-        <value>true</value>
+        <value>false</value>
       </prop>
     </group>
     <group oor:name="InternalMSExport">
commit 556ddb68dca3515597517bb25a7463dcc68fdc2e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 10 04:06:25 2014 +0100

    only use OpenGL for window devices for now
    
    That fixes the build problems that I have seen.
    
    Change-Id: Ida89aa153d73ce4e07e3f0e0499df567e4df5009

diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index d9d333d..4e3b76f 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -590,7 +590,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
     mnPenWidth(GSL_PEN_WIDTH)
 {
     static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
-    bool bUseOpenGL = bOpenGLPossible && !mbPrinter ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
+    bool bUseOpenGL = bOpenGLPossible && mbWindow ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
     if (bUseOpenGL)
         mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
     else
commit ce8e2735dd2a3eb925209ba4cdfc3eba8a62cf9f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 10 04:05:32 2014 +0100

    add code for getting device width and height on window devices
    
    Change-Id: Ib1b84745cd1211a5194da78d83646ade4b01e72a

diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 0af7089..aa29dd9 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -13,13 +13,15 @@
 #include <vcl/dllapi.h>
 
 #include "openglgdiimpl.hxx"
+#include "win/salgdi.h"
 
 class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl
 {
 private:
+    WinSalGraphics& mrParent;
 
 public:
-    WinOpenGLSalGraphicsImpl();
+    WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics);
 
 protected:
     virtual GLfloat GetWidth() const SAL_OVERRIDE;
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 17868c8..e829ca4 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -9,18 +9,55 @@
 
 #include "opengl/win/gdiimpl.hxx"
 
-WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl()
+#include <win/wincomp.hxx>
+#include <win/saldata.hxx>
+#include <win/salframe.h>
+
+WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl(WinSalGraphics& rGraphics):
+    mrParent(rGraphics)
 {
 }
 
 GLfloat WinOpenGLSalGraphicsImpl::GetWidth() const
 {
+    if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) )
+    {
+        WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
+        if( pFrame )
+        {
+            if( pFrame->maGeometry.nWidth )
+                return pFrame->maGeometry.nWidth;
+            else
+            {
+                // TODO: perhaps not needed, maGeometry should always be up-to-date
+                RECT aRect;
+                GetClientRect( mrParent.gethWnd(), &aRect );
+                return aRect.right;
+            }
+        }
+    }
 
     return 1;
 }
 
 GLfloat WinOpenGLSalGraphicsImpl::GetHeight() const
 {
+    if( mrParent.gethWnd() && IsWindow( mrParent.gethWnd() ) )
+    {
+        WinSalFrame* pFrame = GetWindowPtr( mrParent.gethWnd() );
+        if( pFrame )
+        {
+            if( pFrame->maGeometry.nHeight )
+                return pFrame->maGeometry.nHeight;
+            else
+            {
+                // TODO: perhaps not needed, maGeometry should always be up-to-date
+                RECT aRect;
+                GetClientRect( mrParent.gethWnd(), &aRect );
+                return aRect.bottom;
+            }
+        }
+    }
 
     return 1;
 }
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index 28394b5..d9d333d 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -592,7 +592,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
     static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
     bool bUseOpenGL = bOpenGLPossible && !mbPrinter ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
     if (bUseOpenGL)
-        mpImpl.reset(new WinOpenGLSalGraphicsImpl());
+        mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
     else
         mpImpl.reset(new WinSalGraphicsImpl(*this));
 
commit a46b3da152f0de02486d01eefd744e4d4f376ea9
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 01:13:46 2014 +0100

    move README.deprecated from chart2 to vcl
    
    Change-Id: I077209d52805e1b8850a6702b9d88fe63acf8a0b

diff --git a/chart2/opengl/README.deprecated b/vcl/opengl/README.deprecated
similarity index 100%
rename from chart2/opengl/README.deprecated
rename to vcl/opengl/README.deprecated
commit eff8d971c97557691fd11540d1a5a366d225fb21
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Nov 10 00:09:01 2014 +0100

    implementation for OpenGL text rendering in the unx backend
    
    Change-Id: Ib1246f361d5efd13a7e36d568641c6360495604d

diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index bec6f4c..73e5d01 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -95,6 +95,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/gdi/gcach_xpeer \
 	vcl/unx/generic/gdi/gdiimpl \
 	vcl/unx/generic/gdi/pixmap \
+	vcl/unx/generic/gdi/openglx11cairotextrender \
     vcl/unx/generic/gdi/salbmp \
     vcl/unx/generic/gdi/salgdi2 \
     vcl/unx/generic/gdi/salgdi3 \
diff --git a/vcl/inc/cairotextrender.hxx b/vcl/inc/cairotextrender.hxx
index 7bc0b2f..e5db2ab 100644
--- a/vcl/inc/cairotextrender.hxx
+++ b/vcl/inc/cairotextrender.hxx
@@ -77,6 +77,7 @@ class CairoTextRender : public TextRenderImpl
 protected:
     virtual GlyphCache& getPlatformGlyphCache() = 0;
     virtual cairo_surface_t* getCairoSurface() = 0;
+    virtual void drawSurface(cairo_t* cr) = 0;
 
 bool setFont( const FontSelectPattern *pEntry, int nFallbackLevel );
 
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 5adbd87..5b31b92 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -341,6 +341,7 @@ void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout )
         aI = aNext;
     }
 
+    drawSurface(cr);
     cairo_destroy(cr);
 }
 
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index b4df486..47b20bc 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -57,6 +57,7 @@
 #include "gdiimpl.hxx"
 #include "opengl/x11/gdiimpl.hxx"
 #include "x11cairotextrender.hxx"
+#include "openglx11cairotextrender.hxx"
 
 #include "generic/printergfx.hxx"
 #include "xrender_peer.hxx"
@@ -66,7 +67,6 @@
 #include <vcl/opengl/OpenGLHelper.hxx>
 
 X11SalGraphics::X11SalGraphics():
-    mpTextRenderImpl(new X11CairoTextRender(false, *this)),
     m_pFrame(NULL),
     m_pVDev(NULL),
     m_pColormap(NULL),
@@ -87,9 +87,15 @@ X11SalGraphics::X11SalGraphics():
     static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
     bool bUseOpenGL = bOpenGLPossible ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
     if (bUseOpenGL)
+    {
         mpImpl.reset(new X11OpenGLSalGraphicsImpl(*this));
+        mpTextRenderImpl.reset((new OpenGLX11CairoTextRender(false, *this)));
+    }
     else
+    {
+        mpTextRenderImpl.reset((new X11CairoTextRender(false, *this)));
         mpImpl.reset(new X11SalGraphicsImpl(*this));
+    }
 
 }
 
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx
index 3a21c39..2533107 100644
--- a/vcl/unx/generic/gdi/x11cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx
@@ -20,6 +20,7 @@
 #include "x11cairotextrender.hxx"
 #include "unx/saldata.hxx"
 #include "unx/saldisp.hxx"
+#include "unx/salvd.h"
 
 #include "gcach_xpeer.hxx"
 
@@ -93,4 +94,36 @@ void X11CairoTextRender::clipRegion(cairo_t* cr)
     }
 }
 
+size_t X11CairoTextRender::GetWidth() const
+{
+    if( mrParent.m_pFrame )
+        return mrParent.m_pFrame->maGeometry.nWidth;
+    else if( mrParent.m_pVDev )
+    {
+        long nWidth = 0;
+        long nHeight = 0;
+        mrParent.m_pVDev->GetSize( nWidth, nHeight );
+        return nWidth;
+    }
+    return 1;
+}
+
+size_t X11CairoTextRender::GetHeight() const
+{
+    if( mrParent.m_pFrame )
+        return mrParent.m_pFrame->maGeometry.nHeight;
+    else if( mrParent.m_pVDev )
+    {
+        long nWidth = 0;
+        long nHeight = 0;
+        mrParent.m_pVDev->GetSize( nWidth, nHeight );
+        return nHeight;
+    }
+    return 1;
+}
+
+void X11CairoTextRender::drawSurface(cairo_t* /*cr*/)
+{
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.hxx b/vcl/unx/generic/gdi/x11cairotextrender.hxx
index 99688d1..fb0c130 100644
--- a/vcl/unx/generic/gdi/x11cairotextrender.hxx
+++ b/vcl/unx/generic/gdi/x11cairotextrender.hxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#ifndef INCLUDED_VCL_UNX_GENERIC_GDI_X11CAIROTEXTRENDER_HXX
+#define INCLUDED_VCL_UNX_GENERIC_GDI_X11CAIROTEXTRENDER_HXX value
+
 #include "cairotextrender.hxx"
 
 #include "unx/saldata.hxx"
@@ -26,14 +29,22 @@
 
 class X11CairoTextRender : public CairoTextRender
 {
-private:
+protected:
     X11SalGraphics& mrParent;
+
+protected:
+    size_t GetWidth() const;
+    size_t GetHeight() const;
+
 public:
     X11CairoTextRender(bool bPrinter, X11SalGraphics& rParent);
 
     virtual GlyphCache& getPlatformGlyphCache() SAL_OVERRIDE;
     virtual cairo_surface_t* getCairoSurface() SAL_OVERRIDE;
     virtual void clipRegion(cairo_t* cr) SAL_OVERRIDE;
+    virtual void drawSurface(cairo_t* cr) SAL_OVERRIDE;
 };
 
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9f8effdc74b4d74ce04d7c8971c91752d4a9a4cb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 10 00:42:48 2014 +0100

    fix windows build
    
    Change-Id: I4f8d4f9393b931f7593486f8e1fadee7ad35902a

diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index efe0986..81f774a 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -644,6 +644,7 @@ endif
 
 ifeq ($(OS),WNT)
 $(eval $(call gb_Library_add_exception_objects,vcl,\
+	vcl/opengl/win/gdiimpl \
     vcl/win/source/app/saldata \
     vcl/win/source/app/salinfo \
     vcl/win/source/app/salinst \
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
new file mode 100644
index 0000000..0af7089
--- /dev/null
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -0,0 +1,34 @@
+/* -*- 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_WIN_GDIIMPL_HXX
+#define INCLUDED_VCL_INC_OPENGL_WIN_GDIIMPL_HXX
+
+#include <vcl/dllapi.h>
+
+#include "openglgdiimpl.hxx"
+
+class WinOpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl
+{
+private:
+
+public:
+    WinOpenGLSalGraphicsImpl();
+
+protected:
+    virtual GLfloat GetWidth() const SAL_OVERRIDE;
+    virtual GLfloat GetHeight() const SAL_OVERRIDE;
+
+public:
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
new file mode 100644
index 0000000..17868c8
--- /dev/null
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -0,0 +1,28 @@
+/* -*- 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/.
+ */
+
+#include "opengl/win/gdiimpl.hxx"
+
+WinOpenGLSalGraphicsImpl::WinOpenGLSalGraphicsImpl()
+{
+}
+
+GLfloat WinOpenGLSalGraphicsImpl::GetWidth() const
+{
+
+    return 1;
+}
+
+GLfloat WinOpenGLSalGraphicsImpl::GetHeight() const
+{
+
+    return 1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index f185955..28394b5 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -34,7 +34,7 @@
 
 #include "salgdiimpl.hxx"
 #include "gdiimpl.hxx"
-#include "openglgdiimpl.hxx"
+#include "opengl/win/gdiimpl.hxx"
 
 #include <vcl/opengl/OpenGLHelper.hxx>
 
@@ -592,7 +592,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
     static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
     bool bUseOpenGL = bOpenGLPossible && !mbPrinter ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
     if (bUseOpenGL)
-        mpImpl.reset(new OpenGLSalGraphicsImpl());
+        mpImpl.reset(new WinOpenGLSalGraphicsImpl());
     else
         mpImpl.reset(new WinSalGraphicsImpl(*this));
 
commit 6f6cba0e8d16723e42d54db866c4e9e0d00b7a45
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Nov 9 08:50:41 2014 +0100

    remove that method also in the windows backend
    
    Change-Id: I578d842614fdc227459a3aaf889e062499b8bdbf

diff --git a/vcl/win/source/gdi/gdiimpl.cxx b/vcl/win/source/gdi/gdiimpl.cxx
index de9b6e3..453033f 100644
--- a/vcl/win/source/gdi/gdiimpl.cxx
+++ b/vcl/win/source/gdi/gdiimpl.cxx
@@ -294,10 +294,6 @@ WinSalGraphicsImpl::~WinSalGraphicsImpl()
 
 }
 
-void WinSalGraphicsImpl::Init(SalFrame* /*pFrame*/)
-{
-}
-
 void WinSalGraphicsImpl::freeResources()
 {
 }
diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx
index ebef9ea..2a0780f 100644
--- a/vcl/win/source/gdi/gdiimpl.hxx
+++ b/vcl/win/source/gdi/gdiimpl.hxx
@@ -52,8 +52,6 @@ public:
 
     virtual ~WinSalGraphicsImpl();
 
-    virtual void Init(SalFrame* pFrame) SAL_OVERRIDE;
-
     virtual void freeResources() SAL_OVERRIDE;
 
     virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
commit 6b08277cb662fa9a6c780c8ac6949eaf63a75a37
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Nov 9 08:43:44 2014 +0100

    fix windows compile errors in OpenGLContext
    
    Change-Id: Ic1a072d340d9115a6fc110bc9f71532739985d48

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 5508dfd..1062a87 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -42,9 +42,11 @@ OpenGLContext::OpenGLContext():
     mbInitialized(false),
     mbRequestLegacyContext(false),
     mbUseDoubleBufferedRendering(true),
-    mbRequestVirtualDevice(false),
-    mbPixmap(false)
+    mbRequestVirtualDevice(false)
 {
+#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
+    mbPixmap = false;
+#endif
 }
 
 OpenGLContext::~OpenGLContext()
@@ -803,6 +805,8 @@ bool OpenGLContext::ImplInit()
         return false;
     }
 
+    RECT clientRect;
+    GetClientRect(WindowFromDC(m_aGLWin.hDC), &clientRect);
     m_aGLWin.Width = clientRect.right - clientRect.left;
     m_aGLWin.Height = clientRect.bottom - clientRect.top;
 
commit 34925fef4c54ba2b9ecfbac975e4738c8dd69939
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 23:05:32 2014 -0500

    vcl: Re-enable features in vcldemo
    
    Change-Id: If2a17b2c5609b7529d9aa5091ced280dd5ac4176

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index cae3fb0b..daa877f 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -25,10 +25,10 @@
 #include <vcl/virdev.hxx>
 #include <vcl/graphicfilter.hxx>
 
-#if 0
 #  define FIXME_ALPHA_WORKING
 #  define FIXME_ROUNDED_RECT_WORKING
 #  define FIXME_DRAW_TRANSPARENT_WORKING
+#if 0
 #endif
 
 using namespace css;
commit 247137175bc0bd9d89348b85512394b756a5afec
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 23:04:46 2014 -0500

    vcl: Add support for styled lines rendering with OpenGL
    
    Change-Id: Id6117e79d3aec6524598f068500249c9cd286ece

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index d0b1afb..7094727 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -22,9 +22,12 @@
 #include <vcl/gradient.hxx>
 #include <salframe.hxx>
 #include "salvd.hxx"
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dlinegeometry.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolygontriangulator.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <basegfx/polygon/b2dtrapezoid.hxx>
 
 #include <vcl/opengl/OpenGLHelper.hxx>
 #include "opengl/salbmp.hxx"
@@ -648,13 +651,84 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rP
 }
 
 bool OpenGLSalGraphicsImpl::drawPolyLine(
-            const ::basegfx::B2DPolygon&,
-            double /*fTransparency*/,
-            const ::basegfx::B2DVector& /*rLineWidths*/,
-            basegfx::B2DLineJoin,
-            com::sun::star::drawing::LineCap)
-{
-    return false;
+            const ::basegfx::B2DPolygon& rPolygon,
+            double fTransparency,
+            const ::basegfx::B2DVector& rLineWidth,
+            basegfx::B2DLineJoin eLineJoin,
+            com::sun::star::drawing::LineCap eLineCap)
+{
+    SAL_INFO( "vcl.opengl", "::drawPolyLine trans " << fTransparency );
+    if( mnLineColor == SALCOLOR_NONE )
+        return true;
+
+    const bool bIsHairline = (rLineWidth.getX() == rLineWidth.getY()) && (rLineWidth.getX() <= 1.2);
+
+    // #i101491#
+    if( !bIsHairline && (rPolygon.count() > 1000) )
+    {
+        // the used basegfx::tools::createAreaGeometry is simply too
+        // expensive with very big polygons; fallback to caller (who
+        // should use ImplLineConverter normally)
+        // AW: ImplLineConverter had to be removed since it does not even
+        // know LineJoins, so the fallback will now prepare the line geometry
+        // the same way.
+        return false;
+    }
+
+    // #i11575#desc5#b adjust B2D tesselation result to raster positions
+    basegfx::B2DPolygon aPolygon = rPolygon;
+    const double fHalfWidth = 0.5 * rLineWidth.getX();
+
+    // #i122456# This is probably thought to happen to align hairlines to pixel positions, so
+    // it should be a 0.5 translation, not more. It will definitely go wrong with fat lines
+    aPolygon.transform( basegfx::tools::createTranslateB2DHomMatrix(0.5, 0.5) );
+
+    // shortcut for hairline drawing to improve performance
+    //bool bDrawnOk = true;
+    if( bIsHairline )
+    {
+        // hairlines can benefit from a simplified tesselation
+        // e.g. for hairlines the linejoin style can be ignored
+        /*basegfx::B2DTrapezoidVector aB2DTrapVector;
+        basegfx::tools::createLineTrapezoidFromB2DPolygon( aB2DTrapVector, aPolygon, rLineWidth.getX() );
+
+        // draw tesselation result
+        const int nTrapCount = aB2DTrapVector.size();
+        if( nTrapCount > 0 )
+            bDrawnOk = drawFilledTrapezoids( &aB2DTrapVector[0], nTrapCount, fTransparency );
+
+        return bDrawnOk;*/
+    }
+
+    // get the area polygon for the line polygon
+    if( (rLineWidth.getX() != rLineWidth.getY())
+    && !basegfx::fTools::equalZero( rLineWidth.getY() ) )
+    {
+        // prepare for createAreaGeometry() with anisotropic linewidth
+        aPolygon.transform( basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getX() / rLineWidth.getY()));
+    }
+
+    // create the area-polygon for the line
+    const basegfx::B2DPolyPolygon aAreaPolyPoly( basegfx::tools::createAreaGeometry(aPolygon, fHalfWidth, eLineJoin, eLineCap) );
+
+    if( (rLineWidth.getX() != rLineWidth.getY())
+    && !basegfx::fTools::equalZero( rLineWidth.getX() ) )
+    {
+        // postprocess createAreaGeometry() for anisotropic linewidth
+        aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX()));
+    }
+
+    maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+    BeginSolid( mnLineColor, fTransparency );
+    for( sal_uInt32 i = 0; i < aAreaPolyPoly.count(); i++ )
+    {
+        const ::basegfx::B2DPolyPolygon aOnePoly( aAreaPolyPoly.getB2DPolygon( i ) );
+        DrawPolyPolygon( aOnePoly );
+    }
+    EndSolid();
+
+    return true;
 }
 
 bool OpenGLSalGraphicsImpl::drawPolyLineBezier(
commit df713e65d6d29093dde843a84f92427900d53cfc
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 23:03:37 2014 -0500

    vcl: Fix rendering of polypolygons and self-intersecting polygons with OpenGL
    
    Change-Id: I04ed5999360eb43e2a8e2c82a3ecd9b958b16fe0

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 0e30f6a..d0b1afb 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -24,6 +24,7 @@
 #include "salvd.hxx"
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolygontriangulator.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
 
 #include <vcl/opengl/OpenGLHelper.hxx>
 #include "opengl/salbmp.hxx"
@@ -354,54 +355,39 @@ void OpenGLSalGraphicsImpl::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
     if( ::basegfx::tools::isConvex( aPolygon ) )
     {
         if( nPoints > 2L )
-        {
             DrawConvexPolygon( nPoints, pPtAry );
-        }
     }
     else
     {
-        const ::basegfx::B2DPolygon& aResult(
-            ::basegfx::triangulator::triangulate( aPolygon ) );
-        std::vector<GLfloat> aVertices(aResult.count() * 2);
-        sal_uInt32 j( 0 );
-
-        float nHeight = GetHeight();
-        float nWidth = GetWidth();
-        for( sal_uInt32 i = 0; i < aResult.count(); i++ )
-        {
-            const ::basegfx::B2DPoint& rPt( aResult.getB2DPoint(i) );
-            aVertices[j++] = 2 * rPt.getX() / nWidth - 1.0f;
-            aVertices[j++] = 1.0f - 2 * rPt.getY() / nHeight;
-        }
-
-        glEnableVertexAttribArray( GL_ATTRIB_POS );
-        glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
-        glDrawArrays( GL_TRIANGLES, 0, aResult.count() );
-        glDisableVertexAttribArray( GL_ATTRIB_POS );
+        const ::basegfx::B2DPolyPolygon aPolyPolygon( aPolygon );
+        DrawPolyPolygon( aPolyPolygon );
     }
 }
 
-void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& pPolyPolygon )
+void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon )
 {
     sal_uInt32 i, j;
-    ::std::vector< GLushort > pVertices;
+    ::std::vector< GLfloat > pVertices;
+    GLfloat nWidth = GetWidth();
+    GLfloat nHeight = GetHeight();
+    const ::basegfx::B2DPolyPolygon& aSimplePolyPolygon = ::basegfx::tools::solveCrossovers( rPolyPolygon );
 
-    for( i = 0; i < pPolyPolygon.count(); i++ )
+    for( i = 0; i < aSimplePolyPolygon.count(); i++ )
     {
-        const basegfx::B2DPolygon& pPolygon( pPolyPolygon.getB2DPolygon( i ) );
+        const basegfx::B2DPolygon& rPolygon( aSimplePolyPolygon.getB2DPolygon( i ) );
         const ::basegfx::B2DPolygon& aResult(
-            ::basegfx::triangulator::triangulate( pPolygon ) );
+            ::basegfx::triangulator::triangulate( rPolygon ) );
 
         for( j = 0; j < aResult.count(); j++ )
         {
             const ::basegfx::B2DPoint& rPt( aResult.getB2DPoint( j ) );
-            pVertices.push_back( rPt.getX() );
-            pVertices.push_back( rPt.getY() );
+            pVertices.push_back( 2 * rPt.getX() / nWidth - 1.0f );
+            pVertices.push_back( 1.0f - 2 * rPt.getY() / nHeight );
         }
     }
 
     glEnableVertexAttribArray( GL_ATTRIB_POS );
-    glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pVertices.data() );
+    glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pVertices.data() );
     glDrawArrays( GL_TRIANGLES, 0, pVertices.size() / 2 );
     glDisableVertexAttribArray( GL_ATTRIB_POS );
 }
commit 20328280dc38c80d70a3110e7a3153246b90123f
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 23:01:27 2014 -0500

    vcl: Add support for alpha mask rendering with OpenGL
    
    Change-Id: I755c2132f143d5ebd69e53bb4d9ae45121ada22a

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 9368a10..34c2607 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -76,7 +76,7 @@ protected:
     void DrawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon );
     void DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry );
     void DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& rPosAry );
-    void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& rPosAry );
+    void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& rPosAry );
     void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry );
 
 protected:
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 74f7252..0e30f6a 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -444,7 +444,7 @@ void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, con
     glUseProgram( 0 );
 }
 
-void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& /*pPosAry*/ )
+void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask, const Size& rSize, const SalTwoRect& pPosAry )
 {
     if( mnMaskedTextureProgram == 0 )
     {
@@ -460,7 +460,10 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask,
     glActiveTexture( GL_TEXTURE1 );
     glBindTexture( GL_TEXTURE_2D, nMask );
 
-    //DrawTextureRect( pPosAry );
+    glEnable( GL_BLEND );
+    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+    DrawTextureRect( rSize, pPosAry );
+    glDisable( GL_BLEND );
 
     glActiveTexture( GL_TEXTURE1 );
     glBindTexture( GL_TEXTURE_2D, 0 );
@@ -758,9 +761,10 @@ void OpenGLSalGraphicsImpl::drawBitmap(
     const GLuint nTexture( rBitmap.GetTexture( maContext ) );
     const GLuint nMask( rMask.GetTexture( maContext ) );
 
-    SAL_INFO( "vcl.opengl", "::drawBitmap" );
+    SAL_INFO( "vcl.opengl", "::drawBitmap with MASK" );
     maContext.makeCurrent();
-    DrawTextureWithMask( nTexture, nMask, rPosAry );
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+    DrawTextureWithMask( nTexture, nMask, rBitmap.GetSize(), rPosAry );
 }
 
 void OpenGLSalGraphicsImpl::drawMask(
@@ -881,8 +885,10 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
     const GLuint nTexture( rBitmap.GetTexture( maContext ) );
     const GLuint nAlpha( rAlpha.GetTexture( maContext ) );
 
+    SAL_INFO( "vcl.opengl", "::drawAlphaBitmap" );
     maContext.makeCurrent();
-    DrawTextureWithMask( nTexture, nAlpha, rPosAry );
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+    DrawTextureWithMask( nTexture, nAlpha, rBitmap.GetSize(), rPosAry );
     return true;
 }
 
diff --git a/vcl/opengl/maskedTextureFragmentShader.glsl b/vcl/opengl/maskedTextureFragmentShader.glsl
index 8f8148a..badf91e 100644
--- a/vcl/opengl/maskedTextureFragmentShader.glsl
+++ b/vcl/opengl/maskedTextureFragmentShader.glsl
@@ -13,10 +13,11 @@ uniform sampler2D sampler;
 uniform sampler2D mask;
 
 void main() {
-   vec4 texel0, texel1;
-   texel0 = texture2D(sampler, tex_coord);
-   texel1 = texture2D(mask, tex_coord);
-   gl_FragColor = texel0 * texel1.a;
+    vec4 texel0, texel1;
+    texel0 = texture2D(sampler, tex_coord);
+    texel1 = texture2D(mask, tex_coord);
+    gl_FragColor = texel0;
+    gl_FragColor.a = texel1.r;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit fe3b9a813c53d71ed5ac98419e0f450176fd99b6
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 23:00:16 2014 -0500

    vcl: Fix some viewport issues when rendering with OpenGL
    
    Change-Id: I99a76baeac07c1d9ec44ed492caa1d3416eb43ac

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index a9a6884..74f7252 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -498,6 +498,7 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY )
     if( mnLineColor != SALCOLOR_NONE )
     {
         maContext.makeCurrent();
+        glViewport( 0, 0, GetWidth(), GetHeight() );
         BeginSolid( mnLineColor );
         DrawPoint( nX, nY );
         EndSolid();
@@ -510,6 +511,7 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY, SalColor nSalColor )
     if( nSalColor != SALCOLOR_NONE )
     {
         maContext.makeCurrent();
+        glViewport( 0, 0, GetWidth(), GetHeight() );
         BeginSolid( nSalColor );
         DrawPoint( nX, nY );
         EndSolid();
@@ -522,6 +524,7 @@ void OpenGLSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 )
     if( mnLineColor != SALCOLOR_NONE )
     {
         maContext.makeCurrent();
+        glViewport( 0, 0, GetWidth(), GetHeight() );
         BeginSolid( mnLineColor );
         DrawLine( nX1, nY1, nX2, nY2 );
         EndSolid();
@@ -560,6 +563,7 @@ void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pP
 {
     SAL_INFO( "vcl.opengl", "::drawPolyLine" );
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
 
     if( mnLineColor != SALCOLOR_NONE && nPoints > 1 )
     {
@@ -587,6 +591,7 @@ void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
     }
 
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
 
     if( mnFillColor != SALCOLOR_NONE )
     {
@@ -610,6 +615,7 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
         return;
 
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
 
     if( mnFillColor != SALCOLOR_NONE )
     {
@@ -767,6 +773,7 @@ void OpenGLSalGraphicsImpl::drawMask(
 
     SAL_INFO( "vcl.opengl", "::drawMask" );
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
     DrawMask( nTexture, nMaskColor, rPosAry );
 }
 
@@ -788,6 +795,7 @@ SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY )
     char pixel[3];
 
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
     glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
     return MAKE_SALCOLOR( pixel[0], pixel[1], pixel[2] );
 }
@@ -803,6 +811,7 @@ void OpenGLSalGraphicsImpl::invert(
     //   * SAL_INVERT_TRACKFRAME (dash-line rectangle?)
 
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
 
     if( nFlags & SAL_INVERT_TRACKFRAME )
     {
@@ -823,6 +832,7 @@ void OpenGLSalGraphicsImpl::invert(
 void OpenGLSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
 {
     maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
 
     if( nFlags & SAL_INVERT_TRACKFRAME )
     {
commit 4c42104fadecd34e138d40d8b3b864c3bbf7c6aa
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 22:59:09 2014 -0500

    vcl: Fix pixel drawing with OpenGL
    
    Change-Id: If23255d2a78445d2c28ada00778c95e28cbd0683

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 27347a8..a9a6884 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -268,10 +268,10 @@ void OpenGLSalGraphicsImpl::EndInvert( void )
 
 void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
 {
-    GLushort pPoint[2];
+    GLfloat pPoint[2];
 
-    pPoint[0] = nX;
-    pPoint[1] = GetHeight() - nY;
+    pPoint[0] = 2 * nX / GetWidth() - 1.0f;
+    pPoint[1] = 2 * (GetHeight() - nY) / GetHeight() - 1.0f;
 
     glEnableVertexAttribArray( GL_ATTRIB_POS );
     glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pPoint );
commit f89905a77417d7640e1ee2d4b2112fdc017bb6f4
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 22:55:58 2014 -0500

    vcl: Disable clipping in OpenGL for now because it's broken with VDev
    
    Change-Id: Ia1e5de6674e642f428da58164001e8619cd99530

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 55b6a93..27347a8 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -60,25 +60,38 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
 {
     const basegfx::B2DPolyPolygon aClip( rClip.GetAsB2DPolyPolygon() );
 
-    /*glEnable(GL_STENCIL_TEST);
+    SAL_INFO( "vcl.opengl", "::setClipRegion" );
+
+    /*maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+
+    glEnable( GL_STENCIL_TEST );
 
     glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
-    glDepthMask( GL_FALSE );
     glStencilMask( 0xFF );
     glStencilFunc( GL_NEVER, 1, 0xFF );
     glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP );
 
     glClear( GL_STENCIL_BUFFER_BIT );
+    BeginSolid( SALCOLOR_NONE );
     DrawPolyPolygon( aClip );
+    EndSolid();
 
-    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-    glDepthMask( GL_TRUE );
+    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
     glStencilMask( 0x00 );
-    glStencilFunc(GL_EQUAL, 1, 0xFF);*/
+    glStencilFunc( GL_EQUAL, 1, 0xFF );*/
 
     return true;
 }
 
+// set the clip region to empty
+void OpenGLSalGraphicsImpl::ResetClipRegion()
+{
+    SAL_INFO( "vcl.opengl", "::ResetClipRegion" );
+    maContext.makeCurrent();
+    glDisable(GL_STENCIL_TEST);
+}
+
 // get the depth of the device
 sal_uInt16 OpenGLSalGraphicsImpl::GetBitCount() const
 {
@@ -91,12 +104,6 @@ long OpenGLSalGraphicsImpl::GetGraphicsWidth() const
     return GetWidth();
 }
 
-// set the clip region to empty
-void OpenGLSalGraphicsImpl::ResetClipRegion()
-{
-    glDisable(GL_STENCIL_TEST);
-}
-
 // set the line color to transparent (= don't draw lines)
 void OpenGLSalGraphicsImpl::SetLineColor()
 {
commit 5302d5a3b7dddc40110674b509068c37ba1fd7b1
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 22:55:06 2014 -0500

    vcl: Add support for transparent polygon drawing with OpenGL
    
    Change-Id: Iaa7cdcf4742d8148507c69c222bff417b9f9426c

diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index b05a520..9368a10 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -61,6 +61,7 @@ protected:
     bool CreateMaskProgram( void );
 
     void BeginSolid( SalColor nColor, sal_uInt8 nTransparency );
+    void BeginSolid( SalColor nColor, double fTransparency );
     void BeginSolid( SalColor nColor );
     void EndSolid( void );
     void BeginInvert( void );
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 9288260..55b6a93 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -40,6 +40,13 @@
                  ((float) SALCOLOR_BLUE( nColor )) / 255,  \
                  (100 - nTransparency) * (1.0 / 100) )
 
+#define glUniformColorf(nUniform, nColor, fTransparency)   \
+    glUniform4f( nUniform,                                 \
+                 ((float) SALCOLOR_RED( nColor )) / 255,   \
+                 ((float) SALCOLOR_GREEN( nColor )) / 255, \
+                 ((float) SALCOLOR_BLUE( nColor )) / 255,  \
+                 (1.0f - fTransparency) )
+
 OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
 {
 }
@@ -202,18 +209,41 @@ void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, sal_uInt8 nTransparency
             return;
     }
 
+    if( nTransparency > 0 )
+    {
+        glEnable( GL_BLEND );
+        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+    }
     glUseProgram( mnSolidProgram );
     glUniformColor( mnColorUniform, nColor, nTransparency );
 }
 
+void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, double fTransparency )
+{
+    if( mnSolidProgram == 0 )
+    {
+        if( !CreateSolidProgram() )
+            return;
+    }
+
+    if( fTransparency > 0.0f )
+    {
+        glEnable( GL_BLEND );
+        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+    }
+    glUseProgram( mnSolidProgram );
+    glUniformColorf( mnColorUniform, nColor, fTransparency );
+}
+
 void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor )
 {
-    BeginSolid( nColor, 0 );
+    BeginSolid( nColor, 0.0f );
 }
 
 void OpenGLSalGraphicsImpl::EndSolid( void )
 {
     glUseProgram( 0 );
+    glDisable( GL_BLEND );
 }
 
 void OpenGLSalGraphicsImpl::BeginInvert( void )
@@ -592,9 +622,27 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
     }
 }
 
-bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ )
+bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency )
 {
-    return false;
+    SAL_INFO( "vcl.opengl", "::drawPolyPolygon trans " << fTransparency );
+    if( rPolyPolygon.count() <= 0 )
+        return true;
+
+    maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+
+    if( mnFillColor != SALCOLOR_NONE )
+    {
+        BeginSolid( mnFillColor, fTransparency );
+        for( sal_uInt32 i = 0; i < rPolyPolygon.count(); i++ )
+        {
+            const ::basegfx::B2DPolyPolygon aOnePoly( rPolyPolygon.getB2DPolygon( i ) );
+            DrawPolyPolygon( aOnePoly );
+        }
+        EndSolid();
+    }
+
+    return true;
 }
 
 bool OpenGLSalGraphicsImpl::drawPolyLine(
@@ -843,6 +891,7 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect(
                 long nWidth, long nHeight,
                 sal_uInt8 nTransparency )
 {
+    SAL_INFO( "vcl.opengl", "::drawAlphaRect" );
     if( mnFillColor != SALCOLOR_NONE && nTransparency < 100 )
     {
         BeginSolid( mnFillColor, nTransparency );
diff --git a/vcl/opengl/solidFragmentShader.glsl b/vcl/opengl/solidFragmentShader.glsl
index 94d0de0..af75336 100644
--- a/vcl/opengl/solidFragmentShader.glsl
+++ b/vcl/opengl/solidFragmentShader.glsl
@@ -11,7 +11,7 @@
 
 uniform vec4 color;
 void main() {
-   gl_FragColor = color;
+    gl_FragColor = color;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/polygon.cxx b/vcl/source/outdev/polygon.cxx
index 39c2b68..03fa168 100644
--- a/vcl/source/outdev/polygon.cxx
+++ b/vcl/source/outdev/polygon.cxx
@@ -231,7 +231,7 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly )
 
 // Caution: This method is nearly the same as
 // OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency),
-// so when changes are made here do not forget to make change sthere, too
+// so when changes are made here do not forget to make changes there, too
 
 void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
 {
commit ab63fe781cc8862e970932df2915982ce4770f92
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Nov 9 03:10:44 2014 +0100

    one more case of these insane memory alloc/release cycles
    
    Change-Id: I57bfbc46e77785a770226868a8750a74f380ddb4

diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 5f6477a..ccd914d 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -60,8 +60,7 @@ Bitmap::Bitmap( const Bitmap& rBitmap ) :
 
 Bitmap::Bitmap( SalBitmap* pSalBitmap )
 {
-    mpImpBmp = new ImpBitmap();
-    mpImpBmp->ImplSetSalBitmap( pSalBitmap );
+    mpImpBmp = new ImpBitmap(pSalBitmap);
     maPrefMapMode = MapMode( MAP_PIXEL );
     maPrefSize = mpImpBmp->ImplGetSize();
 }
commit b7e30878600b4d03e4102dd743279736c52a70c2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Nov 9 03:06:35 2014 +0100

    prevent insane memory allocation
    
    We release the memory in the next call again.
    
    Change-Id: I9cd974f2c1b2381d0a895bea52a8654143862971

diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index f6663c5..bbe8064 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -38,6 +38,13 @@ private:
 
 public:
                         ImpBitmap();
+                        /**
+                         * takes ownership
+                         * same as Sequence:
+                         * pBmp = new ImpBitmap;
+                         * pBmp->ImplSetSalBitmap(pBitmap);
+                         */
+                        ImpBitmap(SalBitmap* pBitmap);
                         ~ImpBitmap();
 
     void                ImplSetSalBitmap( SalBitmap* pSalBitmap );
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index 1ee75d4..633cff2 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -31,6 +31,13 @@ ImpBitmap::ImpBitmap() :
 {
 }
 
+ImpBitmap::ImpBitmap(SalBitmap* pBitmap) :
+            mnRefCount  ( 1 ),
+            mnChecksum  ( 0 ),
+            mpSalBitmap ( pBitmap )
+{
+}
+
 ImpBitmap::~ImpBitmap()
 {
     delete mpSalBitmap;
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index a191b8b..20e6367 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -457,8 +457,7 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
 
                 if( pSalBmp )
                 {
-                    ImpBitmap* pImpBmp = new ImpBitmap;
-                    pImpBmp->ImplSetSalBitmap( pSalBmp );
+                    ImpBitmap* pImpBmp = new ImpBitmap(pSalBmp);
                     aBmp.ImplSetImpBitmap( pImpBmp );
                 }
             }
commit d846fc0c3bcb03ec422ce7f8227470bb3c5af14c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Nov 9 02:49:12 2014 +0100

    don't delete texture before we were able to read it back
    
    Change-Id: Id59983add682ea3f0e6e9e440b1700817bbc6867

diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 40be728..564426c 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -167,7 +167,6 @@ void OpenGLSalBitmap::Destroy()
 
 bool OpenGLSalBitmap::AllocateUserData()
 {
-    Destroy();
     SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::AllocateUserData" );
 
     if( mnWidth && mnHeight )
commit c245039e7bfda0ebd1355f3c08b5849472002d6f
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 20:13:28 2014 -0500

    vcl: Fix getBitmap operation
    
    Change-Id: Id78065081bbde97738afd0f4da09b502afe468f4

diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 0736773..40be728 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -71,6 +71,7 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, long nX, long nY, long nW
     maPalette = aEmptyPalette;
 
     mpTexture.reset( new OpenGLTexture( nX, nY, nWidth, nHeight ) );
+    mbDirtyTexture = false;
 
     return true;
 }
@@ -107,6 +108,7 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
 
     if( isValidBitCount( nNewBitCount ) )
     {
+        // TODO: lfrb: What about the pending operations?!
         mnBits = nNewBitCount;
         mnBytesPerRow = rSourceBitmap.mnBytesPerRow;
         mnWidth = rSourceBitmap.mnWidth;
@@ -116,6 +118,7 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
         maPalette = rSourceBitmap.maPalette;
         mpContext = rSourceBitmap.mpContext;
         mpTexture = rSourceBitmap.mpTexture;
+        mbDirtyTexture = false;
         maUserBuffer = rSourceBitmap.maUserBuffer;
 
         // TODO Copy buffer data if the bitcount and palette are the same
commit 03c6479fd3227129e4f496a4ac2a5fdf7bed44c1
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 19:32:14 2014 -0500

    basegfx: Solve crossovers even if there is only one polygon in the polypolygon
    
    Change-Id: If4fcb8a2c6ac40a4d694522ce4ed020bcb4466b8

diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index aaad335..d9eea58 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -688,7 +688,7 @@ namespace basegfx
 
         B2DPolyPolygon solveCrossovers(const B2DPolyPolygon& rCandidate)
         {
-            if(rCandidate.count() > 1L)
+            if(rCandidate.count() > 0L)
             {
                 solver aSolver(rCandidate);
                 return aSolver.getB2DPolyPolygon();
commit 60c506a97fa850baba1fafdfc35af73808b03060
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Nov 8 21:41:13 2014 +0000

    vcldemo: add a virtualdevice test.
    
    Change-Id: I8ff8c74e13a128d778b487ec2818820df9d5058a

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 9b314df..cae3fb0b 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -22,6 +22,7 @@
 #include <vcl/svapp.hxx>
 #include <vcl/pngread.hxx>
 #include <vcl/wrkwin.hxx>
+#include <vcl/virdev.hxx>
 #include <vcl/graphicfilter.hxx>
 
 #if 0
@@ -70,12 +71,12 @@ public:
         maIntroBW.Filter( BMP_FILTER_EMBOSS_GREY );
     }
 
-    void drawToDevice(OutputDevice &r);
+    void drawToDevice(OutputDevice &r, bool bVdev);
 
     virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE
     {
         fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
-        drawToDevice(getOutDev());
+        drawToDevice(getOutDev(), false);
     }
 
     std::vector<Rectangle> partitionAndClear(OutputDevice &rDev,
@@ -233,8 +234,19 @@ public:
         rDev.DrawPolyPolygon(aPolyPoly);
 #endif
     }
-    void fetchDrawBitmap(OutputDevice &rDev, Rectangle r)
+    void drawToVirtualDevice(OutputDevice &rDev, Rectangle r)
+    {
+        VirtualDevice aNested;
+        aNested.SetOutputSize(r.GetSize());
+        Rectangle aWhole(Point(0,0), r.GetSize());
+        // mini me
+        drawToDevice(aNested, true);
+
+        Bitmap aBitmap(aNested.GetBitmap(Point(0,0),aWhole.GetSize()));
+        rDev.DrawBitmap(r.TopLeft(), aBitmap);
+    }
 
+    void fetchDrawBitmap(OutputDevice &rDev, Rectangle r)
     {
         // FIXME: should work ...
         Bitmap aBitmap(GetBitmap(Point(0,0),rDev.GetOutputSizePixel()));
@@ -282,7 +294,7 @@ std::vector<Rectangle> DemoWin::partitionAndClear(OutputDevice &rDev, int nX, in
     return aRegions;
 }
 
-void DemoWin::drawToDevice(OutputDevice &rDev)
+void DemoWin::drawToDevice(OutputDevice &rDev, bool bVdev)
 {
     drawBackground(rDev);
 
@@ -297,8 +309,10 @@ void DemoWin::drawToDevice(OutputDevice &rDev)
     drawBitmap(rDev, aRegions[6]);
     drawGradient(rDev, aRegions[7]);
     drawPolyPolgons(rDev, aRegions[8]);
+    if (!bVdev)
+        drawToVirtualDevice(rDev, aRegions[9]);
     // last - thumbnail all the above
-    fetchDrawBitmap(rDev, aRegions[9]);
+    fetchDrawBitmap(rDev, aRegions[10]);
 }
 
 class DemoApp : public Application
commit 2b69366bf8bd0d0b6a3bcfbf58c1b16edfc1a746
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Nov 8 21:34:10 2014 +0000

    vcldemo: re-factor to allow rendering to any outputdevice.
    
    Change-Id: Ie3367c004d89043fb78d0b2dcd49254323353a4c

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index d753c0d..9b314df 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -32,13 +32,23 @@
 
 using namespace css;
 
-class DemoWin : public WorkWindow
+class DemoBase :
+        public WorkWindow // hide OutputDevice if necessary
+{
+public:
+    DemoBase() : WorkWindow( NULL, WB_APP | WB_STDWORK)
+    {
+    }
+    OutputDevice &getOutDev() { return *this; }
+};
+
+class DemoWin : public DemoBase
 {
     Bitmap   maIntroBW;
     BitmapEx maIntro;
 
 public:
-    DemoWin() : WorkWindow( NULL, WB_APP | WB_STDWORK)
+    DemoWin() : DemoBase()
     {
         // Needed to find images
         OUString aPath;
@@ -60,32 +70,39 @@ public:
         maIntroBW.Filter( BMP_FILTER_EMBOSS_GREY );
     }
 
-    virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
+    void drawToDevice(OutputDevice &r);
 
-    std::vector<Rectangle> partitionAndClear(int nX, int nY);
+    virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE
+    {
+        fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
+        drawToDevice(getOutDev());
+    }
 
-    void drawBackground()
+    std::vector<Rectangle> partitionAndClear(OutputDevice &rDev,
+                                             int nX, int nY);
+
+    void drawBackground(OutputDevice &rDev)
     {
-        Rectangle r(Point(0,0), GetSizePixel());
+        Rectangle r(Point(0,0), rDev.GetOutputSizePixel());
         Gradient aGradient;
         aGradient.SetStartColor(COL_BLUE);
         aGradient.SetEndColor(COL_GREEN);
         aGradient.SetStyle(GradientStyle_LINEAR);
 //        aGradient.SetBorder(r.GetSize().Width()/20);
-        DrawGradient(r, aGradient);
+        rDev.DrawGradient(r, aGradient);
     }
 
-    void drawRadialLines(Rectangle r)
+    void drawRadialLines(OutputDevice &rDev, Rectangle r)
     {
-        SetFillColor(Color(COL_LIGHTRED));
-        SetLineColor(Color(COL_BLACK));
-        DrawRect( r );
+        rDev.SetFillColor(Color(COL_LIGHTRED));
+        rDev.SetLineColor(Color(COL_BLACK));
+        rDev.DrawRect( r );
 
         // FIXME: notice these appear reflected at the bottom not the top.
         for(int i=0; i<r.GetHeight(); i+=15)
-            DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) );
+            rDev.DrawLine( Point(r.Left(), r.Top()+i), Point(r.Right(), r.Bottom()-i) );
         for(int i=0; i<r.GetWidth(); i+=15)
-            DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) );
+            rDev.DrawLine( Point(r.Left()+i, r.Bottom()), Point(r.Right()-i, r.Top()) );
 
         // Should draw a white-line across the middle
         Color aLastPixel( COL_WHITE );
@@ -93,23 +110,25 @@ public:
                       (r.Top() + r.Bottom())/2 - 4);
         for(int i=0; i<8; i++)
         {
-            DrawPixel(aCenter, aLastPixel);
-            aLastPixel = GetPixel(aCenter);
+            rDev.DrawPixel(aCenter, aLastPixel);
+            aLastPixel = rDev.GetPixel(aCenter);
             aCenter.Move(1,1);
         }
     }
 
-    void drawText(Rectangle r)
+    void drawText(OutputDevice &rDev, Rectangle r)
+
     {
-        SetTextColor( Color( COL_BLACK ) );
+        rDev.SetTextColor( Color( COL_BLACK ) );
         vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) );
-        SetFont( aFont );
-        DrawText( r, OUString( "Just a simple text" ) );
+        rDev.SetFont( aFont );
+        rDev.DrawText( r, OUString( "Just a simple text" ) );
     }
 
-    void drawPoly(Rectangle r) // pretty
+    void drawPoly(OutputDevice &rDev, Rectangle r)
+ // pretty
     {
-        drawCheckered(r);
+        drawCheckered(rDev, r);
 
         long nDx = r.GetWidth()/20;
         long nDy = r.GetHeight()/20;
@@ -119,22 +138,25 @@ public:
                              r.GetHeight()-nDy*2));
         Polygon aPoly(aShrunk);
         tools::PolyPolygon aPPoly(aPoly);
-        SetLineColor(Color(COL_RED));
-        SetFillColor(Color(COL_RED));
+        rDev.SetLineColor(Color(COL_RED));
+        rDev.SetFillColor(Color(COL_RED));
         // This hits the optional 'drawPolyPolygon' code-path
-        DrawTransparent(aPPoly, 64);
+        rDev.DrawTransparent(aPPoly, 64);
     }
-    void drawEllipse(Rectangle r)
+    void drawEllipse(OutputDevice &rDev, Rectangle r)
+
     {
-        SetLineColor(Color(COL_RED));
-        SetFillColor(Color(COL_GREEN));
-        DrawEllipse(r);
+        rDev.SetLineColor(Color(COL_RED));
+        rDev.SetFillColor(Color(COL_GREEN));
+        rDev.DrawEllipse(r);
     }
-    void drawCheckered(Rectangle r)
+    void drawCheckered(OutputDevice &rDev, Rectangle r)
+
     {
-        DrawCheckered(r.TopLeft(), r.GetSize());
+        rDev.DrawCheckered(r.TopLeft(), r.GetSize());
     }
-    void drawGradient(Rectangle r)
+    void drawGradient(OutputDevice &rDev, Rectangle r)
+
     {
         Gradient aGradient;
         aGradient.SetStartColor(COL_YELLOW);
@@ -142,30 +164,33 @@ public:
 //        aGradient.SetAngle(45);
         aGradient.SetStyle(GradientStyle_RECT);
         aGradient.SetBorder(r.GetSize().Width()/20);
-        DrawGradient(r, aGradient);
+        rDev.DrawGradient(r, aGradient);
     }
-    void drawBitmap(Rectangle r)
+    void drawBitmap(OutputDevice &rDev, Rectangle r)
+
     {
         Bitmap aBitmap(maIntroBW);
         aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY);
-        DrawBitmap(r.TopLeft(), aBitmap);
+        rDev.DrawBitmap(r.TopLeft(), aBitmap);
     }
-    void drawBitmapEx(Rectangle r)
+    void drawBitmapEx(OutputDevice &rDev, Rectangle r)
+
     {
-        drawCheckered(r);
+        drawCheckered(rDev, r);
 
         BitmapEx aBitmap(maIntro);
         aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY);
 #ifdef FIXME_ALPHA_WORKING
         AlphaMask aSemiTransp(aBitmap.GetSizePixel());
         aSemiTransp.Erase(64);
-        DrawBitmapEx(r.TopLeft(), BitmapEx(aBitmap.GetBitmap(),
+        rDev.DrawBitmapEx(r.TopLeft(), BitmapEx(aBitmap.GetBitmap(),
                                            aSemiTransp));
 #else
-        DrawBitmapEx(r.TopLeft(), aBitmap);
+        rDev.DrawBitmapEx(r.TopLeft(), aBitmap);
 #endif
     }
-    void drawPolyPolgons(Rectangle r)
+    void drawPolyPolgons(OutputDevice &rDev, Rectangle r)
+
     {
         struct {
             double nX, nY;
@@ -191,39 +216,40 @@ public:
                                          aSubRect.GetHeight() * aPoints[v].nY),
                                    v);
                 }
-                SetLineColor(Color(COL_YELLOW));
-                SetFillColor(Color(COL_BLACK));
-                DrawPolygon(aPoly);
+                rDev.SetLineColor(Color(COL_YELLOW));
+                rDev.SetFillColor(Color(COL_BLACK));
+                rDev.DrawPolygon(aPoly);
 
                 // now move and add to the polypolygon
                 aPoly.Move(0, r.GetHeight()/2);
                 aPolyPoly.Insert(aPoly);
             }
         }
-        SetLineColor(Color(COL_LIGHTRED));
-        SetFillColor(Color(COL_GREEN));
+        rDev.SetLineColor(Color(COL_LIGHTRED));
+        rDev.SetFillColor(Color(COL_GREEN));
 #ifdef FIXME_DRAW_TRANSPARENT_WORKING
-        DrawTransparent(aPolyPoly, 50);
+        rDev.DrawTransparent(aPolyPoly, 50);
 #else
-        DrawPolyPolygon(aPolyPoly);
+        rDev.DrawPolyPolygon(aPolyPoly);
 #endif
     }
-    void fetchDrawBitmap(Rectangle r)
+    void fetchDrawBitmap(OutputDevice &rDev, Rectangle r)
+
     {
         // FIXME: should work ...
-        Bitmap aBitmap(GetBitmap(Point(0,0),GetSizePixel()));
+        Bitmap aBitmap(GetBitmap(Point(0,0),rDev.GetOutputSizePixel()));
         aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY);
-        DrawBitmap(r.TopLeft(), aBitmap);
+        rDev.DrawBitmap(r.TopLeft(), aBitmap);
     }
 };
 
-std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
+std::vector<Rectangle> DemoWin::partitionAndClear(OutputDevice &rDev, int nX, int nY)
 {
     Rectangle r;
     std::vector<Rectangle> aRegions;
 
     // Make small cleared area for these guys
-    Size aSize(GetSizePixel());
+    Size aSize(rDev.GetOutputSizePixel());
     long nBorderSize = aSize.Width() / 32;
     long nBoxWidth = (aSize.Width() - nBorderSize*(nX+1)) / nX;
     long nBoxHeight = (aSize.Height() - nBorderSize*(nY+1)) / nY;
@@ -236,16 +262,16 @@ std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
             r.SetSize(Size(nBoxWidth, nBoxHeight));
 
             // knock up a nice little border
-            SetLineColor(COL_GRAY);
-            SetFillColor(COL_LIGHTGRAY);
+            rDev.SetLineColor(COL_GRAY);
+            rDev.SetFillColor(COL_LIGHTGRAY);
             if ((x + y) % 2)
-                DrawRect(r);
+                rDev.DrawRect(r);
             else
             {
 #ifdef FIXME_ROUNDED_RECT_WORKING
-                DrawRect(r, nBorderSize, nBorderSize);
+                rDev.DrawRect(r, nBorderSize, nBorderSize);
 #else
-                DrawRect(r);
+                rDev.DrawRect(r);
 #endif
             }
 
@@ -256,25 +282,23 @@ std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
     return aRegions;
 }
 
-void DemoWin::Paint( const Rectangle& rRect )
+void DemoWin::drawToDevice(OutputDevice &rDev)
 {
-    fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
-
-    drawBackground();
-
-    std::vector<Rectangle> aRegions(partitionAndClear(4,3));
-
-    drawRadialLines(aRegions[0]);
-    drawText(aRegions[1]);
-    drawPoly(aRegions[2]);
-    drawEllipse(aRegions[3]);
-    drawCheckered(aRegions[4]);
-    drawBitmapEx(aRegions[5]);
-    drawBitmap(aRegions[6]);
-    drawGradient(aRegions[7]);
-    drawPolyPolgons(aRegions[8]);
+    drawBackground(rDev);
+
+    std::vector<Rectangle> aRegions(partitionAndClear(rDev, 4, 3));
+
+    drawRadialLines(rDev, aRegions[0]);
+    drawText(rDev, aRegions[1]);
+    drawPoly(rDev, aRegions[2]);
+    drawEllipse(rDev, aRegions[3]);
+    drawCheckered(rDev, aRegions[4]);
+    drawBitmapEx(rDev, aRegions[5]);
+    drawBitmap(rDev, aRegions[6]);
+    drawGradient(rDev, aRegions[7]);
+    drawPolyPolgons(rDev, aRegions[8]);
     // last - thumbnail all the above
-    fetchDrawBitmap(aRegions[9]);
+    fetchDrawBitmap(rDev, aRegions[9]);
 }
 
 class DemoApp : public Application
commit 4007df6cc8fc3f2a3a634d9530b6652381d5ba53
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Sat Nov 8 13:14:14 2014 -0500

    vcl: Initial work to have native widgets rendered with OpenGL
    
    Change-Id: I8b244a5bdd12a64a65ca1bab14dfe6917a175ccf

diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index b237fc8..d49f579 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -60,6 +60,7 @@ public:
 
 #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID
     static bool GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rVI);
+    static GLXFBConfig GetPixmapFBConfig( Display* pDisplay, bool& bInverted );
 #endif
 };
 
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index 36e52ee..bec6f4c 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -63,6 +63,8 @@ $(eval $(call gb_Library_add_libs,vclplug_gen,\
 	-lXext \
 	-lSM \
 	-lICE \
+	-lGL \
+	-lGLU \
 ))
 
 $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
@@ -104,6 +106,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/window/salobj \
     vcl/unx/x11/x11sys \
     vcl/unx/x11/xlimits \
+	vcl/opengl/x11/gdiimpl \
 ))
 
 # ultimately we want to split the x11 dependencies out
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
new file mode 100644
index 0000000..878c7c2
--- /dev/null
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -0,0 +1,42 @@
+/* -*- 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_X11_GDIIMPL_HXX
+#define INCLUDED_VCL_INC_OPENGL_X11_GDIIMPL_HXX
+
+#include <vcl/dllapi.h>
+
+#include "unx/salgdi.h"
+#include "unx/x11/x11gdiimpl.h"
+#include "openglgdiimpl.hxx"
+
+class VCL_PLUGIN_PUBLIC X11OpenGLSalGraphicsImpl : public OpenGLSalGraphicsImpl, public X11GraphicsImpl
+{
+private:
+    X11SalGraphics&     mrParent;
+
+public:
+    X11OpenGLSalGraphicsImpl( X11SalGraphics& rParent );
+    virtual ~X11OpenGLSalGraphicsImpl();
+
+protected:
+    GLfloat GetWidth() const SAL_OVERRIDE;
+    GLfloat GetHeight() const SAL_OVERRIDE;
+
+public:
+    // implementation of X11GraphicsImpl
+
+    void Init() SAL_OVERRIDE;
+    X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ) SAL_OVERRIDE;
+    bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
+};
+
+#endif // INCLUDED_VCL_INC_OPENGL_X11_GDIIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index ef80d34..b05a520 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -30,7 +30,7 @@ class SalVirtualDevice;
 
 class VCL_PLUGIN_PUBLIC OpenGLSalGraphicsImpl : public SalGraphicsImpl
 {
-private:
+protected:
 
     OpenGLContext maContext;
     SalFrame* mpFrame;
@@ -55,9 +55,6 @@ private:
     GLuint mnMaskUniform;
     GLuint mnMaskColorUniform;
 
-    inline GLfloat GetWidth() const;
-    inline GLfloat GetHeight() const;
-
     bool CreateSolidProgram( void );
     bool CreateTextureProgram( void );
     bool CreateMaskedTextureProgram( void );
@@ -81,6 +78,13 @@ private:
     void DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& rPosAry );
     void DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& rPosAry );
 
+protected:
+    // get the width of the device
+    virtual GLfloat GetWidth() const = 0;
+
+    // get the height of the device
+    virtual GLfloat GetHeight() const = 0;
+
 
 public:
     virtual ~OpenGLSalGraphicsImpl ();
@@ -89,9 +93,6 @@ public:
 
     virtual void freeResources() SAL_OVERRIDE;
 
-    virtual void Init( SalFrame* pFrame ) SAL_OVERRIDE;
-    virtual void Init( SalVirtualDevice* pVDev ) SAL_OVERRIDE;
-
     virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
     //
     // get the depth of the device
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index dc8c580..5d49952 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -44,10 +44,6 @@ public:
 
     virtual ~SalGraphicsImpl();
 
-    virtual void Init( SalFrame* pFrame ) = 0;
-
-    virtual void Init( SalVirtualDevice* pVDev ) = 0;
-
     virtual void freeResources() = 0;
 
     virtual bool setClipRegion( const vcl::Region& ) = 0;
diff --git a/vcl/inc/unx/pixmap.hxx b/vcl/inc/unx/pixmap.hxx
index f8b23c7..40bc11f 100644
--- a/vcl/inc/unx/pixmap.hxx
+++ b/vcl/inc/unx/pixmap.hxx
@@ -12,6 +12,7 @@
 
 #include <prex.h>
 #include <postx.h>
+#include <tools/gen.hxx>
 #include <unx/saltype.h>
 #include <vclpluginapi.h>
 
@@ -27,6 +28,7 @@ public:
     Drawable GetDrawable() const { return mpPixmap; };
     int GetWidth() const { return mnWidth; };
     int GetHeight() const { return mnHeight; };
+    Size GetSize() const { return Size( mnWidth, mnHeight ); };
     int GetDepth() const { return mnDepth; };
     SalX11Screen GetScreen() const { return mnScreen; }
 
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index b4eee5f..8a5cc0c 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -45,6 +45,7 @@ class SalFrame;
 class X11Pixmap;
 class X11SalVirtualDevice;
 class X11SalGraphicsImpl;
+class X11OpenGLSalGraphicsImpl;
 class PspSalPrinter;
 class PspSalInfoPrinter;
 class ServerFont;
@@ -63,6 +64,7 @@ class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
 {
     friend class ServerFontLayout;
     friend class X11SalGraphicsImpl;
+    friend class X11OpenGLSalGraphicsImpl;
     friend class X11CairoTextRender;
 
 private:
diff --git a/vcl/inc/unx/x11/x11gdiimpl.h b/vcl/inc/unx/x11/x11gdiimpl.h
new file mode 100644
index 0000000..911ea71
--- /dev/null
+++ b/vcl/inc/unx/x11/x11gdiimpl.h
@@ -0,0 +1,27 @@
+/* -*- 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_UNX_X11_X11GDIIMPL_HXX
+#define INCLUDED_VCL_INC_UNX_X11_X11GDIIMPL_HXX
+
+#include "unx/pixmap.hxx"
+
+class X11GraphicsImpl
+{
+public:
+    virtual ~X11GraphicsImpl() {};
+
+    virtual void Init() = 0;
+    virtual X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ) = 0;
+    virtual bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) = 0;
+};
+
+#endif // INCLUDED_VCL_INC_UNX_X11_X11GDIIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 835d344..9288260 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -49,16 +49,6 @@ void OpenGLSalGraphicsImpl::freeResources()
     // Delete shaders, programs and textures if not shared
 }
 
-void OpenGLSalGraphicsImpl::Init( SalFrame* pFrame )
-{
-    mpFrame = pFrame;
-}
-
-void OpenGLSalGraphicsImpl::Init(SalVirtualDevice* pVDev)
-{
-    mpVDev = pVDev;
-}
-
 bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
 {
     const basegfx::B2DPolyPolygon aClip( rClip.GetAsB2DPolyPolygon() );
@@ -94,34 +84,6 @@ long OpenGLSalGraphicsImpl::GetGraphicsWidth() const
     return GetWidth();
 }
 
-inline GLfloat OpenGLSalGraphicsImpl::GetWidth() const
-{
-    if( mpFrame )
-        return mpFrame->maGeometry.nWidth;
-    else if (mpVDev)
-    {
-        long nWidth = 0;
-        long nHeight = 0;
-        mpVDev->GetSize(nWidth, nHeight);
-        return nWidth;
-    }
-    return 1;
-}
-
-inline GLfloat OpenGLSalGraphicsImpl::GetHeight() const
-{
-    if( mpFrame )
-        return mpFrame->maGeometry.nHeight;
-    else if (mpVDev)
-    {
-        long nWidth = 0;
-        long nHeight = 0;
-        mpVDev->GetSize(nWidth, nHeight);
-        return nHeight;
-    }
-    return 1;
-}
-
 // set the clip region to empty
 void OpenGLSalGraphicsImpl::ResetClipRegion()
 {
diff --git a/vcl/opengl/textureFragmentShader.glsl b/vcl/opengl/textureFragmentShader.glsl
index 81d68c7..cc95f2f 100644
--- a/vcl/opengl/textureFragmentShader.glsl
+++ b/vcl/opengl/textureFragmentShader.glsl
@@ -12,7 +12,7 @@ varying vec2 tex_coord;
 uniform sampler2D sampler;
 
 void main() {
-   gl_FragColor = texture2D(sampler, tex_coord);
+    gl_FragColor = texture2D(sampler, tex_coord);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
new file mode 100644
index 0000000..11735edb
--- /dev/null
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -0,0 +1,139 @@
+/* -*- 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/.
+ */
+
+#include "vcl/salbtype.hxx"
+
+#include "unx/pixmap.hxx"
+#include "unx/saldisp.hxx"
+#include "unx/salframe.h"
+#include "unx/salgdi.h"
+#include "unx/salvd.h"
+
+#include "opengl/x11/gdiimpl.hxx"
+
+#include <vcl/opengl/OpenGLContext.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
+
+X11OpenGLSalGraphicsImpl::X11OpenGLSalGraphicsImpl( X11SalGraphics& rParent ):
+    OpenGLSalGraphicsImpl(),
+    mrParent(rParent)
+{
+}
+
+X11OpenGLSalGraphicsImpl::~X11OpenGLSalGraphicsImpl()
+{
+}
+
+GLfloat X11OpenGLSalGraphicsImpl::GetWidth() const
+{
+    if( mrParent.m_pFrame )
+        return mrParent.m_pFrame->maGeometry.nWidth;
+    else if( mrParent.m_pVDev )
+    {
+        long nWidth = 0;
+        long nHeight = 0;
+        mrParent.m_pVDev->GetSize( nWidth, nHeight );
+        return nWidth;
+    }
+    return 1;
+}
+
+GLfloat X11OpenGLSalGraphicsImpl::GetHeight() const
+{
+    if( mrParent.m_pFrame )
+        return mrParent.m_pFrame->maGeometry.nHeight;
+    else if( mrParent.m_pVDev )
+    {
+        long nWidth = 0;
+        long nHeight = 0;
+        mrParent.m_pVDev->GetSize( nWidth, nHeight );
+        return nHeight;
+    }
+    return 1;
+}
+
+void X11OpenGLSalGraphicsImpl::Init()
+{
+    if( mrParent.m_pFrame && dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame) )
+    {
+        Window aWin = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame)->GetX11Window();
+        maContext.init( mrParent.GetXDisplay(), aWin, mrParent.m_nXScreen.getXScreen());
+    }
+    else if( mrParent.m_pVDev )
+    {
+        maContext.init( mrParent.GetXDisplay(), mrParent.m_pVDev->GetDrawable(),
+                        mrParent.m_pVDev->GetWidth(), mrParent.m_pVDev->GetHeight(),
+                        mrParent.m_nXScreen.getXScreen() );
+    }
+    else
+    {
+        SAL_WARN( "vcl.opengl", "what happened here?" );
+    }
+}
+
+X11Pixmap* X11OpenGLSalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect )
+{
+    Display* pDisplay = mrParent.GetXDisplay();
+    SalX11Screen nScreen = mrParent.GetScreenNumber();
+
+    SAL_INFO( "vcl.opengl", "GetPixmapFromScreen" );
+    return new X11Pixmap( pDisplay, nScreen, rRect.GetWidth(), rRect.GetHeight(), 24 );
+}
+
+bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY )
+{
+    const int aAttribs[] = {
+        GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
+        GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
+        None
+    };
+    Display* pDisplay = mrParent.GetXDisplay();
+    GLXFBConfig pFbConfig;
+    GLXPixmap pGlxPixmap;
+    GLuint nTexture;
+    SalTwoRect aPosAry;
+    bool bInverted;
+
+    SAL_INFO( "vcl.opengl", "RenderPixmapToScreen (" << nX << " " << nY << ")" );
+
+    aPosAry.mnSrcX = 0;
+    aPosAry.mnSrcY = 0;
+    aPosAry.mnDestX = nX;
+    aPosAry.mnDestY = nY;
+    aPosAry.mnSrcWidth = aPosAry.mnDestWidth = pPixmap->GetWidth();
+    aPosAry.mnSrcHeight = aPosAry.mnDestHeight = pPixmap->GetHeight();
+
+    XSync( pDisplay, 0 );
+    pFbConfig = OpenGLHelper::GetPixmapFBConfig( pDisplay, bInverted );
+    pGlxPixmap = glXCreatePixmap( pDisplay, pFbConfig, pPixmap->GetPixmap(), aAttribs);
+    XSync( pDisplay, 0 );
+
+    maContext.makeCurrent();
+    glViewport( 0, 0, GetWidth(), GetHeight() );
+
+    glGenTextures( 1, &nTexture );
+    glActiveTexture( GL_TEXTURE0 );
+    glBindTexture( GL_TEXTURE_2D, nTexture );
+
+    //TODO: lfrb: glXGetProc to get the functions
+    glXBindTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT, NULL );
+
+    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+    DrawTexture( nTexture, pPixmap->GetSize(), aPosAry );
+
+    glXReleaseTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT );
+    glDeleteTextures( 1, &nTexture );
+    glXDestroyPixmap( pDisplay, pGlxPixmap );
+
+    return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 4705e3f..5823b80 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -387,6 +387,56 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV
     return true;
 }
 
+GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted )
+{
+    int nScreen = DefaultScreen( pDisplay );
+    GLXFBConfig *aFbConfigs;
+    int i, nFbConfigs, nValue;
+
+    aFbConfigs = glXGetFBConfigs( pDisplay, nScreen, &nFbConfigs );
+    for( i = 0; i < nFbConfigs; i++ )
+    {
+        glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_DRAWABLE_TYPE, &nValue );
+        if( !(nValue & GLX_PIXMAP_BIT) )
+            continue;
+
+        glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &nValue );
+        if( !(nValue & GLX_TEXTURE_2D_BIT_EXT) )
+            continue;
+
+        glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_DEPTH_SIZE, &nValue );
+        if( nValue != 24 )
+            continue;
+
+        glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_RED_SIZE, &nValue );
+        if( nValue != 8 )
+            continue;
+        SAL_INFO( "vcl.opengl", "Red is " << nValue );
+
+        // TODO: lfrb: Make it configurable wrt RGB/RGBA
+        glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &nValue );
+        if( nValue == False )
+        {
+            glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &nValue );
+            if( nValue == False )
+                continue;
+        }
+
+        glXGetFBConfigAttrib( pDisplay, aFbConfigs[i], GLX_Y_INVERTED_EXT, &nValue );
+        bInverted = (nValue == True) ? true : false;
+
+        break;
+    }
+
+    if( i == nFbConfigs )
+    {
+        SAL_WARN( "vcl.opengl", "Unable to find FBconfig for pixmap texturing" );
+        return 0;
+    }
+
+    return aFbConfigs[i];
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index f2ccf90..172ebd6 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -153,16 +153,69 @@ X11SalGraphicsImpl::~X11SalGraphicsImpl()
 {
 }
 
-void X11SalGraphicsImpl::Init( SalFrame* /*pFrame*/ )
+void X11SalGraphicsImpl::Init()
 {
     mnPenPixel = mrParent.GetPixel( mnPenColor );
     mnBrushPixel = mrParent.GetPixel( mnBrushColor );
 }
 
-void X11SalGraphicsImpl::Init( SalVirtualDevice* /*pVDev*/ )
+X11Pixmap* X11SalGraphicsImpl::GetPixmapFromScreen( const Rectangle& rRect )
 {
-    mnPenPixel = mrParent.GetPixel( mnPenColor );
-    mnBrushPixel = mrParent.GetPixel( mnBrushColor );
+    //TODO lfrb: don't hardcode the depth
+    Display* pDpy = mrParent.GetXDisplay();
+    X11Pixmap* pPixmap = new X11Pixmap( pDpy, mrParent.GetScreenNumber(),
+                                        rRect.GetWidth(), rRect.GetHeight(), 24 );
+    GC aTmpGC = XCreateGC( pDpy, pPixmap->GetPixmap(), 0, NULL );
+
+    if( !pPixmap || !aTmpGC )
+    {
+        if ( pPixmap )
+            delete pPixmap;
+        if ( aTmpGC )
+            XFreeGC( pDpy, aTmpGC );
+        SAL_WARN( "vcl", "Could not get valid pixmap from screen" );
+        return NULL;
+    }
+
+    // Copy the background of the screen into a composite pixmap
+    mrParent.CopyScreenArea( mrParent.GetXDisplay(),
+                             mrParent.GetDrawable(), mrParent.GetScreenNumber(),
+                             mrParent.GetVisual().GetDepth(),
+                             pPixmap->GetDrawable(), pPixmap->GetScreen(),
+                             pPixmap->GetDepth(),
+                             aTmpGC,
+                             rRect.Left(), rRect.Top(),
+                             rRect.GetWidth(), rRect.GetHeight(),
+                             0, 0 );
+
+    XFreeGC( pDpy, aTmpGC );
+    return pPixmap;
+}
+
+bool X11SalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY )
+{
+    GC aFontGC = mrParent.GetFontGC();
+
+    // The GC can't be null, otherwise we'd have no clip region
+    if( aFontGC == NULL )
+    {
+        SAL_WARN( "vcl", "no valid GC to render pixmap" );
+        return false;
+    }
+
+    if( !pPixmap )
+        return false;
+
+    mrParent.CopyScreenArea( mrParent.GetXDisplay(),
+                             pPixmap->GetDrawable(), pPixmap->GetScreen(),
+                             pPixmap->GetDepth(),
+                             mrParent.GetDrawable(), mrParent.m_nXScreen,
+                             mrParent.GetVisual().GetDepth(),
+                             aFontGC,
+                             0, 0,
+                             pPixmap->GetWidth(), pPixmap->GetHeight(),
+                             nX, nY );
+    return true;
 }
 
 XID X11SalGraphicsImpl::GetXRenderPicture()
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 799e05c..252fe35 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -24,6 +24,7 @@
 #include <postx.h>
 
 #include "unx/saltype.h"
+#include "unx/x11/x11gdiimpl.h"
 
 #include "salgdiimpl.hxx"
 
@@ -35,10 +36,8 @@ class SalPolyLine;
 class X11SalGraphics;
 class Gradient;
 
-class X11SalGraphicsImpl : public SalGraphicsImpl
+class X11SalGraphicsImpl : public SalGraphicsImpl, public X11GraphicsImpl
 {
-    friend X11SalGraphics;
-
 private:
     X11SalGraphics& mrParent;
 
@@ -108,10 +107,6 @@ public:
 
     virtual ~X11SalGraphicsImpl();
 
-    virtual void Init( SalFrame* pFrame ) SAL_OVERRIDE;
-
-    virtual void Init( SalVirtualDevice* pVDev ) SAL_OVERRIDE;
-
     virtual bool setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
     //
     // get the depth of the device
@@ -269,6 +264,13 @@ public:
     virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) SAL_OVERRIDE;
 
     virtual bool swapBuffers() SAL_OVERRIDE { return false; }
+
+public:
+    // implementation of X11GraphicsImpl
+
+    void Init() SAL_OVERRIDE;
+    X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect ) SAL_OVERRIDE;
+    bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) SAL_OVERRIDE;
 };
 
 #endif
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 0607cac..b4df486 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -48,13 +48,14 @@
 #include "unx/salgdi.h"
 #include "unx/salframe.h"
 #include "unx/salvd.h"
+#include "unx/x11/x11gdiimpl.h"
 #include <unx/x11/xlimits.hxx>
 
 #include "salgdiimpl.hxx"
 #include "unx/x11windowprovider.hxx"
 #include "textrender.hxx"
 #include "gdiimpl.hxx"
-#include "openglgdiimpl.hxx"
+#include "opengl/x11/gdiimpl.hxx"
 #include "x11cairotextrender.hxx"
 
 #include "generic/printergfx.hxx"
@@ -86,7 +87,7 @@ X11SalGraphics::X11SalGraphics():
     static bool bOpenGLPossible = OpenGLHelper::supportsVCLOpenGL();
     bool bUseOpenGL = bOpenGLPossible ? officecfg::Office::Common::VCL::UseOpenGL::get() : false;
     if (bUseOpenGL)
-        mpImpl.reset(new OpenGLSalGraphicsImpl());
+        mpImpl.reset(new X11OpenGLSalGraphicsImpl(*this));
     else
         mpImpl.reset(new X11SalGraphicsImpl(*this));
 
@@ -142,26 +143,7 @@ void X11SalGraphics::SetDrawable( Drawable aDrawable, SalX11Screen nXScreen )
 
     if( hDrawable_ )
     {
-        OpenGLSalGraphicsImpl* pOpenGLImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(mpImpl.get());
-        if (pOpenGLImpl)
-        {
-            if (m_pFrame && dynamic_cast<X11WindowProvider*>(m_pFrame))
-            {
-                Window aWin = dynamic_cast<X11WindowProvider*>(m_pFrame)->GetX11Window();
-                pOpenGLImpl->GetOpenGLContext().init(GetXDisplay(),
-                        aWin, m_nXScreen.getXScreen());
-                mpImpl->Init( m_pFrame );
-            }
-            else if (m_pVDev)
-            {
-                pOpenGLImpl->GetOpenGLContext().init(GetXDisplay(),
-                        m_pVDev->GetDrawable(), m_pVDev->GetWidth(), m_pVDev->GetHeight(), m_nXScreen.getXScreen());
-                mpImpl->Init(m_pVDev);
-            }
-            else
-                SAL_WARN("vcl.opengl", "what happened here?");
-        }
-
+        dynamic_cast<X11GraphicsImpl*>(mpImpl.get())->Init();
         // TODO: moggi: FIXME nTextPixel_     = GetPixel( nTextColor_ );
     }
 }
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index e4d5b3c..63ab32b 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -31,6 +31,7 @@
 #include "unx/salgdi.h"
 #include "unx/salframe.h"
 #include "unx/salvd.h"
+#include "unx/x11/x11gdiimpl.h"
 #include <unx/x11/xlimits.hxx>
 #include "xrender_peer.hxx"
 
@@ -84,59 +85,15 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay,
 
 X11Pixmap* X11SalGraphics::GetPixmapFromScreen( const Rectangle& rRect )
 {
-    Display* pDpy = GetXDisplay();
-    X11Pixmap* pPixmap = new X11Pixmap( pDpy, GetScreenNumber(), rRect.GetWidth(), rRect.GetHeight(), 24 );
-    GC aTmpGC = XCreateGC( pDpy, pPixmap->GetPixmap(), 0, NULL );
-
-    if( !pPixmap || !aTmpGC )
-    {
-        if ( pPixmap )
-            delete pPixmap;
-        if ( aTmpGC )
-            XFreeGC( pDpy, aTmpGC );
-        SAL_WARN( "vcl", "Could not get valid pixmap from screen" );
-        return NULL;
-    }
-
-    // Copy the background of the screen into a composite pixmap
-    CopyScreenArea( GetXDisplay(),
-                    GetDrawable(), GetScreenNumber(), GetVisual().GetDepth(),
-                    pPixmap->GetDrawable(), pPixmap->GetScreen(), pPixmap->GetDepth(),
-                    aTmpGC,
-                    rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight(), 0, 0 );
-
-    XFreeGC( pDpy, aTmpGC );
-    return pPixmap;
+    X11GraphicsImpl* pImpl = dynamic_cast<X11GraphicsImpl*>(mpImpl.get());
+    return pImpl->GetPixmapFromScreen( rRect );
 }
 
 bool X11SalGraphics::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY )
 {
     SAL_INFO( "vcl", "RenderPixmapToScreen" );
-    /*if( UseOpenGL() )
-    {
-        X11OpenGLTexture pTexture( pPixmap );
-        pTexture.Draw( nX, nY );
-        return true;
-    }*/
-
-    GC aFontGC = GetFontGC();
-
-    // The GC can't be null, otherwise we'd have no clip region
-    if( aFontGC == NULL )
-    {
-        SAL_WARN( "vcl", "no valid GC to render pixmap" );
-        return false;
-    }
-
-    if( !pPixmap )
-        return false;
-
-    CopyScreenArea( GetXDisplay(),
-                    pPixmap->GetDrawable(), pPixmap->GetScreen(), pPixmap->GetDepth(),
-                    GetDrawable(), m_nXScreen, GetVisual().GetDepth(),
-                    aFontGC,
-                    0, 0, pPixmap->GetWidth(), pPixmap->GetHeight(), nX, nY );
-    return true;
+    X11GraphicsImpl* pImpl = dynamic_cast<X11GraphicsImpl*>(mpImpl.get());
+    return pImpl->RenderPixmapToScreen( pPixmap, nX, nY );
 }
 
 extern "C"
commit 81798ea6e4461f29e35afc14e322d38da5f6c851
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date:   Fri Nov 7 17:29:44 2014 -0500

    vcl: Add GetPixmapFromScreen and RenderPixmapToScreen to X11SalGraphics
    
    Change-Id: I007408885b5752f3abf55075ef025aa6dacbabde

diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index fe9f4f6..36e52ee 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -92,6 +92,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gen,\
     vcl/unx/generic/gdi/x11cairotextrender \
     vcl/unx/generic/gdi/gcach_xpeer \
 	vcl/unx/generic/gdi/gdiimpl \
+	vcl/unx/generic/gdi/pixmap \
     vcl/unx/generic/gdi/salbmp \
     vcl/unx/generic/gdi/salgdi2 \
     vcl/unx/generic/gdi/salgdi3 \
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index b8b145b..05d763c 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -114,6 +114,7 @@ private:
 
 #else
 
+class GdkX11Pixmap;
 class GtkSalGraphics : public X11SalGraphics
 {
     GtkWidget           *m_pWindow;
@@ -162,8 +163,8 @@ public:
 protected:
     typedef std::list< Rectangle > clipList;
 
-    GdkPixmap* NWGetPixmapFromScreen( Rectangle srcRect );
-    bool NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect );
+    GdkX11Pixmap* NWGetPixmapFromScreen( Rectangle srcRect );
+    bool NWRenderPixmapToScreen( GdkX11Pixmap* pPixmap, Rectangle dstRect );
 
     bool NWPaintGTKArrow( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
                            const Rectangle& rControlRectangle,
diff --git a/vcl/inc/unx/pixmap.hxx b/vcl/inc/unx/pixmap.hxx
new file mode 100644
index 0000000..f8b23c7
--- /dev/null
+++ b/vcl/inc/unx/pixmap.hxx
@@ -0,0 +1,44 @@
+/* -*- 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_UNX_PIXMAP_HXX
+#define INCLUDED_VCL_INC_UNX_PIXMAP_HXX
+
+#include <prex.h>
+#include <postx.h>
+#include <unx/saltype.h>
+#include <vclpluginapi.h>
+
+class VCLPLUG_GEN_PUBLIC X11Pixmap
+{
+public:
+    X11Pixmap();
+    X11Pixmap( Display *pDisplay, SalX11Screen nScreen, int nWidth, int nHeight, int nDepth );
+    X11Pixmap( X11Pixmap& rOther );
+    virtual ~X11Pixmap();
+
+    Pixmap GetPixmap() const { return mpPixmap; };
+    Drawable GetDrawable() const { return mpPixmap; };
+    int GetWidth() const { return mnWidth; };
+    int GetHeight() const { return mnHeight; };
+    int GetDepth() const { return mnDepth; };
+    SalX11Screen GetScreen() const { return mnScreen; }
+
+protected:
+    Display*        mpDisplay;
+    SalX11Screen    mnScreen;
+    Pixmap          mpPixmap;
+    int             mnWidth;
+    int             mnHeight;
+    int             mnDepth;
+};
+
+#endif // INCLUDED_VCL_INC_UNX_PIXMAP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 549698d..b4eee5f 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -42,6 +42,7 @@ class SalBitmap;
 class SalColormap;
 class SalDisplay;
 class SalFrame;
+class X11Pixmap;
 class X11SalVirtualDevice;
 class X11SalGraphicsImpl;
 class PspSalPrinter;
@@ -263,6 +264,13 @@ public:
 
     virtual bool               SwapBuffers() SAL_OVERRIDE;
 
+    // create a pixmap from a screen region
+    X11Pixmap* GetPixmapFromScreen( const Rectangle& rRect );
+
+    // render a pixmap to the screen
+    bool RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY );
+
+
     /*  use to handle GraphicsExpose/NoExpose after XCopyArea & friends
      *  if pFrame is not NULL, corresponding Paint events are generated
      *  and dispatched to pFrame
diff --git a/vcl/unx/generic/gdi/pixmap.cxx b/vcl/unx/generic/gdi/pixmap.cxx
new file mode 100644
index 0000000..beb5589
--- /dev/null
+++ b/vcl/unx/generic/gdi/pixmap.cxx
@@ -0,0 +1,49 @@
+/* -*- 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/.
+ */
+
+#include "unx/pixmap.hxx"
+
+X11Pixmap::X11Pixmap()
+: mpDisplay( NULL )
+, mnScreen( 0 )
+, mnWidth( -1 )
+, mnHeight( -1 )
+, mnDepth( 0 )
+{
+}
+
+X11Pixmap::X11Pixmap( Display* pDisplay, SalX11Screen nScreen, int nWidth, int nHeight, int nDepth )
+: mpDisplay( pDisplay )
+, mnScreen( nScreen )
+, mnWidth( nWidth )
+, mnHeight( nHeight )
+, mnDepth( nDepth )
+{
+    Window root = RootWindow( pDisplay, 0 );
+    mpPixmap = XCreatePixmap( pDisplay, root, nWidth, nHeight, nDepth );
+}
+
+X11Pixmap::X11Pixmap( X11Pixmap& rOther )
+: mpDisplay( rOther.mpDisplay )
+, mnScreen( rOther.mnScreen )
+, mnWidth( rOther.mnWidth )
+, mnHeight( rOther.mnHeight )
+, mnDepth( rOther.mnDepth )
+{
+    mpPixmap = rOther.mpPixmap;
+    rOther.mpPixmap = 0;
+}
+
+X11Pixmap::~X11Pixmap()
+{
+    if( mpPixmap )
+        XFreePixmap( mpDisplay, mpPixmap );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index aa2732a..e4d5b3c 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -23,6 +23,7 @@
 
 #include "vcl/salbtype.hxx"
 
+#include "unx/pixmap.hxx"
 #include "unx/salunx.h"
 #include "unx/saldata.hxx"
 #include "unx/saldisp.hxx"
@@ -81,6 +82,63 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay,
     }
 }
 
+X11Pixmap* X11SalGraphics::GetPixmapFromScreen( const Rectangle& rRect )
+{
+    Display* pDpy = GetXDisplay();
+    X11Pixmap* pPixmap = new X11Pixmap( pDpy, GetScreenNumber(), rRect.GetWidth(), rRect.GetHeight(), 24 );
+    GC aTmpGC = XCreateGC( pDpy, pPixmap->GetPixmap(), 0, NULL );
+
+    if( !pPixmap || !aTmpGC )
+    {
+        if ( pPixmap )
+            delete pPixmap;
+        if ( aTmpGC )
+            XFreeGC( pDpy, aTmpGC );
+        SAL_WARN( "vcl", "Could not get valid pixmap from screen" );
+        return NULL;
+    }
+
+    // Copy the background of the screen into a composite pixmap
+    CopyScreenArea( GetXDisplay(),
+                    GetDrawable(), GetScreenNumber(), GetVisual().GetDepth(),
+                    pPixmap->GetDrawable(), pPixmap->GetScreen(), pPixmap->GetDepth(),
+                    aTmpGC,
+                    rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight(), 0, 0 );
+
+    XFreeGC( pDpy, aTmpGC );
+    return pPixmap;
+}
+
+bool X11SalGraphics::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY )
+{
+    SAL_INFO( "vcl", "RenderPixmapToScreen" );
+    /*if( UseOpenGL() )
+    {
+        X11OpenGLTexture pTexture( pPixmap );
+        pTexture.Draw( nX, nY );
+        return true;
+    }*/
+
+    GC aFontGC = GetFontGC();
+
+    // The GC can't be null, otherwise we'd have no clip region
+    if( aFontGC == NULL )
+    {
+        SAL_WARN( "vcl", "no valid GC to render pixmap" );
+        return false;
+    }
+
+    if( !pPixmap )
+        return false;
+
+    CopyScreenArea( GetXDisplay(),
+                    pPixmap->GetDrawable(), pPixmap->GetScreen(), pPixmap->GetDepth(),
+                    GetDrawable(), m_nXScreen, GetVisual().GetDepth(),
+                    aFontGC,
+                    0, 0, pPixmap->GetWidth(), pPixmap->GetHeight(), nX, nY );
+    return true;
+}
+
 extern "C"
 {
     static Bool GraphicsExposePredicate( Display*, XEvent* pEvent, XPointer pFrameWindow )
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index bab4f5c..50cb193 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -26,6 +26,7 @@
 #include "unx/gtk/gtkinst.hxx"
 #include "unx/gtk/gtkgdi.hxx"
 
+#include "unx/pixmap.hxx"
 #include "unx/saldata.hxx"
 #include "unx/saldisp.hxx"
 
@@ -257,6 +258,71 @@ static int getFrameWidth(GtkWidget* widget);
 
 static Rectangle NWGetScrollButtonRect(    SalX11Screen nScreen, ControlPart nPart, Rectangle aAreaRect );
 
+
+/************************************************************************
+ * GDK implementation of X11Pixmap
+ ************************************************************************/
+
+class GdkX11Pixmap : public X11Pixmap
+{
+public:
+    GdkX11Pixmap( int nWidth, int nHeight, int nDepth );
+    GdkX11Pixmap( X11Pixmap& rOther, GdkWindow *pWindow );
+    virtual ~GdkX11Pixmap();
+
+    GdkPixmap*   GetGdkPixmap() const;
+    GdkDrawable* GetGdkDrawable() const;
+
+protected:
+    GdkPixmap* mpGdkPixmap;
+};
+
+GdkX11Pixmap::GdkX11Pixmap( int nWidth, int nHeight, int nDepth )
+{
+    mpGdkPixmap = gdk_pixmap_new( NULL, nWidth, nHeight, nDepth );
+
+    //mpDisplay = ?
+    mnScreen = SalX11Screen( gdk_screen_get_number( gdk_drawable_get_screen( GDK_DRAWABLE(mpGdkPixmap) ) ) );
+    mnWidth = nWidth;
+    mnHeight = nHeight;
+    mnDepth = nDepth;
+    mpPixmap = GDK_PIXMAP_XID( mpGdkPixmap );
+}
+
+GdkX11Pixmap::GdkX11Pixmap( X11Pixmap& rOther, GdkWindow *pWindow )
+: X11Pixmap( rOther )
+{
+    GdkColormap* pColormap;
+
+#if GTK_CHECK_VERSION(2,10,0)
+    GdkScreen *pScreen = gdk_window_get_screen( pWindow );
+    mpGdkPixmap = gdk_pixmap_foreign_new_for_screen( pScreen, mpPixmap,
+                                                     mnWidth, mnHeight,
+                                                     mnDepth );
+#else
+    mpGdkPixmap = gdk_pixmap_foreign_new( mpPixmap );
+#endif
+
+    pColormap = gdk_drawable_get_colormap( pWindow );
+    gdk_drawable_set_colormap( GDK_DRAWABLE (mpGdkPixmap), pColormap );
+}
+
+GdkX11Pixmap::~GdkX11Pixmap()
+{
+    g_object_unref( mpGdkPixmap );
+}
+
+GdkPixmap* GdkX11Pixmap::GetGdkPixmap() const
+{
+    return mpGdkPixmap;
+}
+
+GdkDrawable* GdkX11Pixmap::GetGdkDrawable() const
+{
+    return GDK_DRAWABLE( mpGdkPixmap );
+}
+
+
 /*********************************************************
  * PixmapCache
  *********************************************************/
@@ -271,13 +337,13 @@ class NWPixmapCacheData
 public:
     ControlType m_nType;
     ControlState m_nState;
-    Rectangle   m_pixmapRect;
-    GdkPixmap*  m_pixmap;
+    Rectangle      m_pixmapRect;
+    GdkX11Pixmap*  m_pixmap;
 
     NWPixmapCacheData() : m_nType(0), m_nState(0), m_pixmap(0) {}
     ~NWPixmapCacheData()
         { SetPixmap( NULL ); };
-    void SetPixmap( GdkPixmap* pPixmap );
+    void SetPixmap( GdkX11Pixmap* pPixmap );
 };
 
 class NWPixmapCache
@@ -294,8 +360,8 @@ public:
         { delete [] pData; m_idx = 0; m_size = n; pData = new NWPixmapCacheData[m_size]; }
     int GetSize() const { return m_size; }
 
-    bool Find( ControlType aType, ControlState aState, const Rectangle& r_pixmapRect, GdkPixmap** pPixmap );
-    void Fill( ControlType aType, ControlState aState, const Rectangle& r_pixmapRect, GdkPixmap* pPixmap );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list