Add CairoImageSurface, properly separate image surface methods from the CairoSurface type

This commit is contained in:
Joshua Granick
2015-07-15 16:40:53 -07:00
parent 6622ac818d
commit 0b4c553622
6 changed files with 193 additions and 77 deletions

View File

@@ -127,6 +127,23 @@ namespace lime {
}
value lime_bytes_from_data_pointer (value data, value length) {
int size = val_int (length);
intptr_t ptr = (intptr_t)val_float (data);
Bytes bytes = Bytes (size);
if (ptr) {
memcpy (bytes.Data (), (const void*)ptr, size);
}
return bytes.Value ();
}
value lime_bytes_get_data_pointer (value bytes) {
Bytes data = Bytes (bytes);
@@ -1111,6 +1128,7 @@ namespace lime {
DEFINE_PRIM (lime_application_set_frame_rate, 2);
DEFINE_PRIM (lime_application_update, 1);
DEFINE_PRIM (lime_audio_load, 1);
DEFINE_PRIM (lime_bytes_from_data_pointer, 2);
DEFINE_PRIM (lime_bytes_get_data_pointer, 1);
DEFINE_PRIM (lime_bytes_read_file, 1);
DEFINE_PRIM (lime_font_get_ascender, 1);

View File

@@ -368,16 +368,37 @@ namespace lime {
}
value lime_cairo_image_surface_get_data (value handle) {
return alloc_float ((intptr_t)cairo_image_surface_get_data ((cairo_surface_t*)(intptr_t)val_float (handle)));
}
value lime_cairo_image_surface_get_format (value handle) {
return alloc_int ((int)cairo_image_surface_get_format ((cairo_surface_t*)(intptr_t)val_float (handle)));
}
value lime_cairo_image_surface_get_height (value handle) {
return alloc_int ((intptr_t)cairo_image_surface_get_height ((cairo_surface_t*)(intptr_t)val_float (handle)));
return alloc_int (cairo_image_surface_get_height ((cairo_surface_t*)(intptr_t)val_float (handle)));
}
value lime_cairo_image_surface_get_stride (value handle) {
return alloc_int (cairo_image_surface_get_stride ((cairo_surface_t*)(intptr_t)val_float (handle)));
}
value lime_cairo_image_surface_get_width (value handle) {
return alloc_int ((intptr_t)cairo_image_surface_get_width ((cairo_surface_t*)(intptr_t)val_float (handle)));
return alloc_int (cairo_image_surface_get_width ((cairo_surface_t*)(intptr_t)val_float (handle)));
}
@@ -993,7 +1014,10 @@ namespace lime {
DEFINE_PRIM (lime_cairo_identity_matrix, 1);
DEFINE_PRIM (lime_cairo_image_surface_create, 3);
DEFINE_PRIM (lime_cairo_image_surface_create_for_data, 5);
DEFINE_PRIM (lime_cairo_image_surface_get_data, 1);
DEFINE_PRIM (lime_cairo_image_surface_get_format, 1);
DEFINE_PRIM (lime_cairo_image_surface_get_height, 1);
DEFINE_PRIM (lime_cairo_image_surface_get_stride, 1);
DEFINE_PRIM (lime_cairo_image_surface_get_width, 1);
DEFINE_PRIM (lime_cairo_in_clip, 3);
DEFINE_PRIM (lime_cairo_in_fill, 3);