cogl-texture: Remove unused function

Commit d8f2f583e6 removed the only caller.
This commit is contained in:
Florian Müllner 2018-02-09 13:54:22 +01:00
parent c75eac27a8
commit 748223b896

View File

@ -542,285 +542,6 @@ cogl_texture_set_data (CoglTexture *texture,
error); error);
} }
/* Reads back the contents of a texture by rendering it to the framebuffer
* and reading back the resulting pixels.
*
* It will perform multiple renders if the texture is larger than the
* current glViewport.
*
* It assumes the projection and modelview have already been setup so
* that rendering to 0,0 with the same width and height of the viewport
* will exactly cover the viewport.
*
* NB: Normally this approach isn't normally used since we can just use
* glGetTexImage, but may be used as a fallback in some circumstances.
*/
static CoglBool
do_texture_draw_and_read (CoglFramebuffer *fb,
CoglPipeline *pipeline,
CoglTexture *texture,
CoglBitmap *target_bmp,
float *viewport,
CoglError **error)
{
float rx1, ry1;
float rx2, ry2;
float tx1, ty1;
float tx2, ty2;
int bw, bh;
CoglBitmap *rect_bmp;
unsigned int tex_width, tex_height;
CoglContext *ctx = fb->context;
tex_width = cogl_texture_get_width (texture);
tex_height = cogl_texture_get_height (texture);
ry2 = 0;
ty2 = 0;
/* Walk Y axis until whole bitmap height consumed */
for (bh = tex_height; bh > 0; bh -= viewport[3])
{
/* Rectangle Y coords */
ry1 = ry2;
ry2 += (bh < viewport[3]) ? bh : viewport[3];
/* Normalized texture Y coords */
ty1 = ty2;
ty2 = (ry2 / (float) tex_height);
rx2 = 0;
tx2 = 0;
/* Walk X axis until whole bitmap width consumed */
for (bw = tex_width; bw > 0; bw-=viewport[2])
{
int width;
int height;
/* Rectangle X coords */
rx1 = rx2;
rx2 += (bw < viewport[2]) ? bw : viewport[2];
width = rx2 - rx1;
height = ry2 - ry1;
/* Normalized texture X coords */
tx1 = tx2;
tx2 = (rx2 / (float) tex_width);
/* Draw a portion of texture */
cogl_framebuffer_draw_textured_rectangle (fb,
pipeline,
0, 0,
rx2 - rx1,
ry2 - ry1,
tx1, ty1,
tx2, ty2);
/* Read into a temporary bitmap */
rect_bmp = _cogl_bitmap_new_with_malloc_buffer
(ctx,
width, height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
error);
if (!rect_bmp)
return FALSE;
if (!_cogl_framebuffer_read_pixels_into_bitmap
(fb,
viewport[0], viewport[1],
COGL_READ_PIXELS_COLOR_BUFFER,
rect_bmp,
error))
{
cogl_object_unref (rect_bmp);
return FALSE;
}
/* Copy to target bitmap */
if (!_cogl_bitmap_copy_subregion (rect_bmp,
target_bmp,
0, 0,
rx1, ry1,
width,
height,
error))
{
cogl_object_unref (rect_bmp);
return FALSE;
}
/* Free temp bitmap */
cogl_object_unref (rect_bmp);
}
}
return TRUE;
}
/* Reads back the contents of a texture by rendering it to the framebuffer
* and reading back the resulting pixels.
*
* NB: Normally this approach isn't normally used since we can just use
* glGetTexImage, but may be used as a fallback in some circumstances.
*/
static CoglBool
_cogl_texture_draw_and_read (CoglTexture *texture,
CoglBitmap *target_bmp,
GLuint target_gl_format,
GLuint target_gl_type,
CoglError **error)
{
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglContext *ctx = framebuffer->context;
float save_viewport[4];
float viewport[4];
CoglBool status = FALSE;
viewport[0] = 0;
viewport[1] = 0;
viewport[2] = cogl_framebuffer_get_width (framebuffer);
viewport[3] = cogl_framebuffer_get_height (framebuffer);
cogl_framebuffer_get_viewport4fv (framebuffer, save_viewport);
_cogl_framebuffer_push_projection (framebuffer);
cogl_framebuffer_orthographic (framebuffer,
0, 0,
viewport[2],
viewport[3],
0, 100);
cogl_framebuffer_push_matrix (framebuffer);
cogl_framebuffer_identity_matrix (framebuffer);
/* Direct copy operation */
if (ctx->texture_download_pipeline == NULL)
{
ctx->texture_download_pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_blend (ctx->texture_download_pipeline,
"RGBA = ADD (SRC_COLOR, 0)",
NULL);
}
cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, texture);
cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
0, /* layer */
"RGBA = REPLACE (TEXTURE)",
NULL);
cogl_pipeline_set_layer_filters (ctx->texture_download_pipeline, 0,
COGL_PIPELINE_FILTER_NEAREST,
COGL_PIPELINE_FILTER_NEAREST);
if (!do_texture_draw_and_read (framebuffer,
ctx->texture_download_pipeline,
texture, target_bmp, viewport,
error))
return FALSE;
/* XXX: As an alleged PowerVR driver bug workaround where the driver
* is apparently not maintaining the alpha component of some
* framebuffers we render the alpha component of the texture
* separately to be sure we retrieve all components of the texture.
*
* TODO: verify if this is still an issue
*/
if ((_cogl_texture_get_format (texture) & COGL_A_BIT)/* && a_bits == 0*/)
{
uint8_t *srcdata;
uint8_t *dstdata;
uint8_t *srcpixel;
uint8_t *dstpixel;
int target_width = cogl_bitmap_get_width (target_bmp);
int target_height = cogl_bitmap_get_height (target_bmp);
int target_rowstride = cogl_bitmap_get_rowstride (target_bmp);
int bpp = _cogl_pixel_format_get_bytes_per_pixel (COGL_PIXEL_FORMAT_RGBA_8888);
int alpha_rowstride = bpp * target_width;
CoglBitmap *alpha_bmp;
int x,y;
if ((dstdata = _cogl_bitmap_map (target_bmp,
COGL_BUFFER_ACCESS_WRITE,
COGL_BUFFER_MAP_HINT_DISCARD,
error)) == NULL)
goto EXIT;
/* Create temp bitmap for alpha values */
alpha_bmp =
_cogl_bitmap_new_with_malloc_buffer (ctx,
target_width,
target_height,
COGL_PIXEL_FORMAT_RGBA_8888,
error);
if (!alpha_bmp)
{
_cogl_bitmap_unmap (target_bmp);
goto EXIT;
}
/* Draw alpha values into RGB channels */
cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
0, /* layer */
"RGBA = REPLACE (TEXTURE[A])",
NULL);
if (!do_texture_draw_and_read (framebuffer,
ctx->texture_download_pipeline,
texture, alpha_bmp, viewport,
error))
{
cogl_object_unref (alpha_bmp);
_cogl_bitmap_unmap (target_bmp);
goto EXIT;
}
/* Copy temp R to target A */
/* Note: we don't try to catch errors since "mapping" an
* malloc buffer should never fail */
srcdata = _cogl_bitmap_map (alpha_bmp,
COGL_BUFFER_ACCESS_READ,
0 /* hints */,
NULL);
for (y=0; y<target_height; ++y)
{
for (x=0; x<target_width; ++x)
{
srcpixel = srcdata + x*bpp;
dstpixel = dstdata + x*bpp;
dstpixel[3] = srcpixel[0];
}
srcdata += alpha_rowstride;
dstdata += target_rowstride;
}
_cogl_bitmap_unmap (alpha_bmp);
_cogl_bitmap_unmap (target_bmp);
cogl_object_unref (alpha_bmp);
}
status = TRUE;
EXIT:
/* Restore old state */
cogl_framebuffer_pop_matrix (framebuffer);
_cogl_framebuffer_pop_projection (framebuffer);
cogl_framebuffer_set_viewport (framebuffer,
save_viewport[0],
save_viewport[1],
save_viewport[2],
save_viewport[3]);
return status;
}
static CoglBool static CoglBool
get_texture_bits_via_offscreen (CoglTexture *meta_texture, get_texture_bits_via_offscreen (CoglTexture *meta_texture,
CoglTexture *sub_texture, CoglTexture *sub_texture,