optimisation of color allocation strategy - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/lua-draw.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2010年09月19日 20:05:31 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2010年09月19日 20:05:31 +0200
commita648800282d2bd763fbf6a182a1673b1f7ac4596 (patch)
treea3a7ce9f4282d4fb0a5cdc9a087a7a7a1ebf06d8 /agg-plot/lua-draw.cpp
parent1aaf01518a0c6bfe971e55dd53b6772f3d0276f7 (diff)
downloadgsl-shell-a648800282d2bd763fbf6a182a1673b1f7ac4596.tar.gz
optimisation of color allocation strategy
Diffstat (limited to 'agg-plot/lua-draw.cpp')
-rw-r--r--agg-plot/lua-draw.cpp 18
1 files changed, 6 insertions, 12 deletions
diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp
index 32c41133..4b9d83ff 100644
--- a/agg-plot/lua-draw.cpp
+++ b/agg-plot/lua-draw.cpp
@@ -62,7 +62,7 @@ static int agg_ellipse_new (lua_State *L);
static int agg_circle_new (lua_State *L);
static int agg_ellipse_free (lua_State *L);
-static int agg_rgba_free (lua_State *L);
+
static int agg_rgba_add (lua_State *L);
static int agg_rgba_mul (lua_State *L);
static int agg_rgba_set_alpha (lua_State *L);
@@ -100,8 +100,8 @@ static const struct luaL_Reg agg_ellipse_methods[] = {
{NULL, NULL}
};
+// no finalizer is needed because rgba does not allocate memory
static const struct luaL_Reg rgba_methods[] = {
- {"__gc", agg_rgba_free},
{"__add", agg_rgba_add },
{"__mul", agg_rgba_mul },
{"alpha", agg_rgba_set_alpha },
@@ -309,7 +309,7 @@ agg_rgb_new (lua_State *L)
int
agg_rgba_set_alpha (lua_State *L)
{
- agg::rgba8 *c = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR);
+ agg::rgba8 *c = object_check<agg::rgba8> (L, 1, GS_RGBA_COLOR);
double a = luaL_checknumber (L, 2);
c->a = agg::rgba8::base_mask * a;
return 0;
@@ -318,8 +318,8 @@ agg_rgba_set_alpha (lua_State *L)
int
agg_rgba_add (lua_State *L)
{
- agg::rgba8 *c1 = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR);
- agg::rgba8 *c2 = (agg::rgba8 *) gs_check_userdata (L, 2, GS_RGBA_COLOR);
+ agg::rgba8 *c1 = object_check<agg::rgba8> (L, 1, GS_RGBA_COLOR);
+ agg::rgba8 *c2 = object_check<agg::rgba8> (L, 2, GS_RGBA_COLOR);
unsigned int r = c1->r + c2->r;
unsigned int g = c1->g + c2->g;
@@ -342,7 +342,7 @@ agg_rgba_mul (lua_State *L)
}
double f = luaL_checknumber (L, is);
- agg::rgba8 *c = (agg::rgba8 *) gs_check_userdata (L, ic, GS_RGBA_COLOR);
+ agg::rgba8 *c = object_check<agg::rgba8> (L, ic, GS_RGBA_COLOR);
unsigned int r = f * c->r, g = f * c->g, b = f * c->b;
@@ -350,12 +350,6 @@ agg_rgba_mul (lua_State *L)
return 1;
}
-int
-agg_rgba_free (lua_State *L)
-{
- return object_free<agg::rgba8>(L, 1, GS_RGBA_COLOR);
-}
-
void
draw_register (lua_State *L)
{
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月14日 03:25:09 +0000

AltStyle によって変換されたページ (->オリジナル) /