Revert "Use the cairo-compatible basebmp surface for headless"
This reverts commita785df6a5f
plus follow-up3594c9ce1c
"presumably destroy flushes" andb5b19508da
"WaE: -Werror=unused-variable," as it triggered the assert(nLen <= 8) in ColorMask::ImplCalcMaskShift (include/vcl/salbtype.hxx) in various tests. Change-Id: Ic5433522fcd9b8cc7c4e82704cebe7d9bbcea586
This commit is contained in:
@@ -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:
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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);
|
||||
|
@@ -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 ...
|
||||
|
@@ -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 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user