[cairo-commit] 2 commits - src/win32
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Feb 9 20:47:45 UTC 2023
src/win32/cairo-dwrite-font.cpp | 38 +-------------------------------------
src/win32/cairo-win32-font.c | 8 ++++----
src/win32/cairo-win32-private.h | 4 ++++
3 files changed, 9 insertions(+), 41 deletions(-)
New commits:
commit 876ee0bb49e2bf94bbc4d06514459ae6a31935b2
Merge: cae2376dd 1d8032c40
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Thu Feb 9 20:47:44 2023 +0000
Merge branch 'dwrite-argb-glyph-mask' into 'master'
DWrite: Don't convert subpixel antialiasing to grayscale
See merge request cairo/cairo!453
commit 1d8032c4069fb0b1bdda0f273db13491cbae2524
Author: Fujii Hironori <Hironori.Fujii at sony.com>
Date: Thu Feb 9 13:19:36 2023 +0900
DWrite: Don't convert subpixel antialiasing to grayscale
Reuse the win32 font code to create a glyph mask for a dwrite font.
Renamed a function _compute_mask in cairo-win32-font.c to
_cairo_compute_glyph_mask.
diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp
index 994889e21..edd606abe 100644
--- a/src/win32/cairo-dwrite-font.cpp
+++ b/src/win32/cairo-dwrite-font.cpp
@@ -1126,42 +1126,6 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s
return CAIRO_INT_STATUS_SUCCESS;
}
-/* Helper function adapted from _compute_mask in cairo-win32-font.c */
-
-/* Compute an alpha-mask from a monochrome RGB24 image
- */
-static cairo_surface_t *
-_compute_a8_mask (cairo_surface_t *surface)
-{
- cairo_image_surface_t *glyph;
- cairo_image_surface_t *mask;
- int i, j;
-
- glyph = (cairo_image_surface_t *)cairo_surface_map_to_image (surface, NULL);
- if (unlikely (glyph->base.status))
- return &glyph->base;
-
- /* No quality param, just use the non-ClearType path */
-
- /* Compute an alpha-mask by using the green channel of a (presumed monochrome)
- * RGB24 image.
- */
- mask = (cairo_image_surface_t *)
- cairo_image_surface_create (CAIRO_FORMAT_A8, glyph->width, glyph->height);
- if (likely (mask->base.status == CAIRO_STATUS_SUCCESS)) {
- for (i = 0; i < glyph->height; i++) {
- uint32_t *p = (uint32_t *) (glyph->data + i * glyph->stride);
- uint8_t *q = (uint8_t *) (mask->data + i * mask->stride);
-
- for (j = 0; j < glyph->width; j++)
- *q++ = 255 - ((*p++ & 0x0000ff00) >> 8);
- }
- }
-
- cairo_surface_unmap_image (surface, &glyph->base);
- return &mask->base;
-}
-
static cairo_int_status_t
_cairo_dwrite_scaled_font_init_glyph_surface(cairo_dwrite_scaled_font_t *scaled_font,
cairo_scaled_glyph_t *scaled_glyph)
@@ -1240,7 +1204,7 @@ _cairo_dwrite_scaled_font_init_glyph_surface(cairo_dwrite_scaled_font_t *scaled_
GdiFlush();
- image = _compute_a8_mask (&surface->base);
+ image = _cairo_compute_glyph_mask (&surface->base, CLEARTYPE_QUALITY);
status = (cairo_int_status_t)image->status;
if (status)
goto FAIL;
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index 6bc8bef94..fd9461363 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -1335,9 +1335,9 @@ _cairo_win32_scaled_font_load_type1_data (void *abstract_font,
length);
}
-static cairo_surface_t *
-_compute_mask (cairo_surface_t *surface,
- int quality)
+cairo_surface_t *
+_cairo_compute_glyph_mask (cairo_surface_t *surface,
+ int quality)
{
cairo_image_surface_t *glyph;
cairo_image_surface_t *mask;
@@ -1421,7 +1421,7 @@ _cairo_win32_scaled_font_init_glyph_surface (cairo_win32_scaled_font_t *scaled_f
if (status)
goto FAIL;
- image = _compute_mask (surface, scaled_font->quality);
+ image = _cairo_compute_glyph_mask (surface, scaled_font->quality);
status = image->status;
if (status)
goto FAIL;
diff --git a/src/win32/cairo-win32-private.h b/src/win32/cairo-win32-private.h
index 486b12811..6af09c0e1 100644
--- a/src/win32/cairo-win32-private.h
+++ b/src/win32/cairo-win32-private.h
@@ -214,6 +214,10 @@ cairo_bool_t
_cairo_win32_surface_get_extents (void *abstract_surface,
cairo_rectangle_int_t *rectangle);
+cairo_surface_t *
+_cairo_compute_glyph_mask (cairo_surface_t *surface,
+ int quality);
+
uint32_t
_cairo_win32_flags_for_dc (HDC dc, cairo_format_t format);
More information about the cairo-commit
mailing list