[Libreoffice-commits] core.git: 16 commits - vcl/inc vcl/opengl vcl/quartz vcl/source vcl/win vcl/workben

Michael Meeks michael.meeks at collabora.com
Sat Nov 15 06:19:16 PST 2014


 vcl/inc/impimagetree.hxx            |    7 
 vcl/opengl/gdiimpl.cxx              |    9 +
 vcl/opengl/salbmp.cxx               |   18 ++
 vcl/opengl/texture.cxx              |   18 ++
 vcl/opengl/x11/gdiimpl.cxx          |    2 
 vcl/quartz/salgdicommon.cxx         |    6 
 vcl/source/gdi/impimage.cxx         |    9 -
 vcl/source/gdi/impimagetree.cxx     |   69 +++++----
 vcl/source/opengl/OpenGLContext.cxx |   12 +
 vcl/source/opengl/OpenGLHelper.cxx  |    9 +
 vcl/source/outdev/bitmap.cxx        |    8 -
 vcl/win/source/gdi/gdiimpl.cxx      |   11 -
 vcl/win/source/gdi/salgdi.cxx       |    1 
 vcl/win/source/gdi/winlayout.cxx    |   72 ++++++++-
 vcl/workben/vcldemo.cxx             |  264 +++++++++++++++++++++++++++++++-----
 15 files changed, 415 insertions(+), 100 deletions(-)

New commits:
commit 4f8442440681eaaa8db1a800843d2ed25f111681
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 16:32:06 2014 +0000

    vcl: assert more useful truths on BitmapWriterAccess completion.
    
    Change-Id: I2ccc5eb64bf3b5d5ce94e2ddd4b9b458c3eda217
    
    Conflicts:
    	vcl/opengl/salbmp.cxx

diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index e411f2c..ad43ef8 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -527,6 +527,12 @@ void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
     // The palette is modified on read during the BitmapWriteAccess,
     // but of course, often it is not modified; interesting.
     maPalette = pBuffer->maPalette;
+
+    // Are there any more ground movements underneath us ?
+    assert( pBuffer->mnWidth == mnWidth );
+    assert( pBuffer->mnHeight == mnHeight );
+    assert( pBuffer->mnBitCount == mnBits );
+
     delete pBuffer;
 }
 
commit 90742105a5d95d175a89b5a253584fa1676ab02a
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 14 21:41:15 2014 +0100

    opengl: Another places where it is too eager to check for errors.
    
    Change-Id: Ib6ca3d653f3fd1155bce418226146934e765928d

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index dab78f3..e630bf9 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1505,8 +1505,6 @@ void OpenGLSalGraphicsImpl::endPaint()
         maContext.makeCurrent();
         glFlush();
     }
-
-    CHECK_GL_ERROR();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 5c2f3c1..938de54 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -92,8 +92,6 @@ ImplOpenGLTexture::~ImplOpenGLTexture()
     SAL_INFO( "vcl.opengl", "~OpenGLTexture " << mnTexture );
     if( mnTexture != 0 )
         glDeleteTextures( 1, &mnTexture );
-
-    CHECK_GL_ERROR();
 }
 
 OpenGLTexture::OpenGLTexture() :
commit bad9b2d464cb350fd59e2808dc4e7415cc6658ea
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 14 20:35:44 2014 +0100

    vcl: The backend should decide whether fast alpha drawing is available.
    
    The unx drawAlphaBitmap() already already checks that the source and
    destination have the same size.
    
    Windows and OpenGL should be able to handle that without trouble.
    
    OS X would need some additional code, so added an early return for the case
    the source and result sizes do not match.
    
    Change-Id: Ib09654aaa9c9064c232cff5094fcaa1190e931c6

diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index ad15432..6a8d953 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -568,6 +568,12 @@ bool AquaSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
 {
     DBG_DRAW_OPERATION("drawAlphaBitmap", true);
 
+    if (rTR.mnSrcWidth != rTR.mnDestWidth || rTR.mnSrcHeight != rTR.mnDestHeight)
+    {
+        // TODO - would be better to scale it by the native code
+        return false;
+    }
+
     // An image mask can't have a depth > 8 bits (should be 1 to 8 bits)
     if( rAlphaBmp.GetBitCount() > 8 )
     {
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 9a2e56d..4b0583b 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -524,10 +524,10 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
 
                 if (bTryDirectPaint)
                 {
-                    // only paint direct when no scaling and no MapMode, else the
+                    // only paint direct when 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())
                     {
                         bTryDirectPaint = false;
                     }
@@ -663,10 +663,10 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r
 
         if (bTryDirectPaint)
         {
-            // only paint direct when no scaling and no MapMode, else the
+            // only paint direct when 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())
             {
                 bTryDirectPaint = false;
             }
diff --git a/vcl/win/source/gdi/gdiimpl.cxx b/vcl/win/source/gdi/gdiimpl.cxx
index 453033f..03ad554 100644
--- a/vcl/win/source/gdi/gdiimpl.cxx
+++ b/vcl/win/source/gdi/gdiimpl.cxx
@@ -774,17 +774,6 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry,
     DBG_ASSERT( !mrParent.isPrinter(), "No transparency print possible!" );
     bool bTryDirectPaint(!mrParent.isPrinter() && !mbXORMode);
 
-    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(rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight)
-        {
-            bTryDirectPaint = false;
-        }
-    }
-
     // try to draw using GdiPlus directly
     if(bTryDirectPaint && drawAlphaBitmap(rPosAry, rSSalBitmap, rSTransparentBitmap))
     {
commit 1e15058e08445d2857755ec8ef06deb2e3393b97
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 14 19:12:11 2014 +0100

    windows opengl: Do not be _that_ eager with CHECK_GL_ERROR().
    
    Turns out that when you call glGetError() and OpenGL is not yet set up (or
    already turned down), it leads to an error; so when we check for errors in a
    loop, we never recover from that ;-)
    
    Change-Id: I849ad1dc30fc93ee1c021b446d9ad379bf9987c0

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 8f691e7..4f6d130 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -78,8 +78,6 @@ OpenGLContext::~OpenGLContext()
             glXDestroyGLXPixmap(m_aGLWin.dpy, m_aGLWin.glPix);
     }
 #endif
-
-    CHECK_GL_ERROR();
 }
 
 void OpenGLContext::requestLegacyContext()
@@ -299,8 +297,7 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat,
     ReleaseDC(hWnd, glWin.hDC);
     DestroyWindow(hWnd);
 
-    CHECK_GL_ERROR();
-    return  bArbMultisampleSupported;
+    return bArbMultisampleSupported;
 }
 #endif
 
commit 340888d3e5c51d39ceb1642e50e9b62c6996ac01
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 14:54:24 2014 +0000

    vcldemo: implement key-bindings and command-line
    
    Change-Id: I98ea70a78f340a2050ef934de3111ba3191ff479
    
    Conflicts:
    	vcl/workben/vcldemo.cxx

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 2d4d2ed..665abd5 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -68,14 +68,21 @@ class DemoWin : public DemoBase
     struct RegionRenderer {
     public:
         virtual ~RegionRenderer() {}
+        virtual OUString getName() = 0;
+        virtual sal_uInt16 getAccelerator() = 0;
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) = 0;
+#define RENDER_DETAILS(name,key) \
+        virtual OUString getName() SAL_OVERRIDE \
+            { return OUString(SAL_STRINGIFY(name)); } \
+        virtual sal_uInt16 getAccelerator() SAL_OVERRIDE \
+            { return key; }
     };
 
     std::vector< RegionRenderer * > maRenderers;
     sal_Int32  mnSelectedRenderer;
 
-    void InitRenderers();
+    void     InitRenderers();
 
 public:
     DemoWin() : DemoBase()
@@ -96,6 +103,9 @@ public:
         InitRenderers();
     }
 
+    OUString getRendererList();
+    void     selectRenderer(const OUString &rName);
+
     // Bouncing windows on click ...
     PushButton     *mpButton;
     FloatingWindow *mpButtonWin;
@@ -104,6 +114,7 @@ public:
     DECL_LINK(BounceTimerCb, void *);
 
     virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
+    virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
 
     virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE
     {
@@ -163,6 +174,7 @@ public:
 
     struct DrawLines : public RegionRenderer
     {
+        RENDER_DETAILS(lines,KEY_L)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
         {
@@ -249,6 +261,7 @@ public:
 
     struct DrawText : public RegionRenderer
     {
+        RENDER_DETAILS(text,KEY_T)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
@@ -261,6 +274,7 @@ public:
 
     struct DrawCheckered : public RegionRenderer
     {
+        RENDER_DETAILS(checks,KEY_C)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
         {
@@ -321,6 +335,7 @@ public:
 
     struct DrawPoly : public RegionRenderer
     {
+        RENDER_DETAILS(poly,KEY_P)
         DrawCheckered maCheckered;
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
@@ -344,6 +359,7 @@ public:
 
     struct DrawEllipse : public RegionRenderer
     {
+        RENDER_DETAILS(ellipse,KEY_E)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
@@ -355,6 +371,7 @@ public:
 
     struct DrawGradient : public RegionRenderer
     {
+        RENDER_DETAILS(gradient,KEY_G)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
         {
@@ -425,6 +442,7 @@ public:
 
     struct DrawBitmap : public RegionRenderer
     {
+        RENDER_DETAILS(bitmap,KEY_B)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
         {
@@ -436,6 +454,7 @@ public:
 
     struct DrawBitmapEx : public RegionRenderer
     {
+        RENDER_DETAILS(bitmapex,KEY_X)
         DrawCheckered maCheckered;
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &rCtx) SAL_OVERRIDE
@@ -453,6 +472,7 @@ public:
 
     struct DrawPolyPolygons : public RegionRenderer
     {
+        RENDER_DETAILS(polypoly,KEY_N)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
@@ -503,6 +523,7 @@ public:
 
     struct DrawToVirtualDevice : public RegionRenderer
     {
+        RENDER_DETAILS(vdev,KEY_V)
         enum RenderType {
             RENDER_AS_BITMAP,
             RENDER_AS_OUTDEV,
@@ -569,6 +590,8 @@ public:
 
     struct DrawIcons : public RegionRenderer
     {
+        RENDER_DETAILS(icons,KEY_I)
+
         std::vector<OUString> maIconNames;
         std::vector<BitmapEx> maIcons;
         bool bHasLoadedAll;
@@ -700,6 +723,7 @@ public:
 
     struct FetchDrawBitmap : public RegionRenderer
     {
+        RENDER_DETAILS(fetchdraw,KEY_F)
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
@@ -757,6 +781,34 @@ IMPL_LINK_NOARG(DemoWin,BounceTimerCb)
     return 0;
 }
 
+void DemoWin::KeyInput(const KeyEvent &rKEvt)
+{
+    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+
+    // click to zoom out
+    if (mnSelectedRenderer >= 0)
+    {
+        if (nCode == KEY_ESCAPE || nCode == KEY_BACKSPACE)
+        {
+            mnSelectedRenderer = -1;
+            Invalidate();
+            return;
+        }
+    }
+    else
+    {
+        for (size_t i = 0; i < maRenderers.size(); i++)
+        {
+            if (nCode == maRenderers[i]->getAccelerator())
+            {
+                mnSelectedRenderer = i;
+                Invalidate();
+                return;
+            }
+        }
+    }
+}
+
 void DemoWin::MouseButtonDown(const MouseEvent& rMEvt)
 {
     // click to zoom out
@@ -820,8 +872,43 @@ void DemoWin::InitRenderers()
     maRenderers.push_back(new FetchDrawBitmap());
 }
 
+OUString DemoWin::getRendererList()
+{
+    OUStringBuffer aBuf;
+    for (size_t i = 0; i < maRenderers.size(); i++)
+    {
+        aBuf.append(maRenderers[i]->getName());
+        aBuf.append(' ');
+    }
+    return aBuf.makeStringAndClear();
+}
+
+void DemoWin::selectRenderer(const OUString &rName)
+{
+    for (size_t i = 0; i < maRenderers.size(); i++)
+    {
+        if (maRenderers[i]->getName() == rName)
+        {
+            mnSelectedRenderer = i;
+            Invalidate();
+            return;
+        }
+    }
+}
+
 class DemoApp : public Application
 {
+    int showHelp(DemoWin &rWin)
+    {
+        fprintf(stderr,"vcldemo - a VCL test app\n");
+        fprintf(stderr,"  --help            - print this text\n");
+        fprintf(stderr,"  --show <renderer> - start with a given renderer, options are:\n");
+        OUString aRenderers(rWin.getRendererList());
+        fprintf(stderr,"         %s\n\n",
+                rtl::OUStringToOString(aRenderers, RTL_TEXTENCODING_UTF8).getStr());
+        return 0;
+    }
+
 public:
     DemoApp() {}
 
@@ -830,6 +917,22 @@ public:
         try
         {
             DemoWin aMainWin;
+
+            for (sal_Int32 i = 0; i < GetCommandLineParamCount(); i++)
+            {
+                bool bLast = i == GetCommandLineParamCount() - 1;
+                OUString aArg = GetCommandLineParam(i);
+                if (aArg == "--help" || aArg == "-h")
+                    return showHelp(aMainWin);
+                if (aArg == "--show")
+                {
+                    if (bLast)
+                        return showHelp(aMainWin);
+                    else
+                        aMainWin.selectRenderer(GetCommandLineParam(++i));
+                }
+            }
+
             aMainWin.SetText("Interactive VCL demo");
             aMainWin.Show();
             Application::Execute();
commit 633c40bc36ea6efe07cb0ccbf527ba5ee94055b6
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 14:09:49 2014 +0000

    vcldemo: BitmapEx rotation, translation and shear.
    
    Change-Id: I5a44597bc39c6bccfcec32403fae8f8d7d4fe94c
    
    Conflicts:
    	vcl/workben/vcldemo.cxx

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 8fb3d90..2d4d2ed 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -25,6 +25,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <vcl/button.hxx>
 #include <vcl/floatwin.hxx>
+#include <basegfx/numeric/ftools.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 
 #if 0
@@ -40,7 +41,7 @@ class DemoBase :
         public WorkWindow // hide OutputDevice if necessary
 {
 public:
-    DemoBase() : WorkWindow( NULL, WB_APP | WB_STDWORK)
+    DemoBase() : WorkWindow(NULL, WB_APP | WB_STDWORK)
     {
     }
     OutputDevice &getOutDev() { return *this; }
@@ -88,8 +89,9 @@ public:
     {
         if (!Application::LoadBrandBitmap("intro", maIntro))
             Application::Abort("Failed to load intro image");
+
         maIntroBW = maIntro.GetBitmap();
-        maIntroBW.Filter( BMP_FILTER_EMBOSS_GREY );
+        maIntroBW.Filter(BMP_FILTER_EMBOSS_GREY);
 
         InitRenderers();
     }
@@ -101,9 +103,9 @@ public:
     int             mnBounceX, mnBounceY;
     DECL_LINK(BounceTimerCb, void *);
 
-    virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+    virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
 
-    virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE
+    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(), false);
@@ -119,9 +121,9 @@ public:
         long nBorderSize = aSize.Width() / 32;
         long nBoxWidth = (aSize.Width() - nBorderSize*(nX+1)) / nX;
         long nBoxHeight = (aSize.Height() - nBorderSize*(nY+1)) / nY;
-        for (int y = 0; y < nY; y++ )
+        for (int y = 0; y < nY; y++)
         {
-            for (int x = 0; x < nX; x++ )
+            for (int x = 0; x < nX; x++)
             {
                 r.SetPos(Point(nBorderSize + (nBorderSize + nBoxWidth) * x,
                                nBorderSize + (nBorderSize + nBoxHeight) * y));
@@ -224,15 +226,15 @@ public:
             {
                 rDev.SetFillColor(Color(COL_LIGHTRED));
                 rDev.SetLineColor(Color(COL_BLACK));
-                rDev.DrawRect( r );
+                rDev.DrawRect(r);
 
                 for(int i=0; i<r.GetHeight(); i+=15)
-                    rDev.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)
-                    rDev.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 );
+                Color aLastPixel(COL_WHITE);
                 Point aCenter((r.Left() + r.Right())/2 - 4,
                               (r.Top() + r.Bottom())/2 - 4);
                 for(int i=0; i<8; i++)
@@ -250,10 +252,10 @@ public:
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
                                   const RenderContext &) SAL_OVERRIDE
         {
-            rDev.SetTextColor( Color( COL_BLACK ) );
-            vcl::Font aFont( OUString( "Times" ), Size( 0, 25 ) );
-            rDev.SetFont( aFont );
-            rDev.DrawText( r, OUString( "Click any rect to zoom" ) );
+            rDev.SetTextColor(Color(COL_BLACK));
+            vcl::Font aFont(OUString("Times"), Size(0, 25));
+            rDev.SetFont(aFont);
+            rDev.DrawText(r, OUString("Click any rect to zoom"));
         }
     };
 
@@ -631,27 +633,39 @@ public:
                 Size aSize(maIcons[i].GetSizePixel());
 //              sAL_DEBUG("Draw icon '" << maIconNames[i] << "'");
 
-                basegfx::B2DHomMatrix aTransform;
-                aTransform.scale(aSize.Width(), aSize.Height());
-                aTransform.translate(p.X(), p.Y());
-                switch (1)
-                {
-                case 0:
+                if (!i % 4)
                     rDev.DrawBitmapEx(p, maIcons[i]);
-                    break;
-                case 1:
-                    rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
-                    break;
-                case 2:
-                    aTransform.shearX(10);
-                    rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
-                    break;
-                case 3:
-                    aTransform.rotate(i);
+                else
+                {
+                    basegfx::B2DHomMatrix aTransform;
+                    aTransform.scale(aSize.Width(), aSize.Height());
+                    switch (i % 4)
+                    {
+                    case 2:
+                        aTransform.shearX((double)((i >> 2) % 8) / 8);
+                        aTransform.shearY((double)((i >> 4) % 8) / 8);
+                        break;
+                    case 3:
+                        aTransform.translate(-aSize.Width()/2, -aSize.Height()/2);
+                        aTransform.rotate(i);
+                        if (i & 0x100)
+                        {
+                            aTransform.shearX((double)((i >> 2) % 8) / 8);
+                            aTransform.shearY((double)((i >> 4) % 8) / 8);
+                        }
+                        aTransform.translate(aSize.Width()/2,  aSize.Height()/2);
+                        break;
+                    default:
+                        aTransform.translate(-aSize.Width()/2, -aSize.Height()/2);
+                        aTransform.rotate(2 * F_2PI * i / nToRender);
+                        aTransform.translate(aSize.Width()/2,  aSize.Height()/2);
+                        break;
+                    }
+                    aTransform.translate(p.X(), p.Y());
                     rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
-                    break;
                 }
 
+                // next position
                 p.Move(aSize.Width(), 0);
                 if (aSize.Height() > nMaxH)
                     nMaxH = aSize.Height();
@@ -743,7 +757,7 @@ IMPL_LINK_NOARG(DemoWin,BounceTimerCb)
     return 0;
 }
 
-void DemoWin::MouseButtonDown( const MouseEvent& rMEvt )
+void DemoWin::MouseButtonDown(const MouseEvent& rMEvt)
 {
     // click to zoom out
     if (mnSelectedRenderer >= 0)
@@ -816,7 +830,7 @@ public:
         try
         {
             DemoWin aMainWin;
-            aMainWin.SetText( "Interactive VCL demo" );
+            aMainWin.SetText("Interactive VCL demo");
             aMainWin.Show();
             Application::Execute();
         }
@@ -842,11 +856,11 @@ protected:
             uno::Reference<uno::XComponentContext> xComponentContext
                 = ::cppu::defaultBootstrap_InitialComponentContext();
             xMSF = uno::Reference<lang::XMultiServiceFactory>
-                ( xComponentContext->getServiceManager(), uno::UNO_QUERY );
-            if( !xMSF.is() )
+                (xComponentContext->getServiceManager(), uno::UNO_QUERY);
+            if(!xMSF.is())
                 Application::Abort("Bootstrap failure - no service manager");
 
-            ::comphelper::setProcessServiceFactory( xMSF );
+            ::comphelper::setProcessServiceFactory(xMSF);
         }
         catch (const uno::Exception &e)
         {
@@ -857,8 +871,8 @@ protected:
     {
         uno::Reference< lang::XComponent >(
             comphelper::getProcessComponentContext(),
-        uno::UNO_QUERY_THROW )-> dispose();
-        ::comphelper::setProcessServiceFactory( NULL );
+        uno::UNO_QUERY_THROW)-> dispose();
+        ::comphelper::setProcessServiceFactory(NULL);
     }
 };
 
commit f7313629efa1bbf44cc328eabfdc1ed8e9a1d537
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 12:27:15 2014 +0000

    vcldemo: exercise more BitmapEx rendering paths.
    
    Change-Id: Iecd02534dfbe0938a8635e3b7c2363b4531ef5ef

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 81dc316..8fb3d90 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -25,6 +25,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <vcl/button.hxx>
 #include <vcl/floatwin.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
 
 #if 0
 #  define FIXME_SELF_INTERSECTING_WORKING
@@ -610,31 +611,61 @@ public:
             bHasLoadedAll = true;
 
             css::uno::Sequence< OUString > aAllIcons = ImageTree_getAllImageNames();
-            for (sal_Int32 i = 0; i < aAllIcons.getLength() && i < 1024; i++)
+            for (sal_Int32 i = 0; i < aAllIcons.getLength(); i++)
             {
                 maIconNames.push_back(aAllIcons[i]);
                 maIcons.push_back(BitmapEx(aAllIcons[i]));
             }
         }
 
-        void doDrawIcons(OutputDevice &rDev, Rectangle r)
+        void doDrawIcons(OutputDevice &rDev, Rectangle r, bool bExpanded)
         {
             long nMaxH = 0, nVPos = 0;
             Point p(r.TopLeft());
-            for (size_t i = 0; i < maIcons.size(); i++)
+            size_t nToRender = maIcons.size();
+
+            if (!bExpanded && maIcons.size() > 64)
+                nToRender = 64;
+            for (size_t i = 0; i < nToRender; i++)
             {
                 Size aSize(maIcons[i].GetSizePixel());
 //              sAL_DEBUG("Draw icon '" << maIconNames[i] << "'");
-                rDev.DrawBitmapEx(p, maIcons[i]);
+
+                basegfx::B2DHomMatrix aTransform;
+                aTransform.scale(aSize.Width(), aSize.Height());
+                aTransform.translate(p.X(), p.Y());
+                switch (1)
+                {
+                case 0:
+                    rDev.DrawBitmapEx(p, maIcons[i]);
+                    break;
+                case 1:
+                    rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
+                    break;
+                case 2:
+                    aTransform.shearX(10);
+                    rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
+                    break;
+                case 3:
+                    aTransform.rotate(i);
+                    rDev.DrawTransformedBitmapEx(aTransform, maIcons[i]);
+                    break;
+                }
+
                 p.Move(aSize.Width(), 0);
                 if (aSize.Height() > nMaxH)
                     nMaxH = aSize.Height();
-                if (p.X() >= r.Right())
+                if (p.X() >= r.Right()) // wrap to next line
                 {
                     nVPos += nMaxH;
                     nMaxH = 0;
                     p = Point(r.Left(), r.Top() + nVPos);
                 }
+                if (p.Y() >= r.Bottom()) // re-start at top
+                {
+                    p = r.TopLeft();
+                    nVPos = 0;
+                }
             }
         }
 
@@ -644,11 +675,11 @@ public:
             if (rCtx.meStyle == RENDER_EXPANDED)
             {
                 LoadAllImages();
-                doDrawIcons(rDev, r);
+                doDrawIcons(rDev, r, true);
             }
             else
             {
-                doDrawIcons(rDev, r);
+                doDrawIcons(rDev, r, false);
             }
         }
     };
commit 1d2c5224b24f0509365cf69e835063a1e3a3bec1
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 14 15:43:44 2014 +0100

    opengl: Add many more CHECK_GL_ERROR()'s before returning from functions.
    
    Change-Id: I63c147acf9a4013008b0f6d76867186f04ee57d5

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 09e80f8..dab78f3 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -120,6 +120,7 @@ void OpenGLSalGraphicsImpl::PostDraw()
         glDisable( GL_SCISSOR_TEST );
     if( mbUseStencil )
         glDisable( GL_STENCIL_TEST );
+
     CHECK_GL_ERROR();
 }
 
@@ -144,6 +145,8 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa
     glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
     glStencilMask( 0x00 );
     glDisable( GL_STENCIL_TEST );
+
+    CHECK_GL_ERROR();
 }
 
 bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
@@ -174,6 +177,7 @@ bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
         ImplSetClipBit( rClip, 0x01 );
     }
 
+    CHECK_GL_ERROR();
     return true;
 }
 
@@ -301,6 +305,7 @@ bool OpenGLSalGraphicsImpl::CheckOffscreenTexture()
     glViewport( 0, 0, GetWidth(), GetHeight() );
     DrawTexture( maOffscreenTex, aPosAry );
 
+    CHECK_GL_ERROR();
     return true;
 }
 
@@ -679,6 +684,8 @@ void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const Sal
         glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
     DrawTexture( rTexture, rPosAry, bInverted );
     glDisable( GL_BLEND );
+
+    CHECK_GL_ERROR();
 }
 
 void OpenGLSalGraphicsImpl::DrawTextureWithMask( OpenGLTexture& rTexture, OpenGLTexture& rMask, const SalTwoRect& pPosAry )
@@ -831,6 +838,7 @@ void OpenGLSalGraphicsImpl::DrawAxialGradient( const Gradient& rGradient, const
 
     glDisableVertexAttribArray( GL_ATTRIB_TEX );
     glUseProgram( 0 );
+
     CHECK_GL_ERROR();
 }
 
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 005fb66..5c2f3c1 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -40,6 +40,8 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate )
     if( bAllocate )
         glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
     glBindTexture( GL_TEXTURE_2D, 0 );
+
+    CHECK_GL_ERROR();
 }
 
 // texture with content retrieved from FBO
@@ -59,6 +61,7 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight )
     glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nX, nY, nWidth, nHeight, 0 );
     CHECK_GL_ERROR();
     glBindTexture( GL_TEXTURE_2D, 0 );
+
     CHECK_GL_ERROR();
 }
 
@@ -80,6 +83,8 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int
     glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
     glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, mnWidth, mnHeight, 0, nFormat, nType, pData );
     glBindTexture( GL_TEXTURE_2D, 0 );
+
+    CHECK_GL_ERROR();
 }
 
 ImplOpenGLTexture::~ImplOpenGLTexture()
@@ -87,6 +92,8 @@ ImplOpenGLTexture::~ImplOpenGLTexture()
     SAL_INFO( "vcl.opengl", "~OpenGLTexture " << mnTexture );
     if( mnTexture != 0 )
         glDeleteTextures( 1, &mnTexture );
+
+    CHECK_GL_ERROR();
 }
 
 OpenGLTexture::OpenGLTexture() :
@@ -198,18 +205,24 @@ void OpenGLTexture::SetFilter( GLenum nFilter )
         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nFilter );
         glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nFilter );
     }
+
+    CHECK_GL_ERROR();
 }
 
 void OpenGLTexture::Bind()
 {
     if( mpImpl )
         glBindTexture( GL_TEXTURE_2D, mpImpl->mnTexture );
+
+    CHECK_GL_ERROR();
 }
 
 void OpenGLTexture::Unbind()
 {
     if( mpImpl )
         glBindTexture( GL_TEXTURE_2D, 0 );
+
+    CHECK_GL_ERROR();
 }
 
 bool OpenGLTexture::Draw()
@@ -243,6 +256,7 @@ bool OpenGLTexture::Draw()
     glDisableVertexAttribArray( 1 );
     glBindTexture( GL_TEXTURE_2D, 0 );
 
+    CHECK_GL_ERROR();
     return true;
 }
 
@@ -269,12 +283,12 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
         GLuint nFramebufferId;
         glGenFramebuffers( 1, &nFramebufferId );
         glBindFramebuffer( GL_FRAMEBUFFER, nFramebufferId );
-    CHECK_GL_ERROR();
+        CHECK_GL_ERROR();
 
         glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Id(), 0 );
-    CHECK_GL_ERROR();
+        CHECK_GL_ERROR();
         glReadPixels( maRect.Left(), mpImpl->mnHeight - maRect.Top(), GetWidth(), GetHeight(), nFormat, nType, pData );
-    CHECK_GL_ERROR();
+        CHECK_GL_ERROR();
 
         glBindFramebuffer( GL_FRAMEBUFFER, 0 );
         glDeleteFramebuffers( 1, &nFramebufferId );
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 3bbb3d3..26355cb 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -113,6 +113,7 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX,
     XFreeGC( pDisplay, aGC );
     XDestroyImage( pImage );
 
+    CHECK_GL_ERROR();
     return true;
 }
 
@@ -160,6 +161,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX,
 
     PostDraw();
 
+    CHECK_GL_ERROR();
     return true;
 }
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 866c38e..8f691e7 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -78,6 +78,8 @@ OpenGLContext::~OpenGLContext()
             glXDestroyGLXPixmap(m_aGLWin.dpy, m_aGLWin.glPix);
     }
 #endif
+
+    CHECK_GL_ERROR();
 }
 
 void OpenGLContext::requestLegacyContext()
@@ -160,6 +162,8 @@ int InitTempWindow(HWND *hwnd, int width, int height, PIXELFORMATDESCRIPTOR inPf
     {
         return -1;
     }
+
+    CHECK_GL_ERROR();
     return 0;
 }
 
@@ -198,6 +202,8 @@ bool WGLisExtensionSupported(const char *extension)
         if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' '))
             return 1; // Match
     }
+
+    CHECK_GL_ERROR();
 }
 
 bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat,
@@ -293,6 +299,7 @@ bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat,
     ReleaseDC(hWnd, glWin.hDC);
     DestroyWindow(hWnd);
 
+    CHECK_GL_ERROR();
     return  bArbMultisampleSupported;
 }
 #endif
@@ -448,6 +455,7 @@ GLXFBConfig* getFBConfigForPixmap(Display* dpy, int& nBestFBC, bool bUseDoubleBu
         }
     }
 
+    CHECK_GL_ERROR();
     return pFBC;
 }
 
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 3ad99db..3dd5df8 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -144,6 +144,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString
         return 0;
     }
 
+    CHECK_GL_ERROR();
     return ProgramID;
 }
 
@@ -184,6 +185,8 @@ void OpenGLHelper::renderToFile(long nWidth, long nHeight, const OUString& rFile
     } catch (...) {
         SAL_WARN("vcl.opengl", "Error writing png to " << rFileName);
     }
+
+    CHECK_GL_ERROR();
 }
 
 BitmapEx OpenGLHelper::ConvertBGRABufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight)
@@ -326,6 +329,8 @@ void OpenGLHelper::createFramebuffer(long nWidth, long nHeight, GLuint& nFramebu
     }
     glBindRenderbuffer(GL_RENDERBUFFER, 0);
     glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+    CHECK_GL_ERROR();
 }
 
 float OpenGLHelper::getGLVersion()
@@ -340,6 +345,8 @@ float OpenGLHelper::getGLVersion()
             fVersion += (aVersion[2] - '0')/10.0;
         }
     }
+
+    CHECK_GL_ERROR();
     return fVersion;
 }
 
@@ -398,6 +405,7 @@ bool OpenGLHelper::GetVisualInfo(Display* pDisplay, int nScreen, XVisualInfo& rV
     rVI = *pVI;
     XFree( pVI );
 
+    CHECK_GL_ERROR();
     return true;
 }
 
@@ -448,6 +456,7 @@ GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted
         return 0;
     }
 
+    CHECK_GL_ERROR();
     return aFbConfigs[i];
 }
 
commit 3bc5e986b38f620db9d0119b5d431c10c67eeb74
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 11:58:28 2014 +0000

    vcldemo: dump and render all icons from images.zip when zoomed in.
    
    Change-Id: I89f37b8a1ed70334a3485bc3ca06d04cfe6d0827

diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx
index 712ec80..9e4f579 100644
--- a/vcl/inc/impimagetree.hxx
+++ b/vcl/inc/impimagetree.hxx
@@ -55,6 +55,8 @@ public:
  *  be too late for the destructors of the bitmaps in m_iconCache)*/
     void shutDown();
 
+    css::uno::Reference< css::container::XNameAccess > getNameAccess();
+
 private:
     bool doLoadImage(
         OUString const & name, OUString const & style,
@@ -62,8 +64,7 @@ private:
 
     typedef std::pair<
         OUString,
-        com::sun::star::uno::Reference<
-            com::sun::star::container::XNameAccess > > Path;
+        css::uno::Reference< css::container::XNameAccess > > Path;
 
     typedef boost::unordered_map<
         OUString, bool, OUStringHash > CheckStyleCache;
@@ -78,6 +79,8 @@ private:
     bool m_cacheIcons;
     IconLinkHash m_linkHash;
 
+    bool checkPathAccess();
+
     void setStyle(OUString const & style );
 
     void resetPaths();
@@ -89,7 +92,6 @@ private:
     void loadImageLinks();
     void parseLinkFile(boost::shared_ptr< SvStream > stream);
     OUString const & getRealImageName(OUString const & name);
-    std::vector<OUString> getAllPaths();
 };
 
 typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef;
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index 807f89e..9f2741b 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -248,17 +248,9 @@ bool ImplImageTree::find(
         }
     }
 
-    if (!m_path.second.is()) {
-        try {
-            m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip");
-        } catch (const css::uno::RuntimeException &) {
-            throw;
-        } catch (const css::uno::Exception & e) {
-            SAL_INFO("vcl", "ImplImageTree::find exception "
-                << e.Message << " for " << m_path.first);
-            return false;
-        }
-    }
+    if (!checkPathAccess())
+        return false;
+
     for (std::vector< OUString >::const_reverse_iterator j(paths.rbegin());
          j != paths.rend(); ++j)
     {
@@ -288,21 +280,9 @@ void ImplImageTree::loadImageLinks()
         }
     }
 
-    if ( !m_path.second.is() )
-    {
-        try
-        {
-            m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip");
-        } catch (const css::uno::RuntimeException &) {
-            throw;
-        }
-        catch (const css::uno::Exception & e)
-        {
-            SAL_INFO("vcl", "ImplImageTree::find exception "
-                << e.Message << " for " << m_path.first);
-            return;
-        }
-    }
+    if (!checkPathAccess())
+        return;
+
     if ( m_path.second->hasByName(aLinkFilename) )
     {
         css::uno::Reference< css::io::XInputStream > s;
@@ -349,21 +329,41 @@ OUString const & ImplImageTree::getRealImageName(OUString const & name)
     return it->second;
 }
 
-std::vector<OUString> ImplImageTree::getAllPaths()
+bool ImplImageTree::checkPathAccess()
 {
-    std::vector<OUString> aNames;
+    if (m_path.second.is())
+        return true;
+
+    try {
+        m_path.second = css::packages::zip::ZipFileAccess::createWithURL(comphelper::getProcessComponentContext(), m_path.first + ".zip");
+    } catch (const css::uno::RuntimeException &) {
+        throw;
+    } catch (const css::uno::Exception & e) {
+        SAL_INFO("vcl", "ImplImageTree::zip file location exception "
+                 << e.Message << " for " << m_path.first);
+        return false;
+    }
+    return m_path.second.is();
+}
 
-    return aNames;
+css::uno::Reference< css::container::XNameAccess > ImplImageTree::getNameAccess()
+{
+    checkPathAccess();
+    return m_path.second;
 }
 
 // For vcldemo / debugging
-SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames();
+SAL_DLLPUBLIC css::uno::Sequence< OUString > ImageTree_getAllImageNames();
 
 /// Recursively dump all names ...
-std::vector<OUString> ImageTree_getAllImageNames()
+css::uno::Sequence< OUString > ImageTree_getAllImageNames()
 {
     static ImplImageTreeSingletonRef aImageTree;
-    return aImageTree.getAllPaths();
+
+    css::uno::Reference< css::container::XNameAccess > xRef(
+        aImageTree->getNameAccess() );
+
+    return xRef->getElementNames();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index e9ffdc7..81dc316 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -31,7 +31,7 @@
 #endif
 
 // debugging hook just for us
-SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames();
+SAL_DLLPUBLIC css::uno::Sequence< OUString > ImageTree_getAllImageNames();
 
 using namespace css;
 
@@ -566,6 +566,7 @@ public:
 
     struct DrawIcons : public RegionRenderer
     {
+        std::vector<OUString> maIconNames;
         std::vector<BitmapEx> maIcons;
         bool bHasLoadedAll;
         DrawIcons() : bHasLoadedAll(false)
@@ -596,18 +597,24 @@ public:
                 "cmd/lc_hyperlinkdialog.png",
               };
             for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
-                maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i])));
+            {
+                maIconNames.push_back(OUString::createFromAscii(pNames[i]));
+                maIcons.push_back(BitmapEx(maIconNames[i]));
+            }
         }
 
-        void LoadAllIcons()
+        void LoadAllImages()
         {
             if (bHasLoadedAll)
                 return;
             bHasLoadedAll = true;
 
-            std::vector<OUString> aAllIcons = ImageTree_getAllImageNames();
-            for (size_t i = 0; i < aAllIcons.size(); i++)
+            css::uno::Sequence< OUString > aAllIcons = ImageTree_getAllImageNames();
+            for (sal_Int32 i = 0; i < aAllIcons.getLength() && i < 1024; i++)
+            {
+                maIconNames.push_back(aAllIcons[i]);
                 maIcons.push_back(BitmapEx(aAllIcons[i]));
+            }
         }
 
         void doDrawIcons(OutputDevice &rDev, Rectangle r)
@@ -617,6 +624,7 @@ public:
             for (size_t i = 0; i < maIcons.size(); i++)
             {
                 Size aSize(maIcons[i].GetSizePixel());
+//              sAL_DEBUG("Draw icon '" << maIconNames[i] << "'");
                 rDev.DrawBitmapEx(p, maIcons[i]);
                 p.Move(aSize.Width(), 0);
                 if (aSize.Height() > nMaxH)
@@ -635,6 +643,7 @@ public:
         {
             if (rCtx.meStyle == RENDER_EXPANDED)
             {
+                LoadAllImages();
                 doDrawIcons(rDev, r);
             }
             else
commit f5b3ea832e39da9bd70fa132699acb533f1e474f
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 11:56:46 2014 +0000

    vcl: Fix palette modification during BitmapWriteAccess lifetime.
    
    Change-Id: I8bdedd63895ff0b3245d996cf35ac92d9ab0ff9d

diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 2e197d3..e411f2c 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -239,9 +239,12 @@ public:
     ImplPixelFormat8( const BitmapPalette& rPalette )
     : mrPalette( rPalette )
     {
+        if ( mrPalette.GetEntryCount() < 256 )
+            SAL_WARN( "vcl.opengl", "Bad sign, if we get an OOB pixel we die" );
     }
     virtual const BitmapColor& ReadPixel() SAL_OVERRIDE
     {
+        assert( mrPalette.GetEntryCount() > *mpData );
         return mrPalette[ *mpData++ ];
     }
 };
@@ -259,6 +262,8 @@ public:
         , mnX(0)
         , mnShift(4)
     {
+        if ( mrPalette.GetEntryCount() < 16 )
+            SAL_WARN( "vcl.opengl", "Bad sign, if we get an OOB pixel we die" );
     }
     virtual void StartLine( sal_uInt8* pLine ) SAL_OVERRIDE
     {
@@ -268,7 +273,9 @@ public:
     }
     virtual const BitmapColor& ReadPixel() SAL_OVERRIDE
     {
-        const BitmapColor& rColor = mrPalette[( mpData[mnX >> 1] >> mnShift) & 0x0f];
+        sal_uInt32 nIdx = ( mpData[mnX >> 1] >> mnShift) & 0x0f;
+        assert( mrPalette.GetEntryCount() > nIdx );
+        const BitmapColor& rColor = mrPalette[nIdx];
         mnX++;
         mnShift ^= 4;
         return rColor;
@@ -517,6 +524,9 @@ void OpenGLSalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly )
         maTexture = OpenGLTexture();
         mbDirtyTexture = true;
     }
+    // The palette is modified on read during the BitmapWriteAccess,
+    // but of course, often it is not modified; interesting.
+    maPalette = pBuffer->maPalette;
     delete pBuffer;
 }
 
commit c7d87b7224557d76d5741311b9c8af627a6ccc79
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 09:47:09 2014 +0000

    vcldemo: much improved icon rendering tests.
    
    Change-Id: I853bc0a0957cf0db629a0a5f1ced67bc069d8403

diff --git a/vcl/inc/impimagetree.hxx b/vcl/inc/impimagetree.hxx
index 85e3640..712ec80 100644
--- a/vcl/inc/impimagetree.hxx
+++ b/vcl/inc/impimagetree.hxx
@@ -89,6 +89,7 @@ private:
     void loadImageLinks();
     void parseLinkFile(boost::shared_ptr< SvStream > stream);
     OUString const & getRealImageName(OUString const & name);
+    std::vector<OUString> getAllPaths();
 };
 
 typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef;
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index d58cc8d..807f89e 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -349,4 +349,21 @@ OUString const & ImplImageTree::getRealImageName(OUString const & name)
     return it->second;
 }
 
+std::vector<OUString> ImplImageTree::getAllPaths()
+{
+    std::vector<OUString> aNames;
+
+    return aNames;
+}
+
+// For vcldemo / debugging
+SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames();
+
+/// Recursively dump all names ...
+std::vector<OUString> ImageTree_getAllImageNames()
+{
+    static ImplImageTreeSingletonRef aImageTree;
+    return aImageTree.getAllPaths();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index e56d95c..e9ffdc7 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -30,6 +30,9 @@
 #  define FIXME_SELF_INTERSECTING_WORKING
 #endif
 
+// debugging hook just for us
+SAL_DLLPUBLIC std::vector<OUString> ImageTree_getAllImageNames();
+
 using namespace css;
 
 class DemoBase :
@@ -564,39 +567,79 @@ public:
     struct DrawIcons : public RegionRenderer
     {
         std::vector<BitmapEx> maIcons;
-        DrawIcons()
+        bool bHasLoadedAll;
+        DrawIcons() : bHasLoadedAll(false)
         {
+            // a few icons to start with
             const char *pNames[] = {
                 "cmd/lc_openurl.png",
                 "cmd/lc_newdoc.png",
+                "cmd/lc_choosemacro.png",
                 "cmd/lc_save.png",
                 "cmd/lc_saveas.png",
+                "cmd/lc_importdialog.png",
                 "cmd/lc_sendmail.png",
                 "cmd/lc_editdoc.png",
                 "cmd/lc_print.png",
+                "cmd/lc_combobox.png",
+                "cmd/lc_insertformcombo.png",
                 "cmd/lc_printpreview.png",
                 "cmd/lc_cut.png",
                 "cmd/lc_copy.png",
                 "cmd/lc_paste.png",
+                "cmd/sc_autopilotmenu.png",
                 "cmd/lc_formatpaintbrush.png",
                 "cmd/lc_undo.png",
                 "cmd/lc_redo.png",
-            };
+                "cmd/lc_marks.png",
+                "cmd/lc_fieldnames.png",
+                "cmd/lc_hyperlinkdialog.png",
+              };
             for (size_t i = 0; i < SAL_N_ELEMENTS(pNames); i++)
                 maIcons.push_back(BitmapEx(OUString::createFromAscii(pNames[i])));
         }
 
-        virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
-                                  const RenderContext &) SAL_OVERRIDE
+        void LoadAllIcons()
         {
-            Rectangle p(r);
+            if (bHasLoadedAll)
+                return;
+            bHasLoadedAll = true;
+
+            std::vector<OUString> aAllIcons = ImageTree_getAllImageNames();
+            for (size_t i = 0; i < aAllIcons.size(); i++)
+                maIcons.push_back(BitmapEx(aAllIcons[i]));
+        }
+
+        void doDrawIcons(OutputDevice &rDev, Rectangle r)
+        {
+            long nMaxH = 0, nVPos = 0;
+            Point p(r.TopLeft());
             for (size_t i = 0; i < maIcons.size(); i++)
             {
                 Size aSize(maIcons[i].GetSizePixel());
-                rDev.DrawBitmapEx(p.TopLeft(), maIcons[i]);
+                rDev.DrawBitmapEx(p, maIcons[i]);
                 p.Move(aSize.Width(), 0);
-                if (p.Left() >= r.Right())
-                    break;
+                if (aSize.Height() > nMaxH)
+                    nMaxH = aSize.Height();
+                if (p.X() >= r.Right())
+                {
+                    nVPos += nMaxH;
+                    nMaxH = 0;
+                    p = Point(r.Left(), r.Top() + nVPos);
+                }
+            }
+        }
+
+        virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
+                                  const RenderContext &rCtx) SAL_OVERRIDE
+        {
+            if (rCtx.meStyle == RENDER_EXPANDED)
+            {
+                doDrawIcons(rDev, r);
+            }
+            else
+            {
+                doDrawIcons(rDev, r);
             }
         }
     };
commit d75c9dfb0c0fbada58485670820a435658df150c
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Nov 14 08:40:45 2014 +0000

    vcl: re-factor image rendering control-flow.
    
    Change-Id: I923f92e5e84d35dafd1c0d1b4d63916ce690cb90

diff --git a/vcl/source/gdi/impimage.cxx b/vcl/source/gdi/impimage.cxx
index c8f4a72..0072087 100644
--- a/vcl/source/gdi/impimage.cxx
+++ b/vcl/source/gdi/impimage.cxx
@@ -331,10 +331,9 @@ pOutDev
     if( !mpDisplayBmp && !maBmpEx.IsEmpty() )
     {
 #if defined WNT
-        if( maBmpEx.IsAlpha() )
-            mpDisplayBmp = new BitmapEx( maBmpEx );
-        else
+        if( !maBmpEx.IsAlpha() )
         {
+            // FIXME: this looks like rather an obsolete code-path to me.
             const Bitmap aBmp( maBmpEx.GetBitmap().CreateDisplayBitmap( pOutDev ) );
 
             if( maBmpEx.IsTransparent() )
@@ -342,9 +341,9 @@ pOutDev
             else
                 mpDisplayBmp = new BitmapEx( aBmp );
         }
-#else
-        mpDisplayBmp = new BitmapEx( maBmpEx );
+        else
 #endif
+            mpDisplayBmp = new BitmapEx( maBmpEx );
     }
 }
 
commit 5b924866e70359b295a4ecdd39430fa2217b8a81
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 14 13:58:09 2014 +0100

    windows opengl: Finally got the text working.
    
    It still does not have a transparent background, but that is pending support in
    OpenGLSalGraphicsImpl.
    
    Change-Id: I477a483e6ac940f54f6ffd6816d753d87206bf23

diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 480e1a0..7f6fdc9 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -192,27 +192,38 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
         // TODO: check the performance of this 2nd approach at some stage and
         // switch to that if it performs well.
 
-        // FIXME so that we don't have to use enormous bitmap, move the text
-        // to 0,0, size the width / height accordingly, and move it back via
-        // SalTwoRects later
-        const int width = 1024;
-        const int height = 1024;
+        Rectangle aRect;
+        GetBoundRect(rGraphics, aRect);
+
+        const int origin_x = aRect.Left();
+        const int origin_y = aRect.Top();
+        const int width = aRect.GetWidth();
+        const int height = aRect.GetHeight();
         const int bpp = 32;
 
         HDC compatibleDC = CreateCompatibleDC(hDC);
 
+        // move the origin so that we always paint at 0,0 - to keep the bitmap
+        // small
+        OffsetViewportOrgEx(compatibleDC, -origin_x, -origin_y, NULL);
+
         sal_uInt8 *data;
         HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&data));
-        // FIXME fill transparent instead of 128, this is for testing
-        memset(data, 128, width*height*4);
 
-        // draw the text to the hidden DC with black color and white
-        // background, we will use the result later as a mask only
+        // setup the hidden DC with black color and white background, we will
+        // use the result of the text drawing later as a mask only
         HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap);
         SelectFont(compatibleDC, mhFont);
+
         SetTextColor(compatibleDC, RGB(0, 0, 0));
         SetBkColor(compatibleDC, RGB(255, 255, 255));
+
+        UINT nTextAlign = GetTextAlign(hDC);
+        SetTextAlign(compatibleDC, nTextAlign);
+
+        // the actual drawing
         DrawTextImpl(compatibleDC);
+
         SelectObject(compatibleDC, hBitmapOld);
 
         // and turn it into a texture
@@ -227,8 +238,8 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
             aRects.mnSrcY = 0;
             aRects.mnSrcWidth = width;
             aRects.mnSrcHeight = height;
-            aRects.mnDestX = 0;
-            aRects.mnDestY = 0;
+            aRects.mnDestX = origin_x;
+            aRects.mnDestY = origin_y;
             aRects.mnDestWidth = width;
             aRects.mnDestHeight = height;
 
commit 30c6b2f1ec9dd2a639c5bcabeb7fa1afc15a1c17
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Nov 14 11:15:17 2014 +0100

    windows opengl: Explain the concept of the text drawing + minor fixes.
    
    Change-Id: I4651e7e9b8163844be548d4ed975a881d4f83fff

diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 30c62ef..480e1a0 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -163,7 +163,34 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
     }
     else
     {
-        // we have to render the text to a hidden texture, and draw it
+        // We have to render the text to a hidden texture, and draw it.
+        //
+        // Note that Windows GDI does not really support the alpha correctly
+        // when drawing - ie. it draws nothing to the alpha channel when
+        // rendering the text, even the antialiasing is done as 'real' pixels,
+        // not alpha...
+        //
+        // Luckily, this does not really limit us:
+        //
+        // To blend properly, we draw the texture, but then use it as an alpha
+        // channel for solid color (that will define the text color).  This
+        // destroys the subpixel antialiasing - turns it into 'classic'
+        // antialiasing - but that is the best we can do, because the subpixel
+        // antialiasing needs to know what is in the background: When the
+        // background is white, or white-ish, it does the subpixel, but when
+        // there is a color, it just darkens the color (and does this even
+        // when part of the character is on a colored background, and part on
+        // white).  It has to work this way, the results would look strange
+        // otherwise.
+        //
+        // For the GL rendering to work even with the subpixel antialiasing,
+        // we would need to get the current texture from the screen, let GDI
+        // draw the text to it (so that it can decide well where to use the
+        // subpixel and where not), and draw the result - but in that case we
+        // don't need alpha anyway.
+        //
+        // TODO: check the performance of this 2nd approach at some stage and
+        // switch to that if it performs well.
 
         // FIXME so that we don't have to use enormous bitmap, move the text
         // to 0,0, size the width / height accordingly, and move it back via
@@ -176,12 +203,15 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
 
         sal_uInt8 *data;
         HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&data));
-        // FIXME fill transparent instead of 128
+        // FIXME fill transparent instead of 128, this is for testing
         memset(data, 128, width*height*4);
 
-        // draw the text to the hidden DC
+        // draw the text to the hidden DC with black color and white
+        // background, we will use the result later as a mask only
         HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap);
         SelectFont(compatibleDC, mhFont);
+        SetTextColor(compatibleDC, RGB(0, 0, 0));
+        SetBkColor(compatibleDC, RGB(255, 255, 255));
         DrawTextImpl(compatibleDC);
         SelectObject(compatibleDC, hBitmapOld);
 
@@ -203,7 +233,12 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
             aRects.mnDestHeight = height;
 
             pImpl->PreDraw();
-            pImpl->DrawAlphaTexture(aTexture, aRects);
+            COLORREF color = GetTextColor(hDC);
+            SalColor salColor = MAKE_SALCOLOR(GetRValue(color), GetGValue(color), GetBValue(color));
+            // TODO when we have it:
+            // pImpl->DrawSolidColorWithMask(salColor, aTexture, aRects);
+            // and kill the following interim thing:
+            pImpl->DrawTexture(aTexture, aRects);
             pImpl->PostDraw();
         }
 
commit 6fd7199230bfc81d6aadf53b3c115def8caba90c
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Nov 13 05:58:01 2014 +0100

    windows opengl: Set PFD_DOUBLEBUFFER even for single buffer rendering.
    
    Otherwise I'm getting lots of errers when dealing with virtual devices...
    
    Change-Id: I34e145817d21dfc2d30fa9ffdfedfa714467d105

diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 0423775..09e80f8 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1478,6 +1478,7 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
         glDisable( GL_STENCIL_TEST );
     PostDraw();
 
+    CHECK_GL_ERROR();
     return true;
 }
 
@@ -1496,6 +1497,8 @@ void OpenGLSalGraphicsImpl::endPaint()
         maContext.makeCurrent();
         glFlush();
     }
+
+    CHECK_GL_ERROR();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 0e760bc..866c38e 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -767,8 +767,9 @@ bool OpenGLContext::ImplInit()
         0, 0, 0                         // Layer Masks Ignored
     };
 
-    if (mbUseDoubleBufferedRendering)
-        PixelFormatFront.dwFlags |= PFD_DOUBLEBUFFER;
+    // interestingly we need this flag being set even if we use single buffer
+    // rendering - otherwise we get errors with virtual devices
+    PixelFormatFront.dwFlags |= PFD_DOUBLEBUFFER;
 
     if (mbRequestVirtualDevice)
         PixelFormatFront.dwFlags |= PFD_DRAW_TO_BITMAP;
commit 4093a540084488ed5d346f590dbf2a6d91286066
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Nov 13 05:28:50 2014 +0100

    request single buffered context on windows
    
    Change-Id: I7b9789053872446e312ae4e3c471986e3c5c55d2

diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index c5f848c..1004fbb 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -487,6 +487,7 @@ void WinSalGraphics::InitGraphics()
     {
         if (mbVirDev)
             pImpl->GetOpenGLContext().requestVirtualDevice();
+        pImpl->GetOpenGLContext().requestSingleBufferedRendering();
         pImpl->GetOpenGLContext().init(mhLocalDC, mhWnd);
     }
 }


More information about the Libreoffice-commits mailing list