[gtk/wip/chergert/macos-iosurface] use bigger tiles for transparent edges (shadows)
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/macos-iosurface] use bigger tiles for transparent edges (shadows)
- Date: Fri, 11 Feb 2022 11:47:17 +0000 (UTC)
commit d40cabb21ed750199561adcaeb7ddb1adeec54cc
Author: Christian Hergert <christian hergert me>
Date: Fri Feb 11 03:46:38 2022 -0800
use bigger tiles for transparent edges (shadows)
gdk/macos/GdkMacosLayer.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
---
diff --git a/gdk/macos/GdkMacosLayer.c b/gdk/macos/GdkMacosLayer.c
index d1aa1431f0..b4b7b905a3 100644
--- a/gdk/macos/GdkMacosLayer.c
+++ b/gdk/macos/GdkMacosLayer.c
@@ -26,6 +26,7 @@
@implementation GdkMacosLayer
#define TILE_MAX_SIZE 128
+#define TILE_EDGE_MAX_SIZE 512
static CGAffineTransform flipTransform;
static gboolean hasFlipTransform;
@@ -71,7 +72,8 @@ tiler_init (Tiler *tiler,
static gboolean
tiler_next (Tiler *tiler,
- cairo_rectangle_int_t *tile)
+ cairo_rectangle_int_t *tile,
+ int max_size)
{
if (tiler->finished)
return FALSE;
@@ -92,19 +94,19 @@ tiler_next (Tiler *tiler,
/* If the next rectangle is too tall, slice the bottom off to
* leave just the height we want into tiler->stash.
*/
- if (tiler->rect.height > TILE_MAX_SIZE)
+ if (tiler->rect.height > max_size)
{
tiler->stash = tiler->rect;
- tiler->stash.y += TILE_MAX_SIZE;
- tiler->stash.height -= TILE_MAX_SIZE;
- tiler->rect.height = TILE_MAX_SIZE;
+ tiler->stash.y += max_size;
+ tiler->stash.height -= max_size;
+ tiler->rect.height = max_size;
}
/* Now we can take the next horizontal slice */
tile->x = tiler->rect.x;
tile->y = tiler->rect.y;
tile->height = tiler->rect.height;
- tile->width = MIN (TILE_MAX_SIZE, tiler->rect.width);
+ tile->width = MIN (max_size, tiler->rect.width);
tiler->rect.x += tile->width;
tiler->rect.width -= tile->width;
@@ -236,6 +238,7 @@ fromCGRect (const CGRect rect)
GArray *ar;
cairo_region_t *transparent;
cairo_rectangle_int_t rect;
+ int max_size;
if (!self->_inSwapBuffer)
return;
@@ -252,9 +255,20 @@ fromCGRect (const CGRect rect)
self->_opaque = cairo_region_is_empty (transparent);
+ /* If we have transparent borders around the opaque region, then
+ * we are okay with a bit larger tiles since they don't change
+ * all that much and are generally small in width.
+ */
+ if (!self->_opaque &&
+ self->_opaqueRegion &&
+ !cairo_region_is_empty (self->_opaqueRegion))
+ max_size = TILE_EDGE_MAX_SIZE;
+ else
+ max_size = TILE_MAX_SIZE;
+
/* Track transparent children */
tiler_init (&tiler, transparent);
- while (tiler_next (&tiler, &rect))
+ while (tiler_next (&tiler, &rect, max_size))
{
TileInfo *info;
@@ -269,7 +283,7 @@ fromCGRect (const CGRect rect)
/* Track opaque children */
tiler_init (&tiler, self->_opaqueRegion);
- while (tiler_next (&tiler, &rect))
+ while (tiler_next (&tiler, &rect, TILE_MAX_SIZE))
{
TileInfo *info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]