tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

23-win32-api-additions.patch (3027B)


      1 # HG changeset patch
      2 # User Jonathan Kew <jkew@mozilla.com>
      3 # Date 1714049062 -3600
      4 #      Thu Apr 25 13:44:22 2024 +0100
      5 # Node ID cae7821ff41ed99081818f5434a347d224833f70
      6 # Parent  8f09f0d54c643029b7601dc58f3a8ff125eca699
      7 Bug 1892913 - patch 21 - Add cairo_win32_surface APIs wanted for gecko.
      8 
      9 diff --git a/gfx/cairo/cairo/src/cairo-win32.h b/gfx/cairo/cairo/src/cairo-win32.h
     10 --- a/gfx/cairo/cairo/src/cairo-win32.h
     11 +++ b/gfx/cairo/cairo/src/cairo-win32.h
     12 @@ -72,6 +72,14 @@ cairo_win32_surface_get_dc (cairo_surfac
     13 cairo_public cairo_surface_t *
     14 cairo_win32_surface_get_image (cairo_surface_t *surface);
     15 
     16 +cairo_public HDC
     17 +cairo_win32_get_dc_with_clip(cairo_t* cr);
     18 +
     19 +cairo_public cairo_status_t
     20 +cairo_win32_surface_get_size(const cairo_surface_t* surface,
     21 +                             int* width,
     22 +                             int* height);
     23 +
     24 #if CAIRO_HAS_WIN32_FONT
     25 
     26 /*
     27 diff --git a/gfx/cairo/cairo/src/win32/cairo-win32-surface.c b/gfx/cairo/cairo/src/win32/cairo-win32-surface.c
     28 --- a/gfx/cairo/cairo/src/win32/cairo-win32-surface.c
     29 +++ b/gfx/cairo/cairo/src/win32/cairo-win32-surface.c
     30 @@ -163,6 +163,52 @@ cairo_win32_surface_get_dc (cairo_surfac
     31 }
     32 
     33 /**
     34 + * cairo_win32_get_dc_with_clip:
     35 + * (Mozilla addition)
     36 + */
     37 +HDC
     38 +cairo_win32_get_dc_with_clip(cairo_t* cr)
     39 +{
     40 +  cairo_surface_t* surface = cairo_get_target(cr);
     41 +  if (cr->backend->type == CAIRO_TYPE_DEFAULT) {
     42 +    cairo_default_context_t* c = (cairo_default_context_t*)cr;
     43 +    cairo_clip_t* clip = _cairo_clip_copy(_cairo_gstate_get_clip(c->gstate));
     44 +    if (_cairo_surface_is_win32(surface)) {
     45 +      cairo_win32_display_surface_t* winsurf = (cairo_win32_display_surface_t*)surface;
     46 +
     47 +      _cairo_win32_display_surface_set_clip(winsurf, clip);
     48 +
     49 +      _cairo_clip_destroy(clip);
     50 +      return winsurf->win32.dc;
     51 +    }
     52 +
     53 +    if (_cairo_surface_is_paginated(surface)) {
     54 +      cairo_surface_t* target;
     55 +
     56 +      target = _cairo_paginated_surface_get_target(surface);
     57 +
     58 +#ifndef CAIRO_OMIT_WIN32_PRINTING
     59 +      if (_cairo_surface_is_win32_printing(target)) {
     60 +        cairo_status_t status;
     61 +        cairo_win32_printing_surface_t* psurf = (cairo_win32_printing_surface_t*)target;
     62 +
     63 +        status = _cairo_surface_clipper_set_clip(&psurf->clipper, clip);
     64 +
     65 +        _cairo_clip_destroy(clip);
     66 +
     67 +        if (status)
     68 +          return NULL;
     69 +
     70 +        return psurf->win32.dc;
     71 +      }
     72 +#endif
     73 +    }
     74 +    _cairo_clip_destroy(clip);
     75 +  }
     76 +  return NULL;
     77 +}
     78 +
     79 +/**
     80  * _cairo_surface_is_win32:
     81  * @surface: a #cairo_surface_t
     82  *
     83 @@ -337,3 +383,17 @@ cairo_int_status_t
     84 #endif
     85 }
     86 #undef STACK_GLYPH_SIZE
     87 +
     88 +cairo_status_t
     89 +cairo_win32_surface_get_size(const cairo_surface_t* surface, int* width, int* height)
     90 +{
     91 +  if (!_cairo_surface_is_win32(surface))
     92 +    return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
     93 +
     94 +  const cairo_win32_surface_t* winsurface = (const cairo_win32_surface_t*)surface;
     95 +
     96 +  *width = winsurface->extents.width;
     97 +  *height = winsurface->extents.height;
     98 +
     99 +  return CAIRO_STATUS_SUCCESS;
    100 +}
    101 \ No newline at end of file