[Libreoffice-commits] core.git: 3 commits - vcl/opengl vcl/source vcl/win

Jan Holesovsky kendy at collabora.com
Tue Nov 11 12:48:54 PST 2014


 vcl/opengl/gdiimpl.cxx         |    3 +++
 vcl/opengl/salbmp.cxx          |   11 ++++++++---
 vcl/source/outdev/bitmap.cxx   |   21 +++++++++++----------
 vcl/win/source/app/salinst.cxx |    9 +++++++--
 4 files changed, 29 insertions(+), 15 deletions(-)

New commits:
commit 93b34d091756de6fc3e5424aa45e00397146cc51
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 11 21:33:53 2014 +0100

    vcl: Use the fast path for rendering.
    
    There was a discrepancy between the comment and the code; and I believe the
    comment was right, and the code wrong - so adapted the code accordingly.
    
    [I guess we will want to kill this condition for good when rendering via
    OpenGL at some stage; the assert() will tell us ;-)]
    
    Change-Id: I651261373068e975004c898b2a930c602c158b64

diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 4955b4b..9a2e56d 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -527,7 +527,7 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
                     // only paint direct when no scaling and no MapMode, else the
                     // more expensive conversions may be done for short-time Bitmap/BitmapEx
                     // used for buffering only
-                    if(!IsMapMode() && aPosAry.mnSrcWidth == aPosAry.mnDestWidth && aPosAry.mnSrcHeight == aPosAry.mnDestHeight)
+                    if (IsMapMode() || aPosAry.mnSrcWidth != aPosAry.mnDestWidth || aPosAry.mnSrcHeight != aPosAry.mnDestHeight)
                     {
                         bTryDirectPaint = false;
                     }
@@ -661,18 +661,16 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
         // separate alpha VDev
         bool bTryDirectPaint(!mpAlphaVDev && !pDisableNative && !bHMirr && !bVMirr);
 
-#ifdef WNT
-        if(bTryDirectPaint)
+        if (bTryDirectPaint)
         {
             // only paint direct when no scaling and no MapMode, else the
             // more expensive conversions may be done for short-time Bitmap/BitmapEx
             // used for buffering only
-            if(!IsMapMode() && rSrcSizePixel.Width() == aOutSz.Width() && rSrcSizePixel.Height() == aOutSz.Height())
+            if (IsMapMode() || rSrcSizePixel.Width() != aOutSz.Width() || rSrcSizePixel.Height() != aOutSz.Height())
             {
                 bTryDirectPaint = false;
             }
         }
-#endif
 
         if(bTryDirectPaint)
         {
commit d87b163f8dc787d3bbb17d4a0008ef60c61fe6b0
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 11 21:25:07 2014 +0100

    windows opengl: Make sure we don't reach the slow parts of the code.
    
    Change-Id: I2a4d1bd294d1d88651c8556091f5453ef0aa5293

diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 20e6367..4955b4b 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -20,6 +20,7 @@
 #include <vcl/bitmap.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/bmpacc.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/image.hxx>
@@ -32,7 +33,6 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <boost/scoped_array.hpp>
 
-
 void OutputDevice::DrawBitmap( const Point& rDestPt, const Bitmap& rBitmap )
 {
     const Size aSizePix( rBitmap.GetSizePixel() );
@@ -656,7 +656,6 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
 
     if( !aDstRect.Intersection( Rectangle( aOutPt, aOutSz ) ).IsEmpty() )
     {
-        bool bNativeAlpha = false;
         static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA");
         // #i83087# Naturally, system alpha blending cannot work with
         // separate alpha VDev
@@ -686,14 +685,18 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
             };
             SalBitmap* pSalSrcBmp = rBmp.ImplGetImpBitmap()->ImplGetSalBitmap();
             SalBitmap* pSalAlphaBmp = rAlpha.ImplGetImpBitmap()->ImplGetSalBitmap();
-            bNativeAlpha = mpGraphics->DrawAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, this );
+
+            if (mpGraphics->DrawAlphaBitmap( aTR, *pSalSrcBmp, *pSalAlphaBmp, this ))
+                return;
         }
 
+        // we need to make sure OpenGL never reaches this slow code path
+        assert(!OpenGLHelper::isVCLOpenGLEnabled());
+
         VirtualDevice* pOldVDev = mpAlphaVDev;
 
         Rectangle aBmpRect( Point(), rBmp.GetSizePixel() );
-        if( !bNativeAlpha
-                &&  !aBmpRect.Intersection( Rectangle( rSrcPtPixel, rSrcSizePixel ) ).IsEmpty() )
+        if (!aBmpRect.Intersection(Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty())
         {
             // The scaling in this code path produces really ugly results - it
             // does the most trivial scaling with no smoothing.
commit d9fbaf248ea907428c3a5d0422d0c9a9ce50b907
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Nov 11 21:19:02 2014 +0100

    windows opengl: Instantiate OpenGLSalBitmap even on Windows.
    
    Change-Id: I2229141cc12ad7bc9fccfd6e2c7fec44ac4f6284

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 8a2f89b..2cf9806 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -865,6 +865,9 @@ void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* /*
 
 void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
 {
+    // check that carefully only in the debug mode
+    assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBitmap));
+
     const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
     GLuint nTexture = rBitmap.GetTexture( maContext );
     const Size aSize = rSalBitmap.GetSize();
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 5a93aaa..e4f9205 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -34,6 +34,7 @@ static bool isValidBitCount( sal_uInt16 nBitCount )
 
 OpenGLSalBitmap::OpenGLSalBitmap()
 : mpContext(NULL)
+, mpTexture(NULL)
 , mbDirtyTexture(true)
 , mnBits(0)
 , mnBytesPerRow(0)
@@ -57,7 +58,7 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pT
     static const BitmapPalette aEmptyPalette;
 
     Destroy();
-    SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO" );
+    SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight );
 
     mpContext = &rContext;
     mnWidth = nWidth;
@@ -83,7 +84,7 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pT
 bool OpenGLSalBitmap::Create( const Size& rSize, sal_uInt16 nBits, const BitmapPalette& rBitmapPalette )
 {
     Destroy();
-    SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size" );
+    SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create with size: " << rSize );
 
     if( !isValidBitCount( nBits ) )
         return false;
@@ -106,9 +107,12 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, SalGraphics* pGraphics )
 
 bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount )
 {
+    // check that carefully only in the debug mode
+    assert(dynamic_cast<const OpenGLSalBitmap*>(&rSalBmp));
+
     const OpenGLSalBitmap& rSourceBitmap = static_cast<const OpenGLSalBitmap&>(rSalBmp);
 
-    SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from BMP " << rSourceBitmap.mnHeight );
+    SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from BMP: " << rSourceBitmap.mnWidth << "x" << rSourceBitmap.mnHeight );
 
     if( isValidBitCount( nNewBitCount ) )
     {
@@ -328,6 +332,7 @@ Size OpenGLSalBitmap::GetSize() const
 
 GLuint OpenGLSalBitmap::CreateTexture()
 {
+    SAL_INFO( "vcl.opengl", "::CreateTexture" );
     GLenum nFormat = GL_RGBA;
     GLenum nType = GL_UNSIGNED_BYTE;
     sal_uInt8* pData( NULL );
diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx
index b1d33e4..a601ff5 100644
--- a/vcl/win/source/app/salinst.cxx
+++ b/vcl/win/source/app/salinst.cxx
@@ -26,9 +26,11 @@
 
 #include <tools/solarmutex.hxx>
 
-#include <vcl/timer.hxx>
 #include <vcl/apptypes.hxx>
+#include <vcl/opengl/OpenGLHelper.hxx>
+#include <vcl/timer.hxx>
 
+#include <opengl/salbmp.hxx>
 #include <win/wincomp.hxx>
 #include <win/salids.hrc>
 #include <win/saldata.hxx>
@@ -1007,7 +1009,10 @@ SalTimer* WinSalInstance::CreateSalTimer()
 
 SalBitmap* WinSalInstance::CreateSalBitmap()
 {
-    return new WinSalBitmap();
+    if (OpenGLHelper::isVCLOpenGLEnabled())
+        return new OpenGLSalBitmap();
+    else
+        return new WinSalBitmap();
 }
 
 class WinImeStatus : public SalI18NImeStatus


More information about the Libreoffice-commits mailing list