diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c index 3b87d4ce1..986707f42 100644 --- a/cogl/cogl-atlas-texture.c +++ b/cogl/cogl-atlas-texture.c @@ -437,52 +437,52 @@ _cogl_atlas_texture_set_region_with_border (CoglAtlasTexture *atlas_tex, CoglAtlas *atlas = atlas_tex->atlas; /* Copy the central data */ - if (!_cogl_texture_set_region_from_bitmap (atlas->texture, - src_x, src_y, - dst_x + atlas_tex->rectangle.x + 1, - dst_y + atlas_tex->rectangle.y + 1, - dst_width, - dst_height, - bmp)) + if (!cogl_texture_set_region_from_bitmap (atlas->texture, + src_x, src_y, + dst_x + atlas_tex->rectangle.x + 1, + dst_y + atlas_tex->rectangle.y + 1, + dst_width, + dst_height, + bmp)) return FALSE; /* Update the left edge pixels */ if (dst_x == 0 && - !_cogl_texture_set_region_from_bitmap (atlas->texture, - src_x, src_y, - atlas_tex->rectangle.x, - dst_y + atlas_tex->rectangle.y + 1, - 1, dst_height, - bmp)) + !cogl_texture_set_region_from_bitmap (atlas->texture, + src_x, src_y, + atlas_tex->rectangle.x, + dst_y + atlas_tex->rectangle.y + 1, + 1, dst_height, + bmp)) return FALSE; /* Update the right edge pixels */ if (dst_x + dst_width == atlas_tex->rectangle.width - 2 && - !_cogl_texture_set_region_from_bitmap (atlas->texture, - src_x + dst_width - 1, src_y, - atlas_tex->rectangle.x + - atlas_tex->rectangle.width - 1, - dst_y + atlas_tex->rectangle.y + 1, - 1, dst_height, - bmp)) + !cogl_texture_set_region_from_bitmap (atlas->texture, + src_x + dst_width - 1, src_y, + atlas_tex->rectangle.x + + atlas_tex->rectangle.width - 1, + dst_y + atlas_tex->rectangle.y + 1, + 1, dst_height, + bmp)) return FALSE; /* Update the top edge pixels */ if (dst_y == 0 && - !_cogl_texture_set_region_from_bitmap (atlas->texture, - src_x, src_y, - dst_x + atlas_tex->rectangle.x + 1, - atlas_tex->rectangle.y, - dst_width, 1, - bmp)) + !cogl_texture_set_region_from_bitmap (atlas->texture, + src_x, src_y, + dst_x + atlas_tex->rectangle.x + 1, + atlas_tex->rectangle.y, + dst_width, 1, + bmp)) return FALSE; /* Update the bottom edge pixels */ if (dst_y + dst_height == atlas_tex->rectangle.height - 2 && - !_cogl_texture_set_region_from_bitmap (atlas->texture, - src_x, src_y + dst_height - 1, - dst_x + atlas_tex->rectangle.x + 1, - atlas_tex->rectangle.y + - atlas_tex->rectangle.height - 1, - dst_width, 1, - bmp)) + !cogl_texture_set_region_from_bitmap (atlas->texture, + src_x, src_y + dst_height - 1, + dst_x + atlas_tex->rectangle.x + 1, + atlas_tex->rectangle.y + + atlas_tex->rectangle.height - 1, + dst_width, 1, + bmp)) return FALSE; return TRUE; @@ -526,11 +526,11 @@ _cogl_atlas_texture_set_region (CoglTexture *tex, } else /* Otherwise we can just forward on to the sub texture */ - return _cogl_texture_set_region_from_bitmap (atlas_tex->sub_texture, - src_x, src_y, - dst_x, dst_y, - dst_width, dst_height, - bmp); + return cogl_texture_set_region_from_bitmap (atlas_tex->sub_texture, + src_x, src_y, + dst_x, dst_y, + dst_width, dst_height, + bmp); } static CoglPixelFormat diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h index 3df519f91..78962bf0d 100644 --- a/cogl/cogl-bitmap-private.h +++ b/cogl/cogl-bitmap-private.h @@ -83,17 +83,6 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp, int height, int rowstride); -/* This creates a cogl bitmap that internally references a pixel - array. The data is not copied. _cogl_bitmap_map will divert to - mapping the pixel array */ -CoglBitmap * -_cogl_bitmap_new_from_buffer (CoglBuffer *buffer, - CoglPixelFormat format, - int width, - int height, - int rowstride, - int offset); - gboolean _cogl_bitmap_can_convert (CoglPixelFormat src, CoglPixelFormat dst); diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index 88ad073b9..781e6f8d1 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -327,12 +327,12 @@ cogl_bitmap_new_from_file (const char *filename, } CoglBitmap * -_cogl_bitmap_new_from_buffer (CoglBuffer *buffer, - CoglPixelFormat format, - int width, - int height, - int rowstride, - int offset) +cogl_bitmap_new_from_buffer (CoglBuffer *buffer, + CoglPixelFormat format, + int width, + int height, + int rowstride, + int offset) { CoglBitmap *bmp; diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h index 1983802b2..958327d78 100644 --- a/cogl/cogl-bitmap.h +++ b/cogl/cogl-bitmap.h @@ -29,6 +29,7 @@ #define __COGL_BITMAP_H__ #include +#include G_BEGIN_DECLS @@ -62,6 +63,37 @@ CoglBitmap * cogl_bitmap_new_from_file (const char *filename, GError **error); +#if defined (COGL_ENABLE_EXPERIMENTAL_API) + +#define cogl_bitmap_new_from_buffer cogl_bitmap_new_from_buffer_EXP +/** + * cogl_bitmap_new_from_buffer: + * @buffer: A #CoglBuffer containing image data + * @format: The #CoglPixelFormat defining the format of the image data + * in the given @buffer. + * @width: The width of the image data in the given @buffer. + * @height: The height of the image data in the given @buffer. + * @rowstride: The rowstride in bytes of the image data in the given @buffer. + * @offset: The offset into the given @buffer to the first pixel that + * should be considered part of the #CoglBitmap. + * + * Wraps some image data that has been uploaded into a #CoglBuffer as + * a #CoglBitmap. The data is not copied in this process. + * + * Return value: a #CoglBitmap encapsulating the given @buffer. + * + * Since: 1.8 + * Stability: unstable + */ +CoglBitmap * +cogl_bitmap_new_from_buffer (CoglBuffer *buffer, + CoglPixelFormat format, + int width, + int height, + int rowstride, + int offset); +#endif + /** * cogl_bitmap_get_size_from_file: * @filename: the file to check diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c index d00dcd5bb..933a325b9 100644 --- a/cogl/cogl-sub-texture.c +++ b/cogl/cogl-sub-texture.c @@ -409,12 +409,12 @@ _cogl_sub_texture_set_region (CoglTexture *tex, { CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex); - return _cogl_texture_set_region_from_bitmap (sub_tex->full_texture, - src_x, src_y, - dst_x + sub_tex->sub_x, - dst_y + sub_tex->sub_y, - dst_width, dst_height, - bmp); + return cogl_texture_set_region_from_bitmap (sub_tex->full_texture, + src_x, src_y, + dst_x + sub_tex->sub_x, + dst_y + sub_tex->sub_y, + dst_width, dst_height, + bmp); } static CoglPixelFormat diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c index 9f516e4e7..0775277c4 100644 --- a/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl-texture-2d-sliced.c @@ -318,18 +318,18 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds, NULL, NULL); - _cogl_texture_set_region_from_bitmap (slice_tex, - 0, /* src_x */ - 0, /* src_y */ - /* dst_x */ - x_span->size - x_span->waste, - y_iter->intersect_start - - y_span->start, /* dst_y */ - x_span->waste, /* dst_width */ - /* dst_height */ - y_iter->intersect_end - - y_iter->intersect_start, - waste_bmp); + cogl_texture_set_region_from_bitmap (slice_tex, + 0, /* src_x */ + 0, /* src_y */ + /* dst_x */ + x_span->size - x_span->waste, + y_iter->intersect_start - + y_span->start, /* dst_y */ + x_span->waste, /* dst_width */ + /* dst_height */ + y_iter->intersect_end - + y_iter->intersect_start, + waste_bmp); cogl_object_unref (waste_bmp); } @@ -374,17 +374,17 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds, NULL, NULL); - _cogl_texture_set_region_from_bitmap (slice_tex, - 0, /* src_x */ - 0, /* src_y */ - /* dst_x */ - x_iter->intersect_start - - x_iter->pos, - /* dst_y */ - y_span->size - y_span->waste, - copy_width, /* dst_width */ - y_span->waste, /* dst_height */ - waste_bmp); + cogl_texture_set_region_from_bitmap (slice_tex, + 0, /* src_x */ + 0, /* src_y */ + /* dst_x */ + x_iter->intersect_start - + x_iter->pos, + /* dst_y */ + y_span->size - y_span->waste, + copy_width, /* dst_width */ + y_span->waste, /* dst_height */ + waste_bmp); cogl_object_unref (waste_bmp); } @@ -426,16 +426,16 @@ _cogl_texture_2d_sliced_upload_to_gl (CoglTexture2DSliced *tex_2ds, slice_tex = g_array_index (tex_2ds->slice_textures, CoglHandle, slice_num); - _cogl_texture_set_region_from_bitmap (slice_tex, - x_span->start, /* src x */ - y_span->start, /* src y */ - 0, /* dst x */ - 0, /* dst y */ - x_span->size - - x_span->waste, /* width */ - y_span->size - - y_span->waste, /* height */ - bmp); + cogl_texture_set_region_from_bitmap (slice_tex, + x_span->start, /* src x */ + y_span->start, /* src y */ + 0, /* dst x */ + 0, /* dst y */ + x_span->size - + x_span->waste, /* width */ + y_span->size - + y_span->waste, /* height */ + bmp); /* Set up a fake iterator that covers the whole slice */ x_iter.intersect_start = x_span->start; @@ -559,14 +559,14 @@ _cogl_texture_2d_sliced_upload_subregion_to_gl (CoglTexture2DSliced *tex_2ds, slice_tex = g_array_index (tex_2ds->slice_textures, CoglHandle, slice_num); - _cogl_texture_set_region_from_bitmap (slice_tex, - source_x, - source_y, - local_x, /* dst x */ - local_y, /* dst y */ - inter_w, /* width */ - inter_h, /* height */ - source_bmp); + cogl_texture_set_region_from_bitmap (slice_tex, + source_x, + source_y, + local_x, /* dst x */ + local_y, /* dst y */ + inter_w, /* width */ + inter_h, /* height */ + source_bmp); _cogl_texture_2d_sliced_set_waste (tex_2ds, source_bmp, diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h index fa0d57917..767069a4e 100644 --- a/cogl/cogl-texture-private.h +++ b/cogl/cogl-texture-private.h @@ -280,16 +280,6 @@ _cogl_texture_draw_and_read (CoglHandle handle, gboolean _cogl_texture_is_foreign (CoglHandle handle); -gboolean -_cogl_texture_set_region_from_bitmap (CoglHandle handle, - int src_x, - int src_y, - int dst_x, - int dst_y, - unsigned int dst_width, - unsigned int dst_height, - CoglBitmap *bmp); - void _cogl_texture_associate_framebuffer (CoglHandle handle, CoglFramebuffer *framebuffer); diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index 134e5f5b8..165811f9e 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -627,11 +627,11 @@ cogl_texture_new_from_buffer_EXP (CoglHandle buffer, } /* Wrap the buffer into a bitmap */ - bmp = _cogl_bitmap_new_from_buffer (cogl_buffer, - format, - width, height, - rowstride, - offset); + bmp = cogl_bitmap_new_from_buffer (cogl_buffer, + format, + width, height, + rowstride, + offset); texture = cogl_texture_new_from_bitmap (bmp, flags, internal_format); @@ -852,14 +852,14 @@ _cogl_texture_ensure_non_quad_rendering (CoglHandle handle) } gboolean -_cogl_texture_set_region_from_bitmap (CoglHandle handle, - int src_x, - int src_y, - int dst_x, - int dst_y, - unsigned int dst_width, - unsigned int dst_height, - CoglBitmap *bmp) +cogl_texture_set_region_from_bitmap (CoglHandle handle, + int src_x, + int src_y, + int dst_x, + int dst_y, + unsigned int dst_width, + unsigned int dst_height, + CoglBitmap *bmp) { CoglTexture *tex = COGL_TEXTURE (handle); GLenum closest_gl_format; @@ -924,11 +924,11 @@ cogl_texture_set_region (CoglHandle handle, NULL, /* destroy_fn */ NULL); /* destroy_fn_data */ - ret = _cogl_texture_set_region_from_bitmap (handle, - src_x, src_y, - dst_x, dst_y, - dst_width, dst_height, - source_bmp); + ret = cogl_texture_set_region_from_bitmap (handle, + src_x, src_y, + dst_x, dst_y, + dst_width, dst_height, + source_bmp); cogl_object_unref (source_bmp); diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h index 93c1c3cb0..41e6ee487 100644 --- a/cogl/cogl-texture.h +++ b/cogl/cogl-texture.h @@ -367,6 +367,41 @@ cogl_texture_set_region (CoglHandle handle, unsigned int rowstride, const guint8 *data); +#if defined (COGL_ENABLE_EXPERIMENTAL_API) + +#define cogl_texture_set_region_from_bitmap \ + cogl_texture_set_region_from_bitmap_EXP +/** + * cogl_texture_set_region_from_bitmap: + * @handle: a #CoglHandle for a texture + * @src_x: upper left coordinate to use from the source bitmap. + * @src_y: upper left coordinate to use from the source bitmap + * @dst_x: upper left destination horizontal coordinate. + * @dst_y: upper left destination vertical coordinate. + * @dst_width: width of destination region to write. + * @dst_height: height of destination region to write. + * @bitmap: The source bitmap to read from + * + * Copies a specified source region from @bitmap to the position + * (@src_x, @src_y) of the given destination texture @handle. + * + * Return value: %TRUE if the subregion upload was successful, and + * %FALSE otherwise + * + * Since: 1.8 + * Stability: unstable + */ +gboolean +cogl_texture_set_region_from_bitmap (CoglHandle handle, + int src_x, + int src_y, + int dst_x, + int dst_y, + unsigned int dst_width, + unsigned int dst_height, + CoglBitmap *bitmap); +#endif + /** * cogl_texture_new_from_sub_texture: * @full_texture: a #CoglHandle to an existing texture