[Libreoffice-commits] core.git: Branch 'private/mmeeks/icontest' - 2 commits - vcl/source vcl/workben

Michael Meeks michael.meeks at collabora.com
Sat Oct 11 15:25:06 PDT 2014


 vcl/source/bitmap/bitmapscalesuper.cxx |   10 +++++++++
 vcl/workben/icontest.cxx               |   36 ++++++++++++++++++++++++++-------
 2 files changed, 39 insertions(+), 7 deletions(-)

New commits:
commit 54cab7f193d5dc6b13350c78695fd3f4485476bd
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Oct 11 23:24:42 2014 +0100

    icontest: allow initial scaling to test direct bitmap rendering path.
    
    Change-Id: Id670bfd4af8bfabe01b5b006ce5c9ccf029dfb6c

diff --git a/vcl/workben/icontest.cxx b/vcl/workben/icontest.cxx
index 7e2fd41..a8df1c9 100644
--- a/vcl/workben/icontest.cxx
+++ b/vcl/workben/icontest.cxx
@@ -54,7 +54,6 @@ namespace {
         return (double)aValue.Seconds +
             (double)aValue.Nanosec / (1000*1000*1000);
     }
-
 }
 
 class MyWorkWindow : public WorkWindow
@@ -97,12 +96,15 @@ void MyWorkWindow::Paint( const Rectangle& /* rRect */ )
     OutputDevice &rDev = *this;
 
     // yes indeed drawinglayer re-scales the image per render etc.
-    BitmapEx aScaledBitamp( maGraphic.GetBitmapEx() );
-    aScaledBitamp.Scale( maDestinationSize, BMP_SCALE_SUPER);
+    BitmapEx aScaledBitmap( maGraphic.GetBitmapEx() );
+    aScaledBitmap.Scale( maDestinationSize, BMP_SCALE_SUPER);
 
     std::cerr << "==> Paint! " << nPaintCount++ << " (vcl) " << GetSizePixel() << " " << getTimeNow() - nStartTime << " image of size " << maGraphic.GetBitmapEx().GetSizePixel() << " scale to size " << maDestinationSize << std::endl;
 
-    rDev.DrawBitmapEx( Point( 0, 0 ), aScaledBitamp );
+    rDev.DrawBitmapEx( Point( 0, 0 ), aScaledBitmap );
+
+    if (nPaintCount > 100)
+        Application::Quit();
 
     Invalidate( INVALIDATE_CHILDREN ); // trigger re-render
 }
@@ -112,12 +114,20 @@ void MyWorkWindow::Paint( const Rectangle& /* rRect */ )
 void MyOpenGLWorkWindow::Paint( const Rectangle& )
 {
     std::cerr << "==> Paint! "<< nPaintCount++ << " (OpenGL) " << GetSizePixel() << " " << getTimeNow() - nStartTime << std::endl;
+
     OpenGLContext& aCtx = mpOpenGLWindow->getContext();
     aCtx.makeCurrent();
     CHECK_GL_ERROR();
     aCtx.requestLegacyContext();
     CHECK_GL_ERROR();
 
+    if (aCtx.supportMultiSampling())
+    {
+        // doesn't work but worth a try ...
+        glEnable(GL_MULTISAMPLE);
+        CHECK_GL_ERROR();
+    }
+
     if (!mbHaveTexture)
         LoadTexture();
 
@@ -143,7 +153,7 @@ void MyOpenGLWorkWindow::Paint( const Rectangle& )
     glPushMatrix();
     CHECK_GL_ERROR();
 
-    glTranslatef(-1, -1, 0);
+    glTranslatef(-1, -0.5, 0);
     glScalef(2, 2, 2);
 
     if (mnTextureAspect >= ((float) WIDTH) / HEIGHT)
@@ -170,6 +180,9 @@ void MyOpenGLWorkWindow::Paint( const Rectangle& )
     aCtx.swapBuffers();
     CHECK_GL_ERROR();
 
+    if (nPaintCount > 100)
+        Application::Quit();
+
     Invalidate( INVALIDATE_CHILDREN ); // trigger re-render
 }
 
@@ -225,9 +238,11 @@ void MyOpenGLWorkWindow::LoadTexture()
     CHECK_GL_ERROR();
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     CHECK_GL_ERROR();
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+    // Need to better simulate scale24bitRGB2 cf. bitmapscalesuper.cxx
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     CHECK_GL_ERROR();
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     CHECK_GL_ERROR();
 
     BitmapEx aBitmap( maGraphic.GetBitmapEx( ) );
@@ -365,6 +380,13 @@ void MyWorkWindow::LoadGraphic( const OUString &sImageFile )
             maDestinationSize = Size( WIDTH, HEIGHT/aspect );
         else
             maDestinationSize = Size( WIDTH * aspect, HEIGHT );
+
+        if (getenv("PRESCALE")) // test non-scaling rendering
+        {
+            BitmapEx aScaledBitmap( maGraphic.GetBitmapEx() );
+            aScaledBitmap.Scale( maDestinationSize, BMP_SCALE_SUPER);
+            maGraphic = Graphic( aScaledBitmap );
+        }
     }
     catch (const uno::Exception &e)
     {
commit 3b6414908f271be9ddde18889c3c28d9ee4c4bea
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Oct 11 22:49:46 2014 +0100

    vcl: add a brief comment on bitmap scaling.
    
    Change-Id: Id177f2af0d264d144509fb47aa072d011f46b2a6

diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx
index cbfb08e..206054f 100644
--- a/vcl/source/bitmap/bitmapscalesuper.cxx
+++ b/vcl/source/bitmap/bitmapscalesuper.cxx
@@ -24,6 +24,16 @@
 
 #define MAP( cVal0, cVal1, nFrac )  ((sal_uInt8)((((long)(cVal0)<<7L)+nFrac*((long)(cVal1)-(cVal0)))>>7L))
 
+/**
+ * generate a map of pixel source locations and errors for each
+ * destination pixel; we should end up with pMapIX containing a
+ * series of effectively integer pixel offsets across the row eg.
+ * for something slightly larger than a doubling in size with
+ * no flips:
+ *     pMapIX: 0 0 1 1 1 2 2 3 3 3 ...
+ * then pMapFX - contains fixed-point offsets from these
+ * co-ordinates to reflect sub-pixel positions.
+ */
 void generateMap(long nW, long nDstW, bool bHMirr, long* pMapIX, long* pMapFX)
 {
     const double fRevScaleX = (nDstW > 1L) ? (double) (nW - 1) / (nDstW - 1) : 0.0;


More information about the Libreoffice-commits mailing list