cogl: Drop cogl_texture_new_from_data

And, since this is the last public function of cogl-auto-texture.h,
drop the files entirely too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
This commit is contained in:
Georges Basile Stavracas Neto 2022-03-31 13:11:44 -03:00
parent 0b47554f74
commit 2c520f76b5
6 changed files with 40 additions and 379 deletions

View File

@ -317,12 +317,11 @@ cogl_primitive_new_with_attributes (CoglVerticesMode mode,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -371,12 +370,11 @@ cogl_primitive_new_p2 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -427,12 +425,11 @@ cogl_primitive_new_p3 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -483,12 +480,11 @@ cogl_primitive_new_p2c4 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -539,12 +535,11 @@ cogl_primitive_new_p3c4 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -595,12 +590,11 @@ cogl_primitive_new_p2t2 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -651,12 +645,11 @@ cogl_primitive_new_p3t2 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().
@ -707,12 +700,11 @@ cogl_primitive_new_p2t2c4 (CoglContext *context,
* <note>The primitive API doesn't support drawing with sliced
* textures (since switching between slices implies changing state and
* so that implies multiple primitives need to be submitted). You
* should pass the %COGL_TEXTURE_NO_SLICING flag to all textures that
* might be used while drawing with this API. If your hardware doesn't
* support non-power of two textures (For example you are using GLES
* 1.1) then you will need to make sure your assets are resized to a
* power-of-two size (though they don't have to be square)</note>
* so that implies multiple primitives need to be submitted). If your
* hardware doesn't support non-power of two textures (For example you
* are using GLES 1.1) then you will need to make sure your assets are
* resized to a power-of-two size (though they don't have to be square)
* </note>
*
* Return value: (transfer full): A newly allocated #CoglPrimitive
* with a reference of 1. This can be freed using cogl_object_unref().

View File

@ -184,30 +184,6 @@ struct _CoglTextureVertex
};
COGL_STRUCT_SIZE_ASSERT (CoglTextureVertex, 36);
/**
* CoglTextureFlags:
* @COGL_TEXTURE_NONE: No flags specified
* @COGL_TEXTURE_NO_AUTO_MIPMAP: Disables the automatic generation of
* the mipmap pyramid from the base level image whenever it is
* updated. The mipmaps are only generated when the texture is
* rendered with a mipmap filter so it should be free to leave out
* this flag when using other filtering modes
* @COGL_TEXTURE_NO_SLICING: Disables the slicing of the texture
* @COGL_TEXTURE_NO_ATLAS: Disables the insertion of the texture inside
* the texture atlas used by Cogl
*
* Flags to pass to the cogl_texture_new_* family of functions.
*
* Since: 1.0
*/
typedef enum
{
COGL_TEXTURE_NONE = 0,
COGL_TEXTURE_NO_AUTO_MIPMAP = 1 << 0,
COGL_TEXTURE_NO_SLICING = 1 << 1,
COGL_TEXTURE_NO_ATLAS = 1 << 2
} CoglTextureFlags;
/**
* COGL_BLEND_STRING_ERROR:
*

View File

@ -83,7 +83,6 @@
* they enable the experimental api... */
#include <cogl/deprecated/cogl-type-casts.h>
#include <cogl/deprecated/cogl-auto-texture.h>
#include <cogl/deprecated/cogl-shader.h>
#ifdef COGL_ENABLE_MUTTER_API

View File

@ -1,227 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2007,2008,2009,2011,2012 Intel Corporation.
* Copyright (C) 2010 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*
* Authors:
* Matthew Allum <mallum@openedhand.com>
* Neil Roberts <neil@linux.intel.com>
* Robert Bragg <robert@linux.intel.com>
*/
#include "cogl-config.h"
#include "cogl-context-private.h"
#include "cogl-texture.h"
#include "cogl-util.h"
#include "cogl-texture-2d.h"
#include "cogl-texture-2d-private.h"
#include "cogl-primitive-texture.h"
#include "cogl-texture-2d-sliced-private.h"
#include "cogl-private.h"
#include "cogl-object.h"
#include "cogl-bitmap-private.h"
#include "cogl-atlas-texture-private.h"
#include "cogl-sub-texture.h"
#include "deprecated/cogl-auto-texture.h"
static CoglTexture *
_cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
CoglTextureFlags flags,
CoglPixelFormat internal_format,
gboolean can_convert_in_place,
GError **error);
static void
set_auto_mipmap_cb (CoglTexture *sub_texture,
const float *sub_texture_coords,
const float *meta_coords,
void *user_data)
{
cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (sub_texture),
FALSE);
}
static CoglTexture *
_cogl_texture_new_from_data (CoglContext *ctx,
int width,
int height,
CoglTextureFlags flags,
CoglPixelFormat format,
CoglPixelFormat internal_format,
int rowstride,
const uint8_t *data,
GError **error)
{
CoglBitmap *bmp;
CoglTexture *tex;
g_return_val_if_fail (format != COGL_PIXEL_FORMAT_ANY, NULL);
g_return_val_if_fail (cogl_pixel_format_get_n_planes (format) == 1, NULL);
g_return_val_if_fail (data != NULL, NULL);
/* Rowstride from width if not given */
if (rowstride == 0)
rowstride = width * cogl_pixel_format_get_bytes_per_pixel (format, 0);
/* Wrap the data into a bitmap */
bmp = cogl_bitmap_new_for_data (ctx,
width, height,
format,
rowstride,
(uint8_t *) data);
tex = _cogl_texture_new_from_bitmap (bmp,
flags,
internal_format,
FALSE, /* can't convert in place */
error);
cogl_object_unref (bmp);
return tex;
}
CoglTexture *
cogl_texture_new_from_data (int width,
int height,
CoglTextureFlags flags,
CoglPixelFormat format,
CoglPixelFormat internal_format,
int rowstride,
const uint8_t *data)
{
g_autoptr (GError) error = NULL;
CoglTexture *tex;
_COGL_GET_CONTEXT (ctx, NULL);
tex = _cogl_texture_new_from_data (ctx,
width, height,
flags,
format, internal_format,
rowstride,
data,
&error);
if (!tex)
{
COGL_NOTE (TEXTURES, "Failed to create texture with size %dx%d and "
"format %s (internal: %s) from data: %s",
width, height,
cogl_pixel_format_to_string (format),
cogl_pixel_format_to_string (internal_format),
error->message);
return NULL;
}
return tex;
}
static CoglTexture *
_cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
CoglTextureFlags flags,
CoglPixelFormat internal_format,
gboolean can_convert_in_place,
GError **error)
{
CoglTexture *tex;
GError *internal_error = NULL;
if (!flags &&
!COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_ATLAS))
{
/* First try putting the texture in the atlas */
CoglAtlasTexture *atlas_tex =
_cogl_atlas_texture_new_from_bitmap (bitmap,
can_convert_in_place);
_cogl_texture_set_internal_format (COGL_TEXTURE (atlas_tex),
internal_format);
if (cogl_texture_allocate (COGL_TEXTURE (atlas_tex), &internal_error))
return COGL_TEXTURE (atlas_tex);
g_error_free (internal_error);
internal_error = NULL;
cogl_object_unref (atlas_tex);
}
/* If that doesn't work try a fast path 2D texture */
tex = COGL_TEXTURE (_cogl_texture_2d_new_from_bitmap (bitmap,
can_convert_in_place));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, &internal_error))
{
COGL_NOTE (TEXTURES,
"Failed to allocate texture from bitmap with size "
"%dx%d and format %s (internal: %s), "
"falling back on slicing: %s",
cogl_bitmap_get_width (bitmap),
cogl_bitmap_get_height (bitmap),
cogl_pixel_format_to_string (cogl_bitmap_get_format (bitmap)),
cogl_pixel_format_to_string (internal_format),
internal_error->message);
g_error_free (internal_error);
internal_error = NULL;
cogl_object_unref (tex);
tex = NULL;
}
if (!tex)
{
/* Otherwise create a sliced texture */
int max_waste = flags & COGL_TEXTURE_NO_SLICING ? -1 : COGL_TEXTURE_MAX_WASTE;
tex = COGL_TEXTURE (_cogl_texture_2d_sliced_new_from_bitmap (bitmap,
max_waste,
can_convert_in_place));
_cogl_texture_set_internal_format (tex, internal_format);
if (!cogl_texture_allocate (tex, error))
{
cogl_object_unref (tex);
tex = NULL;
}
}
if (tex &&
flags & COGL_TEXTURE_NO_AUTO_MIPMAP)
{
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (tex),
0, 0, 1, 1,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
set_auto_mipmap_cb,
NULL);
}
return tex;
}

View File

@ -1,77 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*/
#ifndef __COGL_AUTO_TEXTURE_H__
#define __COGL_AUTO_TEXTURE_H__
G_BEGIN_DECLS
#include <cogl/cogl-texture.h>
/**
* cogl_texture_new_from_data:
* @width: width of texture in pixels
* @height: height of texture in pixels
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
* @format: the #CoglPixelFormat the buffer is stored in in RAM
* @internal_format: the #CoglPixelFormat that will be used for storing
* the buffer on the GPU. If COGL_PIXEL_FORMAT_ANY is given then a
* premultiplied format similar to the format of the source data will
* be used. The default blending equations of Cogl expect premultiplied
* color data; the main use of passing a non-premultiplied format here
* is if you have non-premultiplied source data and are going to adjust
* the blend mode (see cogl_material_set_blend()) or use the data for
* something other than straight blending.
* @rowstride: the memory offset in bytes between the starts of
* scanlines in @data
* @data: (array): pointer the memory region where the source buffer resides
*
* Creates a new #CoglTexture based on data residing in memory.
*
* Return value: (transfer full): A newly created #CoglTexture or
* %NULL on failure
*
* Since: 0.8
* Deprecated: 1.18: Use specific constructors such as
* cogl_texture_2d_new_from_data()
*/
COGL_DEPRECATED_FOR (cogl_texture_2d_new_from_data__OR__cogl_texture_2d_sliced_new_from_data)
COGL_EXPORT CoglTexture *
cogl_texture_new_from_data (int width,
int height,
CoglTextureFlags flags,
CoglPixelFormat format,
CoglPixelFormat internal_format,
int rowstride,
const uint8_t *data);
G_END_DECLS
#endif /* __COGL_AUTO_TEXTURE_H__ */

View File

@ -65,7 +65,6 @@ cogl_deprecated_headers = [
'deprecated/cogl-shader.h',
'deprecated/cogl-clutter.h',
'deprecated/cogl-type-casts.h',
'deprecated/cogl-auto-texture.h',
]
cogl_headers = [
@ -349,7 +348,6 @@ cogl_sources = [
'cogl-scanout.c',
'deprecated/cogl-program.c',
'deprecated/cogl-program-private.h',
'deprecated/cogl-auto-texture.c',
'deprecated/cogl-shader-private.h',
'deprecated/cogl-shader.c',
'deprecated/cogl-clutter.c',