mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-07 20:18:02 +02:00
Normalize indentation after previous commit.
This commit is contained in:
parent
0152bd3a56
commit
57edf3f28f
1 changed files with 158 additions and 160 deletions
|
|
@ -715,187 +715,185 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
|
||||||
width = bitmap->width;
|
width = bitmap->width;
|
||||||
height = bitmap->rows;
|
height = bitmap->rows;
|
||||||
|
|
||||||
{
|
switch (bitmap->pixel_mode) {
|
||||||
switch (bitmap->pixel_mode) {
|
case FT_PIXEL_MODE_MONO:
|
||||||
case FT_PIXEL_MODE_MONO:
|
stride = (((width + 31) & ~31) >> 3);
|
||||||
stride = (((width + 31) & ~31) >> 3);
|
if (own_buffer) {
|
||||||
|
data = bitmap->buffer;
|
||||||
|
assert (stride == bitmap->pitch);
|
||||||
|
} else {
|
||||||
|
data = malloc (stride * height);
|
||||||
|
if (!data)
|
||||||
|
return CAIRO_STATUS_NO_MEMORY;
|
||||||
|
|
||||||
|
if (stride == bitmap->pitch) {
|
||||||
|
memcpy (data, bitmap->buffer, stride * height);
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
unsigned char *source, *dest;
|
||||||
|
|
||||||
|
source = bitmap->buffer;
|
||||||
|
dest = data;
|
||||||
|
for (i = height; i; i--) {
|
||||||
|
memcpy (dest, source, bitmap->pitch);
|
||||||
|
memset (dest + bitmap->pitch, '\0', stride - bitmap->pitch);
|
||||||
|
|
||||||
|
source += bitmap->pitch;
|
||||||
|
dest += stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_native_byte_order_lsb())
|
||||||
|
{
|
||||||
|
unsigned char *d = data, c;
|
||||||
|
int count = stride * height;
|
||||||
|
|
||||||
|
while (count--) {
|
||||||
|
c = *d;
|
||||||
|
c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
|
||||||
|
c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
|
||||||
|
c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
|
||||||
|
*d++ = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
format = CAIRO_FORMAT_A1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FT_PIXEL_MODE_LCD:
|
||||||
|
case FT_PIXEL_MODE_LCD_V:
|
||||||
|
case FT_PIXEL_MODE_GRAY:
|
||||||
|
switch (font_options->antialias) {
|
||||||
|
case CAIRO_ANTIALIAS_DEFAULT:
|
||||||
|
case CAIRO_ANTIALIAS_GRAY:
|
||||||
|
case CAIRO_ANTIALIAS_NONE:
|
||||||
|
default:
|
||||||
|
stride = bitmap->pitch;
|
||||||
if (own_buffer) {
|
if (own_buffer) {
|
||||||
data = bitmap->buffer;
|
data = bitmap->buffer;
|
||||||
assert (stride == bitmap->pitch);
|
|
||||||
} else {
|
} else {
|
||||||
data = malloc (stride * height);
|
data = malloc (stride * height);
|
||||||
if (!data)
|
if (!data)
|
||||||
return CAIRO_STATUS_NO_MEMORY;
|
return CAIRO_STATUS_NO_MEMORY;
|
||||||
|
memcpy (data, bitmap->buffer, stride * height);
|
||||||
if (stride == bitmap->pitch) {
|
|
||||||
memcpy (data, bitmap->buffer, stride * height);
|
|
||||||
} else {
|
|
||||||
int i;
|
|
||||||
unsigned char *source, *dest;
|
|
||||||
|
|
||||||
source = bitmap->buffer;
|
|
||||||
dest = data;
|
|
||||||
for (i = height; i; i--) {
|
|
||||||
memcpy (dest, source, bitmap->pitch);
|
|
||||||
memset (dest + bitmap->pitch, '\0', stride - bitmap->pitch);
|
|
||||||
|
|
||||||
source += bitmap->pitch;
|
|
||||||
dest += stride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
format = CAIRO_FORMAT_A8;
|
||||||
if (_native_byte_order_lsb())
|
|
||||||
{
|
|
||||||
unsigned char *d = data, c;
|
|
||||||
int count = stride * height;
|
|
||||||
|
|
||||||
while (count--) {
|
|
||||||
c = *d;
|
|
||||||
c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
|
|
||||||
c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
|
|
||||||
c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
|
|
||||||
*d++ = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
format = CAIRO_FORMAT_A1;
|
|
||||||
break;
|
break;
|
||||||
|
case CAIRO_ANTIALIAS_SUBPIXEL: {
|
||||||
|
int x, y;
|
||||||
|
unsigned char *in_line, *out_line, *in;
|
||||||
|
unsigned int *out;
|
||||||
|
unsigned int red, green, blue;
|
||||||
|
int rf, gf, bf;
|
||||||
|
int s;
|
||||||
|
int o, os;
|
||||||
|
unsigned char *data_rgba;
|
||||||
|
unsigned int width_rgba, stride_rgba;
|
||||||
|
int vmul = 1;
|
||||||
|
int hmul = 1;
|
||||||
|
|
||||||
case FT_PIXEL_MODE_LCD:
|
switch (font_options->subpixel_order) {
|
||||||
case FT_PIXEL_MODE_LCD_V:
|
case CAIRO_SUBPIXEL_ORDER_DEFAULT:
|
||||||
case FT_PIXEL_MODE_GRAY:
|
case CAIRO_SUBPIXEL_ORDER_RGB:
|
||||||
switch (font_options->antialias) {
|
case CAIRO_SUBPIXEL_ORDER_BGR:
|
||||||
case CAIRO_ANTIALIAS_DEFAULT:
|
|
||||||
case CAIRO_ANTIALIAS_GRAY:
|
|
||||||
case CAIRO_ANTIALIAS_NONE:
|
|
||||||
default:
|
default:
|
||||||
stride = bitmap->pitch;
|
width /= 3;
|
||||||
if (own_buffer) {
|
hmul = 3;
|
||||||
data = bitmap->buffer;
|
|
||||||
} else {
|
|
||||||
data = malloc (stride * height);
|
|
||||||
if (!data)
|
|
||||||
return CAIRO_STATUS_NO_MEMORY;
|
|
||||||
memcpy (data, bitmap->buffer, stride * height);
|
|
||||||
}
|
|
||||||
format = CAIRO_FORMAT_A8;
|
|
||||||
break;
|
break;
|
||||||
case CAIRO_ANTIALIAS_SUBPIXEL: {
|
case CAIRO_SUBPIXEL_ORDER_VRGB:
|
||||||
int x, y;
|
case CAIRO_SUBPIXEL_ORDER_VBGR:
|
||||||
unsigned char *in_line, *out_line, *in;
|
vmul = 3;
|
||||||
unsigned int *out;
|
height /= 3;
|
||||||
unsigned int red, green, blue;
|
break;
|
||||||
int rf, gf, bf;
|
}
|
||||||
int s;
|
/*
|
||||||
int o, os;
|
* Filter the glyph to soften the color fringes
|
||||||
unsigned char *data_rgba;
|
*/
|
||||||
unsigned int width_rgba, stride_rgba;
|
width_rgba = width;
|
||||||
int vmul = 1;
|
stride = bitmap->pitch;
|
||||||
int hmul = 1;
|
stride_rgba = (width_rgba * 4 + 3) & ~3;
|
||||||
|
data_rgba = calloc (1, stride_rgba * height);
|
||||||
|
|
||||||
switch (font_options->subpixel_order) {
|
os = 1;
|
||||||
case CAIRO_SUBPIXEL_ORDER_DEFAULT:
|
switch (font_options->subpixel_order) {
|
||||||
case CAIRO_SUBPIXEL_ORDER_RGB:
|
case CAIRO_SUBPIXEL_ORDER_VRGB:
|
||||||
case CAIRO_SUBPIXEL_ORDER_BGR:
|
os = stride;
|
||||||
default:
|
case CAIRO_SUBPIXEL_ORDER_DEFAULT:
|
||||||
width /= 3;
|
case CAIRO_SUBPIXEL_ORDER_RGB:
|
||||||
hmul = 3;
|
default:
|
||||||
break;
|
rf = 0;
|
||||||
case CAIRO_SUBPIXEL_ORDER_VRGB:
|
gf = 1;
|
||||||
case CAIRO_SUBPIXEL_ORDER_VBGR:
|
bf = 2;
|
||||||
vmul = 3;
|
break;
|
||||||
height /= 3;
|
case CAIRO_SUBPIXEL_ORDER_VBGR:
|
||||||
break;
|
os = stride;
|
||||||
}
|
case CAIRO_SUBPIXEL_ORDER_BGR:
|
||||||
/*
|
bf = 0;
|
||||||
* Filter the glyph to soften the color fringes
|
gf = 1;
|
||||||
*/
|
rf = 2;
|
||||||
width_rgba = width;
|
break;
|
||||||
stride = bitmap->pitch;
|
}
|
||||||
stride_rgba = (width_rgba * 4 + 3) & ~3;
|
in_line = bitmap->buffer;
|
||||||
data_rgba = calloc (1, stride_rgba * height);
|
out_line = data_rgba;
|
||||||
|
for (y = 0; y < height; y++)
|
||||||
os = 1;
|
{
|
||||||
switch (font_options->subpixel_order) {
|
in = in_line;
|
||||||
case CAIRO_SUBPIXEL_ORDER_VRGB:
|
out = (unsigned int *) out_line;
|
||||||
os = stride;
|
in_line += stride * vmul;
|
||||||
case CAIRO_SUBPIXEL_ORDER_DEFAULT:
|
out_line += stride_rgba;
|
||||||
case CAIRO_SUBPIXEL_ORDER_RGB:
|
for (x = 0; x < width * hmul; x += hmul)
|
||||||
default:
|
|
||||||
rf = 0;
|
|
||||||
gf = 1;
|
|
||||||
bf = 2;
|
|
||||||
break;
|
|
||||||
case CAIRO_SUBPIXEL_ORDER_VBGR:
|
|
||||||
os = stride;
|
|
||||||
case CAIRO_SUBPIXEL_ORDER_BGR:
|
|
||||||
bf = 0;
|
|
||||||
gf = 1;
|
|
||||||
rf = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
in_line = bitmap->buffer;
|
|
||||||
out_line = data_rgba;
|
|
||||||
for (y = 0; y < height; y++)
|
|
||||||
{
|
{
|
||||||
in = in_line;
|
red = green = blue = 0;
|
||||||
out = (unsigned int *) out_line;
|
o = 0;
|
||||||
in_line += stride * vmul;
|
for (s = 0; s < 3; s++)
|
||||||
out_line += stride_rgba;
|
|
||||||
for (x = 0; x < width * hmul; x += hmul)
|
|
||||||
{
|
{
|
||||||
red = green = blue = 0;
|
red += filters[rf][s]*in[x+o];
|
||||||
o = 0;
|
green += filters[gf][s]*in[x+o];
|
||||||
for (s = 0; s < 3; s++)
|
blue += filters[bf][s]*in[x+o];
|
||||||
{
|
o += os;
|
||||||
red += filters[rf][s]*in[x+o];
|
|
||||||
green += filters[gf][s]*in[x+o];
|
|
||||||
blue += filters[bf][s]*in[x+o];
|
|
||||||
o += os;
|
|
||||||
}
|
|
||||||
red = red / 65536;
|
|
||||||
green = green / 65536;
|
|
||||||
blue = blue / 65536;
|
|
||||||
*out++ = (green << 24) | (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
}
|
||||||
|
red = red / 65536;
|
||||||
|
green = green / 65536;
|
||||||
|
blue = blue / 65536;
|
||||||
|
*out++ = (green << 24) | (red << 16) | (green << 8) | blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Images here are stored in native format. The
|
|
||||||
* backend must convert to its own format as needed
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (own_buffer)
|
|
||||||
free (bitmap->buffer);
|
|
||||||
data = data_rgba;
|
|
||||||
stride = stride_rgba;
|
|
||||||
format = CAIRO_FORMAT_ARGB32;
|
|
||||||
subpixel = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Images here are stored in native format. The
|
||||||
|
* backend must convert to its own format as needed
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (own_buffer)
|
||||||
|
free (bitmap->buffer);
|
||||||
|
data = data_rgba;
|
||||||
|
stride = stride_rgba;
|
||||||
|
format = CAIRO_FORMAT_ARGB32;
|
||||||
|
subpixel = TRUE;
|
||||||
break;
|
break;
|
||||||
case FT_PIXEL_MODE_GRAY2:
|
|
||||||
case FT_PIXEL_MODE_GRAY4:
|
|
||||||
/* These could be triggered by very rare types of TrueType fonts */
|
|
||||||
default:
|
|
||||||
return CAIRO_STATUS_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*surface = (cairo_image_surface_t *)
|
|
||||||
cairo_image_surface_create_for_data (data,
|
|
||||||
format,
|
|
||||||
width, height, stride);
|
|
||||||
if ((*surface)->base.status) {
|
|
||||||
free (data);
|
|
||||||
return CAIRO_STATUS_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
if (subpixel)
|
case FT_PIXEL_MODE_GRAY2:
|
||||||
pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
|
case FT_PIXEL_MODE_GRAY4:
|
||||||
|
/* These could be triggered by very rare types of TrueType fonts */
|
||||||
_cairo_image_surface_assume_ownership_of_data ((*surface));
|
default:
|
||||||
|
return CAIRO_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*surface = (cairo_image_surface_t *)
|
||||||
|
cairo_image_surface_create_for_data (data,
|
||||||
|
format,
|
||||||
|
width, height, stride);
|
||||||
|
if ((*surface)->base.status) {
|
||||||
|
free (data);
|
||||||
|
return CAIRO_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subpixel)
|
||||||
|
pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
|
||||||
|
|
||||||
|
_cairo_image_surface_assume_ownership_of_data ((*surface));
|
||||||
|
|
||||||
return CAIRO_STATUS_SUCCESS;
|
return CAIRO_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue