Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-06-30 15:27:27 +0000
committerAlexander Kurtakov2017-06-30 15:44:24 +0000
commitfece871913dbb6e63efee0d54e5e2037dbfd1097 (patch)
tree15af19aed3c162257d5b218b95ce0bd70f0e245f /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt
parente38175d7318fb138b87e7ad3bc7275c3e97a0dc7 (diff)
downloadeclipse.platform.swt-fece871913dbb6e63efee0d54e5e2037dbfd1097.tar.gz
eclipse.platform.swt-fece871913dbb6e63efee0d54e5e2037dbfd1097.tar.xz
eclipse.platform.swt-fece871913dbb6e63efee0d54e5e2037dbfd1097.zip
Bug 518532 - Drop GDK drawing
Now that cairo is enforced remove non-cairo drawing from Composite background drawing. Change-Id: Iea94e6254da215edd59befcbee241bc02835c198 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java93
1 files changed, 36 insertions, 57 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index fdb2530c89..0e05077abf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -398,72 +398,51 @@ void drawBackgroundInPixels (GC gc, int x, int y, int width, int height, int off
if (control != null) {
GCData data = gc.getGCData ();
long /*int*/ cairo = data.cairo;
- if (cairo != 0) {
- Cairo.cairo_save (cairo);
- if (control.backgroundImage != null) {
- Point pt = display.mapInPixels (this, control, 0, 0);
- Cairo.cairo_translate (cairo, -pt.x - offsetX, -pt.y - offsetY);
- x += pt.x + offsetX;
- y += pt.y + offsetY;
- long /*int*/ surface = control.backgroundImage.surface;
- if (surface == 0) {
- long /*int*/ drawable = control.backgroundImage.pixmap;
- int [] w = new int [1], h = new int [1];
- OS.gdk_pixmap_get_size (drawable, w, h);
- if (OS.isX11()) {
- long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
- long /*int*/ xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system());
- long /*int*/ xDrawable = OS.GDK_PIXMAP_XID (drawable);
- surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w [0], h [0]);
- } else {
- surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, w [0], h [0]);
- }
- if (surface == 0) error (SWT.ERROR_NO_HANDLES);
+ Cairo.cairo_save (cairo);
+ if (control.backgroundImage != null) {
+ Point pt = display.mapInPixels (this, control, 0, 0);
+ Cairo.cairo_translate (cairo, -pt.x - offsetX, -pt.y - offsetY);
+ x += pt.x + offsetX;
+ y += pt.y + offsetY;
+ long /*int*/ surface = control.backgroundImage.surface;
+ if (surface == 0) {
+ long /*int*/ drawable = control.backgroundImage.pixmap;
+ int [] w = new int [1], h = new int [1];
+ OS.gdk_pixmap_get_size (drawable, w, h);
+ if (OS.isX11()) {
+ long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
+ long /*int*/ xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system());
+ long /*int*/ xDrawable = OS.GDK_PIXMAP_XID (drawable);
+ surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w [0], h [0]);
} else {
- Cairo.cairo_surface_reference(surface);
- }
- long /*int*/ pattern = Cairo.cairo_pattern_create_for_surface (surface);
- if (pattern == 0) error (SWT.ERROR_NO_HANDLES);
- Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT);
- if ((data.style & SWT.MIRRORED) != 0) {
- double[] matrix = {-1, 0, 0, 1, 0, 0};
- Cairo.cairo_pattern_set_matrix(pattern, matrix);
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, w [0], h [0]);
}
- Cairo.cairo_set_source (cairo, pattern);
- Cairo.cairo_surface_destroy (surface);
- Cairo.cairo_pattern_destroy (pattern);
+ if (surface == 0) error (SWT.ERROR_NO_HANDLES);
} else {
- if (OS.GTK3) {
- GdkRGBA rgba = control.getBackgroundGdkRGBA ();
- Cairo.cairo_set_source_rgba (cairo, rgba.red, rgba.green, rgba.blue, rgba.alpha);
- } else {
- GdkColor color = control.getBackgroundGdkColor ();
- Cairo.cairo_set_source_rgba_compatibility (cairo, color);
- }
+ Cairo.cairo_surface_reference(surface);
+ }
+ long /*int*/ pattern = Cairo.cairo_pattern_create_for_surface (surface);
+ if (pattern == 0) error (SWT.ERROR_NO_HANDLES);
+ Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT);
+ if ((data.style & SWT.MIRRORED) != 0) {
+ double[] matrix = {-1, 0, 0, 1, 0, 0};
+ Cairo.cairo_pattern_set_matrix(pattern, matrix);
}
- Cairo.cairo_rectangle (cairo, x, y, width, height);
- Cairo.cairo_fill (cairo);
- Cairo.cairo_restore (cairo);
+ Cairo.cairo_set_source (cairo, pattern);
+ Cairo.cairo_surface_destroy (surface);
+ Cairo.cairo_pattern_destroy (pattern);
} else {
- long /*int*/ gdkGC = gc.handle;
- GdkGCValues values = new GdkGCValues ();
- OS.gdk_gc_get_values (gdkGC, values);
- if (control.backgroundImage != null) {
- Point pt = display.mapInPixels (this, control, 0, 0);
- OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
- OS.gdk_gc_set_ts_origin (gdkGC, -pt.x - offsetX, -pt.y - offsetY);
- OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap);
- OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height);
- OS.gdk_gc_set_fill (gdkGC, values.fill);
- OS.gdk_gc_set_ts_origin (gdkGC, values.ts_x_origin, values.ts_y_origin);
+ if (OS.GTK3) {
+ GdkRGBA rgba = control.getBackgroundGdkRGBA ();
+ Cairo.cairo_set_source_rgba (cairo, rgba.red, rgba.green, rgba.blue, rgba.alpha);
} else {
GdkColor color = control.getBackgroundGdkColor ();
- OS.gdk_gc_set_foreground (gdkGC, color);
- OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height);
- color.pixel = values.foreground_pixel;
- OS.gdk_gc_set_foreground (gdkGC, color);
+ Cairo.cairo_set_source_rgba_compatibility (cairo, color);
}
}
+ Cairo.cairo_rectangle (cairo, x, y, width, height);
+ Cairo.cairo_fill (cairo);
+ Cairo.cairo_restore (cairo);
} else {
gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(x, y, width, height)));

Back to the top