diff --git a/cogl/cogl/cogl-clip-stack.c b/cogl/cogl/cogl-clip-stack.c index 96eb105a0..aa3172e2e 100644 --- a/cogl/cogl/cogl-clip-stack.c +++ b/cogl/cogl/cogl-clip-stack.c @@ -36,7 +36,6 @@ #include #include "cogl-clip-stack.h" -#include "cogl-primitives.h" #include "cogl-context-private.h" #include "cogl-framebuffer-private.h" #include "cogl-journal-private.h" diff --git a/cogl/cogl/cogl-context-private.h b/cogl/cogl/cogl-context-private.h index 112b0b211..4b7567c37 100644 --- a/cogl/cogl/cogl-context-private.h +++ b/cogl/cogl/cogl-context-private.h @@ -39,7 +39,6 @@ #endif #include "cogl-display-private.h" -#include "cogl-primitives.h" #include "cogl-clip-stack.h" #include "cogl-matrix-stack.h" #include "cogl-pipeline-private.h" diff --git a/cogl/cogl/cogl-primitives.c b/cogl/cogl/cogl-primitives.c index 5b0aa2eec..9636d60c5 100644 --- a/cogl/cogl/cogl-primitives.c +++ b/cogl/cogl/cogl-primitives.c @@ -720,136 +720,6 @@ _cogl_framebuffer_draw_multitextured_rectangles ( cogl_object_unref (pipeline); } -static void -_cogl_rectangles_with_multitexture_coords ( - CoglMultiTexturedRect *rects, - int n_rects) -{ - _cogl_framebuffer_draw_multitextured_rectangles (cogl_get_draw_framebuffer (), - cogl_get_source (), - rects, - n_rects, - FALSE); -} - -void -cogl_rectangles (const float *verts, - unsigned int n_rects) -{ - CoglMultiTexturedRect *rects; - int i; - - /* XXX: All the cogl_rectangle* APIs normalize their input into an array of - * CoglMultiTexturedRect rectangles and pass these on to our work horse; - * _cogl_rectangles_with_multitexture_coords. - */ - - rects = g_alloca (n_rects * sizeof (CoglMultiTexturedRect)); - - for (i = 0; i < n_rects; i++) - { - rects[i].position = &verts[i * 4]; - rects[i].tex_coords = NULL; - rects[i].tex_coords_len = 0; - } - - _cogl_rectangles_with_multitexture_coords (rects, n_rects); -} - -void -cogl_rectangles_with_texture_coords (const float *verts, - unsigned int n_rects) -{ - CoglMultiTexturedRect *rects; - int i; - - /* XXX: All the cogl_rectangle* APIs normalize their input into an array of - * CoglMultiTexturedRect rectangles and pass these on to our work horse; - * _cogl_rectangles_with_multitexture_coords. - */ - - rects = g_alloca (n_rects * sizeof (CoglMultiTexturedRect)); - - for (i = 0; i < n_rects; i++) - { - rects[i].position = &verts[i * 8]; - rects[i].tex_coords = &verts[i * 8 + 4]; - rects[i].tex_coords_len = 4; - } - - _cogl_rectangles_with_multitexture_coords (rects, n_rects); -} - -void -cogl_rectangle_with_texture_coords (float x_1, - float y_1, - float x_2, - float y_2, - float tx_1, - float ty_1, - float tx_2, - float ty_2) -{ - const float position[4] = {x_1, y_1, x_2, y_2}; - const float tex_coords[4] = {tx_1, ty_1, tx_2, ty_2}; - CoglMultiTexturedRect rect; - - /* XXX: All the cogl_rectangle* APIs normalize their input into an array of - * CoglMultiTexturedRect rectangles and pass these on to our work horse; - * _cogl_rectangles_with_multitexture_coords. - */ - - rect.position = position; - rect.tex_coords = tex_coords; - rect.tex_coords_len = 4; - - _cogl_rectangles_with_multitexture_coords (&rect, 1); -} - -void -cogl_rectangle_with_multitexture_coords (float x_1, - float y_1, - float x_2, - float y_2, - const float *user_tex_coords, - int user_tex_coords_len) -{ - const float position[4] = {x_1, y_1, x_2, y_2}; - CoglMultiTexturedRect rect; - - /* XXX: All the cogl_rectangle* APIs normalize their input into an array of - * CoglMultiTexturedRect rectangles and pass these on to our work horse; - * _cogl_rectangles_with_multitexture_coords. - */ - - rect.position = position; - rect.tex_coords = user_tex_coords; - rect.tex_coords_len = user_tex_coords_len; - - _cogl_rectangles_with_multitexture_coords (&rect, 1); -} - -void -cogl_rectangle (float x_1, - float y_1, - float x_2, - float y_2) -{ - const float position[4] = {x_1, y_1, x_2, y_2}; - CoglMultiTexturedRect rect; - - /* XXX: All the cogl_rectangle* APIs normalize their input into an array of - * CoglMultiTexturedRect rectangles and pass these on to our work horse; - * _cogl_rectangles_with_multitexture_coords. - */ - - rect.position = position; - rect.tex_coords = NULL; - rect.tex_coords_len = 0; - - _cogl_rectangles_with_multitexture_coords (&rect, 1); -} - void _cogl_rectangle_immediate (CoglFramebuffer *framebuffer, CoglPipeline *pipeline, @@ -898,243 +768,3 @@ _cogl_rectangle_immediate (CoglFramebuffer *framebuffer, cogl_object_unref (attributes[0]); cogl_object_unref (attribute_buffer); } - -typedef struct _AppendTexCoordsState -{ - const CoglTextureVertex *vertices_in; - int vertex; - int layer; - float *vertices_out; -} AppendTexCoordsState; - -static gboolean -append_tex_coord_attributes_cb (CoglPipeline *pipeline, - int layer_index, - void *user_data) -{ - AppendTexCoordsState *state = user_data; - CoglTexture *texture; - float tx, ty; - float *t; - - tx = state->vertices_in[state->vertex].tx; - ty = state->vertices_in[state->vertex].ty; - - /* NULL textures will be handled in - * _cogl_pipeline_flush_layers_gl_state but there is no need to worry - * about scaling texture coordinates in this case */ - texture = cogl_pipeline_get_layer_texture (pipeline, layer_index); - if (texture != NULL) - _cogl_texture_transform_coords_to_gl (texture, &tx, &ty); - - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - t = state->vertices_out + 3 + 2 * state->layer; - t[0] = tx; - t[1] = ty; - - state->layer++; - - return TRUE; -} - -typedef struct _ValidateState -{ - CoglPipeline *original_pipeline; - CoglPipeline *pipeline; -} ValidateState; - -static gboolean -_cogl_polygon_validate_layer_cb (CoglPipeline *pipeline, - int layer_index, - void *user_data) -{ - ValidateState *state = user_data; - - /* By default COGL_PIPELINE_WRAP_MODE_AUTOMATIC becomes - * GL_CLAMP_TO_EDGE but we want the polygon API to use GL_REPEAT to - * maintain compatibility with previous releases - */ - - if (cogl_pipeline_get_layer_wrap_mode_s (pipeline, layer_index) == - COGL_PIPELINE_WRAP_MODE_AUTOMATIC) - { - if (state->original_pipeline == state->pipeline) - state->pipeline = cogl_pipeline_copy (pipeline); - - cogl_pipeline_set_layer_wrap_mode_s (state->pipeline, layer_index, - COGL_PIPELINE_WRAP_MODE_REPEAT); - } - - if (cogl_pipeline_get_layer_wrap_mode_t (pipeline, layer_index) == - COGL_PIPELINE_WRAP_MODE_AUTOMATIC) - { - if (state->original_pipeline == state->pipeline) - state->pipeline = cogl_pipeline_copy (pipeline); - - cogl_pipeline_set_layer_wrap_mode_t (state->pipeline, layer_index, - COGL_PIPELINE_WRAP_MODE_REPEAT); - } - - return TRUE; -} - -void -cogl_polygon (const CoglTextureVertex *vertices, - unsigned int n_vertices, - gboolean use_color) -{ - CoglPipeline *pipeline; - ValidateState validate_state; - int n_layers; - int n_attributes; - CoglAttribute **attributes; - int i; - unsigned int stride; - size_t stride_bytes; - CoglAttributeBuffer *attribute_buffer; - float *v; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - pipeline = cogl_get_source (); - - validate_state.original_pipeline = pipeline; - validate_state.pipeline = pipeline; - cogl_pipeline_foreach_layer (pipeline, - _cogl_polygon_validate_layer_cb, - &validate_state); - pipeline = validate_state.pipeline; - - n_layers = cogl_pipeline_get_n_layers (pipeline); - - n_attributes = 1 + n_layers + (use_color ? 1 : 0); - attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes); - - /* Our data is arranged like: - * [X, Y, Z, TX0, TY0, TX1, TY1..., R, G, B, A,...] */ - stride = 3 + (2 * n_layers) + (use_color ? 1 : 0); - stride_bytes = stride * sizeof (float); - - /* Make sure there is enough space in the global vertex array. This - * is used so we can render the polygon with a single call to OpenGL - * but still support any number of vertices */ - g_array_set_size (ctx->polygon_vertices, n_vertices * stride); - - attribute_buffer = - cogl_attribute_buffer_new (ctx, n_vertices * stride_bytes, NULL); - - attributes[0] = cogl_attribute_new (attribute_buffer, - "cogl_position_in", - stride_bytes, - 0, - 3, - COGL_ATTRIBUTE_TYPE_FLOAT); - - for (i = 0; i < n_layers; i++) - { - static const char *names[] = { - "cogl_tex_coord0_in", - "cogl_tex_coord1_in", - "cogl_tex_coord2_in", - "cogl_tex_coord3_in", - "cogl_tex_coord4_in", - "cogl_tex_coord5_in", - "cogl_tex_coord6_in", - "cogl_tex_coord7_in" - }; - char *allocated_name = NULL; - const char *name; - - if (i < 8) - name = names[i]; - else - name = allocated_name = g_strdup_printf ("cogl_tex_coord%d_in", i); - - attributes[i + 1] = cogl_attribute_new (attribute_buffer, - name, - stride_bytes, - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - 12 + 8 * i, - 2, - COGL_ATTRIBUTE_TYPE_FLOAT); - - g_free (allocated_name); - } - - if (use_color) - { - attributes[n_attributes - 1] = - cogl_attribute_new (attribute_buffer, - "cogl_color_in", - stride_bytes, - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - 12 + 8 * n_layers, - 4, - COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); - } - - /* Convert the vertices into an array of float vertex attributes */ - v = (float *)ctx->polygon_vertices->data; - for (i = 0; i < n_vertices; i++) - { - AppendTexCoordsState append_tex_coords_state; - uint8_t *c; - - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - v[0] = vertices[i].x; - v[1] = vertices[i].y; - v[2] = vertices[i].z; - - append_tex_coords_state.vertices_in = vertices; - append_tex_coords_state.vertex = i; - append_tex_coords_state.layer = 0; - append_tex_coords_state.vertices_out = v; - cogl_pipeline_foreach_layer (pipeline, - append_tex_coord_attributes_cb, - &append_tex_coords_state); - - if (use_color) - { - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - c = (uint8_t *) (v + 3 + 2 * n_layers); - c[0] = cogl_color_get_red_byte (&vertices[i].color); - c[1] = cogl_color_get_green_byte (&vertices[i].color); - c[2] = cogl_color_get_blue_byte (&vertices[i].color); - c[3] = cogl_color_get_alpha_byte (&vertices[i].color); - } - - v += stride; - } - - v = (float *)ctx->polygon_vertices->data; - cogl_buffer_set_data (COGL_BUFFER (attribute_buffer), - 0, - v, - ctx->polygon_vertices->len * sizeof (float)); - - /* XXX: although this may seem redundant, we need to do this since - * cogl_polygon() can be used with legacy state and its the source stack - * which track whether legacy state is enabled. - * - * (We only have a CoglDrawFlag to disable legacy state not one - * to enable it) */ - cogl_push_source (pipeline); - - _cogl_framebuffer_draw_attributes (cogl_get_draw_framebuffer (), - pipeline, - COGL_VERTICES_MODE_TRIANGLE_FAN, - 0, n_vertices, - attributes, - n_attributes, - 0 /* no draw flags */); - - cogl_pop_source (); - - if (pipeline != validate_state.original_pipeline) - cogl_object_unref (pipeline); - - cogl_object_unref (attribute_buffer); - - for (i = 0; i < n_attributes; i++) - cogl_object_unref (attributes[i]); -} diff --git a/cogl/cogl/cogl-primitives.h b/cogl/cogl/cogl-primitives.h deleted file mode 100644 index 60e0f4c68..000000000 --- a/cogl/cogl/cogl-primitives.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2007,2008,2009 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_PRIMITIVES_H -#define __COGL_PRIMITIVES_H - -#include - -G_BEGIN_DECLS - -/** - * SECTION:cogl-primitives - * @short_description: Functions that draw various primitive 3D shapes - * - * The primitives API provides utilities for drawing some - * common 3D shapes. - */ - -/** - * cogl_rectangle: - * @x_1: X coordinate of the top-left corner - * @y_1: Y coordinate of the top-left corner - * @x_2: X coordinate of the bottom-right corner - * @y_2: Y coordinate of the bottom-right corner - * - * Fills a rectangle at the given coordinates with the current source material - **/ -void -cogl_rectangle (float x_1, - float y_1, - float x_2, - float y_2); - -/** - * cogl_rectangle_with_texture_coords: - * @x1: x coordinate upper left on screen. - * @y1: y coordinate upper left on screen. - * @x2: x coordinate lower right on screen. - * @y2: y coordinate lower right on screen. - * @tx1: x part of texture coordinate to use for upper left pixel - * @ty1: y part of texture coordinate to use for upper left pixel - * @tx2: x part of texture coordinate to use for lower right pixel - * @ty2: y part of texture coordinate to use for left pixel - * - * Draw a rectangle using the current material and supply texture coordinates - * to be used for the first texture layer of the material. To draw the entire - * texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0. - * - * Since: 1.0 - */ -void -cogl_rectangle_with_texture_coords (float x1, - float y1, - float x2, - float y2, - float tx1, - float ty1, - float tx2, - float ty2); - -/** - * cogl_rectangle_with_multitexture_coords: - * @x1: x coordinate upper left on screen. - * @y1: y coordinate upper left on screen. - * @x2: x coordinate lower right on screen. - * @y2: y coordinate lower right on screen. - * @tex_coords: (in) (array) (transfer none): An array containing groups of - * 4 float values: [tx1, ty1, tx2, ty2] that are interpreted as two texture - * coordinates; one for the upper left texel, and one for the lower right - * texel. Each value should be between 0.0 and 1.0, where the coordinate - * (0.0, 0.0) represents the top left of the texture, and (1.0, 1.0) the - * bottom right. - * @tex_coords_len: The length of the tex_coords array. (e.g. for one layer - * and one group of texture coordinates, this would be 4) - * - * This function draws a rectangle using the current source material to - * texture or fill with. As a material may contain multiple texture layers - * this interface lets you supply texture coordinates for each layer of the - * material. - * - * The first pair of coordinates are for the first layer (with the smallest - * layer index) and if you supply less texture coordinates than there are - * layers in the current source material then default texture coordinates - * (0.0, 0.0, 1.0, 1.0) are generated. - * - * Since: 1.0 - */ -void -cogl_rectangle_with_multitexture_coords (float x1, - float y1, - float x2, - float y2, - const float *tex_coords, - int tex_coords_len); - -/** - * cogl_rectangles_with_texture_coords: - * @verts: (in) (array) (transfer none): an array of vertices - * @n_rects: number of rectangles to draw - * - * Draws a series of rectangles in the same way that - * cogl_rectangle_with_texture_coords() does. In some situations it can give a - * significant performance boost to use this function rather than - * calling cogl_rectangle_with_texture_coords() separately for each rectangle. - * - * @verts should point to an array of #floats with - * @n_rects * 8 elements. Each group of 8 values corresponds to the - * parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same - * meaning as in cogl_rectangle_with_texture_coords(). - * - * Since: 0.8.6 - */ -void -cogl_rectangles_with_texture_coords (const float *verts, - unsigned int n_rects); - -/** - * cogl_rectangles: - * @verts: (in) (array) (transfer none): an array of vertices - * @n_rects: number of rectangles to draw - * - * Draws a series of rectangles in the same way that - * cogl_rectangle() does. In some situations it can give a - * significant performance boost to use this function rather than - * calling cogl_rectangle() separately for each rectangle. - * - * @verts should point to an array of #floats with - * @n_rects * 4 elements. Each group of 4 values corresponds to the - * parameters x1, y1, x2, and y2, and have the same - * meaning as in cogl_rectangle(). - * - * Since: 1.0 - */ -void -cogl_rectangles (const float *verts, - unsigned int n_rects); - -/** - * cogl_polygon: - * @vertices: An array of #CoglTextureVertex structs - * @n_vertices: The length of the vertices array - * @use_color: %TRUE if the color member of #CoglTextureVertex should be used - * - * Draws a convex polygon using the current source material to fill / texture - * with according to the texture coordinates passed. - * - * If @use_color is %TRUE then the color will be changed for each vertex using - * the value specified in the color member of #CoglTextureVertex. This can be - * used for example to make the texture fade out by setting the alpha value of - * the color. - * - * All of the texture coordinates must be in the range [0,1] and repeating the - * texture is not supported. - * - * Because of the way this function is implemented it will currently - * only work if either the texture is not sliced or the backend is not - * OpenGL ES and the minifying and magnifying functions are both set - * to COGL_MATERIAL_FILTER_NEAREST. - * - * Since: 1.0 - */ -void -cogl_polygon (const CoglTextureVertex *vertices, - unsigned int n_vertices, - gboolean use_color); - -G_END_DECLS - -#endif /* __COGL_PRIMITIVES_H */ diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index f9b7e63e9..587088c97 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -52,7 +52,6 @@ #include "cogl-context-private.h" #include "cogl-object-private.h" #include "cogl-object-private.h" -#include "cogl-primitives.h" #include "cogl-framebuffer-private.h" #include "cogl1-context.h" #include "cogl-sub-texture.h" diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index 29601cc58..732726a2a 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -65,7 +65,6 @@ #include #include #include -#include #include #include #include diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c index 47d1a9799..5b33a0a25 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c @@ -43,7 +43,6 @@ #include "cogl-pipeline.h" #include "cogl-context-private.h" #include "cogl-object-private.h" -#include "cogl-primitives.h" #include "driver/gl/cogl-pipeline-opengl-private.h" #include "driver/gl/cogl-util-gl-private.h" #include "driver/gl/cogl-texture-gl-private.h" diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c index b7b354467..01653bc87 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c @@ -43,7 +43,6 @@ #include "cogl-pipeline.h" #include "cogl-context-private.h" #include "cogl-object-private.h" -#include "cogl-primitives.h" #include "driver/gl/cogl-pipeline-opengl-private.h" #include "driver/gl/cogl-util-gl-private.h" #include "driver/gl/cogl-texture-gl-private.h" diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index f9d5c5ef4..008b3bfb6 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -88,7 +88,6 @@ cogl_headers = [ 'cogl-pipeline-state.h', 'cogl-pipeline-layer-state.h', 'cogl-pixel-format.h', - 'cogl-primitives.h', 'cogl-texture.h', 'cogl-texture-2d.h', 'cogl-texture-2d-sliced.h', @@ -237,7 +236,6 @@ cogl_sources = [ 'cogl-bitmap-conversion.c', 'cogl-bitmap-packing.h', 'cogl-primitives-private.h', - 'cogl-primitives.h', 'cogl-primitives.c', 'cogl-bitmap-pixbuf.c', 'cogl-clip-stack.h',