/src/cairo/subprojects/pixman-0.44.2/pixman/pixman-noop.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */ |
2 | | /* |
3 | | * Copyright © 2011 Red Hat, Inc. |
4 | | * |
5 | | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | | * copy of this software and associated documentation files (the "Software"), |
7 | | * to deal in the Software without restriction, including without limitation |
8 | | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 | | * and/or sell copies of the Software, and to permit persons to whom the |
10 | | * Software is furnished to do so, subject to the following conditions: |
11 | | * |
12 | | * The above copyright notice and this permission notice (including the next |
13 | | * paragraph) shall be included in all copies or substantial portions of the |
14 | | * Software. |
15 | | * |
16 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
19 | | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
20 | | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
21 | | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | | * DEALINGS IN THE SOFTWARE. |
23 | | */ |
24 | | #ifdef HAVE_CONFIG_H |
25 | | #include <pixman-config.h> |
26 | | #endif |
27 | | #include <string.h> |
28 | | #include <stdlib.h> |
29 | | #include "pixman-private.h" |
30 | | #include "pixman-combine32.h" |
31 | | #include "pixman-inlines.h" |
32 | | |
33 | | static void |
34 | | noop_composite (pixman_implementation_t *imp, |
35 | | pixman_composite_info_t *info) |
36 | 0 | { |
37 | 0 | return; |
38 | 0 | } |
39 | | |
40 | | static uint32_t * |
41 | | noop_get_scanline (pixman_iter_t *iter, const uint32_t *mask) |
42 | 0 | { |
43 | 0 | uint32_t *result = iter->buffer; |
44 | |
|
45 | 0 | iter->buffer += iter->image->bits.rowstride; |
46 | |
|
47 | 0 | return result; |
48 | 0 | } |
49 | | |
50 | | static void |
51 | | noop_init_solid_narrow (pixman_iter_t *iter, |
52 | | const pixman_iter_info_t *info) |
53 | 29.7k | { |
54 | 29.7k | pixman_image_t *image = iter->image; |
55 | 29.7k | uint32_t *buffer = iter->buffer; |
56 | 29.7k | uint32_t *end = buffer + iter->width; |
57 | 29.7k | uint32_t color; |
58 | | |
59 | 29.7k | if (iter->image->type == SOLID) |
60 | 29.7k | color = image->solid.color_32; |
61 | 0 | else |
62 | 0 | color = image->bits.fetch_pixel_32 (&image->bits, 0, 0); |
63 | | |
64 | 59.5k | while (buffer < end) |
65 | 29.7k | *(buffer++) = color; |
66 | 29.7k | } |
67 | | |
68 | | static void |
69 | | noop_init_solid_wide (pixman_iter_t *iter, |
70 | | const pixman_iter_info_t *info) |
71 | 0 | { |
72 | 0 | pixman_image_t *image = iter->image; |
73 | 0 | argb_t *buffer = (argb_t *)iter->buffer; |
74 | 0 | argb_t *end = buffer + iter->width; |
75 | 0 | argb_t color; |
76 | |
|
77 | 0 | if (iter->image->type == SOLID) |
78 | 0 | color = image->solid.color_float; |
79 | 0 | else |
80 | 0 | color = image->bits.fetch_pixel_float (&image->bits, 0, 0); |
81 | |
|
82 | 0 | while (buffer < end) |
83 | 0 | *(buffer++) = color; |
84 | 0 | } |
85 | | |
86 | | static void |
87 | | noop_init_direct_buffer (pixman_iter_t *iter, const pixman_iter_info_t *info) |
88 | 27.6k | { |
89 | 27.6k | pixman_image_t *image = iter->image; |
90 | | |
91 | 27.6k | iter->buffer = |
92 | 27.6k | image->bits.bits + iter->y * image->bits.rowstride + iter->x; |
93 | 27.6k | } |
94 | | |
95 | | static void |
96 | | dest_write_back_direct (pixman_iter_t *iter) |
97 | 27.6k | { |
98 | 27.6k | iter->buffer += iter->image->bits.rowstride; |
99 | 27.6k | } |
100 | | |
101 | | static const pixman_iter_info_t noop_iters[] = |
102 | | { |
103 | | /* Source iters */ |
104 | | { PIXMAN_any, |
105 | | 0, ITER_IGNORE_ALPHA | ITER_IGNORE_RGB | ITER_SRC, |
106 | | NULL, |
107 | | _pixman_iter_get_scanline_noop, |
108 | | NULL |
109 | | }, |
110 | | { PIXMAN_solid, |
111 | | FAST_PATH_NO_ALPHA_MAP, ITER_NARROW | ITER_SRC, |
112 | | noop_init_solid_narrow, |
113 | | _pixman_iter_get_scanline_noop, |
114 | | NULL, |
115 | | }, |
116 | | { PIXMAN_solid, |
117 | | FAST_PATH_NO_ALPHA_MAP, ITER_WIDE | ITER_SRC, |
118 | | noop_init_solid_wide, |
119 | | _pixman_iter_get_scanline_noop, |
120 | | NULL |
121 | | }, |
122 | | { PIXMAN_a8r8g8b8, |
123 | | FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | |
124 | | FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST, |
125 | | ITER_NARROW | ITER_SRC, |
126 | | noop_init_direct_buffer, |
127 | | noop_get_scanline, |
128 | | NULL |
129 | | }, |
130 | | /* Dest iters */ |
131 | | { PIXMAN_a8r8g8b8, |
132 | | FAST_PATH_STD_DEST_FLAGS, ITER_NARROW | ITER_DEST, |
133 | | noop_init_direct_buffer, |
134 | | _pixman_iter_get_scanline_noop, |
135 | | dest_write_back_direct |
136 | | }, |
137 | | { PIXMAN_x8r8g8b8, |
138 | | FAST_PATH_STD_DEST_FLAGS, ITER_NARROW | ITER_DEST | ITER_LOCALIZED_ALPHA, |
139 | | noop_init_direct_buffer, |
140 | | _pixman_iter_get_scanline_noop, |
141 | | dest_write_back_direct |
142 | | }, |
143 | | { PIXMAN_null }, |
144 | | }; |
145 | | |
146 | | static const pixman_fast_path_t noop_fast_paths[] = |
147 | | { |
148 | | { PIXMAN_OP_DST, PIXMAN_any, 0, PIXMAN_any, 0, PIXMAN_any, 0, noop_composite }, |
149 | | { PIXMAN_OP_NONE }, |
150 | | }; |
151 | | |
152 | | pixman_implementation_t * |
153 | | _pixman_implementation_create_noop (pixman_implementation_t *fallback) |
154 | 10 | { |
155 | 10 | pixman_implementation_t *imp = |
156 | 10 | _pixman_implementation_create (fallback, noop_fast_paths); |
157 | | |
158 | 10 | imp->iter_info = noop_iters; |
159 | | |
160 | 10 | return imp; |
161 | 10 | } |