diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-02-26 20:22:41 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-02-26 20:59:24 +0000 |
commit | 46ce83541b2670e72f1281f8d3a7df5af9c4aed2 (patch) | |
tree | 5cfe08acd645573211dcbe606151c6eb6e13faa5 /vcl/unx/gtk3/gdi | |
parent | 00646102569739e0bf8929c271963f129d747a5a (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
Diffstat (limited to 'vcl/unx/gtk3/gdi')
-rw-r--r-- | vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 50 |
1 files changed, 17 insertions, 33 deletions
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 ); } |