[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/unx

Caolán McNamara caolanm at redhat.com
Wed Mar 4 05:38:55 PST 2015


 vcl/inc/unx/gtk/gtkframe.hxx                  |    1 
 vcl/inc/unx/gtk/gtkgdi.hxx                    |    1 
 vcl/unx/gtk/window/gtksalframe.cxx            |   43 ++++++++++++--------------
 vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx |   13 -------
 4 files changed, 24 insertions(+), 34 deletions(-)

New commits:
commit c26e2c8794651120e644ab5b1e1de15bb113c4f0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 4 13:30:08 2015 +0000

    move getCairoContext to GtkSalFrame and reuse
    
    Change-Id: I8c50e6dd51299214ad622b253ffc401244653225

diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index a11f1fa8..5cb0d9c 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -341,6 +341,7 @@ public:
 
 #if GTK_CHECK_VERSION(3,0,0)
     // only for gtk3 ...
+    cairo_t* getCairoContext();
     void pushIgnoreDamage();
     void popIgnoreDamage();
     bool isDuringRender();
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index a984f1b..66aa0e0 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -58,6 +58,7 @@ public:
     static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer );
 
     cairo_t* getCairoContext();
+
     void clipRegion(cairo_t* cr);
 
 private:
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 16d8653..0418f17 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -3334,6 +3334,24 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi
 }
 
 #if GTK_CHECK_VERSION(3,0,0)
+
+cairo_t* GtkSalFrame::getCairoContext()
+{
+    basebmp::RawMemorySharedArray data = m_aFrame->getBuffer();
+    basegfx::B2IVector size = m_aFrame->getSize();
+    sal_Int32 nStride = m_aFrame->getScanlineStride();
+    assert(cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX()) == nStride);
+    cairo_surface_t *target =
+        cairo_image_surface_create_for_data(data.get(),
+                                        CAIRO_FORMAT_RGB24,
+                                        size.getX(), size.getY(),
+                                        nStride);
+    cairo_t* cr = cairo_create(target);
+    cairo_surface_destroy(target);
+    return cr;
+//    return gdk_cairo_create(gtk_widget_get_window(mpFrame->getWindow()));
+}
+
 void GtkSalFrame::pushIgnoreDamage()
 {
     m_nDuringRender++;
@@ -3393,7 +3411,6 @@ void GtkSalFrame::renderArea( cairo_t *cr, cairo_rectangle_t *area )
 
     basebmp::RawMemorySharedArray data = m_aFrame->getBuffer();
     basegfx::B2IVector size = m_aFrame->getSize();
-    sal_Int32 nStride = m_aFrame->getScanlineStride();
 
     long ax = area->x;
     long ay = area->y;
@@ -3422,28 +3439,12 @@ void GtkSalFrame::renderArea( cairo_t *cr, cairo_rectangle_t *area )
 
     cairo_save( cr );
 
-    unsigned char *src = data.get();
-    assert(cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX()) == nStride);
-    cairo_surface_t *pSurface =
-        cairo_image_surface_create_for_data(src,
-                                            CAIRO_FORMAT_RGB24,
-                                            size.getX(), size.getY(),
-                                            nStride);
-    /*
-        int cairo_stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX());
-        g_warning( "Fixed cairo status %d %d strides: %d vs %d, mask %d\n",
-               (int) cairo_status( cr ),
-               (int) cairo_surface_status( pSurface ),
-               (int) nStride,
-               (int) cairo_stride,
-               (int) (cairo_stride & (sizeof (uint32_t)-1)) );
-    */
+    cairo_surface_t *pSurface = cairo_get_target(getCairoContext());
 
     cairo_set_operator( cr, CAIRO_OPERATOR_OVER );
     cairo_set_source_surface( cr, pSurface, 0, 0 );
     cairo_rectangle( cr, ax, ay, awidth, aheight );
     cairo_fill( cr );
-    cairo_surface_destroy( pSurface );
     cairo_restore( cr );
 
     // Render red rectangles to show what was re-rendered ...
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 966f964..1f4f3a8 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -1586,18 +1586,7 @@ void GtkSalGraphics::copyArea( long nDestX, long nDestY,
 
 cairo_t* GtkSalGraphics::getCairoContext()
 {
-    basebmp::RawMemorySharedArray data = mpFrame->m_aFrame->getBuffer();
-    basegfx::B2IVector size = mpFrame->m_aFrame->getSize();
-    sal_Int32 nStride = mpFrame->m_aFrame->getScanlineStride();
-    cairo_surface_t *target =
-        cairo_image_surface_create_for_data(data.get(),
-                                        CAIRO_FORMAT_RGB24,
-                                        size.getX(), size.getY(),
-                                        nStride);
-    cairo_t* cr = cairo_create(target);
-    cairo_surface_destroy(target);
-    return cr;
-//    return gdk_cairo_create(gtk_widget_get_window(mpFrame->getWindow()));
+    return mpFrame->getCairoContext();
 }
 
 void GtkSalGraphics::clipRegion(cairo_t* cr)
commit f462c9800299f3fa2a7e7f5c718197acc37bbac2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 4 13:26:49 2015 +0000

    quieten spew
    
    Change-Id: I40107e53a36aa8af2253bb8708de23239de0546e

diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 21ee7f8..16d8653 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -3482,12 +3482,10 @@ gboolean GtkSalFrame::signalDraw( GtkWidget*, cairo_t *cr, gpointer frame )
     // clip region, and just pushing (with renderArea) smaller pieces
     // is faster ...
     cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list (cr);
-    fprintf( stderr, "paint %d regions\n", rects->num_rectangles);
+    SAL_INFO("vcl.gtk3", "paint " << rects->num_rectangles << " regions");
     for (int i = 0; i < rects->num_rectangles; i++) {
         cairo_rectangle_t rect = rects->rectangles[i];
-        fprintf( stderr, "\t%d -> %g,%g %gx%g\n", i,
-                 rect.x, rect.y, rect.width, rect.height );
-
+        SAL_INFO("vcl.gtk3", "\t" << i << " -> " << rect.x << "," << rect.y << " " << rect.width << "x" << rect.height);
         struct SalPaintEvent aEvent( rect.x, rect.y, rect.width, rect.height );
         aEvent.mbImmediateUpdate = true;
         pThis->CallCallback( SALEVENT_PAINT, &aEvent );


More information about the Libreoffice-commits mailing list