[Pkg-e-commits] [SCM] Python bindings for Evas branch, upstream-vcs, updated. a2d7e40fb9fbbe948f479174a461f735a2f530fb
barbieri
barbieri at alioth.debian.org
Sat May 24 16:31:52 UTC 2008
The following commit has been merged in the upstream-vcs branch:
commit ac4486ded06c7fe5378cded18c998ab32878bf48
Author: barbieri <barbieri>
Date: Wed Mar 12 19:57:49 2008 +0000
Fix build of modules dependent on python-evas.
Move evas_object_image_python_extras.h inside include/evas and install
it so python-ecore doesn't fail.
diff --git a/evas/evas_object_image_mask.c b/evas/evas_object_image_mask.c
index 1f13b51..9ebe7fb 100644
--- a/evas/evas_object_image_mask.c
+++ b/evas/evas_object_image_mask.c
@@ -2,67 +2,68 @@
#include <stdlib.h>
#include <Evas.h>
-#include "evas_object_image_python_extras.h"
+#include "evas/evas_object_image_python_extras.h"
#define BPIXEL(base, x, y, stride) (base + (y * stride + x))
#define MEDPIXEL(src, msk, srf) (((src) * (msk)) + (srf) * (255 - (msk)))/255
static void
-_argb8888_image_mask_fill(char *dst, const char *src, const char *msk, const char *srf, int x_msk, int y_msk, int x_srf, int y_srf, int src_stride, int src_width, int src_height, int msk_stride, int msk_width, int msk_height, int srf_stride, int srf_width, int srf_height)
+_argb8888_image_mask_fill(DATA32 *dst, const DATA32 *src, const DATA32 *msk, const DATA32 *srf, int x_msk, int y_msk, int x_srf, int y_srf, int src_stride, int src_width, int src_height, int msk_stride, int msk_width, int msk_height, int srf_stride, int srf_width, int srf_height)
{
- int x, y, xp, yp, xs, ys;
- int r, g, b, a;
- DATA32 pixel, pxa, pxb;
- DATA32 *sp = (DATA32 *) src;
- DATA32 *mp = (DATA32 *) msk;
- DATA32 *fp = (DATA32 *) srf;
- DATA32 *dp = (DATA32 *) dst;
+ int y;
for (y = 0; y < src_height; y++)
- for (x = 0; x < src_width; x++)
- {
- xp = x - x_msk;
- yp = y - y_msk;
- xs = x - x_srf;
- ys = y - y_srf;
-
- pixel = *(BPIXEL(sp, x, y, src_stride));
-
- if ((xp >= 0) && (xp < msk_width) &&
- (yp >= 0) && (yp < msk_height) &&
- (xs >= 0) && (xs < srf_width) &&
- (ys >= 0) && (ys < srf_height))
- {
- pxa = *(BPIXEL(mp, xp, yp, msk_stride));
- pxb = *(BPIXEL(fp, xs, ys, srf_stride));
- if (pxa != 0)
- {
- a = MEDPIXEL((pixel >> 24) & 0xFF,
- (pxa >> 24) & 0xFF, (pxb >> 24) & 0xFF);
- r = MEDPIXEL((pixel >> 16) & 0xFF,
- (pxa >> 16) & 0xFF, (pxb >> 16) & 0xFF);
- g = MEDPIXEL((pixel >> 8) & 0xFF,
- (pxa >> 8) & 0xFF, (pxb >> 8) & 0xFF);
- b = MEDPIXEL(pixel & 0xFF, pxa & 0xFF, pxb & 0xFF);
- pixel = (a << 24) | (r << 16) | (g << 8) | b;
- }
- }
-
- *(BPIXEL(dp, x, y, src_stride)) = pixel;
- }
+ {
+ int x;
+
+ for (x = 0; x < src_width; x++)
+ {
+ int xp, yp, xs, ys;
+ DATA32 pixel;
+
+ xp = x - x_msk;
+ yp = y - y_msk;
+ xs = x - x_srf;
+ ys = y - y_srf;
+
+ pixel = *(BPIXEL(src, x, y, src_stride));
+
+ if ((xp >= 0) && (xp < msk_width) &&
+ (yp >= 0) && (yp < msk_height) &&
+ (xs >= 0) && (xs < srf_width) &&
+ (ys >= 0) && (ys < srf_height))
+ {
+ DATA32 pxa, pxb;
+
+ pxa = *(BPIXEL(msk, xp, yp, msk_stride));
+ pxb = *(BPIXEL(srf, xs, ys, srf_stride));
+ if (pxa != 0)
+ {
+ int r, g, b, a;
+
+ a = MEDPIXEL((pixel >> 24) & 0xFF,
+ (pxa >> 24) & 0xFF, (pxb >> 24) & 0xFF);
+ r = MEDPIXEL((pixel >> 16) & 0xFF,
+ (pxa >> 16) & 0xFF, (pxb >> 16) & 0xFF);
+ g = MEDPIXEL((pixel >> 8) & 0xFF,
+ (pxa >> 8) & 0xFF, (pxb >> 8) & 0xFF);
+ b = MEDPIXEL(pixel & 0xFF, pxa & 0xFF, pxb & 0xFF);
+ pixel = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ }
+
+ *(BPIXEL(dst, x, y, src_stride)) = pixel;
+ }
+ }
}
-
int
evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object *surface, int x_mask, int y_mask, int x_surface, int y_surface)
{
int alloc_size;
unsigned char has_alpha;
- char *src_data;
- char *msk_data;
- char *srf_data;
- char *new_buffer;
+ void *src_data, *msk_data, *srf_data, *new_buffer;
int src_stride, src_width, src_height;
int msk_stride, msk_width, msk_height;
int srf_stride, srf_width, srf_height;
@@ -77,10 +78,15 @@ evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object *su
evas_object_image_size_get(src, &src_width, &src_height);
src_stride = evas_object_image_stride_get(src);
+ src_data = evas_object_image_data_get(src, 0);
+
evas_object_image_size_get(mask, &msk_width, &msk_height);
msk_stride = evas_object_image_stride_get(mask);
+ msk_data = evas_object_image_data_get(mask, 0);
+
evas_object_image_size_get(surface, &srf_width, &srf_height);
srf_stride = evas_object_image_stride_get(surface);
+ srf_data = evas_object_image_data_get(surface, 0);
has_alpha = evas_object_image_alpha_get(src);
@@ -92,10 +98,6 @@ evas_object_image_mask_fill(Evas_Object *src, Evas_Object *mask, Evas_Object *su
if (!new_buffer)
return 3;
- src_data = evas_object_image_data_get(src, 0);
- msk_data = evas_object_image_data_get(mask, 0);
- srf_data = evas_object_image_data_get(surface, 0);
-
_argb8888_image_mask_fill(new_buffer, src_data, msk_data,
srf_data, x_mask, y_mask,
x_surface, y_surface,
diff --git a/evas/evas_object_image_rotate.c b/evas/evas_object_image_rotate.c
index fb6cb95..eb888a6 100644
--- a/evas/evas_object_image_rotate.c
+++ b/evas/evas_object_image_rotate.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <Evas.h>
-#include "evas_object_image_python_extras.h"
+#include "evas/evas_object_image_python_extras.h"
static inline int
_calc_stride(int w)
@@ -34,10 +34,12 @@ _calc_image_byte_size(Evas_Colorspace colorspace, Evas_Object_Image_Rotation rot
switch (colorspace)
{
case EVAS_COLORSPACE_ARGB8888:
- image_byte_size = IMG_BYTE_SIZE_ARGB8888(dst_stride, dst_height, has_alpha);
+ image_byte_size = IMG_BYTE_SIZE_ARGB8888(dst_stride, dst_height,
+ has_alpha);
break;
case EVAS_COLORSPACE_RGB565_A5P:
- image_byte_size = IMG_BYTE_SIZE_RGB565(dst_stride, dst_height, has_alpha);
+ image_byte_size = IMG_BYTE_SIZE_RGB565(dst_stride, dst_height,
+ has_alpha);
break;
default:
image_byte_size = -1;
@@ -48,18 +50,20 @@ _calc_image_byte_size(Evas_Colorspace colorspace, Evas_Object_Image_Rotation rot
}
static void
-_data8_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data8_image_rotate_90(DATA8 *dst, const DATA8 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA8 *dp, *sp;
- int x, y;
+ const DATA8 *sp;
+ DATA8 *dp;
+ int y;
- sp = (DATA8 *) src;
- dp = ((DATA8 *) dst) + ((out_x +
- (w + out_y - 1) * dst_stride));
+ sp = src;
+ dp = dst + ((out_x + (w + out_y - 1) * dst_stride));
for (y = 0; y < h; y++)
{
- DATA8 *dp_itr, *sp_itr;
+ const DATA8 *sp_itr;
+ DATA8 *dp_itr;
+ int x;
sp_itr = sp;
dp_itr = dp;
@@ -77,18 +81,20 @@ _data8_image_rotate_90(char *dst, const char *src, int dst_stride, int src_strid
}
static void
-_data16_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data16_image_rotate_90(DATA16 *dst, const DATA16 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA16 *dp, *sp;
- int x, y;
+ const DATA16 *sp;
+ DATA16 *dp;
+ int y;
- sp = (DATA16 *) src;
- dp = ((DATA16 *) dst) + ((out_x +
- (w + out_y - 1) * dst_stride));
+ sp = src;
+ dp = dst + ((out_x + (w + out_y - 1) * dst_stride));
for (y = 0; y < h; y++)
{
- DATA16 *dp_itr, *sp_itr;
+ const DATA16 *sp_itr;
+ DATA16 *dp_itr;
+ int x;
sp_itr = sp;
dp_itr = dp;
@@ -106,18 +112,20 @@ _data16_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stri
}
static void
-_data32_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data32_image_rotate_90(DATA32 *dst, const DATA32 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA32 *dp, *sp;
- int x, y;
+ const DATA32 *sp;
+ DATA32 *dp;
+ int y;
- sp = (DATA32 *) src;
- dp = ((DATA32 *) dst) + ((out_x +
- (w + out_y - 1) * dst_stride));
+ sp = src;
+ dp = dst + ((out_x + (w + out_y - 1) * dst_stride));
for (y = 0; y < h; y++)
{
- DATA32 *dp_itr, *sp_itr;
+ const DATA32 *sp_itr;
+ DATA32 *dp_itr;
+ int x;
sp_itr = sp;
dp_itr = dp;
@@ -135,18 +143,21 @@ _data32_image_rotate_90(char *dst, const char *src, int dst_stride, int src_stri
}
static void
-_data8_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data8_image_rotate_180(DATA8 *dst, const DATA8 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA8 *dp, *sp;
- int x, y;
+ const DATA8 *sp;
+ DATA8 *dp;
+ int y;
- sp = (DATA8 *) src;
- dp = ((DATA8 *) dst) + ((w + out_x - 1) +
- (h + out_y - 1) * dst_stride);
+ sp = src;
+ dp = dst + ((w + out_x - 1) + (h + out_y - 1) * dst_stride);
for (y = 0; y < h; y++)
{
- DATA8 *dp_itr, *sp_itr;
+ const DATA8 *sp_itr;
+ DATA8 *dp_itr;
+ int x;
+
sp_itr = sp;
dp_itr = dp;
@@ -163,18 +174,21 @@ _data8_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stri
}
static void
-_data16_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data16_image_rotate_180(DATA16 *dst, const DATA16 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA16 *dp, *sp;
- int x, y;
+ const DATA16 *sp;
+ DATA16 *dp;
+ int y;
- sp = (DATA16 *) src;
- dp = ((DATA16 *) dst) + ((w + out_x - 1) +
- (h + out_y - 1) * dst_stride);
+ sp = src;
+ dp = dst + ((w + out_x - 1) + (h + out_y - 1) * dst_stride);
for (y = 0; y < h; y++)
{
- DATA16 *dp_itr, *sp_itr;
+ const DATA16 *sp_itr;
+ DATA16 *dp_itr;
+ int x;
+
sp_itr = sp;
dp_itr = dp;
@@ -189,19 +203,23 @@ _data16_image_rotate_180(char *dst, const char *src, int dst_stride, int src_str
dp -= dst_stride;
}
}
+
static void
-_data32_image_rotate_180(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data32_image_rotate_180(DATA32 *dst, const DATA32 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA32 *dp, *sp;
- int x, y;
+ const DATA32 *sp;
+ DATA32 *dp;
+ int y;
- sp = (DATA32 *) src;
- dp = ((DATA32 *) dst) + ((w + out_x - 1) +
- (h + out_y - 1) * dst_stride);
+ sp = src;
+ dp = dst + ((w + out_x - 1) + (h + out_y - 1) * dst_stride);
for (y = 0; y < h; y++)
{
- DATA32 *dp_itr, *sp_itr;
+ const DATA32 *sp_itr;
+ DATA32 *dp_itr;
+ int x;
+
sp_itr = sp;
dp_itr = dp;
@@ -218,18 +236,21 @@ _data32_image_rotate_180(char *dst, const char *src, int dst_stride, int src_str
}
static void
-_data8_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data8_image_rotate_270(DATA8 *dst, const DATA8 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA8 *dp, *sp;
- int x, y;
+ const DATA8 *sp;
+ DATA8 *dp;
+ int y;
- sp = (DATA8 *) src;
- dp = ((DATA8 *) dst) + ((h + out_x - 1) +
- out_y * dst_stride);
+ sp = src;
+ dp = dst + ((h + out_x - 1) + out_y * dst_stride);
for (y = 0; y < h; y++)
{
- DATA8 *dp_itr, *sp_itr;
+ const DATA8 *sp_itr;
+ DATA8 *dp_itr;
+ int x;
+
sp_itr = sp;
dp_itr = dp;
@@ -246,18 +267,21 @@ _data8_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stri
}
static void
-_data16_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data16_image_rotate_270(DATA16 *dst, const DATA16 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA16 *dp, *sp;
- int x, y;
+ const DATA16 *sp;
+ DATA16 *dp;
+ int y;
- sp = (DATA16 *) src;
- dp = ((DATA16 *) dst) + ((h + out_x - 1) +
- out_y * dst_stride);
+ sp = src;
+ dp = dst + ((h + out_x - 1) + out_y * dst_stride);
for (y = 0; y < h; y++)
{
- DATA16 *dp_itr, *sp_itr;
+ const DATA16 *sp_itr;
+ DATA16 *dp_itr;
+ int x;
+
sp_itr = sp;
dp_itr = dp;
@@ -274,18 +298,21 @@ _data16_image_rotate_270(char *dst, const char *src, int dst_stride, int src_str
}
static void
-_data32_image_rotate_270(char *dst, const char *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
+_data32_image_rotate_270(DATA32 *dst, const DATA32 *src, int dst_stride, int src_stride, int out_x, int out_y, int w, int h)
{
- DATA32 *dp, *sp;
- int x, y;
+ const DATA32 *sp;
+ DATA32 *dp;
+ int y;
- sp = (DATA32 *) src;
- dp = ((DATA32 *) dst) + ((h + out_x - 1) +
- out_y * dst_stride);
+ sp = src;
+ dp = dst + ((h + out_x - 1) + out_y * dst_stride);
for (y = 0; y < h; y++)
{
- DATA32 *dp_itr, *sp_itr;
+ const DATA32 *sp_itr;
+ DATA32 *dp_itr;
+ int x;
+
sp_itr = sp;
dp_itr = dp;
@@ -302,14 +329,14 @@ _data32_image_rotate_270(char *dst, const char *src, int dst_stride, int src_str
}
static void
-_rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char *src, int src_stride, unsigned char has_alpha, int out_x, int out_y, int w, int h)
+_rgb565_image_rotate(Evas_Object_Image_Rotation rotation, DATA16 *dst, const DATA16 *src, int src_stride, unsigned char has_alpha, int out_x, int out_y, int w, int h)
{
int dst_stride;
- char *dst_alpha;
- const char *src_alpha;
+ DATA8 *dst_alpha;
+ const DATA8 *src_alpha;
if (has_alpha)
- src_alpha = src + src_stride * h * 2;
+ src_alpha = (const DATA8*)(src + src_stride * h);
switch (rotation)
{
@@ -320,7 +347,7 @@ _rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char
out_x, out_y, w, h);
if (has_alpha)
{
- dst_alpha = dst + dst_stride * w * 2;
+ dst_alpha = (DATA8 *)(dst + dst_stride * w);
_data8_image_rotate_90(dst_alpha, src_alpha,
dst_stride, src_stride,
out_x, out_y, w, h);
@@ -333,7 +360,7 @@ _rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char
out_x, out_y, w, h);
if (has_alpha)
{
- dst_alpha = dst + dst_stride * h * 2;
+ dst_alpha = (DATA8 *)(dst + dst_stride * h);
_data8_image_rotate_180(dst_alpha, src_alpha,
dst_stride, src_stride,
out_x, out_y, w, h);
@@ -346,7 +373,7 @@ _rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char
out_x, out_y, w, h);
if (has_alpha)
{
- dst_alpha = dst + dst_stride * w * 2;
+ dst_alpha = (DATA8 *)(dst + dst_stride * w);
_data8_image_rotate_270(dst_alpha, src_alpha,
dst_stride, src_stride,
out_x, out_y, w, h);
@@ -358,7 +385,7 @@ _rgb565_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char
}
static void
-_argb8888_image_rotate(Evas_Object_Image_Rotation rotation, char *dst, const char *src, int src_stride, int out_x, int out_y, int w, int h)
+_argb8888_image_rotate(Evas_Object_Image_Rotation rotation, DATA32 *dst, const DATA32 *src, int src_stride, int out_x, int out_y, int w, int h)
{
int dst_stride;
@@ -394,8 +421,7 @@ evas_object_image_rotate(Evas_Object *image, Evas_Object_Image_Rotation rotation
int image_byte_size;
int stride, width, height;
unsigned char has_alpha;
- char *new_buffer;
- char *src_data;
+ void *new_buffer, *src_data;
evas_object_image_size_get(image, &width, &height);
stride = evas_object_image_stride_get(image);
@@ -408,6 +434,9 @@ evas_object_image_rotate(Evas_Object *image, Evas_Object_Image_Rotation rotation
return;
new_buffer = malloc(image_byte_size);
+ if (!new_buffer)
+ return;
+
src_data = evas_object_image_data_get(image, 0);
switch (colorspace)
diff --git a/include/evas/c_evas.pxd b/include/evas/c_evas.pxd
index 978d31a..13efae5 100644
--- a/include/evas/c_evas.pxd
+++ b/include/evas/c_evas.pxd
@@ -531,7 +531,7 @@ cdef extern from "Evas.h":
void evas_object_text_style_pad_get(Evas_Object *obj, int *l, int *r, int *t, int *b)
-cdef extern from "evas_object_image_python_extras.h":
+cdef extern from "evas/evas_object_image_python_extras.h":
ctypedef enum Evas_Object_Image_Rotation:
ROTATE_NONE
ROTATE_90
diff --git a/include/evas_object_image_python_extras.h b/include/evas/evas_object_image_python_extras.h
similarity index 100%
copy from include/evas_object_image_python_extras.h
copy to include/evas/evas_object_image_python_extras.h
diff --git a/setup.py b/setup.py
index 29ae265..065688b 100644
--- a/setup.py
+++ b/setup.py
@@ -60,6 +60,7 @@ evasmodule = Extension('evas.c_evas',
headers = ['evas/evas.c_evas.h',
+ 'include/evas/evas_object_image_python_extras.h',
'include/evas/python_evas_utils.h',
'include/evas/c_evas.pxd',
'include/evas/python.pxd',
--
Python bindings for Evas
More information about the Pkg-e-commits
mailing list