summaryrefslogtreecommitdiffstats
path: root/libdimension-python
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-31 13:54:56 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-31 13:55:26 -0400
commitc10255ab3da17507d63bdc7e1fdfc809ffd32f7f (patch)
treede65eefb9152ebb049c2adbb8e2cf00abe09063e /libdimension-python
parent70373204b341fc91694c0293796230e447c51067 (diff)
downloaddimension-c10255ab3da17507d63bdc7e1fdfc809ffd32f7f.tar.xz
pigment: Use pool.
Diffstat (limited to 'libdimension-python')
-rw-r--r--libdimension-python/dimension.pxd11
-rw-r--r--libdimension-python/dimension.pyx18
2 files changed, 7 insertions, 22 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd
index 36785ee..45a081f 100644
--- a/libdimension-python/dimension.pxd
+++ b/libdimension-python/dimension.pxd
@@ -257,13 +257,10 @@ cdef extern from "../libdimension/dimension.h":
DMNSN_PIGMENT_MAP_REGULAR
DMNSN_PIGMENT_MAP_SRGB
- void dmnsn_delete_pigment(dmnsn_pigment *pigment)
-
- dmnsn_pigment *dmnsn_new_solid_pigment(dmnsn_tcolor tcolor)
- dmnsn_pigment *dmnsn_new_canvas_pigment(dmnsn_canvas *canvas)
- dmnsn_pigment *dmnsn_new_pigment_map_pigment(dmnsn_pattern *pattern,
- dmnsn_map *map,
- dmnsn_pigment_map_flags flags)
+ dmnsn_pigment *dmnsn_new_solid_pigment(dmnsn_pool *pool, dmnsn_tcolor tcolor)
+ dmnsn_pigment *dmnsn_new_canvas_pigment(dmnsn_pool *pool, dmnsn_canvas *canvas)
+ dmnsn_pigment *dmnsn_new_pigment_map_pigment(dmnsn_pool *pool, dmnsn_pattern *pattern,
+ dmnsn_map *map, dmnsn_pigment_map_flags flags)
############
# Finishes #
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index 846772a..0a90b07 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -793,15 +793,11 @@ cdef class Pigment(_Transformable):
if self._pigment == NULL:
if isinstance(quick_color, Pigment):
self._pigment = (<Pigment>quick_color)._pigment
- DMNSN_INCREF(self._pigment)
else:
- self._pigment = dmnsn_new_solid_pigment(TColor(quick_color)._tc)
+ self._pigment = dmnsn_new_solid_pigment(_get_pool(), TColor(quick_color)._tc)
else:
self._pigment.quick_color = TColor(quick_color)._tc
- def __dealloc__(self):
- dmnsn_delete_pigment(self._pigment)
-
def transform(self, Matrix trans not None):
"""Transform a pigment."""
self._pigment.trans = dmnsn_matrix_mul(trans._m, self._pigment.trans)
@@ -811,7 +807,6 @@ cdef Pigment _Pigment(dmnsn_pigment *pigment):
"""Wrap a Pigment object around a dmnsn_pigment *."""
cdef Pigment self = Pigment.__new__(Pigment)
self._pigment = pigment
- DMNSN_INCREF(self._pigment)
return self
cdef class ImageMap(Pigment):
@@ -834,7 +829,7 @@ cdef class ImageMap(Pigment):
if fclose(file) != 0:
_raise_OSError()
- self._pigment = dmnsn_new_canvas_pigment(canvas)
+ self._pigment = dmnsn_new_canvas_pigment(_get_pool(), canvas)
Pigment.__init__(self, *args, **kwargs)
cdef class PigmentMap(Pigment):
@@ -857,13 +852,11 @@ cdef class PigmentMap(Pigment):
for i, pigment in map.items():
pigment = Pigment(pigment)
real_pigment = (<Pigment>pigment)._pigment
- DMNSN_INCREF(real_pigment)
dmnsn_map_add_entry(pigment_map, i, &real_pigment)
else:
for i, pigment in enumerate(map):
pigment = Pigment(pigment)
real_pigment = (<Pigment>pigment)._pigment
- DMNSN_INCREF(real_pigment)
dmnsn_map_add_entry(pigment_map, i/len(map), &real_pigment)
cdef dmnsn_pigment_map_flags flags
@@ -872,8 +865,7 @@ cdef class PigmentMap(Pigment):
else:
flags = DMNSN_PIGMENT_MAP_REGULAR
- self._pigment = dmnsn_new_pigment_map_pigment(pattern._pattern, pigment_map,
- flags)
+ self._pigment = dmnsn_new_pigment_map_pigment(_get_pool(), pattern._pattern, pigment_map, flags)
Pigment.__init__(self, *args, **kwargs)
############
@@ -996,14 +988,12 @@ cdef class Texture(_Transformable):
else:
return _Pigment(self._texture.pigment)
def __set__(self, pigment):
- dmnsn_delete_pigment(self._texture.pigment)
cdef Pigment real_pigment
if pigment is None:
self._texture.pigment = NULL
else:
real_pigment = Pigment(pigment)
self._texture.pigment = real_pigment._pigment
- DMNSN_INCREF(self._texture.pigment)
property finish:
"""The texture's finish."""
@@ -1559,10 +1549,8 @@ cdef class Scene:
def __get__(self):
return _Pigment(self._scene.background)
def __set__(self, pigment):
- dmnsn_delete_pigment(self._scene.background)
cdef Pigment real_pigment = Pigment(pigment)
self._scene.background = real_pigment._pigment
- DMNSN_INCREF(self._scene.background)
property adc_bailout:
"""The adaptive depth control bailout (default: 1/255)."""