Fixed texturing in Gallium.
[cairo/gpu.git] / src / cairo-spans-private.h
blobc285f94959f286c5047a11db2b321e174b2023ef
1 /* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
2 /* cairo - a vector graphics library with display and print output
4 * Copyright (c) 2008 M Joonas Pihlaja
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
13 * conditions:
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef CAIRO_SPANS_PRIVATE_H
28 #define CAIRO_SPANS_PRIVATE_H
29 #include "cairo-types-private.h"
30 #include "cairo-compiler-private.h"
32 /* Number of bits of precision used for alpha. */
33 #define CAIRO_SPANS_UNIT_COVERAGE_BITS 8
34 #define CAIRO_SPANS_UNIT_COVERAGE ((1 << CAIRO_SPANS_UNIT_COVERAGE_BITS)-1)
36 /* A structure representing an open-ended horizontal span of constant
37 * pixel coverage. */
38 typedef struct _cairo_half_open_span {
39 /* The inclusive x-coordinate of the start of the span. */
40 int x;
42 /* The pixel coverage for the pixels to the right. */
43 int coverage;
44 } cairo_half_open_span_t;
46 /* Span renderer interface. Instances of renderers are provided by
47 * surfaces if they want to composite spans instead of trapezoids. */
48 typedef struct _cairo_span_renderer cairo_span_renderer_t;
49 struct _cairo_span_renderer {
50 /* Called to destroy the renderer. */
51 cairo_destroy_func_t destroy;
53 /* Render the spans on row y of the source by whatever compositing
54 * method is required. The function should ignore spans outside
55 * the bounding box set by the init() function. */
56 cairo_status_t (*render_row)(
57 void *abstract_renderer,
58 int y,
59 const cairo_half_open_span_t *coverages,
60 unsigned num_coverages);
62 /* Called after all rows have been rendered to perform whatever
63 * final rendering step is required. This function is called just
64 * once before the renderer is destroyed. */
65 cairo_status_t (*finish)(
66 void *abstract_renderer);
68 /* Private status variable. */
69 cairo_status_t status;
72 /* Scan converter interface. */
73 typedef struct _cairo_scan_converter cairo_scan_converter_t;
74 struct _cairo_scan_converter {
75 /* Destroy this scan converter. */
76 cairo_destroy_func_t destroy;
78 /* Add an edge to the converter. */
79 cairo_status_t
80 (*add_edge)(
81 void *abstract_converter,
82 cairo_fixed_t x1,
83 cairo_fixed_t y1,
84 cairo_fixed_t x2,
85 cairo_fixed_t y2);
87 /* Generates coverage spans for rows for the added edges and calls
88 * the renderer function for each row. After generating spans the
89 * only valid thing to do with the converter is to destroy it. */
90 cairo_status_t
91 (*generate)(
92 void *abstract_converter,
93 cairo_span_renderer_t *renderer);
95 /* Private status. Read with _cairo_scan_converter_status(). */
96 cairo_status_t status;
99 /* Scan converter constructors. */
101 cairo_private cairo_scan_converter_t *
102 _cairo_tor_scan_converter_create(
103 int xmin,
104 int ymin,
105 int xmax,
106 int ymax,
107 cairo_fill_rule_t fill_rule);
109 /* cairo-spans.c: */
111 cairo_private cairo_scan_converter_t *
112 _cairo_scan_converter_create_in_error (cairo_status_t error);
114 cairo_private cairo_status_t
115 _cairo_scan_converter_status (void *abstract_converter);
117 cairo_private cairo_status_t
118 _cairo_scan_converter_set_error (void *abstract_converter,
119 cairo_status_t error);
121 cairo_private cairo_span_renderer_t *
122 _cairo_span_renderer_create_in_error (cairo_status_t error);
124 cairo_private cairo_status_t
125 _cairo_span_renderer_status (void *abstract_renderer);
127 /* Set the renderer into an error state. This sets all the method
128 * pointers except ->destroy() of the renderer to no-op
129 * implementations that just return the error status. */
130 cairo_private cairo_status_t
131 _cairo_span_renderer_set_error (void *abstract_renderer,
132 cairo_status_t error);
134 cairo_private cairo_status_t
135 _cairo_path_fixed_fill_using_spans (
136 cairo_operator_t op,
137 const cairo_pattern_t *pattern,
138 cairo_path_fixed_t *path,
139 cairo_surface_t *dst,
140 cairo_fill_rule_t fill_rule,
141 double tolerance,
142 cairo_antialias_t antialias,
143 const cairo_composite_rectangles_t *rects);
144 #endif /* CAIRO_SPANS_PRIVATE_H */