From c02dded0f6793ad377b566360371c23dbe61b4bc Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Mon, 8 Feb 2010 17:11:43 +0000 Subject: [PATCH] cogl-buffer: Use TEXTURE as the only value for CoglBufferUsageHint We should try to use more explicit defines than GL for our hints. For now we only support using a CoglBuffer to generate textures. --- clutter/cogl/cogl/cogl-buffer.c | 38 ++++++-------------------- clutter/cogl/cogl/cogl-buffer.h | 12 ++------ clutter/cogl/cogl/cogl-pixel-buffer.c | 2 +- tests/conform/test-cogl-pixel-buffer.c | 12 ++++---- 4 files changed, 19 insertions(+), 45 deletions(-) diff --git a/clutter/cogl/cogl/cogl-buffer.c b/clutter/cogl/cogl/cogl-buffer.c index 954c44bbe..49374706f 100644 --- a/clutter/cogl/cogl/cogl-buffer.c +++ b/clutter/cogl/cogl/cogl-buffer.c @@ -147,33 +147,13 @@ GLenum _cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint, CoglBufferUpdateHint update_hint) { - if (usage_hint == COGL_BUFFER_USAGE_HINT_DRAW) - { - if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC) - return GL_STATIC_DRAW; - if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC) - return GL_DYNAMIC_DRAW; - if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM) - return GL_STREAM_DRAW; - } - if (usage_hint == COGL_BUFFER_USAGE_HINT_READ) - { - if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC) - return GL_STATIC_READ; - if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC) - return GL_DYNAMIC_READ; - if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM) - return GL_STREAM_READ; - } - if (usage_hint == COGL_BUFFER_USAGE_HINT_COPY) - { - if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC) - return GL_STATIC_COPY; - if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC) - return GL_DYNAMIC_COPY; - if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM) - return GL_STREAM_COPY; - } + /* usage hint is always TEXTURE for now */ + if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC) + return GL_STATIC_DRAW; + if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC) + return GL_DYNAMIC_DRAW; + if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM) + return GL_STREAM_DRAW; return GL_STATIC_DRAW; } @@ -219,8 +199,8 @@ cogl_buffer_set_usage_hint_EXP (CoglHandle handle, if (!cogl_is_buffer (handle)) return; - if (G_UNLIKELY (hint > COGL_BUFFER_USAGE_HINT_COPY)) - hint = COGL_BUFFER_USAGE_HINT_DRAW; + if (G_UNLIKELY (hint > COGL_BUFFER_USAGE_HINT_TEXTURE)) + hint = COGL_BUFFER_USAGE_HINT_TEXTURE; COGL_BUFFER (handle)->usage_hint = hint; } diff --git a/clutter/cogl/cogl/cogl-buffer.h b/clutter/cogl/cogl/cogl-buffer.h index c4f025426..ddad4bc31 100644 --- a/clutter/cogl/cogl/cogl-buffer.h +++ b/clutter/cogl/cogl/cogl-buffer.h @@ -75,12 +75,8 @@ cogl_buffer_get_size (CoglHandle handle); /** * CoglBufferUsageHint: - * @COGL_BUFFER_USAGE_HINT_DRAW: the buffer will be used as a source for - * drawing commands (e.g. texture), the data coming from the application - * @COGL_BUFFER_USAGE_HINT_READ: the buffer will be read by the application, - * the data store being modified by the GPU - * @COGL_BUFFER_USAGE_HINT_COPY: the buffer will be used as a source for - * drawing commands, the data coming from the GPU + * @COGL_BUFFER_USAGE_HINT_TEXTURE: the buffer will be used as a source data + * for a texture * * The usage hint on a buffer allows the user to give some clue on how the * buffer will be used. @@ -89,9 +85,7 @@ cogl_buffer_get_size (CoglHandle handle); * Stability: Unstable */ typedef enum { /*< prefix=COGL_BUFFER_USAGE_HINT >*/ - COGL_BUFFER_USAGE_HINT_DRAW, - COGL_BUFFER_USAGE_HINT_READ, - COGL_BUFFER_USAGE_HINT_COPY, + COGL_BUFFER_USAGE_HINT_TEXTURE, } CoglBufferUsageHint; /** diff --git a/clutter/cogl/cogl/cogl-pixel-buffer.c b/clutter/cogl/cogl/cogl-pixel-buffer.c index 69eac9c4a..4ee739814 100644 --- a/clutter/cogl/cogl/cogl-pixel-buffer.c +++ b/clutter/cogl/cogl/cogl-pixel-buffer.c @@ -148,7 +148,7 @@ cogl_pixel_buffer_new_EXP (guint size) /* parent's constructor */ _cogl_buffer_initialize (buffer, size, - COGL_BUFFER_USAGE_HINT_DRAW, + COGL_BUFFER_USAGE_HINT_TEXTURE, COGL_BUFFER_UPDATE_HINT_STATIC); /* malloc version only for GLES */ diff --git a/tests/conform/test-cogl-pixel-buffer.c b/tests/conform/test-cogl-pixel-buffer.c index 04bf07a38..cc4c28943 100644 --- a/tests/conform/test-cogl-pixel-buffer.c +++ b/tests/conform/test-cogl-pixel-buffer.c @@ -72,10 +72,10 @@ create_map_tile (TestTile *tile) g_assert (cogl_is_buffer (buffer)); /* while at it, set/get the hints */ - cogl_buffer_set_usage_hint (buffer, COGL_BUFFER_USAGE_HINT_DRAW); + cogl_buffer_set_usage_hint (buffer, COGL_BUFFER_USAGE_HINT_TEXTURE); g_assert_cmpint (cogl_buffer_get_usage_hint (buffer), ==, - COGL_BUFFER_USAGE_HINT_DRAW); + COGL_BUFFER_USAGE_HINT_TEXTURE); cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_DYNAMIC); g_assert_cmpint (cogl_buffer_get_update_hint (buffer), ==, @@ -112,8 +112,8 @@ create_set_region_tile (TestTile *tile) g_assert (cogl_is_buffer (buffer)); /* while at it, set/get the hint */ - cogl_buffer_set_hint (buffer, COGL_BUFFER_HINT_STATIC_DRAW); - g_assert (cogl_buffer_get_hint (buffer) == COGL_BUFFER_HINT_STATIC_DRAW); + cogl_buffer_set_hint (buffer, COGL_BUFFER_HINT_STATIC_TEXTURE); + g_assert (cogl_buffer_get_hint (buffer) == COGL_BUFFER_HINT_STATIC_TEXTURE); data = g_malloc (TILE_SIZE * TILE_SIZE * 4); /* create a buffer with the data we want to copy to the buffer */ @@ -161,10 +161,10 @@ create_set_data_tile (TestTile *tile) g_assert_cmpint (cogl_buffer_get_size (buffer), ==, rowstride * TILE_SIZE); /* while at it, set/get the hint */ - cogl_buffer_set_usage_hint (buffer, COGL_BUFFER_USAGE_HINT_DRAW); + cogl_buffer_set_usage_hint (buffer, COGL_BUFFER_USAGE_HINT_TEXTURE); g_assert_cmpint (cogl_buffer_get_usage_hint (buffer), ==, - COGL_BUFFER_USAGE_HINT_DRAW); + COGL_BUFFER_USAGE_HINT_TEXTURE); /* create a buffer with the data we want to copy to the buffer */ data = g_malloc (TILE_SIZE * TILE_SIZE * 4);