cogl: Remove API implicitly switching between built in pipelines

This means cogl_set_source_color*() that switches to the opaque or
blending pipeline, or cogl_source_set_texture() which switches to the
texture pipeline.

Left is the opaque pipeline, as it is still used to compare other
pipelines to check whether they are opaque or not, and as the default
pipeline still pushed to the source stack during initialization.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
This commit is contained in:
Jonas Ådahl 2019-11-22 16:49:07 +01:00 committed by Georges Basile Stavracas Neto
parent 3819291cb7
commit 77b3c0d670
4 changed files with 4 additions and 172 deletions

View File

@ -145,10 +145,9 @@ struct _CoglContext
GArray *texture_units; GArray *texture_units;
int active_texture_unit; int active_texture_unit;
/* Pipelines */ /* Only used for comparing other pipelines when reading pixels. */
CoglPipeline *opaque_color_pipeline; /* used for set_source_color */ CoglPipeline *opaque_color_pipeline;
CoglPipeline *blended_color_pipeline; /* used for set_source_color */
CoglPipeline *texture_pipeline; /* used for set_source_texture */
GString *codegen_header_buffer; GString *codegen_header_buffer;
GString *codegen_source_buffer; GString *codegen_source_buffer;
GString *codegen_boilerplate_buffer; GString *codegen_boilerplate_buffer;

View File

@ -255,8 +255,7 @@ cogl_context_new (CoglDisplay *display,
} }
context->opaque_color_pipeline = cogl_pipeline_new (context); context->opaque_color_pipeline = cogl_pipeline_new (context);
context->blended_color_pipeline = cogl_pipeline_new (context);
context->texture_pipeline = cogl_pipeline_new (context);
context->codegen_header_buffer = g_string_new (""); context->codegen_header_buffer = g_string_new ("");
context->codegen_source_buffer = g_string_new (""); context->codegen_source_buffer = g_string_new ("");
context->codegen_boilerplate_buffer = g_string_new (""); context->codegen_boilerplate_buffer = g_string_new ("");
@ -414,10 +413,6 @@ _cogl_context_free (CoglContext *context)
if (context->opaque_color_pipeline) if (context->opaque_color_pipeline)
cogl_object_unref (context->opaque_color_pipeline); cogl_object_unref (context->opaque_color_pipeline);
if (context->blended_color_pipeline)
cogl_object_unref (context->blended_color_pipeline);
if (context->texture_pipeline)
cogl_object_unref (context->texture_pipeline);
if (context->blit_texture_pipeline) if (context->blit_texture_pipeline)
cogl_object_unref (context->blit_texture_pipeline); cogl_object_unref (context->blit_texture_pipeline);

View File

@ -123,29 +123,6 @@ cogl_get_backface_culling_enabled (void)
return ctx->legacy_backface_culling_enabled; return ctx->legacy_backface_culling_enabled;
} }
void
cogl_set_source_color (const CoglColor *color)
{
CoglPipeline *pipeline;
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
if (cogl_color_get_alpha_byte (color) == 0xff)
{
cogl_pipeline_set_color (ctx->opaque_color_pipeline, color);
pipeline = ctx->opaque_color_pipeline;
}
else
{
CoglColor premultiplied = *color;
cogl_color_premultiply (&premultiplied);
cogl_pipeline_set_color (ctx->blended_color_pipeline, &premultiplied);
pipeline = ctx->blended_color_pipeline;
}
cogl_set_source (pipeline);
}
gboolean gboolean
cogl_has_feature (CoglContext *ctx, CoglFeatureID feature) cogl_has_feature (CoglContext *ctx, CoglFeatureID feature)
{ {
@ -339,41 +316,6 @@ cogl_set_source (void *material_or_pipeline)
} }
} }
void
cogl_set_source_texture (CoglTexture *texture)
{
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
g_return_if_fail (texture != NULL);
cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture);
cogl_set_source (ctx->texture_pipeline);
}
void
cogl_set_source_color4ub (uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t alpha)
{
CoglColor c = { 0, };
cogl_color_init_from_4ub (&c, red, green, blue, alpha);
cogl_set_source_color (&c);
}
void
cogl_set_source_color4f (float red,
float green,
float blue,
float alpha)
{
CoglColor c = { 0, };
cogl_color_init_from_4f (&c, red, green, blue, alpha);
cogl_set_source_color (&c);
}
/* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) /* Scale from OpenGL normalized device coordinates (ranging from -1 to 1)
* to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with
* (0,0) being top left. */ * (0,0) being top left. */

View File

@ -212,110 +212,6 @@ COGL_DEPRECATED
void void
cogl_pop_source (void); cogl_pop_source (void);
/**
* cogl_set_source_color:
* @color: a #CoglColor
*
* This is a convenience function for creating a solid fill source material
* from the given color. This color will be used for any subsequent drawing
* operation.
*
* The color will be premultiplied by Cogl, so the color should be
* non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for
* semi-transparent red.
*
* See also cogl_set_source_color4ub() and cogl_set_source_color4f()
* if you already have the color components.
*
* Since: 1.0
* Deprecated: 1.16: Latest drawing apis all take an explicit
* #CoglPipeline argument so this stack of
* #CoglMaterial<!-- -->s shouldn't be used.
*/
COGL_DEPRECATED
void
cogl_set_source_color (const CoglColor *color);
/**
* cogl_set_source_color4ub:
* @red: value of the red channel, between 0 and 255
* @green: value of the green channel, between 0 and 255
* @blue: value of the blue channel, between 0 and 255
* @alpha: value of the alpha channel, between 0 and 255
*
* This is a convenience function for creating a solid fill source material
* from the given color using unsigned bytes for each component. This
* color will be used for any subsequent drawing operation.
*
* The value for each component is an unsigned byte in the range
* between 0 and 255.
*
* Since: 1.0
* Deprecated: 1.16: Latest drawing apis all take an explicit
* #CoglPipeline argument so this stack of
* #CoglMaterial<!-- -->s shouldn't be used.
*/
COGL_DEPRECATED
void
cogl_set_source_color4ub (uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t alpha);
/**
* cogl_set_source_color4f:
* @red: value of the red channel, between 0 and %1.0
* @green: value of the green channel, between 0 and %1.0
* @blue: value of the blue channel, between 0 and %1.0
* @alpha: value of the alpha channel, between 0 and %1.0
*
* This is a convenience function for creating a solid fill source material
* from the given color using normalized values for each component. This color
* will be used for any subsequent drawing operation.
*
* The value for each component is a fixed point number in the range
* between 0 and %1.0. If the values passed in are outside that
* range, they will be clamped.
*
* Since: 1.0
* Deprecated: 1.16: Latest drawing apis all take an explicit
* #CoglPipeline argument so this stack of
* #CoglMaterial<!-- -->s shouldn't be used.
*/
COGL_DEPRECATED
void
cogl_set_source_color4f (float red,
float green,
float blue,
float alpha);
/**
* cogl_set_source_texture:
* @texture: The #CoglTexture you want as your source
*
* This is a convenience function for creating a material with the first
* layer set to @texture and setting that material as the source with
* cogl_set_source.
*
* Note: There is no interaction between calls to cogl_set_source_color
* and cogl_set_source_texture. If you need to blend a texture with a color then
* you can create a simple material like this:
* <programlisting>
* material = cogl_material_new ();
* cogl_material_set_color4ub (material, 0xff, 0x00, 0x00, 0x80);
* cogl_material_set_layer (material, 0, tex_handle);
* cogl_set_source (material);
* </programlisting>
*
* Since: 1.0
* Deprecated: 1.16: Latest drawing apis all take an explicit
* #CoglPipeline argument so this stack of
* #CoglMaterial<!-- -->s shouldn't be used.
*/
COGL_DEPRECATED
void
cogl_set_source_texture (CoglTexture *texture);
/** /**
* cogl_flush: * cogl_flush:
* *