cogl: Remove filling with cogl-path

This removes code that uses the cogl-path library, which was not
used except when manually modifying a preprocessor flag. It could
not use path caching, was slightly broken, and all of its
functionality was provided better by different code paths.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
This commit is contained in:
George Matsumura 2020-08-23 21:23:01 -06:00
parent ecbd7ed174
commit e47d0de8d2
6 changed files with 11 additions and 305 deletions

View file

@ -400,7 +400,7 @@ CAIRO_ENABLE_SURFACE_BACKEND(glesv3, OpenGLESv3, no, [
dnl ===========================================================================
CAIRO_ENABLE_SURFACE_BACKEND(cogl, Cogl, no, [
cogl_REQUIRES="cogl-2.0-experimental, cogl-path-2.0-experimental"
cogl_REQUIRES="cogl-2.0-experimental"
PKG_CHECK_MODULES(cogl, $cogl_REQUIRES,, [use_cogl="no"])
])

View file

@ -467,8 +467,6 @@ cairo_vg_sources = cairo-vg-surface.c
cairo_cogl_headers = cairo-cogl.h
cairo_cogl_private = cairo-cogl-private.h \
cairo-cogl-gradient-private.h \
cairo-cogl-utils-private.h
cairo-cogl-gradient-private.h
cairo_cogl_sources = cairo-cogl-surface.c \
cairo-cogl-gradient.c \
cairo-cogl-utils.c
cairo-cogl-gradient.c

View file

@ -43,7 +43,6 @@
#include "cairo-cogl-gradient-private.h"
#include "cairo-arc-private.h"
#include "cairo-traps-private.h"
#include "cairo-cogl-utils-private.h"
#include "cairo-surface-subsurface-inline.h"
#include "cairo-surface-fallback-private.h"
#include "cairo-surface-offset-private.h"
@ -54,8 +53,6 @@
#include <glib.h>
#define CAIRO_COGL_DEBUG 0
//#define FILL_WITH_COGL_PATH
//#define USE_CAIRO_PATH_FLATTENER
//#define DISABLE_BATCHING
#define MAX_JOURNAL_SIZE 100
@ -102,7 +99,6 @@ typedef struct _cairo_cogl_pipeline {
typedef enum _cairo_cogl_journal_entry_type {
CAIRO_COGL_JOURNAL_ENTRY_TYPE_RECTANGLE,
CAIRO_COGL_JOURNAL_ENTRY_TYPE_PRIMITIVE,
CAIRO_COGL_JOURNAL_ENTRY_TYPE_PATH,
CAIRO_COGL_JOURNAL_ENTRY_TYPE_CLIP
} cairo_cogl_journal_entry_type_t;
@ -134,13 +130,6 @@ typedef struct _cairo_cogl_journal_prim_entry {
cairo_matrix_t transform;
} cairo_cogl_journal_prim_entry_t;
typedef struct _cairo_cogl_journal_path_entry {
cairo_cogl_journal_entry_t base;
cairo_cogl_pipeline_t *pipeline;
CoglPath *path;
} cairo_cogl_journal_path_entry_t;
typedef struct _cairo_cogl_path_fill_meta {
cairo_cache_entry_t base;
cairo_path_fixed_t path;
@ -324,19 +313,6 @@ _cairo_cogl_journal_discard (cairo_cogl_surface_t *surface)
entry_size = sizeof (cairo_cogl_journal_prim_entry_t);
break;
}
case CAIRO_COGL_JOURNAL_ENTRY_TYPE_PATH: {
cairo_cogl_journal_path_entry_t *path_entry =
(cairo_cogl_journal_path_entry_t *)entry;
cogl_object_unref (path_entry->pipeline->pipeline);
cogl_object_unref (path_entry->path);
if (path_entry->pipeline->has_src_tex_clip)
_cairo_path_fixed_fini (&path_entry->pipeline->src_tex_clip);
if (path_entry->pipeline->has_mask_tex_clip)
_cairo_path_fixed_fini (&path_entry->pipeline->mask_tex_clip);
g_free (path_entry->pipeline);
entry_size = sizeof (cairo_cogl_journal_path_entry_t);
break;
}
default:
assert (0); /* not reached! */
entry_size = 0; /* avoid compiler warning */
@ -360,39 +336,6 @@ _cairo_cogl_journal_free (cairo_cogl_surface_t *surface)
surface->journal = NULL;
}
#ifdef FILL_WITH_COGL_PATH
static void
_cairo_cogl_journal_log_path (cairo_cogl_surface_t *surface,
cairo_cogl_pipeline_t *pipeline,
CoglPath *path)
{
cairo_cogl_journal_path_entry_t *entry;
if (unlikely (surface->journal == NULL))
surface->journal = g_queue_new ();
/* FIXME: Instead of a GList here we should stack allocate the journal
* entries so it would be cheaper to allocate and they can all be freed in
* one go after flushing! */
entry = g_slice_new (cairo_cogl_journal_path_entry_t);
entry->base.type = CAIRO_COGL_JOURNAL_ENTRY_TYPE_PATH;
entry->pipeline = pipeline;
entry->path = cogl_object_ref (path);
g_queue_push_tail (surface->journal, entry);
#ifdef DISABLE_BATCHING
_cairo_cogl_journal_flush (surface);
#else
/* To avoid consuming too much memory, flush the journal if it gets
* to a certain size */
if (g_queue_get_length (surface->journal) > MAX_JOURNAL_SIZE)
_cairo_cogl_journal_flush (surface);
#endif /* DISABLE_BATCHING */
}
#endif /* FILL_WITH_COGL_PATH */
static void
_cairo_cogl_journal_log_primitive (cairo_cogl_surface_t *surface,
cairo_cogl_pipeline_t *pipeline,
@ -576,14 +519,14 @@ _cairo_cogl_traps_to_triangles_buffer (cairo_cogl_surface_t *surface,
CoglVertexP2 *p = &triangles[i * 6];
cairo_trapezoid_t *trap = &traps->traps[i];
p[0].x = _cairo_cogl_util_fixed_to_float (trap->left.p1.x);
p[0].y = _cairo_cogl_util_fixed_to_float (trap->left.p1.y);
p[0].x = _cairo_fixed_to_double (trap->left.p1.x);
p[0].y = _cairo_fixed_to_double (trap->left.p1.y);
p[1].x = _cairo_cogl_util_fixed_to_float (trap->left.p2.x);
p[1].y = _cairo_cogl_util_fixed_to_float (trap->left.p2.y);
p[1].x = _cairo_fixed_to_double (trap->left.p2.x);
p[1].y = _cairo_fixed_to_double (trap->left.p2.y);
p[2].x = _cairo_cogl_util_fixed_to_float (trap->right.p2.x);
p[2].y = _cairo_cogl_util_fixed_to_float (trap->right.p2.y);
p[2].x = _cairo_fixed_to_double (trap->right.p2.x);
p[2].y = _cairo_fixed_to_double (trap->right.p2.y);
p[3].x = p[0].x;
p[3].y = p[0].y;
@ -591,8 +534,8 @@ _cairo_cogl_traps_to_triangles_buffer (cairo_cogl_surface_t *surface,
p[4].x = p[2].x;
p[4].y = p[2].y;
p[5].x = _cairo_cogl_util_fixed_to_float (trap->right.p1.x);
p[5].y = _cairo_cogl_util_fixed_to_float (trap->right.p1.y);
p[5].x = _cairo_fixed_to_double (trap->right.p1.x);
p[5].y = _cairo_fixed_to_double (trap->right.p1.y);
}
if (!one_shot)
@ -1527,43 +1470,6 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
cogl_framebuffer_pop_matrix (surface->framebuffer);
break;
}
case CAIRO_COGL_JOURNAL_ENTRY_TYPE_PATH: {
cairo_cogl_journal_path_entry_t *path_entry =
(cairo_cogl_journal_path_entry_t *)entry;
cairo_bool_t needs_vertex_render;
CoglPipeline *unbounded_pipeline;
_cairo_cogl_apply_tex_clips (surface,
&clip_stack_depth,
path_entry->pipeline);
/* Use this until cogl2_path_fill is updated to take
* framebuffer and pipeline arguments */
cogl_framebuffer_fill_path (surface->framebuffer,
path_entry->pipeline->pipeline,
path_entry->path);
_cairo_cogl_unbounded_render (surface,
&clip_stack_depth,
path_entry->pipeline,
&needs_vertex_render);
if (needs_vertex_render) {
unbounded_pipeline =
_cairo_cogl_setup_unbounded_area_pipeline (surface,
path_entry->pipeline->op);
cogl_framebuffer_fill_path (surface->framebuffer,
unbounded_pipeline,
path_entry->path);
cogl_object_unref (unbounded_pipeline);
}
_cairo_cogl_post_unbounded_render (surface,
&clip_stack_depth,
path_entry->pipeline);
cogl_framebuffer_pop_matrix (surface->framebuffer);
break;
}
default:
assert (0); /* not reached! */
}
@ -3689,7 +3595,6 @@ _cairo_cogl_surface_fill (void *abstract_surface,
if (unlikely (status))
return status;
#ifndef FILL_WITH_COGL_PATH
status = _cairo_cogl_fill_to_primitive (surface, path, fill_rule,
tolerance, TRUE, &prim,
&transform);
@ -3700,7 +3605,6 @@ _cairo_cogl_surface_fill (void *abstract_surface,
} else if (unlikely (status)) {
goto BAIL;
}
#endif /* !FILL_WITH_COGL_PATH */
get_source_mask_operator_destination_pipelines (pipelines,
NULL,
@ -3716,7 +3620,6 @@ _cairo_cogl_surface_fill (void *abstract_surface,
_cairo_cogl_maybe_log_clip (surface, &extents);
#ifndef FILL_WITH_COGL_PATH
if (pipelines[0])
_cairo_cogl_journal_log_primitive (surface,
pipelines[0],
@ -3727,20 +3630,6 @@ _cairo_cogl_surface_fill (void *abstract_surface,
pipelines[1],
prim,
&transform);
#else
CoglPath * cogl_path = _cairo_cogl_util_path_from_cairo (path, fill_rule, tolerance);
if (pipelines[0])
_cairo_cogl_journal_log_path (surface,
pipelines[0],
cogl_path);
if (pipelines[1])
_cairo_cogl_journal_log_path (surface,
pipelines[1],
cogl_path);
/* The journal will take a reference on the path */
cogl_object_unref (cogl_path);
#endif
BAIL:
/* The journal will take a reference on the prim */

View file

@ -1,54 +0,0 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.og/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* Contributor(s):
* Robert Bragg <robert@linux.intel.com>
*/
#ifndef CAIRO_COGL_UTILS_PRIVATE_H
#define CAIRO_COGL_UTILS_PRIVATE_H
#include "cairo-path-fixed-private.h"
#include <cogl/cogl2-experimental.h>
CoglPath *
_cairo_cogl_util_path_from_cairo (const cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
float tolerance);
int
_cairo_cogl_util_next_p2 (int a);
#define CAIRO_FIXED_ONE_FLOAT ((float)(1 << CAIRO_FIXED_FRAC_BITS))
static inline float
_cairo_cogl_util_fixed_to_float (cairo_fixed_t f)
{
return ((float) f) / CAIRO_FIXED_ONE_FLOAT;
}
#endif /* CAIRO_COGL_UTILS_PRIVATE_H */

View file

@ -1,126 +0,0 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.og/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* Contributor(s):
* Robert Bragg <robert@linux.intel.com>
*/
#include "cairoint.h"
#include "cairo-cogl-utils-private.h"
#include <cogl/cogl.h>
#include <glib.h>
static cairo_status_t
_cogl_move_to (void *closure,
const cairo_point_t *point)
{
cogl_path_move_to (closure,
_cairo_cogl_util_fixed_to_float (point->x),
_cairo_cogl_util_fixed_to_float (point->y));
return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t
_cogl_line_to (void *closure,
const cairo_point_t *point)
{
cogl_path_line_to (closure,
_cairo_cogl_util_fixed_to_float (point->x),
_cairo_cogl_util_fixed_to_float (point->y));
return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t
_cogl_curve_to (void *closure,
const cairo_point_t *p0,
const cairo_point_t *p1,
const cairo_point_t *p2)
{
cogl_path_curve_to (closure,
_cairo_cogl_util_fixed_to_float (p0->x),
_cairo_cogl_util_fixed_to_float (p0->y),
_cairo_cogl_util_fixed_to_float (p1->x),
_cairo_cogl_util_fixed_to_float (p1->y),
_cairo_cogl_util_fixed_to_float (p2->x),
_cairo_cogl_util_fixed_to_float (p2->y));
return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t
_cogl_close_path (void *closure)
{
cogl_path_close (closure);
return CAIRO_STATUS_SUCCESS;
}
CoglPath *
_cairo_cogl_util_path_from_cairo (const cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
float tolerance)
{
CoglPath *cogl_path = cogl_path_new ();
cairo_status_t status;
if (fill_rule == CAIRO_FILL_RULE_EVEN_ODD)
cogl_path_set_fill_rule (cogl_path, COGL_PATH_FILL_RULE_EVEN_ODD);
else
cogl_path_set_fill_rule (cogl_path, COGL_PATH_FILL_RULE_NON_ZERO);
#ifdef USE_CAIRO_PATH_FLATTENER
/* XXX: rely on cairo to do path flattening, since it seems Cogl's
* curve_to flattening is much slower */
status = _cairo_path_fixed_interpret_flat (path,
_cogl_move_to,
_cogl_line_to,
_cogl_close_path,
cogl_path,
tolerance);
#else
status = _cairo_path_fixed_interpret (path,
_cogl_move_to,
_cogl_line_to,
_cogl_curve_to,
_cogl_close_path,
cogl_path);
#endif
assert (status == CAIRO_STATUS_SUCCESS);
return cogl_path;
}
int
_cairo_cogl_util_next_p2 (int a)
{
int rval = 1;
while (rval < a)
rval <<= 1;
return rval;
}

View file

@ -217,7 +217,6 @@ cairo_feature_sources = {
'cairo-cogl': [
'cairo-cogl-surface.c',
'cairo-cogl-gradient.c',
'cairo-cogl-utils.c',
],
'cairo-directfb': [
'cairo-directfb-surface.c',