summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-26 20:22:41 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-02-26 20:59:24 +0000
commit46ce83541b2670e72f1281f8d3a7df5af9c4aed2 (patch)
tree5cfe08acd645573211dcbe606151c6eb6e13faa5
parent00646102569739e0bf8929c271963f129d747a5a (diff)
Restore "Use the cairo-compatible basebmp surface for headless"
as it now works again after ancient emf import bug is fixed by commit 5e5b90c12862b522a4553337fbf6309bb8278b8c Date: Thu Feb 26 13:47:58 2015 +0000 in BITFIELDS mode (3) there are *3* pal entries not 12 and two writer qa tests adapted to test for the actual pixel color vs the underlying pixel data This reverts commit 3c4f7704e0af64bf967f5f767bf4b4cff7f59d6c. Change-Id: Id94f98f9c620c90fda097fa97fc34c9ee957c483
-rw-r--r--vcl/headless/svpbmp.cxx10
-rw-r--r--vcl/headless/svpgdi.cxx1
-rw-r--r--vcl/headless/svpinst.cxx4
-rw-r--r--vcl/inc/headless/svpbmp.hxx2
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx2
-rw-r--r--vcl/unx/gtk/window/gtksalframe.cxx45
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx50
7 files changed, 48 insertions, 66 deletions
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index cedb9751a025..d9da88b920d7 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -185,6 +185,15 @@ 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;
@@ -389,6 +398,7 @@ 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 b65e7b973e0e..3f63146bd149 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -126,6 +126,7 @@ 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 7523dfd36368..a1088834def4 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_TWENTYFOUR_BIT_TC_MASK;
+ return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX;
case 32:
return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA;
case 0:
#ifdef ANDROID
return FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA;
#else
- return FORMAT_TWENTYFOUR_BIT_TC_MASK;
+ return FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX;
#endif
default:
return SVP_DEFAULT_BITMAP_FORMAT;
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index cb3336d9dd00..4b65acc8e9da 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_TWENTYFOUR_BIT_TC_MASK
+#define SVP_DEFAULT_BITMAP_FORMAT basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX
class SvpSalBitmap : public SalBitmap
{
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 568ef5caade5..15742daf947e 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_t* cr, cairo_rectangle_int_t *region );
+ void renderAreaToPix( cairo_surface_t* source, 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 ebc038ccb123..05d5e4662127 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 );
- sal_Int32 nStride(basebmp::getBitmapDeviceStrideForWidth(basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK, aFrameSize.getX()));
+ int cairo_stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, aFrameSize.getX());
m_aFrame = basebmp::createBitmapDevice(aFrameSize, true,
- basebmp::FORMAT_TWENTYFOUR_BIT_TC_MASK, nStride);
+ basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRX, cairo_stride);
m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr(new DamageTracker(*this)) );
fprintf( stderr, "allocated m_aFrame size of %dx%d \n",
@@ -3423,41 +3423,28 @@ void GtkSalFrame::renderArea( cairo_t *cr, cairo_rectangle_t *area )
cairo_save( cr );
- 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;
- }
+ 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( mem,
- CAIRO_FORMAT_ARGB32,
- awidth, aheight,
- cairo_stride );
- /* g_warning( "Fixed cairo status %d %d strides: %d vs %d, mask %d\n",
+ 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)) ); */
+ (int) (cairo_stride & (sizeof (uint32_t)-1)) );
+ */
cairo_set_operator( cr, CAIRO_OPERATOR_OVER );
- cairo_set_source_surface( cr, pSurface, ax, ay );
- cairo_paint( cr );
+ cairo_set_source_surface( cr, pSurface, 0, 0 );
+ cairo_rectangle( cr, ax, ay, awidth, aheight );
+ cairo_fill( 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 ac708fc5e1b7..e23f10318a24 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -912,7 +912,6 @@ 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);
@@ -960,18 +959,14 @@ 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;
}
-// 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,
+void GtkSalGraphics::renderAreaToPix( cairo_surface_t *source,
cairo_rectangle_int_t *region)
{
if( !mpFrame->m_aFrame.get() )
@@ -982,33 +977,22 @@ void GtkSalGraphics::renderAreaToPix( cairo_t *cr,
sal_Int32 nStride = mpFrame->m_aFrame->getScanlineStride();
long ax = region->x;
long ay = region->y;
- 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 awidth = MIN (region->width, size.getX() - ax);
long aheight = MIN (region->height, size.getY() - ay);
- 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;
- }
+ 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);
+
if ( !mpFrame->isDuringRender() )
gtk_widget_queue_draw_area( mpFrame->getWindow(), ax, ay, awidth, aheight );
}