cogl-gst: More pedantic style fixes

• Fixes some overly long lines, hugging asterisks in the pointer type
  declarations and indentation issues.

• Tidies up the GLSL source so that it will look nicer in the
  debug output.

• Removes the backwards ‘parent_class’ define which hacks the
  implementation of the G_DEFINE_TYPE macro and just uses the full
  type name instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 3ffe8979da4d4dc7deb221e5653b6f24f41b412c)
This commit is contained in:
Neil Roberts 2013-03-19 19:37:19 +00:00 committed by Lionel Landwerlin
parent 30001939ad
commit 7acdf0114e
3 changed files with 90 additions and 78 deletions

View File

@ -45,12 +45,13 @@
static CoglBool static CoglBool
_plugin_init (GstPlugin *coglgstvideosink) _plugin_init (GstPlugin *coglgstvideosink)
{ {
return gst_element_register (coglgstvideosink, "coglsink", GST_RANK_PRIMARY, return gst_element_register (coglgstvideosink,
"coglsink",
GST_RANK_PRIMARY,
COGL_GST_TYPE_VIDEO_SINK); COGL_GST_TYPE_VIDEO_SINK);
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MAJOR,
GST_VERSION_MINOR, GST_VERSION_MINOR,
cogl, cogl,
"Sends video data from GStreamer to a Cogl pipeline", "Sends video data from GStreamer to a Cogl pipeline",
@ -58,5 +59,4 @@ GST_PLUGIN_DEFINE (
VERSION, VERSION,
"LGPL", "LGPL",
"CoglGst", "CoglGst",
"http://gstreamer.net/" "http://gstreamer.net/")
)

View File

@ -38,13 +38,17 @@
const char const char
_cogl_gst_shader_rgba_to_rgba_decl[] = _cogl_gst_shader_rgba_to_rgba_decl[] =
"vec4 cogl_gst_sample_video (vec2 UV) {\n" "vec4\n"
"cogl_gst_sample_video (vec2 UV)\n"
"{\n"
" return texture2D (cogl_sampler0, UV);\n" " return texture2D (cogl_sampler0, UV);\n"
"}"; "}\n";
const char const char
_cogl_gst_shader_yv12_to_rgba_decl[] = _cogl_gst_shader_yv12_to_rgba_decl[] =
"vec4 cogl_gst_sample_video (vec2 UV) {\n" "vec4\n"
"cogl_gst_sample_video (vec2 UV)\n"
"{\n"
" float y = 1.1640625 * (texture2D (cogl_sampler0, UV).g - 0.0625);\n" " float y = 1.1640625 * (texture2D (cogl_sampler0, UV).g - 0.0625);\n"
" float u = texture2D (cogl_sampler1, UV).g - 0.5;\n" " float u = texture2D (cogl_sampler1, UV).g - 0.5;\n"
" float v = texture2D (cogl_sampler2, UV).g - 0.5;\n" " float v = texture2D (cogl_sampler2, UV).g - 0.5;\n"
@ -54,11 +58,13 @@ _cogl_gst_shader_yv12_to_rgba_decl[] =
" color.b = y + 2.015625 * u;\n" " color.b = y + 2.015625 * u;\n"
" color.a = 1.0;\n" " color.a = 1.0;\n"
" return color;\n" " return color;\n"
"}"; "}\n";
const char const char
_cogl_gst_shader_ayuv_to_rgba_decl[] = _cogl_gst_shader_ayuv_to_rgba_decl[] =
"vec4 cogl_gst_sample_video (vec2 UV) {\n" "vec4\n"
"cogl_gst_sample_video (vec2 UV)\n"
"{\n"
" vec4 color = texture2D (cogl_sampler0, UV);\n" " vec4 color = texture2D (cogl_sampler0, UV);\n"
" float y = 1.1640625 * (color.g - 0.0625);\n" " float y = 1.1640625 * (color.g - 0.0625);\n"
" float u = color.b - 0.5;\n" " float u = color.b - 0.5;\n"
@ -68,8 +74,8 @@ _cogl_gst_shader_ayuv_to_rgba_decl[] =
" color.g = y - 0.390625 * u - 0.8125 * v;\n" " color.g = y - 0.390625 * u - 0.8125 * v;\n"
" color.b = y + 2.015625 * u;\n" " color.b = y + 2.015625 * u;\n"
" return color;\n" " return color;\n"
"}"; "}\n";
const char const char
_cogl_gst_shader_default_sample[] = _cogl_gst_shader_default_sample[] =
"cogl_layer = cogl_gst_sample_video (cogl_tex_coord0_in.st);"; " cogl_layer = cogl_gst_sample_video (cogl_tex_coord0_in.st);\n";

View File

@ -47,7 +47,7 @@
#define COGL_GST_TEXTURE_FLAGS \ #define COGL_GST_TEXTURE_FLAGS \
(COGL_TEXTURE_NO_SLICING | COGL_TEXTURE_NO_ATLAS) (COGL_TEXTURE_NO_SLICING | COGL_TEXTURE_NO_ATLAS)
#define COGL_GST_DEFAULT_PRIORITY (G_PRIORITY_HIGH_IDLE) #define COGL_GST_DEFAULT_PRIORITY G_PRIORITY_HIGH_IDLE
#define BASE_SINK_CAPS "{ AYUV," \ #define BASE_SINK_CAPS "{ AYUV," \
"YV12," \ "YV12," \
@ -57,15 +57,14 @@
"RGB," \ "RGB," \
"BGR }" "BGR }"
#define SINK_CAPS GST_VIDEO_CAPS_MAKE (BASE_SINK_CAPS) #define SINK_CAPS GST_VIDEO_CAPS_MAKE (BASE_SINK_CAPS)
static GstStaticPadTemplate sinktemplate_all = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sinktemplate_all =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS (SINK_CAPS)); GST_STATIC_CAPS (SINK_CAPS));
#define cogl_gst_video_sink_parent_class parent_class
G_DEFINE_TYPE (CoglGstVideoSink, cogl_gst_video_sink, GST_TYPE_BASE_SINK); G_DEFINE_TYPE (CoglGstVideoSink, cogl_gst_video_sink, GST_TYPE_BASE_SINK);
enum enum
@ -365,7 +364,6 @@ map_fail:
} }
} }
static CoglGstRenderer rgb24_renderer = static CoglGstRenderer rgb24_renderer =
{ {
"RGB 24", "RGB 24",
@ -613,7 +611,8 @@ cogl_gst_build_caps (GSList *renderers)
} }
void void
cogl_gst_video_sink_set_context (CoglGstVideoSink *vt, CoglContext *ctx) cogl_gst_video_sink_set_context (CoglGstVideoSink *vt,
CoglContext *ctx)
{ {
CoglGstVideoSinkPrivate *priv = vt->priv; CoglGstVideoSinkPrivate *priv = vt->priv;
@ -691,7 +690,8 @@ cogl_gst_video_sink_parse_caps (GstCaps *caps,
if (!gst_video_info_from_caps (&vinfo, caps)) if (!gst_video_info_from_caps (&vinfo, caps))
goto unknown_format; goto unknown_format;
switch (vinfo.finfo->format) { switch (vinfo.finfo->format)
{
case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_YV12:
format = COGL_GST_YV12; format = COGL_GST_YV12;
break; break;
@ -729,7 +729,8 @@ cogl_gst_video_sink_parse_caps (GstCaps *caps,
GST_INFO_OBJECT (sink, "found the %s renderer", renderer->name); GST_INFO_OBJECT (sink, "found the %s renderer", renderer->name);
if (save) { if (save)
{
priv->info = vinfo; priv->info = vinfo;
priv->format = format; priv->format = format;
@ -950,7 +951,7 @@ cogl_gst_video_sink_dispose (GObject *object)
priv->caps = NULL; priv->caps = NULL;
} }
G_OBJECT_CLASS(parent_class)->dispose (object); G_OBJECT_CLASS (cogl_gst_video_sink_parent_class)->dispose (object);
} }
static void static void
@ -960,7 +961,7 @@ cogl_gst_video_sink_finalize (GObject *object)
cogl_gst_video_sink_set_context (self, NULL); cogl_gst_video_sink_set_context (self, NULL);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (cogl_gst_video_sink_parent_class)->finalize (object);
} }
static CoglBool static CoglBool
@ -1037,6 +1038,7 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
GObjectClass *go_class = G_OBJECT_CLASS (klass); GObjectClass *go_class = G_OBJECT_CLASS (klass);
GstBaseSinkClass *gb_class = GST_BASE_SINK_CLASS (klass); GstBaseSinkClass *gb_class = GST_BASE_SINK_CLASS (klass);
GstElementClass *ge_class = GST_ELEMENT_CLASS (klass); GstElementClass *ge_class = GST_ELEMENT_CLASS (klass);
GstPadTemplate *pad_template;
GParamSpec *pspec; GParamSpec *pspec;
g_type_class_add_private (klass, sizeof (CoglGstVideoSinkPrivate)); g_type_class_add_private (klass, sizeof (CoglGstVideoSinkPrivate));
@ -1045,14 +1047,18 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
go_class->dispose = cogl_gst_video_sink_dispose; go_class->dispose = cogl_gst_video_sink_dispose;
go_class->finalize = cogl_gst_video_sink_finalize; go_class->finalize = cogl_gst_video_sink_finalize;
gst_element_class_add_pad_template (ge_class, pad_template = gst_static_pad_template_get (&sinktemplate_all);
gst_static_pad_template_get (&sinktemplate_all)); gst_element_class_add_pad_template (ge_class, pad_template);
gst_element_class_set_metadata (ge_class, "Cogl video sink", "Sink/Video",
"Sends video data from GStreamer to a Cogl pipeline", gst_element_class_set_metadata (ge_class,
"Cogl video sink", "Sink/Video",
"Sends video data from GStreamer to a "
"Cogl pipeline",
"Jonathan Matthew <jonathan@kaolin.wh9.net>, " "Jonathan Matthew <jonathan@kaolin.wh9.net>, "
"Matthew Allum <mallum@o-hand.com, " "Matthew Allum <mallum@o-hand.com, "
"Chris Lord <chris@o-hand.com>, " "Chris Lord <chris@o-hand.com>, "
"Plamena Manolova <plamena.n.manolova@intel.com>"); "Plamena Manolova "
"<plamena.n.manolova@intel.com>");
gb_class->render = _cogl_gst_video_sink_render; gb_class->render = _cogl_gst_video_sink_render;
gb_class->preroll = _cogl_gst_video_sink_render; gb_class->preroll = _cogl_gst_video_sink_render;