[seed] cairo: Implement more of cairo context
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] cairo: Implement more of cairo context
- Date: Thu, 14 May 2009 06:55:10 -0400 (EDT)
commit fc8594290b523771315bd00f4f30ec7844671843
Author: Robert Carr <racarr svn gnome org>
Date: Thu May 14 06:08:29 2009 -0400
cairo: Implement more of cairo context
---
modules/cairo/seed-cairo-enums.c | 9 ++-
modules/cairo/seed-cairo.c | 151 ++++++++++++++++++++++++++++++++++----
2 files changed, 144 insertions(+), 16 deletions(-)
diff --git a/modules/cairo/seed-cairo-enums.c b/modules/cairo/seed-cairo-enums.c
index 614fbe8..e002c8c 100644
--- a/modules/cairo/seed-cairo-enums.c
+++ b/modules/cairo/seed-cairo-enums.c
@@ -8,7 +8,7 @@ void
seed_define_cairo_enums (SeedContext ctx,
SeedObject namespace_ref)
{
- SeedObject content_holder, format_holder;
+ SeedObject content_holder, format_holder, antialias_holder;
content_holder = seed_make_object (ctx, NULL, NULL);
seed_object_set_property (ctx, namespace_ref, "Content", content_holder);
@@ -22,4 +22,11 @@ seed_define_cairo_enums (SeedContext ctx,
ENUM_MEMBER(format_holder, "RGB23", CAIRO_FORMAT_RGB24);
ENUM_MEMBER(format_holder, "A8", CAIRO_FORMAT_A8);
ENUM_MEMBER(format_holder, "A1", CAIRO_FORMAT_A1);
+
+ antialias_holder = seed_make_object (ctx, NULL, NULL);
+ seed_object_set_property (ctx, namespace_ref, "Antialias", antialias_holder);
+ ENUM_MEMBER(antialias_holder, "DEFAULT", CAIRO_ANTIALIAS_DEFAULT);
+ ENUM_MEMBER(antialias_holder, "NONE", CAIRO_ANTIALIAS_NONE);
+ ENUM_MEMBER(antialias_holder, "GRAY", CAIRO_ANTIALIAS_GRAY);
+ ENUM_MEMBER(antialias_holder, "SUBPIXEL", CAIRO_ANTIALIAS_SUBPIXEL);
}
diff --git a/modules/cairo/seed-cairo.c b/modules/cairo/seed-cairo.c
index c1292b5..b31a23e 100644
--- a/modules/cairo/seed-cairo.c
+++ b/modules/cairo/seed-cairo.c
@@ -200,7 +200,129 @@ seed_cairo_get_group_target (SeedContext ctx,
return seed_object_from_cairo_surface (ctx, cairo_get_group_target (cr));
}
+static SeedValue
+seed_cairo_set_source_rgb(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ gdouble r,g,b;
+ cairo_t *cr;
+ CHECK_THIS();
+ cr = seed_object_get_private (this_object);
+
+ if (argument_count != 3)
+ {
+ EXPECTED_EXCEPTION("set_source_rgb", "3 arguments");
+ }
+ r = seed_value_to_double (ctx, arguments[0], exception);
+ g = seed_value_to_double (ctx, arguments[1], exception);
+ b = seed_value_to_double (ctx, arguments[2], exception);
+ cairo_set_source_rgb (cr, r, g, b);
+
+ return seed_make_undefined (ctx);
+}
+
+static SeedValue
+seed_cairo_set_source_rgba(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ gdouble r,g,b,a;
+ cairo_t *cr;
+
+ CHECK_THIS();
+ cr = seed_object_get_private (this_object);
+
+ if (argument_count != 4)
+ {
+ EXPECTED_EXCEPTION("set_source_rgba", "4 arguments");
+ }
+ r = seed_value_to_double (ctx, arguments[0], exception);
+ g = seed_value_to_double (ctx, arguments[1], exception);
+ b = seed_value_to_double (ctx, arguments[2], exception);
+ a = seed_value_to_double (ctx, arguments[3], exception);
+ cairo_set_source_rgba (cr, r, g, b, a);
+
+ return seed_make_undefined (ctx);
+}
+
+static SeedValue
+seed_cairo_set_source_surface (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ gdouble x,y;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ CHECK_THIS();
+ if (argument_count != 3)
+ {
+ EXPECTED_EXCEPTION("set_source_surface", "3 arguments");
+ }
+ cr = seed_object_get_private (this_object);
+ surface = seed_object_to_cairo_surface (ctx, arguments[0], exception);
+ if (!surface)
+ return seed_make_undefined (ctx);
+
+ x = seed_value_to_double (ctx, arguments[1], exception);
+ y = seed_value_to_double (ctx, arguments[2], exception);
+ cairo_set_source_surface (cr, surface, x, y);
+
+ return seed_make_undefined (ctx);
+}
+
+static SeedValue
+seed_cairo_set_antialias (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ cairo_t *cr;
+ cairo_antialias_t antialias;
+
+ CHECK_THIS();
+ if (argument_count != 1)
+ {
+ EXPECTED_EXCEPTION("set_antialias", "1 argument");
+ }
+ cr = seed_object_get_private (this_object);
+ antialias = seed_value_to_long (ctx, arguments[0], exception);
+
+ cairo_set_antialias (cr, antialias);
+ return seed_make_undefined (ctx);
+}
+
+static SeedValue
+seed_cairo_get_antialias (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ cairo_antialias_t antialias;
+ cairo_t *cr;
+
+ CHECK_THIS();
+ cr = seed_object_get_private (this_object);
+ antialias = cairo_get_antialias (cr);
+
+ return seed_value_from_long (ctx, antialias, exception);
+}
+
seed_static_function cairo_funcs[] = {
{"save", seed_cairo_save, 0},
{"restore", seed_cairo_restore, 0},
@@ -210,16 +332,21 @@ seed_static_function cairo_funcs[] = {
// {"pop_group", seed_cairo_pop_group, 0},
{"pop_group_to_source", seed_cairo_pop_group_to_source, 0},
{"get_group_target", seed_cairo_get_group_target, 0},
+ {"set_source_rgb", seed_cairo_set_source_rgb, 0},
+ {"set_source_rgba", seed_cairo_set_source_rgba, 0},
+ // {"set_source", seed_cairo_set_source, 0},
+ {"set_source_surface", seed_cairo_set_source_surface, 0},
+// {"get_source", seed_cairo_get_source, 0},
+ {"set_antialias", seed_cairo_set_antialias, 0},
+ {"get_antialias", seed_cairo_get_antialias, 0},
{0, 0, 0}
};
SeedObject
seed_module_init(SeedEngine * local_eng)
{
- SeedClass context_constructor_class;
- //SeedObject context_constructor_ref;
+ SeedObject context_constructor_ref;
SeedObject namespace_ref;
- seed_class_definition context_constructor_class_def = seed_empty_class;
seed_class_definition cairo_def = seed_empty_class;
eng = local_eng;
namespace_ref = seed_make_object (eng->context, NULL, NULL);
@@ -232,19 +359,13 @@ seed_module_init(SeedEngine * local_eng)
cairo_def.class_name = "CairoContext";
cairo_def.finalize = seed_cairo_context_finalize;
seed_cairo_context_class = seed_create_class (&cairo_def);
+// Hack around WebKit GC bug.
+ context_constructor_ref = seed_make_constructor (eng->context,
+ NULL,
+// seed_cairo_context_class,
+ seed_cairo_construct_context);
-// Hack around WebKit GC bug.m
-// context_constructor_ref = seed_make_constructor (eng->context,
-// seed_cairo_context_class,
-// seed_cairo_construct_context);
-
- context_constructor_class_def.class_name = "CairoContextConstructor";
- context_constructor_class_def.call_as_constructor = seed_cairo_construct_context;
-
- context_constructor_class = seed_create_class(&context_constructor_class_def);
- seed_object_set_property (eng->context, namespace_ref, "Context", seed_make_object (eng->context, context_constructor_class, NULL));
-
- // seed_object_set_property (eng->context, namespace_ref, "Context", context_constructor_ref);
+ seed_object_set_property (eng->context, namespace_ref, "Context", context_constructor_ref);
return namespace_ref;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]