Commit c599d124 authored by Andy Hertzfeld's avatar Andy Hertzfeld

added Raph's scalable vector icons machinery


         added Raph's scalable vector icons machinery
parent 74748cdc
2000-04-13 Andy Hertzfeld <andy@eazel.com>
added Raph's scalable icon machinery. Right now the only way to see it
is to use the eazel theme and drag a file over a folder; the open folder
is a vector icon. Soon we'll add lots more.
* librsvg/*
Raph's new library
* libnautilus/nautilus-icon-factory.c:
integrate vector icons with the icon factory. Right now, it prefers
them to bitmapped ones, which is probably wrong.
* Makefile.am: added librsvg
* configure.in: added librsvg
* src/Makefile.am: link with librsvg
* components/*/Makefile.am: link with librsvg
* icons/eazel/Makefile.am: added i-directory-accept.svg
* icons/eazel/i-directory-accept.svg: our sole vector icon
2000-04-13 Darin Adler <darin@eazel.com>
* components/html/ntl-web-browser.c: (browser_vfs_read_callback):
......
NULL=
SUBDIRS =\
librsvg \
libnautilus \
nautilus-widgets \
src \
......
......@@ -12,6 +12,7 @@ INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
LDADD =\
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
$(XML_LIBS)
......
......@@ -5,6 +5,7 @@ INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOMEUI_CFLAGS) $(BONOBO_CFLAGS) $(
LDADD=\
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS)
......
......@@ -31,6 +31,7 @@ ntl_web_browser_SOURCES = \
ntl_web_browser_LDFLAGS = \
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(GTKHTML_LIBS) \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
......
......@@ -25,6 +25,7 @@ nautilus_music_view_SOURCES = \
nautilus_music_view_LDFLAGS = \
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
$(VFS_LIBS) \
......
......@@ -5,6 +5,7 @@ INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOMEUI_CFLAGS) $(BONOBO_CFLAGS) $(
LDADD=\
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS)
......
......@@ -26,6 +26,7 @@ nautilus_rpm_view_SOURCES = \
nautilus_rpm_view_LDFLAGS = \
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
-lrpm \
......
......@@ -24,6 +24,7 @@ nautilus_sample_content_view_SOURCES = \
nautilus_sample_content_view_LDFLAGS = \
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
$(VFS_LIBS) \
......
......@@ -28,6 +28,7 @@ nautilus_service_startup_view_SOURCES = \
nautilus_service_startup_view_LDFLAGS = \
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
$(VFS_LIBS) \
......
......@@ -5,6 +5,7 @@ INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOMEUI_CFLAGS) $(BONOBO_CFLAGS) $(
LDADD=\
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS)
......
......@@ -152,6 +152,7 @@ data/Makefile
data/mime/Makefile
data/top/Makefile
idl/Makefile
librsvg/Makefile
libnautilus/Makefile
nautilus-widgets/Makefile
src/Makefile
......
......@@ -9,6 +9,7 @@ eazel_DATA = \
i-directory-accept.png \
i-directory-accept-36.png \
i-directory-accept-72.png \
i-directory-accept.svg \
i-regular.png \
i-regular.xml \
i-regular-36.png \
......
<svg width="70" height="42">
<!-- Open folder 1.eps converted by ill2svg.pl -->
<g style="fill: #000000">
<path d="M9.54 41.4L60.9 41.4C60.9 41.4 69.156 12.216 69.348 11.544C69.54 10.872 69.924 9.816 68.916 9.048C68.366 8.628 66.852 8.568 65.316 8.664C63.78 8.76 52.26 8.664 52.26 8.664C52.26 8.664 52.452 6.552 51.684 5.88C50.916 5.208 50.244 4.728 46.884 4.824C43.524 4.92 22.884 4.824 22.884 4.824C22.884 4.824 22.404 5.4 21.54 4.056C20.676 2.712 19.908 0.792 18.948 0.696C17.988 0.6 6.468 0.696 6.468 0.696C6.468 0.696 5.06 0.696 4.772 2.04C4.484 3.384 4.459 4.253 4.164 4.632C3.716 5.208 3.14 4.984 2.468 5.08C1.796 5.176 0.196 4.92 0.132 6.552C0.076 7.994 2.148 14.616 2.244 15.288C2.34 15.96 9.54 41.4 9.54 41.4z"/>
</g>
<g style="fill: #ffffc0; stroke:#000000; stroke-width:0.6">
<path d="M10.5 40.056L17.86 13.88C17.86 13.88 18.228 12.504 19.588 12.6C20.61 12.672 37.38 12.664 37.892 12.664C38.404 12.664 38.9 12.081 40.068 10.936C41.652 9.384 42.308 9.848 43.396 9.784C44.355 9.728 67.012 9.848 67.012 9.848C67.012 9.848 68.292 10.104 68.036 11.064C67.78 12.024 59.716 40.184 59.716 40.184L10.5 40.056z"/>
</g>
<g style="fill: #ffc040; stroke:#000000; stroke-width:0.6">
<path d="M9.732 37.08C9.732 37.08 16.26 13.656 16.452 13.272C16.644 12.888 17.268 11.352 18.468 11.256C19.138 11.202 37.476 11.256 37.476 11.256C37.476 11.256 37.956 11.544 39.3 10.008C40.644 8.472 40.932 8.472 45.348 8.472C49.764 8.472 51.012 8.568 51.012 8.568C51.012 8.568 51.108 7.608 50.82 7.032C50.532 6.456 50.244 6.072 48.228 6.072C46.212 6.072 23.076 6.072 22.5 6.072C21.924 6.072 20.868 6.264 20.1 4.92C19.332 3.576 19.236 1.944 17.412 1.944C15.588 1.944 6.756 1.944 6.756 1.944C6.756 1.944 6.116 1.976 5.924 2.552C5.732 3.128 5.732 4.728 5.156 5.4C4.58 6.072 4.563 5.978 3.62 6.072C2.66 6.168 1.476 6.04 1.476 7.224C1.476 8.664 9.732 37.08 9.732 37.08z"/>
</g>
</svg>
......@@ -41,6 +41,8 @@
#include <parser.h>
#include <xmlmemory.h>
#include "librsvg/rsvg.h"
#include "nautilus-string.h"
#include "nautilus-default-file-icon.h"
#include "nautilus-metadata.h"
......@@ -54,6 +56,8 @@
static const char *icon_file_name_suffixes[] =
{
"",
".svg",
".SVG",
".png",
".PNG",
".gif",
......@@ -507,6 +511,18 @@ make_full_icon_path (const char *path, const char *suffix)
return full_path;
}
/* Return true if the given suffix is a scalable image. */
static gboolean
suffix_is_scalable (const char *path)
{
const char *suffix;
suffix = (const char *)strrchr (path, '.');
if (suffix == NULL)
return FALSE;
return (!strcmp (suffix, ".svg") || !strcmp (suffix, ".SVG"));
}
/* Pick a particular icon to use, trying all the various suffixes.
* Return the path of the icon or NULL if no icon is found.
*/
......@@ -535,11 +551,15 @@ get_themed_icon_file_path (const char *theme_name,
/* Try each suffix. */
for (i = 0; i < NAUTILUS_N_ELEMENTS (icon_file_name_suffixes); i++) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s%s%.0u",
themed_icon_name,
include_size ? "-" : "",
include_size ? icon_size : 0);
if (include_size &&
!suffix_is_scalable (icon_file_name_suffixes[i])) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s-%u",
themed_icon_name,
icon_size);
} else {
partial_path = g_strdup (themed_icon_name);
}
path = make_full_icon_path (partial_path,
icon_file_name_suffixes[i]);
......@@ -1011,6 +1031,24 @@ get_next_icon_size_to_try (guint target_size, guint *current_size)
return FALSE;
}
/* This loads an SVG image, scaling it to the appropriate size. */
static GdkPixbuf *
load_specific_image_svg (const char *path, guint size_in_pixels)
{
FILE *f;
GdkPixbuf *result;
f = fopen (path, "r");
if (f == NULL) {
return NULL;
}
result = rsvg_render_file (f, size_in_pixels *
(1.0 / NAUTILUS_ICON_SIZE_STANDARD));
fclose (f);
return result;
}
/* This load function returns NULL if the icon is not available at this size. */
static GdkPixbuf *
load_specific_image (NautilusScalableIcon *scalable_icon,
......@@ -1046,7 +1084,10 @@ load_specific_image (NautilusScalableIcon *scalable_icon,
if (path == NULL) {
return NULL;
}
image = gdk_pixbuf_new_from_file (path);
if (suffix_is_scalable (path))
image = load_specific_image_svg (path, size_in_pixels);
else
image = gdk_pixbuf_new_from_file (path);
g_free (path);
return image;
}
......
......@@ -41,6 +41,8 @@
#include <parser.h>
#include <xmlmemory.h>
#include "librsvg/rsvg.h"
#include "nautilus-string.h"
#include "nautilus-default-file-icon.h"
#include "nautilus-metadata.h"
......@@ -54,6 +56,8 @@
static const char *icon_file_name_suffixes[] =
{
"",
".svg",
".SVG",
".png",
".PNG",
".gif",
......@@ -507,6 +511,18 @@ make_full_icon_path (const char *path, const char *suffix)
return full_path;
}
/* Return true if the given suffix is a scalable image. */
static gboolean
suffix_is_scalable (const char *path)
{
const char *suffix;
suffix = (const char *)strrchr (path, '.');
if (suffix == NULL)
return FALSE;
return (!strcmp (suffix, ".svg") || !strcmp (suffix, ".SVG"));
}
/* Pick a particular icon to use, trying all the various suffixes.
* Return the path of the icon or NULL if no icon is found.
*/
......@@ -535,11 +551,15 @@ get_themed_icon_file_path (const char *theme_name,
/* Try each suffix. */
for (i = 0; i < NAUTILUS_N_ELEMENTS (icon_file_name_suffixes); i++) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s%s%.0u",
themed_icon_name,
include_size ? "-" : "",
include_size ? icon_size : 0);
if (include_size &&
!suffix_is_scalable (icon_file_name_suffixes[i])) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s-%u",
themed_icon_name,
icon_size);
} else {
partial_path = g_strdup (themed_icon_name);
}
path = make_full_icon_path (partial_path,
icon_file_name_suffixes[i]);
......@@ -1011,6 +1031,24 @@ get_next_icon_size_to_try (guint target_size, guint *current_size)
return FALSE;
}
/* This loads an SVG image, scaling it to the appropriate size. */
static GdkPixbuf *
load_specific_image_svg (const char *path, guint size_in_pixels)
{
FILE *f;
GdkPixbuf *result;
f = fopen (path, "r");
if (f == NULL) {
return NULL;
}
result = rsvg_render_file (f, size_in_pixels *
(1.0 / NAUTILUS_ICON_SIZE_STANDARD));
fclose (f);
return result;
}
/* This load function returns NULL if the icon is not available at this size. */
static GdkPixbuf *
load_specific_image (NautilusScalableIcon *scalable_icon,
......@@ -1046,7 +1084,10 @@ load_specific_image (NautilusScalableIcon *scalable_icon,
if (path == NULL) {
return NULL;
}
image = gdk_pixbuf_new_from_file (path);
if (suffix_is_scalable (path))
image = load_specific_image_svg (path, size_in_pixels);
else
image = gdk_pixbuf_new_from_file (path);
g_free (path);
return image;
}
......
......@@ -41,6 +41,8 @@
#include <parser.h>
#include <xmlmemory.h>
#include "librsvg/rsvg.h"
#include "nautilus-string.h"
#include "nautilus-default-file-icon.h"
#include "nautilus-metadata.h"
......@@ -54,6 +56,8 @@
static const char *icon_file_name_suffixes[] =
{
"",
".svg",
".SVG",
".png",
".PNG",
".gif",
......@@ -507,6 +511,18 @@ make_full_icon_path (const char *path, const char *suffix)
return full_path;
}
/* Return true if the given suffix is a scalable image. */
static gboolean
suffix_is_scalable (const char *path)
{
const char *suffix;
suffix = (const char *)strrchr (path, '.');
if (suffix == NULL)
return FALSE;
return (!strcmp (suffix, ".svg") || !strcmp (suffix, ".SVG"));
}
/* Pick a particular icon to use, trying all the various suffixes.
* Return the path of the icon or NULL if no icon is found.
*/
......@@ -535,11 +551,15 @@ get_themed_icon_file_path (const char *theme_name,
/* Try each suffix. */
for (i = 0; i < NAUTILUS_N_ELEMENTS (icon_file_name_suffixes); i++) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s%s%.0u",
themed_icon_name,
include_size ? "-" : "",
include_size ? icon_size : 0);
if (include_size &&
!suffix_is_scalable (icon_file_name_suffixes[i])) {
/* Build a path for this icon. */
partial_path = g_strdup_printf ("%s-%u",
themed_icon_name,
icon_size);
} else {
partial_path = g_strdup (themed_icon_name);
}
path = make_full_icon_path (partial_path,
icon_file_name_suffixes[i]);
......@@ -1011,6 +1031,24 @@ get_next_icon_size_to_try (guint target_size, guint *current_size)
return FALSE;
}
/* This loads an SVG image, scaling it to the appropriate size. */
static GdkPixbuf *
load_specific_image_svg (const char *path, guint size_in_pixels)
{
FILE *f;
GdkPixbuf *result;
f = fopen (path, "r");
if (f == NULL) {
return NULL;
}
result = rsvg_render_file (f, size_in_pixels *
(1.0 / NAUTILUS_ICON_SIZE_STANDARD));
fclose (f);
return result;
}
/* This load function returns NULL if the icon is not available at this size. */
static GdkPixbuf *
load_specific_image (NautilusScalableIcon *scalable_icon,
......@@ -1046,7 +1084,10 @@ load_specific_image (NautilusScalableIcon *scalable_icon,
if (path == NULL) {
return NULL;
}
image = gdk_pixbuf_new_from_file (path);
if (suffix_is_scalable (path))
image = load_specific_image_svg (path, size_in_pixels);
else
image = gdk_pixbuf_new_from_file (path);
g_free (path);
return image;
}
......
NULL=
lib_LTLIBRARIES=librsvg.la
INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
$(GNOME_CFLAGS) \
$(GNOMECANVASPIXBUF_INCLUDEDIR) \
$(XML_CFLAGS) \
$(WERROR) \
-D_REENTRANT
librsvg_la_LDFLAGS=\
$(GNOME_LIBS) \
$(GNOMECANVASPIXBUF_LIBS) \
$(XML_LIBS) \
$(LIBPNG)
librsvgincludedir=$(includedir)/librsvg
librsvginclude_HEADERS= \
rsvg.h \
$(NULL)
librsvg_la_SOURCES= \
rsvg.c \
rsvg-path.c \
rsvg-bpath-util.c \
art_rgba.c \
art_rgba_svp.c \
$(NULL)
#include <libart_lgpl/art_misc.h>
#include "art_rgba.h"
#define ART_OPTIMIZE_SPACE
#ifndef ART_OPTIMIZE_SPACE
#include "art_rgba_table.c"
#endif
/**
* art_rgba_rgba_composite: Composite RGBA image over RGBA buffer.
* @dst: Destination RGBA buffer.
* @src: Source RGBA buffer.
* @n: Number of RGBA pixels to composite.
*
* Composites the RGBA pixels in @dst over the @src buffer.
**/
void
art_rgba_rgba_composite (art_u8 *dst, const art_u8 *src, int n)
{
int i;
#ifdef WORDS_BIGENDIAN
art_u32 src_rgba, dst_rgba;
#else
art_u32 src_abgr, dst_abgr;
#endif
art_u8 src_alpha, dst_alpha;
for (i = 0; i < n; i++)
{
#ifdef WORDS_BIGENDIAN
src_rgba = ((art_u32 *)src)[i];
src_alpha = src_rgba & 0xff;
#else
src_abgr = ((art_u32 *)src)[i];
src_alpha = (src_abgr >> 24) & 0xff;
#endif
if (src_alpha)
{
if (src_alpha == 0xff ||
(
#ifdef WORDS_BIGENDIAN
dst_rgba = ((art_u32 *)dst)[i],
dst_alpha = dst_rgba & 0xff,
#else
dst_abgr = ((art_u32 *)dst)[i],
dst_alpha = (dst_abgr >> 24),
#endif
dst_alpha == 0))
#ifdef WORDS_BIGENDIAN
((art_u32 *)dst)[i] = src_rgba;
#else
((art_u32 *)dst)[i] = src_abgr;
#endif
else
{
int r, g, b, a;
int src_r, src_g, src_b;
int dst_r, dst_g, dst_b;
int tmp;
int c;
#ifdef ART_OPTIMIZE_SPACE
tmp = (255 - src_alpha) * (255 - dst_alpha) + 0x80;
a = 255 - ((tmp + (tmp >> 8)) >> 8);
c = ((src_alpha << 16) + (a >> 1)) / a;
#else
tmp = art_rgba_composite_table[(src_alpha << 8) + dst_alpha];
c = tmp & 0x1ffff;
a = tmp >> 24;
#endif
#ifdef WORDS_BIGENDIAN
src_r = (src_rgba >> 24) & 0xff;
src_g = (src_rgba >> 16) & 0xff;
src_b = (src_rgba >> 8) & 0xff;
dst_r = (dst_rgba >> 24) & 0xff;
dst_g = (dst_rgba >> 16) & 0xff;
dst_b = (dst_rgba >> 8) & 0xff;
#else
src_r = src_abgr & 0xff;
src_g = (src_abgr >> 8) & 0xff;
src_b = (src_abgr >> 16) & 0xff;
dst_r = dst_abgr & 0xff;
dst_g = (dst_abgr >> 8) & 0xff;
dst_b = (dst_abgr >> 16) & 0xff;
#endif
r = dst_r + (((src_r - dst_r) * c + 0x8000) >> 16);
g = dst_g + (((src_g - dst_g) * c + 0x8000) >> 16);
b = dst_b + (((src_b - dst_b) * c + 0x8000) >> 16);
#ifdef WORDS_BIGENDIAN
((art_u32 *)dst)[i] = (r << 24) | (g << 16) | (b << 8) | a;
#else
((art_u32 *)dst)[i] = (a << 24) | (b << 16) | (g << 8) | r;
#endif
}
}
#if 0
/* it's not clear to me this optimization really wins */
else
{
/* skip over run of transparent pixels */
for (; i < n - 1; i++)
{
#ifdef WORDS_BIGENDIAN
src_rgba = ((art_u32 *)src)[i + 1];
if (src_rgba & 0xff)
break;
#else
src_abgr = ((art_u32 *)src)[i + 1];
if (src_abgr & 0xff000000)
break;
#endif
}
}
#endif
}
}
/**
* art_rgba_fill_run: fill an RGBA buffer a solid RGB color.
* @buf: Buffer to fill.
* @r: Red, range 0..255.
* @g: Green, range 0..255.
* @b: Blue, range 0..255.
* @n: Number of RGB triples to fill.
*
* Fills a buffer with @n copies of the (@r, @g, @b) triple, solid
* alpha. Thus, locations @buf (inclusive) through @buf + 4 * @n
* (exclusive) are written.
**/
void
art_rgba_fill_run (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int n)
{
int i;
#ifdef WORDS_BIGENDIAN
art_u32 src_rgba;
#else
art_u32 src_abgr;
#endif
#ifdef WORDS_BIGENDIAN
src_rgba = (r << 24) | (g << 16) | (b << 8) | 255;
#else
src_abgr = (255 << 24) | (b << 16) | (g << 8) | r;
#endif
for (i = 0; i < n; i++)
{
#ifdef WORDS_BIGENDIAN
((art_u32 *)buf)[i] = src_rgba;
#else
((art_u32 *)buf)[i] = src_abgr;
#endif
}
}
/**
* art_rgba_run_alpha: Render semitransparent color over RGBA buffer.
* @buf: Buffer for rendering.
* @r: Red, range 0..255.
* @g: Green, range 0..255.
* @b: Blue, range 0..255.
* @alpha: Alpha, range 0..255.
* @n: Number of RGB triples to render.
*
* Renders a sequential run of solid (@r, @g, @b) color over @buf with
* opacity @alpha. Note that the range of @alpha is 0..255, in contrast
* to art_rgb_run_alpha, which has a range of 0..256.
**/
void
art_rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n)
{
int i;
#ifdef WORDS_BIGENDIAN
art_u32 src_rgba, dst_rgba;
#else
art_u32 src_abgr, dst_abgr;
#endif
art_u8 dst_alpha;
int a;
int dst_r, dst_g, dst_b;
int tmp;
int c;
#ifdef WORDS_BIGENDIAN
src_rgba = (r << 24) | (g << 16) | (b << 8) | alpha;
#else
src_abgr = (alpha << 24) | (b << 16) | (g << 8) | r;
#endif
for (i = 0; i < n; i++)
{
#ifdef WORDS_BIGENDIAN
dst_rgba = ((art_u32 *)buf)[i];
dst_alpha = dst_rgba & 0xff;
#else
dst_abgr = ((art_u32 *)buf)[i];
dst_alpha = (dst_abgr >> 24) & 0xff;
#endif
if (dst_alpha)
{
#ifdef ART_OPTIMIZE_SPACE
tmp = (255 - alpha) * (255 - dst_alpha) + 0x80;
a = 255 - ((tmp + (tmp >> 8)) >> 8);
c = ((alpha << 16) + (a >> 1)) / a;
#else
tmp = art_rgba_composite_table[(alpha << 8) + dst_alpha];
c = tmp & 0x1ffff;
a = tmp >> 24;
#endif
#ifdef WORDS_BIGENDIAN
dst_r = (dst_rgba >> 24) & 0xff;
dst_g = (dst_rgba >> 16) & 0xff;
dst_b = (dst_rgba >> 8) & 0xff;
#else
dst_r = dst_abgr & 0xff;
dst_g = (dst_abgr >> 8) & 0xff;
dst_b = (dst_abgr >> 16) & 0xff;
#endif
dst_r += (((r - dst_r) * c + 0x8000) >> 16);
dst_g += (((g - dst_g) * c + 0x8000) >> 16);
dst_b += (((b - dst_b) * c + 0x8000) >> 16);
#ifdef WORDS_BIGENDIAN
((art_u32 *)buf)[i] = (dst_r << 24) | (dst_g << 16) | (dst_b << 8) | a;
#else
((art_u32 *)buf)[i] = (a << 24) | (dst_b << 16) | (dst_g << 8) | dst_r;
#endif
}
else
{
#ifdef WORDS_BIGENDIAN
((art_u32 *)buf)[i] = src_rgba;
#else
((art_u32 *)buf)[i] = src_abgr;
#endif
}
}
}
#ifndef __ART_RGBA_H__
#define __ART_RGBA_H__
void
art_rgba_rgba_composite (art_u8 *dst, const art_u8 *src, int n);
void
art_rgba_fill_run (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int n);
void
art_rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n);
#endif
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_svp.h>
#include <libart_lgpl/art_svp_render_aa.h>
#include "art_rgba.h"
#include "art_rgba_svp.h"
typedef struct _ArtRgbaSVPAlphaData ArtRgbaSVPAlphaData;
struct _ArtRgbaSVPAlphaData {
int alphatab[256];
art_u8 r, g, b, alpha;
art_u8 *buf;
int rowstride;
int x0, x1;
};
static void
art_rgba_svp_alpha_callback (void *callback_data, int y,
int start, ArtSVPRenderAAStep *steps, int n_steps)
{
ArtRgbaSVPAlphaData *data = callback_data;
art_u8 *linebuf;
int run_x0, run_x1;
art_u32 running_sum = start;
int x0, x1;
int k;
art_u8 r, g, b;
int *alphatab;
int alpha;
linebuf = data->buf;
x0 = data->x0;