You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/10/10 12:19:16 UTC

svn commit: r1396533 - /incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx

Author: alg
Date: Wed Oct 10 10:19:15 2012
New Revision: 1396533

URL: http://svn.apache.org/viewvc?rev=1396533&view=rev
Log:
#121183# Added buffering non-bitmap formats in Graphic

Modified:
    incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx

Modified: incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx?rev=1396533&r1=1396532&r2=1396533&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx (original)
+++ incubator/ooo/trunk/main/vcl/source/gdi/impgraph.cxx Wed Oct 10 10:19:15 2012
@@ -554,74 +554,81 @@ Bitmap ImpGraphic::ImplGetBitmap(const G
     }
     else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
     {
-        // calculate size
-        VirtualDevice aVDev;
-        Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
-
-        if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
+        if(maEx.IsEmpty())
         {
-            // apply given size if exists
-            aDrawSize = rParameters.getSizePixel();
-        }
+            // calculate size
+            VirtualDevice aVDev;
+            Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
 
-        if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
-            && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
-        {
-            // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
-            double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height());
-
-            if(fWH <= 1.0)
+            if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
             {
-                aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH));
-                aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT);
+                // apply given size if exists
+                aDrawSize = rParameters.getSizePixel();
             }
-            else
+
+            if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
+                && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
             {
-                aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT);
-                aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH));
+                // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
+                double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height());
+
+                if(fWH <= 1.0)
+                {
+                    aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH));
+                    aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT);
+                }
+                else
+                {
+                    aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT);
+                    aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH));
+                }
             }
-        }
 
-        // calculate pixel size. Normally, it's the same as aDrawSize, but may
-        // need to be extended when hairlines are on the right or bottom edge
-        Size aPixelSize(aDrawSize);
+            // calculate pixel size. Normally, it's the same as aDrawSize, but may
+            // need to be extended when hairlines are on the right or bottom edge
+            Size aPixelSize(aDrawSize);
 
-        if(GRAPHIC_GDIMETAFILE == ImplGetType())
-        {
-            // get hairline and full bound rect
-            Rectangle aHairlineRect;
-            const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect));
+            if(GRAPHIC_GDIMETAFILE == ImplGetType())
+            {
+                // get hairline and full bound rect
+                Rectangle aHairlineRect;
+                const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect));
+
+                if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
+                {
+                    // expand if needed to allow bottom and right hairlines to be added
+                    if(aRect.Right() == aHairlineRect.Right())
+                    {
+                        aPixelSize.setWidth(aPixelSize.getWidth() + 1);
+                    }
 
-            if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
+                    if(aRect.Bottom() == aHairlineRect.Bottom())
+                    {
+                        aPixelSize.setHeight(aPixelSize.getHeight() + 1);
+                    }
+                }
+            }
+
+            if(aVDev.SetOutputSizePixel(aPixelSize))
             {
-                // expand if needed to allow bottom and right hairlines to be added
-                if(aRect.Right() == aHairlineRect.Right())
+                if(rParameters.getAntiAliase())
                 {
-                    aPixelSize.setWidth(aPixelSize.getWidth() + 1);
+                    aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
                 }
 
-                if(aRect.Bottom() == aHairlineRect.Bottom())
+                if(rParameters.getSnapHorVerLines())
                 {
-                    aPixelSize.setHeight(aPixelSize.getHeight() + 1);
+                    aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
                 }
-            }
-        }
 
-        if(aVDev.SetOutputSizePixel(aPixelSize))
-        {
-            if(rParameters.getAntiAliase())
-            {
-                aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
-            }
+                ImplDraw( &aVDev, Point(), aDrawSize );
 
-            if(rParameters.getSnapHorVerLines())
-            {
-                aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
+                // use maEx as local buffer for rendered metafile
+                const_cast< ImpGraphic* >(this)->maEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
             }
-
-            ImplDraw( &aVDev, Point(), aDrawSize );
-            aRetBmp =  aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
         }
+
+        aRetBmp = maEx.GetBitmap();
     }
 
 	if( !!aRetBmp )
@@ -654,8 +661,15 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(con
     }
     else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
     {
-		const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
-		aRetBmpEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters));
+        if(maEx.IsEmpty())
+        {
+		    const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
+
+            // use maEx as local buffer for rendered metafile
+            const_cast< ImpGraphic* >(this)->maEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters));
+        }
+
+        aRetBmpEx = maEx;
     }
 
     return aRetBmpEx;