mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Revert "Implement GdkRegion in terms of cairo_region_t"
This reverts commit 5616bdc3dc
.
I always thought cairo_region_t was a Cairo 1.8 feature. Apparently it
isn't, so the 3 patches I just reverted made Gtk depend on an unreleased
Cairo version. This is obviously not a good thing.
Expect those patches to reland once there's a Cairo 1.10 out (probably
around Gtk 4...)
This commit is contained in:
parent
863853ec5f
commit
6c7dc26935
@ -20,6 +20,7 @@
|
||||
#include "gdkcairo.h"
|
||||
#include "gdkdrawable.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkregion-generic.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
/**
|
||||
@ -142,19 +143,21 @@ void
|
||||
gdk_cairo_region (cairo_t *cr,
|
||||
const GdkRegion *region)
|
||||
{
|
||||
cairo_rectangle_int_t box;
|
||||
GdkRegionBox *boxes;
|
||||
gint n_boxes, i;
|
||||
|
||||
g_return_if_fail (cr != NULL);
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
n_boxes = cairo_region_num_rectangles (region);
|
||||
boxes = region->rects;
|
||||
n_boxes = region->numRects;
|
||||
|
||||
for (i = 0; i < n_boxes; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &box);
|
||||
cairo_rectangle (cr, box.x, box.y, box.width, box.height);
|
||||
}
|
||||
cairo_rectangle (cr,
|
||||
boxes[i].x1,
|
||||
boxes[i].y1,
|
||||
boxes[i].x2 - boxes[i].x1,
|
||||
boxes[i].y2 - boxes[i].y1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,25 +382,29 @@ FreeStorage (ScanLineListBlock *pSLLBlock)
|
||||
* stack by the calling procedure.
|
||||
*
|
||||
*/
|
||||
static cairo_region_t *
|
||||
static int
|
||||
PtsToRegion (int numFullPtBlocks,
|
||||
int iCurPtBlock,
|
||||
POINTBLOCK *FirstPtBlock)
|
||||
POINTBLOCK *FirstPtBlock,
|
||||
GdkRegion *reg)
|
||||
{
|
||||
GdkRectangle *rects, *allRects;
|
||||
GdkRegionBox *rects;
|
||||
GdkPoint *pts;
|
||||
POINTBLOCK *CurPtBlock;
|
||||
int i;
|
||||
GdkRegionBox *extents;
|
||||
int numRects;
|
||||
cairo_region_t *region;
|
||||
|
||||
extents = ®->extents;
|
||||
|
||||
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
|
||||
|
||||
allRects = g_new (GdkRectangle, numRects);
|
||||
GROWREGION(reg, numRects);
|
||||
|
||||
CurPtBlock = FirstPtBlock;
|
||||
rects = allRects - 1;
|
||||
rects = reg->rects - 1;
|
||||
numRects = 0;
|
||||
extents->x1 = G_MAXSHORT, extents->x2 = G_MINSHORT;
|
||||
|
||||
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
|
||||
/* the loop uses 2 points per iteration */
|
||||
@ -410,24 +414,37 @@ PtsToRegion (int numFullPtBlocks,
|
||||
for (pts = CurPtBlock->pts; i--; pts += 2) {
|
||||
if (pts->x == pts[1].x)
|
||||
continue;
|
||||
if (numRects && pts->x == rects->x && pts->y == rects->y + rects->height &&
|
||||
pts[1].x == rects->x + rects->width &&
|
||||
(numRects == 1 || rects[-1].y != rects->y) &&
|
||||
if (numRects && pts->x == rects->x1 && pts->y == rects->y2 &&
|
||||
pts[1].x == rects->x2 &&
|
||||
(numRects == 1 || rects[-1].y1 != rects->y1) &&
|
||||
(i && pts[2].y > pts[1].y)) {
|
||||
rects->height = pts[1].y + 1 - rects->y;
|
||||
rects->y2 = pts[1].y + 1;
|
||||
continue;
|
||||
}
|
||||
numRects++;
|
||||
rects++;
|
||||
rects->x = pts->x; rects->y = pts->y;
|
||||
rects->width = pts[1].x - rects->x; rects->height = pts[1].y + 1 - rects->y;
|
||||
rects->x1 = pts->x; rects->y1 = pts->y;
|
||||
rects->x2 = pts[1].x; rects->y2 = pts[1].y + 1;
|
||||
if (rects->x1 < extents->x1)
|
||||
extents->x1 = rects->x1;
|
||||
if (rects->x2 > extents->x2)
|
||||
extents->x2 = rects->x2;
|
||||
}
|
||||
CurPtBlock = CurPtBlock->next;
|
||||
}
|
||||
|
||||
region = cairo_region_create_rectangles ((cairo_rectangle_int_t *) allRects, numRects);
|
||||
g_free (allRects);
|
||||
return region;
|
||||
if (numRects) {
|
||||
extents->y1 = reg->rects->y1;
|
||||
extents->y2 = rects->y2;
|
||||
} else {
|
||||
extents->x1 = 0;
|
||||
extents->y1 = 0;
|
||||
extents->x2 = 0;
|
||||
extents->y2 = 0;
|
||||
}
|
||||
reg->numRects = numRects;
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -464,6 +481,8 @@ gdk_region_polygon (const GdkPoint *points,
|
||||
POINTBLOCK *tmpPtBlock;
|
||||
int numFullPtBlocks = 0;
|
||||
|
||||
region = gdk_region_new ();
|
||||
|
||||
/* special case a rectangle */
|
||||
if (((n_points == 4) ||
|
||||
((n_points == 5) && (points[4].x == points[0].x) && (points[4].y == points[0].y))) &&
|
||||
@ -475,13 +494,16 @@ gdk_region_polygon (const GdkPoint *points,
|
||||
(points[1].y == points[2].y) &&
|
||||
(points[2].x == points[3].x) &&
|
||||
(points[3].y == points[0].y)))) {
|
||||
GdkRectangle extents;
|
||||
|
||||
extents.x = MIN(points[0].x, points[2].x);
|
||||
extents.y = MIN(points[0].y, points[2].y);
|
||||
extents.width = MAX(points[0].x, points[2].x) - extents.x;
|
||||
extents.height = MAX(points[0].y, points[2].y) - extents.y;
|
||||
return gdk_region_rectangle (&extents);
|
||||
region->extents.x1 = MIN(points[0].x, points[2].x);
|
||||
region->extents.y1 = MIN(points[0].y, points[2].y);
|
||||
region->extents.x2 = MAX(points[0].x, points[2].x);
|
||||
region->extents.y2 = MAX(points[0].y, points[2].y);
|
||||
if ((region->extents.x1 != region->extents.x2) &&
|
||||
(region->extents.y1 != region->extents.y2)) {
|
||||
region->numRects = 1;
|
||||
*(region->rects) = region->extents;
|
||||
}
|
||||
return(region);
|
||||
}
|
||||
|
||||
pETEs = g_new (EdgeTableEntry, n_points);
|
||||
@ -588,7 +610,7 @@ gdk_region_polygon (const GdkPoint *points,
|
||||
}
|
||||
}
|
||||
FreeStorage(SLLBlock.next);
|
||||
region = PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock);
|
||||
(void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
|
||||
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
|
||||
tmpPtBlock = curPtBlock->next;
|
||||
g_free (curPtBlock);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,6 @@
|
||||
#include <glib.h>
|
||||
#include <pango/pango.h>
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
# ifdef GDK_COMPILATION
|
||||
@ -106,7 +105,7 @@ typedef struct _GdkCursor GdkCursor;
|
||||
typedef struct _GdkFont GdkFont;
|
||||
typedef struct _GdkGC GdkGC;
|
||||
typedef struct _GdkImage GdkImage;
|
||||
typedef cairo_region_t GdkRegion;
|
||||
typedef struct _GdkRegion GdkRegion;
|
||||
typedef struct _GdkVisual GdkVisual;
|
||||
|
||||
typedef struct _GdkDrawable GdkDrawable;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkx.h"
|
||||
#include "gdkregion-generic.h"
|
||||
|
||||
#include <cairo-xlib.h>
|
||||
|
||||
@ -366,16 +367,22 @@ gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable,
|
||||
|
||||
if (clip_region)
|
||||
{
|
||||
XRectangle *rects;
|
||||
int n_rects;
|
||||
GdkRegionBox *boxes = clip_region->rects;
|
||||
gint n_boxes = clip_region->numRects;
|
||||
XRectangle *rects = g_new (XRectangle, n_boxes);
|
||||
int i;
|
||||
|
||||
_gdk_region_get_xrectangles (clip_region,
|
||||
gc->clip_x_origin,
|
||||
gc->clip_y_origin,
|
||||
&rects,
|
||||
&n_rects);
|
||||
for (i=0; i < n_boxes; i++)
|
||||
{
|
||||
rects[i].x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT);
|
||||
rects[i].y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT);
|
||||
rects[i].width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rects[i].x;
|
||||
rects[i].height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rects[i].y;
|
||||
}
|
||||
|
||||
XRenderSetPictureClipRectangles (xdisplay, picture,
|
||||
0, 0, rects, n_rects);
|
||||
0, 0, rects, n_boxes);
|
||||
|
||||
g_free (rects);
|
||||
}
|
||||
else
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "gdkgc.h"
|
||||
#include "gdkprivate-x11.h"
|
||||
#include "gdkregion-generic.h"
|
||||
#include "gdkx.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "gdkdisplay-x11.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkintl.h"
|
||||
#include "gdkregion-generic.h"
|
||||
#include "gdkinputprivate.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
@ -647,24 +648,20 @@ _gdk_region_get_xrectangles (const GdkRegion *region,
|
||||
XRectangle **rects,
|
||||
gint *n_rects)
|
||||
{
|
||||
XRectangle *rectangles;
|
||||
cairo_rectangle_int_t box;
|
||||
gint i, n;
|
||||
XRectangle *rectangles = g_new (XRectangle, region->numRects);
|
||||
GdkRegionBox *boxes = region->rects;
|
||||
gint i;
|
||||
|
||||
n = cairo_region_num_rectangles (region);
|
||||
rectangles = g_new (XRectangle, n);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (i = 0; i < region->numRects; i++)
|
||||
{
|
||||
cairo_region_get_rectangle (region, i, &box);
|
||||
rectangles[i].x = CLAMP (box.x + x_offset, G_MINSHORT, G_MAXSHORT);
|
||||
rectangles[i].y = CLAMP (box.y + y_offset, G_MINSHORT, G_MAXSHORT);
|
||||
rectangles[i].width = CLAMP (box.width, G_MINSHORT, G_MAXSHORT);
|
||||
rectangles[i].height = CLAMP (box.height, G_MINSHORT, G_MAXSHORT);
|
||||
rectangles[i].x = CLAMP (boxes[i].x1 + x_offset, G_MINSHORT, G_MAXSHORT);
|
||||
rectangles[i].y = CLAMP (boxes[i].y1 + y_offset, G_MINSHORT, G_MAXSHORT);
|
||||
rectangles[i].width = CLAMP (boxes[i].x2 + x_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].x;
|
||||
rectangles[i].height = CLAMP (boxes[i].y2 + y_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].y;
|
||||
}
|
||||
|
||||
*n_rects = n;
|
||||
*rects = rectangles;
|
||||
*n_rects = region->numRects;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user