summaryrefslogtreecommitdiff
path: root/src/lib/ector
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2018-02-08 14:27:15 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2018-02-08 14:44:29 +0900
commit48433efc43de9eeaf353e3da18c7109e434902da (patch)
tree38bba818fa70f69175e8677b35e8e4da9a8f102c /src/lib/ector
parent80cc3f230d47bc3f3d049e59adde449694e93b2c (diff)
ector: Updated the ector_buffer_pixels_set() api with stride info
Reviewers: jypark, jpeg Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D5795
Diffstat (limited to 'src/lib/ector')
-rw-r--r--src/lib/ector/cairo/ector_cairo_software_surface.c4
-rw-r--r--src/lib/ector/ector_buffer.eo1
-rw-r--r--src/lib/ector/software/ector_software_buffer.c10
3 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/ector/cairo/ector_cairo_software_surface.c b/src/lib/ector/cairo/ector_cairo_software_surface.c
index 98dd8e0a4f..96bf1c1081 100644
--- a/src/lib/ector/cairo/ector_cairo_software_surface.c
+++ b/src/lib/ector/cairo/ector_cairo_software_surface.c
@@ -51,7 +51,7 @@ struct _Ector_Cairo_Software_Surface_Data
51 51
52EOLIAN static Eina_Bool 52EOLIAN static Eina_Bool
53_ector_cairo_software_surface_ector_buffer_pixels_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, 53_ector_cairo_software_surface_ector_buffer_pixels_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd,
54 void *pixels, int width, int height, 54 void *pixels, int width, int height, int stride,
55 Efl_Gfx_Colorspace cspace, Eina_Bool writable) 55 Efl_Gfx_Colorspace cspace, Eina_Bool writable)
56{ 56{
57 cairo_t *ctx = NULL; 57 cairo_t *ctx = NULL;
@@ -72,7 +72,7 @@ _ector_cairo_software_surface_ector_buffer_pixels_set(Eo *obj, Ector_Cairo_Softw
72 cairo_surface_destroy(pd->surface); 72 cairo_surface_destroy(pd->surface);
73 pd->surface = NULL; 73 pd->surface = NULL;
74 74
75 ok = ector_buffer_pixels_set(efl_super(obj, MY_CLASS), pixels, width, height, cspace, writable); 75 ok = ector_buffer_pixels_set(efl_super(obj, MY_CLASS), pixels, width, height, stride, cspace, writable);
76 76
77 if (ok && pixels) 77 if (ok && pixels)
78 { 78 {
diff --git a/src/lib/ector/ector_buffer.eo b/src/lib/ector/ector_buffer.eo
index 143dcbb846..58d5409f37 100644
--- a/src/lib/ector/ector_buffer.eo
+++ b/src/lib/ector/ector_buffer.eo
@@ -77,6 +77,7 @@ mixin Ector.Buffer
77 @in pixels: void_ptr; [[If $null, allocates an empty buffer]] 77 @in pixels: void_ptr; [[If $null, allocates an empty buffer]]
78 @in width: int; [[Buffer width]] 78 @in width: int; [[Buffer width]]
79 @in height: int; [[Buffer height]] 79 @in height: int; [[Buffer height]]
80 @in stride: int; [[Buffer stride (in bytes). If 0 then calculated based on $cspace and $width]]
80 @in cspace: Efl.Gfx.Colorspace; [[Buffer colorspace]] 81 @in cspace: Efl.Gfx.Colorspace; [[Buffer colorspace]]
81 @in writable: bool; [[Buffer is writable]] 82 @in writable: bool; [[Buffer is writable]]
82 } 83 }
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c
index d44962bbec..8afe6c85c4 100644
--- a/src/lib/ector/software/ector_software_buffer.c
+++ b/src/lib/ector/software/ector_software_buffer.c
@@ -71,10 +71,10 @@ on_fail:
71 71
72EOLIAN static Eina_Bool 72EOLIAN static Eina_Bool
73_ector_software_buffer_base_ector_buffer_pixels_set(Eo *obj, Ector_Software_Buffer_Base_Data *pd, 73_ector_software_buffer_base_ector_buffer_pixels_set(Eo *obj, Ector_Software_Buffer_Base_Data *pd,
74 void *pixels, int width, int height, 74 void *pixels, int width, int height, int stride,
75 Efl_Gfx_Colorspace cspace, Eina_Bool writable) 75 Efl_Gfx_Colorspace cspace, Eina_Bool writable)
76{ 76{
77 unsigned pxs, stride; 77 unsigned pxs;
78 78
79 if (pd->generic->immutable) 79 if (pd->generic->immutable)
80 fail("This buffer is immutable."); 80 fail("This buffer is immutable.");
@@ -92,7 +92,11 @@ _ector_software_buffer_base_ector_buffer_pixels_set(Eo *obj, Ector_Software_Buff
92 if (((unsigned long long)(uintptr_t)pixels) & (pxs - 1)) 92 if (((unsigned long long)(uintptr_t)pixels) & (pxs - 1))
93 fail ("Pixel data is not aligned to %u bytes!", pxs); 93 fail ("Pixel data is not aligned to %u bytes!", pxs);
94 94
95 stride = width * pxs; 95 if (stride == 0)
96 stride = width * pxs;
97 else if (stride < (int)(width * pxs))
98 fail ("Stride is less than minimum stride: provided %u bytes, minimum %u bytes!", stride, (width * pxs));
99
96 if (pd->pixels.u8 && (pd->pixels.u8 != pixels)) 100 if (pd->pixels.u8 && (pd->pixels.u8 != pixels))
97 _ector_software_buffer_base_pixels_clear(obj, pd); 101 _ector_software_buffer_base_pixels_clear(obj, pd);
98 102