[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/unx
Stephan Bergmann
sbergman at redhat.com
Thu Feb 26 05:01:38 PST 2015
vcl/headless/svpbmp.cxx | 10 -----
vcl/headless/svpgdi.cxx | 1
vcl/headless/svpinst.cxx | 4 +-
vcl/inc/headless/svpbmp.hxx | 2 -
vcl/inc/unx/gtk/gtkgdi.hxx | 2 -
vcl/unx/gtk/window/gtksalframe.cxx | 45 +++++++++++++++--------
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 50 +++++++++++++++++---------
7 files changed, 66 insertions(+), 48 deletions(-)
New commits:
commit 3c4f7704e0af64bf967f5f767bf4b4cff7f59d6c
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Feb 26 13:58:22 2015 +0100
Revert "Use the cairo-compatible basebmp surface for headless"
This reverts commit a785df6a5f9ad327210f51163129ef8b59c3af29 plus follow-up
3594c9ce1c94dfc52b9efe526a88baa79ea4b3e9 "presumably destroy flushes" and
b5b19508dafc2702eb3713fb6b07edb5e05d6601 "WaE: -Werror=unused-variable," as it
triggered the assert(nLen <= 8) in ColorMask::ImplCalcMaskShift
(include/vcl/salbtype.hxx) in various tests.
Change-Id: Ic5433522fcd9b8cc7c4e82704cebe7d9bbcea586
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index d9da88b..cedb975 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -185,15 +185,6 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( BitmapAccessMode )
nBitCount = 24;
pBuf->mnFormat = BMP_FORMAT_24BIT_TC_BGR;
break;
- case FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX:
- nBitCount = 32;
- pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
-#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
-#else
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
-#endif
- break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
@@ -398,7 +389,6 @@ sal_uInt32 SvpSalBitmap::getBitCountFromScanlineFormat( basebmp::Format nFormat
case FORMAT_TWENTYFOUR_BIT_TC_MASK:
nBitCount = 24;
break;
- case FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX:
case FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA:
case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 3f63146..b65e7b9 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -126,7 +126,6 @@ void SvpSalGraphics::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
case basebmp::FORMAT_SIXTEEN_BIT_LSB_TC_MASK:
case basebmp::FORMAT_SIXTEEN_BIT_MSB_TC_MASK:
case basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK:
- case basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX:
case basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA:
case basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
case basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index a108883..7523dfd 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -439,14 +439,14 @@ Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount )
return FORMAT_SIXTEEN_BIT_LSB_TC_MASK;
#endif
case 24:
- return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX;
+ return FORMAT_TWENTYFOUR_BIT_TC_MASK;
case 32:
return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA;
case 0:
#ifdef ANDROID
return FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA;
#else
- return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX;
+ return FORMAT_TWENTYFOUR_BIT_TC_MASK;
#endif
default:
return SVP_DEFAULT_BITMAP_FORMAT;
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index 4b65acc..cb3336d 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -27,7 +27,7 @@
#include <salbmp.hxx>
-#define SVP_DEFAULT_BITMAP_FORMAT basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX
+#define SVP_DEFAULT_BITMAP_FORMAT basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK
class SvpSalBitmap : public SalBitmap
{
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 15742da..568ef5c 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -74,7 +74,7 @@ private:
static GtkStyleContext *mpComboboxStyle;
static GtkStyleContext *mpListboxStyle;
- void renderAreaToPix( cairo_surface_t* source, cairo_rectangle_int_t *region );
+ void renderAreaToPix( cairo_t* cr, cairo_rectangle_int_t *region );
void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 05d5e46..ebc038c 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -1965,9 +1965,9 @@ void GtkSalFrame::AllocateFrame()
aFrameSize.setX( 1 );
if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 );
- int cairo_stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, aFrameSize.getX());
+ sal_Int32 nStride(basebmp::getBitmapDeviceStrideForWidth(basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK, aFrameSize.getX()));
m_aFrame = basebmp::createBitmapDevice(aFrameSize, true,
- basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX, cairo_stride);
+ basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK, nStride);
m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr(new DamageTracker(*this)) );
fprintf( stderr, "allocated m_aFrame size of %dx%d \n",
@@ -3423,28 +3423,41 @@ 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);
+ int cairo_stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, area->width);
+ unsigned char *p, *src, *mem = (unsigned char *)malloc (cairo_stride * area->height);
+ p = mem;
+ src = data.get();
+ src += (int)ay * nStride + (int)ax * 3;
+
+ for (int y = 0; y < aheight; ++y)
+ {
+ for (int x = 0; x < awidth; ++x)
+ {
+ p[x*4 + 0] = src[x*3 + 0]; // B
+ p[x*4 + 1] = src[x*3 + 1]; // G
+ p[x*4 + 2] = src[x*3 + 2]; // R
+ p[x*4 + 3] = 255; // A
+ }
+ src += nStride;
+ p += cairo_stride;
+ }
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",
+ cairo_image_surface_create_for_data( mem,
+ CAIRO_FORMAT_ARGB32,
+ awidth, aheight,
+ cairo_stride );
+ /* 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)) );
- */
+ (int) (cairo_stride & (sizeof (uint32_t)-1)) ); */
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_set_source_surface( cr, pSurface, ax, ay );
+ cairo_paint( cr );
cairo_surface_destroy( pSurface );
+ free (mem);
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 e23f103..ac708fc 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -912,6 +912,7 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
translatedRegion.width, translatedRegion.height);
cairo_t *cr = cairo_create(surface);
+ cairo_surface_destroy(surface); // unref
gtk_style_context_save(context);
gtk_style_context_set_state(context, flags);
@@ -959,14 +960,18 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
break;
}
+ gtk_style_context_restore(context);
+
+ renderAreaToPix(cr, &translatedRegion);
cairo_destroy(cr); // unref
- renderAreaToPix(surface, &translatedRegion);
- cairo_surface_destroy(surface); // unref
return true;
}
-void GtkSalGraphics::renderAreaToPix( cairo_surface_t *source,
+// FIXME: This is incredibly lame... but so is cairo's insistence on - exactly -
+// its own stride - neither more nor less - particularly not more aligned
+// we like 8byte aligned, it likes 4 - most odd.
+void GtkSalGraphics::renderAreaToPix( cairo_t *cr,
cairo_rectangle_int_t *region)
{
if( !mpFrame->m_aFrame.get() )
@@ -977,22 +982,33 @@ void GtkSalGraphics::renderAreaToPix( cairo_surface_t *source,
sal_Int32 nStride = mpFrame->m_aFrame->getScanlineStride();
long ax = region->x;
long ay = region->y;
- long awidth = MIN (region->width, size.getX() - ax);
+ long awidth = region->width;
+
+ /* Get the cairo surface and the data */
+ cairo_surface_t* surface = cairo_get_target(cr);
+ g_assert(surface != NULL);
+ cairo_surface_flush(surface);
+ unsigned char* cairo_data = cairo_image_surface_get_data(surface);
+ g_assert(cairo_data != NULL);
+ int cairo_stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, awidth);
+
+ unsigned char *src = data.get();
+ src += (int)ay * nStride + (int)ax * 3;
+ awidth = MIN (region->width, size.getX() - ax);
long aheight = MIN (region->height, size.getY() - ay);
- 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_set_source_surface( cr, source, ax, ay );
- cairo_rectangle( cr, ax, ay, awidth, aheight );
- cairo_fill( cr );
- cairo_destroy(cr);
- cairo_surface_destroy(target);
-
+ for (int y = 0; y < aheight; ++y)
+ {
+ for (int x = 0; x < awidth && y < aheight; ++x)
+ {
+ double alpha = ((float)cairo_data[x*4 + 3])/255.0;
+ src[x*3 + 0] = src[x*3 + 0] * (1.0 - alpha) + cairo_data[x*4+0];
+ src[x*3 + 1] = src[x*3 + 1] * (1.0 - alpha) + cairo_data[x*4+1];
+ src[x*3 + 2] = src[x*3 + 2] * (1.0 - alpha) + cairo_data[x*4+2];
+ }
+ src += nStride;
+ cairo_data += cairo_stride;
+ }
if ( !mpFrame->isDuringRender() )
gtk_widget_queue_draw_area( mpFrame->getWindow(), ax, ay, awidth, aheight );
}
More information about the Libreoffice-commits
mailing list