示例#1
0
static void
gst_gl_colorscale_del_gl_resources (GstGLFilter * filter)
{
  GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter);

  if (colorscale->shader) {
    gst_gl_context_del_shader (filter->context, colorscale->shader);
    colorscale->shader = NULL;
  }
}
static gboolean
gst_gl_colorscale_filter_texture (GstGLFilter * filter, GstGLMemory * in_tex,
    GstGLMemory * out_tex)
{
  GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter);

  if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context))
    gst_gl_filter_render_to_target_with_shader (filter, in_tex, out_tex,
        colorscale->shader);

  return TRUE;
}
static void
gst_gl_colorscale_gl_stop (GstGLBaseFilter * base_filter)
{
  GstGLColorscale *colorscale = GST_GL_COLORSCALE (base_filter);

  if (colorscale->shader) {
    gst_object_unref (colorscale->shader);
    colorscale->shader = NULL;
  }

  return GST_GL_BASE_FILTER_CLASS (parent_class)->gl_stop (base_filter);
}
static gboolean
gst_gl_colorscale_del_gl_resources (GstBaseTransform * trans)
{
  GstGLColorscale *colorscale = GST_GL_COLORSCALE (trans);

  if (colorscale->shader) {
    gst_gl_context_del_shader (GST_GL_BASE_FILTER (trans)->context,
        colorscale->shader);
    colorscale->shader = NULL;
  }

  return GST_BASE_TRANSFORM_CLASS (parent_class)->stop (trans);
}
static gboolean
gst_gl_colorscale_filter_texture (GstGLFilter * filter, guint in_tex,
    guint out_tex)
{
  GstGLColorscale *colorscale;

  colorscale = GST_GL_COLORSCALE (filter);

  if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) &
      (GST_GL_API_GLES2 | GST_GL_API_OPENGL3))
    gst_gl_filter_render_to_target_with_shader (filter, TRUE, in_tex, out_tex,
        colorscale->shader);

  if (gst_gl_context_get_gl_api (GST_GL_BASE_FILTER (filter)->context) &
      GST_GL_API_OPENGL)
    gst_gl_filter_render_to_target (filter, TRUE, in_tex, out_tex,
        gst_gl_colorscale_callback, colorscale);

  return TRUE;
}
示例#6
0
static gboolean
gst_gl_colorscale_gen_gl_resources (GstGLFilter * filter)
{
  GstGLColorscale *colorscale = GST_GL_COLORSCALE (filter);

  if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_GLES2) {
    gst_gl_context_thread_add (filter->context,
        (GstGLContextThreadFunc) _compile_identity_shader, colorscale);

    if (!colorscale->shader) {
      gst_gl_context_set_error (filter->context,
          "Failed to initialize identity shader");
      GST_ELEMENT_ERROR (colorscale, RESOURCE, NOT_FOUND, ("%s",
              gst_gl_context_get_error ()), (NULL));
      return FALSE;
    }
  }

  return TRUE;
}
示例#7
0
static gboolean
gst_gl_colorscale_filter_texture (GstGLFilter * filter, guint in_tex,
    guint out_tex)
{
  GstGLColorscale *colorscale;

  colorscale = GST_GL_COLORSCALE (filter);

#if GST_GL_HAVE_GLES2
  if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_GLES2)
    gst_gl_filter_render_to_target_with_shader (filter, TRUE, in_tex, out_tex,
        colorscale->shader);
#endif

#if GST_GL_HAVE_OPENGL
  if (gst_gl_context_get_gl_api (filter->context) & GST_GL_API_OPENGL)
    gst_gl_filter_render_to_target (filter, TRUE, in_tex, out_tex,
        gst_gl_colorscale_callback, colorscale);
#endif

  return TRUE;
}
static gboolean
gst_gl_colorscale_gl_start (GstGLBaseFilter * base_filter)
{
  GstGLColorscale *colorscale = GST_GL_COLORSCALE (base_filter);
  GstGLFilter *filter = GST_GL_FILTER (base_filter);
  GstGLShader *shader;
  GError *error = NULL;

  if (!(shader = gst_gl_shader_new_default (base_filter->context, &error))) {
    GST_ERROR_OBJECT (colorscale, "Failed to initialize shader: %s",
        error->message);
    gst_object_unref (shader);
    return FALSE;
  }

  filter->draw_attr_position_loc =
      gst_gl_shader_get_attribute_location (shader, "a_position");
  filter->draw_attr_texture_loc =
      gst_gl_shader_get_attribute_location (shader, "a_texcoord");

  colorscale->shader = shader;

  return GST_GL_BASE_FILTER_CLASS (parent_class)->gl_start (base_filter);
}