mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +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 "gdkcairo.h"
|
||||||
#include "gdkdrawable.h"
|
#include "gdkdrawable.h"
|
||||||
#include "gdkinternals.h"
|
#include "gdkinternals.h"
|
||||||
|
#include "gdkregion-generic.h"
|
||||||
#include "gdkalias.h"
|
#include "gdkalias.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,19 +143,21 @@ void
|
|||||||
gdk_cairo_region (cairo_t *cr,
|
gdk_cairo_region (cairo_t *cr,
|
||||||
const GdkRegion *region)
|
const GdkRegion *region)
|
||||||
{
|
{
|
||||||
cairo_rectangle_int_t box;
|
GdkRegionBox *boxes;
|
||||||
gint n_boxes, i;
|
gint n_boxes, i;
|
||||||
|
|
||||||
g_return_if_fail (cr != NULL);
|
g_return_if_fail (cr != NULL);
|
||||||
g_return_if_fail (region != 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++)
|
for (i = 0; i < n_boxes; i++)
|
||||||
{
|
cairo_rectangle (cr,
|
||||||
cairo_region_get_rectangle (region, i, &box);
|
boxes[i].x1,
|
||||||
cairo_rectangle (cr, box.x, box.y, box.width, box.height);
|
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.
|
* stack by the calling procedure.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static cairo_region_t *
|
static int
|
||||||
PtsToRegion (int numFullPtBlocks,
|
PtsToRegion (int numFullPtBlocks,
|
||||||
int iCurPtBlock,
|
int iCurPtBlock,
|
||||||
POINTBLOCK *FirstPtBlock)
|
POINTBLOCK *FirstPtBlock,
|
||||||
|
GdkRegion *reg)
|
||||||
{
|
{
|
||||||
GdkRectangle *rects, *allRects;
|
GdkRegionBox *rects;
|
||||||
GdkPoint *pts;
|
GdkPoint *pts;
|
||||||
POINTBLOCK *CurPtBlock;
|
POINTBLOCK *CurPtBlock;
|
||||||
int i;
|
int i;
|
||||||
|
GdkRegionBox *extents;
|
||||||
int numRects;
|
int numRects;
|
||||||
cairo_region_t *region;
|
|
||||||
|
extents = ®->extents;
|
||||||
|
|
||||||
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
|
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
|
||||||
|
|
||||||
allRects = g_new (GdkRectangle, numRects);
|
GROWREGION(reg, numRects);
|
||||||
|
|
||||||
CurPtBlock = FirstPtBlock;
|
CurPtBlock = FirstPtBlock;
|
||||||
rects = allRects - 1;
|
rects = reg->rects - 1;
|
||||||
numRects = 0;
|
numRects = 0;
|
||||||
|
extents->x1 = G_MAXSHORT, extents->x2 = G_MINSHORT;
|
||||||
|
|
||||||
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
|
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
|
||||||
/* the loop uses 2 points per iteration */
|
/* the loop uses 2 points per iteration */
|
||||||
@ -410,24 +414,37 @@ PtsToRegion (int numFullPtBlocks,
|
|||||||
for (pts = CurPtBlock->pts; i--; pts += 2) {
|
for (pts = CurPtBlock->pts; i--; pts += 2) {
|
||||||
if (pts->x == pts[1].x)
|
if (pts->x == pts[1].x)
|
||||||
continue;
|
continue;
|
||||||
if (numRects && pts->x == rects->x && pts->y == rects->y + rects->height &&
|
if (numRects && pts->x == rects->x1 && pts->y == rects->y2 &&
|
||||||
pts[1].x == rects->x + rects->width &&
|
pts[1].x == rects->x2 &&
|
||||||
(numRects == 1 || rects[-1].y != rects->y) &&
|
(numRects == 1 || rects[-1].y1 != rects->y1) &&
|
||||||
(i && pts[2].y > pts[1].y)) {
|
(i && pts[2].y > pts[1].y)) {
|
||||||
rects->height = pts[1].y + 1 - rects->y;
|
rects->y2 = pts[1].y + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
numRects++;
|
numRects++;
|
||||||
rects++;
|
rects++;
|
||||||
rects->x = pts->x; rects->y = pts->y;
|
rects->x1 = pts->x; rects->y1 = pts->y;
|
||||||
rects->width = pts[1].x - rects->x; rects->height = pts[1].y + 1 - rects->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;
|
CurPtBlock = CurPtBlock->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
region = cairo_region_create_rectangles ((cairo_rectangle_int_t *) allRects, numRects);
|
if (numRects) {
|
||||||
g_free (allRects);
|
extents->y1 = reg->rects->y1;
|
||||||
return region;
|
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;
|
POINTBLOCK *tmpPtBlock;
|
||||||
int numFullPtBlocks = 0;
|
int numFullPtBlocks = 0;
|
||||||
|
|
||||||
|
region = gdk_region_new ();
|
||||||
|
|
||||||
/* special case a rectangle */
|
/* special case a rectangle */
|
||||||
if (((n_points == 4) ||
|
if (((n_points == 4) ||
|
||||||
((n_points == 5) && (points[4].x == points[0].x) && (points[4].y == points[0].y))) &&
|
((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[1].y == points[2].y) &&
|
||||||
(points[2].x == points[3].x) &&
|
(points[2].x == points[3].x) &&
|
||||||
(points[3].y == points[0].y)))) {
|
(points[3].y == points[0].y)))) {
|
||||||
GdkRectangle extents;
|
region->extents.x1 = MIN(points[0].x, points[2].x);
|
||||||
|
region->extents.y1 = MIN(points[0].y, points[2].y);
|
||||||
extents.x = MIN(points[0].x, points[2].x);
|
region->extents.x2 = MAX(points[0].x, points[2].x);
|
||||||
extents.y = MIN(points[0].y, points[2].y);
|
region->extents.y2 = MAX(points[0].y, points[2].y);
|
||||||
extents.width = MAX(points[0].x, points[2].x) - extents.x;
|
if ((region->extents.x1 != region->extents.x2) &&
|
||||||
extents.height = MAX(points[0].y, points[2].y) - extents.y;
|
(region->extents.y1 != region->extents.y2)) {
|
||||||
return gdk_region_rectangle (&extents);
|
region->numRects = 1;
|
||||||
|
*(region->rects) = region->extents;
|
||||||
|
}
|
||||||
|
return(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
pETEs = g_new (EdgeTableEntry, n_points);
|
pETEs = g_new (EdgeTableEntry, n_points);
|
||||||
@ -588,7 +610,7 @@ gdk_region_polygon (const GdkPoint *points,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FreeStorage(SLLBlock.next);
|
FreeStorage(SLLBlock.next);
|
||||||
region = PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock);
|
(void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
|
||||||
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
|
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
|
||||||
tmpPtBlock = curPtBlock->next;
|
tmpPtBlock = curPtBlock->next;
|
||||||
g_free (curPtBlock);
|
g_free (curPtBlock);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <cairo.h>
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
# ifdef GDK_COMPILATION
|
# ifdef GDK_COMPILATION
|
||||||
@ -106,7 +105,7 @@ typedef struct _GdkCursor GdkCursor;
|
|||||||
typedef struct _GdkFont GdkFont;
|
typedef struct _GdkFont GdkFont;
|
||||||
typedef struct _GdkGC GdkGC;
|
typedef struct _GdkGC GdkGC;
|
||||||
typedef struct _GdkImage GdkImage;
|
typedef struct _GdkImage GdkImage;
|
||||||
typedef cairo_region_t GdkRegion;
|
typedef struct _GdkRegion GdkRegion;
|
||||||
typedef struct _GdkVisual GdkVisual;
|
typedef struct _GdkVisual GdkVisual;
|
||||||
|
|
||||||
typedef struct _GdkDrawable GdkDrawable;
|
typedef struct _GdkDrawable GdkDrawable;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gdkx.h"
|
#include "gdkx.h"
|
||||||
|
#include "gdkregion-generic.h"
|
||||||
|
|
||||||
#include <cairo-xlib.h>
|
#include <cairo-xlib.h>
|
||||||
|
|
||||||
@ -366,16 +367,22 @@ gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable,
|
|||||||
|
|
||||||
if (clip_region)
|
if (clip_region)
|
||||||
{
|
{
|
||||||
XRectangle *rects;
|
GdkRegionBox *boxes = clip_region->rects;
|
||||||
int n_rects;
|
gint n_boxes = clip_region->numRects;
|
||||||
|
XRectangle *rects = g_new (XRectangle, n_boxes);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
_gdk_region_get_xrectangles (clip_region,
|
|
||||||
gc->clip_x_origin,
|
|
||||||
gc->clip_y_origin,
|
|
||||||
&rects,
|
|
||||||
&n_rects);
|
|
||||||
XRenderSetPictureClipRectangles (xdisplay, picture,
|
XRenderSetPictureClipRectangles (xdisplay, picture,
|
||||||
0, 0, rects, n_rects);
|
0, 0, rects, n_boxes);
|
||||||
|
|
||||||
g_free (rects);
|
g_free (rects);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "gdkgc.h"
|
#include "gdkgc.h"
|
||||||
#include "gdkprivate-x11.h"
|
#include "gdkprivate-x11.h"
|
||||||
|
#include "gdkregion-generic.h"
|
||||||
#include "gdkx.h"
|
#include "gdkx.h"
|
||||||
#include "gdkalias.h"
|
#include "gdkalias.h"
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "gdkdisplay-x11.h"
|
#include "gdkdisplay-x11.h"
|
||||||
#include "gdkinternals.h"
|
#include "gdkinternals.h"
|
||||||
#include "gdkintl.h"
|
#include "gdkintl.h"
|
||||||
|
#include "gdkregion-generic.h"
|
||||||
#include "gdkinputprivate.h"
|
#include "gdkinputprivate.h"
|
||||||
#include "gdkalias.h"
|
#include "gdkalias.h"
|
||||||
|
|
||||||
@ -647,24 +648,20 @@ _gdk_region_get_xrectangles (const GdkRegion *region,
|
|||||||
XRectangle **rects,
|
XRectangle **rects,
|
||||||
gint *n_rects)
|
gint *n_rects)
|
||||||
{
|
{
|
||||||
XRectangle *rectangles;
|
XRectangle *rectangles = g_new (XRectangle, region->numRects);
|
||||||
cairo_rectangle_int_t box;
|
GdkRegionBox *boxes = region->rects;
|
||||||
gint i, n;
|
gint i;
|
||||||
|
|
||||||
n = cairo_region_num_rectangles (region);
|
for (i = 0; i < region->numRects; i++)
|
||||||
rectangles = g_new (XRectangle, n);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
{
|
||||||
cairo_region_get_rectangle (region, i, &box);
|
rectangles[i].x = CLAMP (boxes[i].x1 + x_offset, G_MINSHORT, G_MAXSHORT);
|
||||||
rectangles[i].x = CLAMP (box.x + x_offset, G_MINSHORT, G_MAXSHORT);
|
rectangles[i].y = CLAMP (boxes[i].y1 + y_offset, G_MINSHORT, G_MAXSHORT);
|
||||||
rectangles[i].y = CLAMP (box.y + y_offset, G_MINSHORT, G_MAXSHORT);
|
rectangles[i].width = CLAMP (boxes[i].x2 + x_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].x;
|
||||||
rectangles[i].width = CLAMP (box.width, G_MINSHORT, G_MAXSHORT);
|
rectangles[i].height = CLAMP (boxes[i].y2 + y_offset, G_MINSHORT, G_MAXSHORT) - rectangles[i].y;
|
||||||
rectangles[i].height = CLAMP (box.height, G_MINSHORT, G_MAXSHORT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*n_rects = n;
|
|
||||||
*rects = rectangles;
|
*rects = rectangles;
|
||||||
|
*n_rects = region->numRects;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user