diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-02-26 13:58:22 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-02-26 13:58:22 +0100 |
commit | 3c4f7704e0af64bf967f5f767bf4b4cff7f59d6c (patch) | |
tree | 9d72d858bd7c52d98e7af23947b4cbcd61ff1dcd /vcl/unx | |
parent | dee6cbbc1aa16f1f51d7880d6e622146e3baf21d (diff) |
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
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/gtk/window/gtksalframe.cxx | 45 | ||||
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 50 |
2 files changed, 62 insertions, 33 deletions
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index 05d5e4662127..ebc038ccb123 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 e23f10318a24..ac708fc5e1b7 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 ); } |