1 /* 2 * Copyright (c) 2012 3 * MIPS Technologies, Inc., California. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Author: Nemanja Lukic (nlukic (at) mips.com) 30 */ 31 32 #ifndef PIXMAN_MIPS_DSPR2_H 33 #define PIXMAN_MIPS_DSPR2_H 34 35 #include "pixman-private.h" 36 #include "pixman-inlines.h" 37 38 #define SKIP_ZERO_SRC 1 39 #define SKIP_ZERO_MASK 2 40 #define DO_FAST_MEMCPY 3 41 42 void 43 pixman_mips_fast_memcpy (void *dst, void *src, uint32_t n_bytes); 44 void 45 pixman_fill_buff16_mips (void *dst, uint32_t n_bytes, uint16_t value); 46 void 47 pixman_fill_buff32_mips (void *dst, uint32_t n_bytes, uint32_t value); 48 49 /****************************************************************/ 50 51 #define PIXMAN_MIPS_BIND_FAST_PATH_SRC_DST(flags, name, \ 52 src_type, src_cnt, \ 53 dst_type, dst_cnt) \ 54 void \ 55 pixman_composite_##name##_asm_mips (dst_type *dst, \ 56 src_type *src, \ 57 int32_t w); \ 58 \ 59 static void \ 60 mips_composite_##name (pixman_implementation_t *imp, \ 61 pixman_composite_info_t *info) \ 62 { \ 63 PIXMAN_COMPOSITE_ARGS (info); \ 64 dst_type *dst_line, *dst; \ 65 src_type *src_line, *src; \ 66 int32_t dst_stride, src_stride; \ 67 int bpp = PIXMAN_FORMAT_BPP (dest_image->bits.format) / 8; \ 68 \ 69 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ 70 src_stride, src_line, src_cnt); \ 71 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 72 dst_stride, dst_line, dst_cnt); \ 73 \ 74 while (height--) \ 75 { \ 76 dst = dst_line; \ 77 dst_line += dst_stride; \ 78 src = src_line; \ 79 src_line += src_stride; \ 80 \ 81 if (flags == DO_FAST_MEMCPY) \ 82 pixman_mips_fast_memcpy (dst, src, width * bpp); \ 83 else \ 84 pixman_composite_##name##_asm_mips (dst, src, width); \ 85 } \ 86 } 87 88 /****************************************************************/ 89 90 #define PIXMAN_MIPS_BIND_FAST_PATH_N_DST(flags, name, \ 91 dst_type, dst_cnt) \ 92 void \ 93 pixman_composite_##name##_asm_mips (dst_type *dst, \ 94 uint32_t src, \ 95 int32_t w); \ 96 \ 97 static void \ 98 mips_composite_##name (pixman_implementation_t *imp, \ 99 pixman_composite_info_t *info) \ 100 { \ 101 PIXMAN_COMPOSITE_ARGS (info); \ 102 dst_type *dst_line, *dst; \ 103 int32_t dst_stride; \ 104 uint32_t src; \ 105 \ 106 src = _pixman_image_get_solid ( \ 107 imp, src_image, dest_image->bits.format); \ 108 \ 109 if ((flags & SKIP_ZERO_SRC) && src == 0) \ 110 return; \ 111 \ 112 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 113 dst_stride, dst_line, dst_cnt); \ 114 \ 115 while (height--) \ 116 { \ 117 dst = dst_line; \ 118 dst_line += dst_stride; \ 119 \ 120 pixman_composite_##name##_asm_mips (dst, src, width); \ 121 } \ 122 } 123 124 /*******************************************************************/ 125 126 #define PIXMAN_MIPS_BIND_FAST_PATH_N_MASK_DST(flags, name, \ 127 mask_type, mask_cnt, \ 128 dst_type, dst_cnt) \ 129 void \ 130 pixman_composite_##name##_asm_mips (dst_type *dst, \ 131 uint32_t src, \ 132 mask_type *mask, \ 133 int32_t w); \ 134 \ 135 static void \ 136 mips_composite_##name (pixman_implementation_t *imp, \ 137 pixman_composite_info_t *info) \ 138 { \ 139 PIXMAN_COMPOSITE_ARGS (info); \ 140 dst_type *dst_line, *dst; \ 141 mask_type *mask_line, *mask; \ 142 int32_t dst_stride, mask_stride; \ 143 uint32_t src; \ 144 \ 145 src = _pixman_image_get_solid ( \ 146 imp, src_image, dest_image->bits.format); \ 147 \ 148 if ((flags & SKIP_ZERO_SRC) && src == 0) \ 149 return; \ 150 \ 151 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 152 dst_stride, dst_line, dst_cnt); \ 153 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \ 154 mask_stride, mask_line, mask_cnt); \ 155 \ 156 while (height--) \ 157 { \ 158 dst = dst_line; \ 159 dst_line += dst_stride; \ 160 mask = mask_line; \ 161 mask_line += mask_stride; \ 162 pixman_composite_##name##_asm_mips (dst, src, mask, width); \ 163 } \ 164 } 165 166 /*******************************************************************/ 167 168 #define PIXMAN_MIPS_BIND_FAST_PATH_SRC_N_DST(flags, name, \ 169 src_type, src_cnt, \ 170 dst_type, dst_cnt) \ 171 void \ 172 pixman_composite_##name##_asm_mips (dst_type *dst, \ 173 src_type *src, \ 174 uint32_t mask, \ 175 int32_t w); \ 176 \ 177 static void \ 178 mips_composite_##name (pixman_implementation_t *imp, \ 179 pixman_composite_info_t *info) \ 180 { \ 181 PIXMAN_COMPOSITE_ARGS (info); \ 182 dst_type *dst_line, *dst; \ 183 src_type *src_line, *src; \ 184 int32_t dst_stride, src_stride; \ 185 uint32_t mask; \ 186 \ 187 mask = _pixman_image_get_solid ( \ 188 imp, mask_image, dest_image->bits.format); \ 189 \ 190 if ((flags & SKIP_ZERO_MASK) && mask == 0) \ 191 return; \ 192 \ 193 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 194 dst_stride, dst_line, dst_cnt); \ 195 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ 196 src_stride, src_line, src_cnt); \ 197 \ 198 while (height--) \ 199 { \ 200 dst = dst_line; \ 201 dst_line += dst_stride; \ 202 src = src_line; \ 203 src_line += src_stride; \ 204 \ 205 pixman_composite_##name##_asm_mips (dst, src, mask, width); \ 206 } \ 207 } 208 209 /************************************************************************/ 210 211 #define PIXMAN_MIPS_BIND_FAST_PATH_SRC_MASK_DST(name, src_type, src_cnt, \ 212 mask_type, mask_cnt, \ 213 dst_type, dst_cnt) \ 214 void \ 215 pixman_composite_##name##_asm_mips (dst_type *dst, \ 216 src_type *src, \ 217 mask_type *mask, \ 218 int32_t w); \ 219 \ 220 static void \ 221 mips_composite_##name (pixman_implementation_t *imp, \ 222 pixman_composite_info_t *info) \ 223 { \ 224 PIXMAN_COMPOSITE_ARGS (info); \ 225 dst_type *dst_line, *dst; \ 226 src_type *src_line, *src; \ 227 mask_type *mask_line, *mask; \ 228 int32_t dst_stride, src_stride, mask_stride; \ 229 \ 230 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type, \ 231 dst_stride, dst_line, dst_cnt); \ 232 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, src_type, \ 233 src_stride, src_line, src_cnt); \ 234 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type, \ 235 mask_stride, mask_line, mask_cnt); \ 236 \ 237 while (height--) \ 238 { \ 239 dst = dst_line; \ 240 dst_line += dst_stride; \ 241 mask = mask_line; \ 242 mask_line += mask_stride; \ 243 src = src_line; \ 244 src_line += src_stride; \ 245 pixman_composite_##name##_asm_mips (dst, src, mask, width); \ 246 } \ 247 } 248 249 /****************************************************************************/ 250 251 #define PIXMAN_MIPS_BIND_SCALED_NEAREST_SRC_DST(name, op, \ 252 src_type, dst_type) \ 253 void \ 254 pixman_scaled_nearest_scanline_##name##_##op##_asm_mips ( \ 255 dst_type * dst, \ 256 const src_type * src, \ 257 int32_t w, \ 258 pixman_fixed_t vx, \ 259 pixman_fixed_t unit_x); \ 260 \ 261 static force_inline void \ 262 scaled_nearest_scanline_mips_##name##_##op (dst_type * pd, \ 263 const src_type * ps, \ 264 int32_t w, \ 265 pixman_fixed_t vx, \ 266 pixman_fixed_t unit_x, \ 267 pixman_fixed_t max_vx, \ 268 pixman_bool_t zero_src) \ 269 { \ 270 pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (pd, ps, w, \ 271 vx, unit_x); \ 272 } \ 273 \ 274 FAST_NEAREST_MAINLOOP (mips_##name##_cover_##op, \ 275 scaled_nearest_scanline_mips_##name##_##op, \ 276 src_type, dst_type, COVER) \ 277 FAST_NEAREST_MAINLOOP (mips_##name##_none_##op, \ 278 scaled_nearest_scanline_mips_##name##_##op, \ 279 src_type, dst_type, NONE) \ 280 FAST_NEAREST_MAINLOOP (mips_##name##_pad_##op, \ 281 scaled_nearest_scanline_mips_##name##_##op, \ 282 src_type, dst_type, PAD) 283 284 /* Provide entries for the fast path table */ 285 #define PIXMAN_MIPS_SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \ 286 SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \ 287 SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \ 288 SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func) 289 290 291 /*****************************************************************************/ 292 293 #define PIXMAN_MIPS_BIND_SCALED_NEAREST_SRC_A8_DST(flags, name, op, \ 294 src_type, dst_type) \ 295 void \ 296 pixman_scaled_nearest_scanline_##name##_##op##_asm_mips ( \ 297 dst_type * dst, \ 298 const src_type * src, \ 299 const uint8_t * mask, \ 300 int32_t w, \ 301 pixman_fixed_t vx, \ 302 pixman_fixed_t unit_x); \ 303 \ 304 static force_inline void \ 305 scaled_nearest_scanline_mips_##name##_##op (const uint8_t * mask, \ 306 dst_type * pd, \ 307 const src_type * ps, \ 308 int32_t w, \ 309 pixman_fixed_t vx, \ 310 pixman_fixed_t unit_x, \ 311 pixman_fixed_t max_vx, \ 312 pixman_bool_t zero_src) \ 313 { \ 314 if ((flags & SKIP_ZERO_SRC) && zero_src) \ 315 return; \ 316 pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (pd, ps, \ 317 mask, w, \ 318 vx, unit_x); \ 319 } \ 320 \ 321 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_cover_##op, \ 322 scaled_nearest_scanline_mips_##name##_##op, \ 323 src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\ 324 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_none_##op, \ 325 scaled_nearest_scanline_mips_##name##_##op, \ 326 src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \ 327 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_pad_##op, \ 328 scaled_nearest_scanline_mips_##name##_##op, \ 329 src_type, uint8_t, dst_type, PAD, TRUE, FALSE) 330 331 /* Provide entries for the fast path table */ 332 #define PIXMAN_MIPS_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \ 333 SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \ 334 SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \ 335 SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func) 336 337 /****************************************************************************/ 338 339 #define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_DST(flags, name, op, \ 340 src_type, dst_type) \ 341 void \ 342 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips( \ 343 dst_type * dst, \ 344 const src_type * src_top, \ 345 const src_type * src_bottom, \ 346 int32_t w, \ 347 int wt, \ 348 int wb, \ 349 pixman_fixed_t vx, \ 350 pixman_fixed_t unit_x); \ 351 static force_inline void \ 352 scaled_bilinear_scanline_mips_##name##_##op (dst_type * dst, \ 353 const uint32_t * mask, \ 354 const src_type * src_top, \ 355 const src_type * src_bottom, \ 356 int32_t w, \ 357 int wt, \ 358 int wb, \ 359 pixman_fixed_t vx, \ 360 pixman_fixed_t unit_x, \ 361 pixman_fixed_t max_vx, \ 362 pixman_bool_t zero_src) \ 363 { \ 364 if ((flags & SKIP_ZERO_SRC) && zero_src) \ 365 return; \ 366 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (dst, src_top, \ 367 src_bottom, w, \ 368 wt, wb, \ 369 vx, unit_x); \ 370 } \ 371 \ 372 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op, \ 373 scaled_bilinear_scanline_mips_##name##_##op, \ 374 src_type, uint32_t, dst_type, COVER, FLAG_NONE) \ 375 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op, \ 376 scaled_bilinear_scanline_mips_##name##_##op, \ 377 src_type, uint32_t, dst_type, NONE, FLAG_NONE) \ 378 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op, \ 379 scaled_bilinear_scanline_mips_##name##_##op, \ 380 src_type, uint32_t, dst_type, PAD, FLAG_NONE) \ 381 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op, \ 382 scaled_bilinear_scanline_mips_##name##_##op, \ 383 src_type, uint32_t, dst_type, NORMAL, \ 384 FLAG_NONE) 385 386 /*****************************************************************************/ 387 388 #define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, name, op, \ 389 src_type, dst_type) \ 390 void \ 391 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips ( \ 392 dst_type * dst, \ 393 const uint8_t * mask, \ 394 const src_type * top, \ 395 const src_type * bottom, \ 396 int wt, \ 397 int wb, \ 398 pixman_fixed_t x, \ 399 pixman_fixed_t ux, \ 400 int width); \ 401 \ 402 static force_inline void \ 403 scaled_bilinear_scanline_mips_##name##_##op (dst_type * dst, \ 404 const uint8_t * mask, \ 405 const src_type * src_top, \ 406 const src_type * src_bottom, \ 407 int32_t w, \ 408 int wt, \ 409 int wb, \ 410 pixman_fixed_t vx, \ 411 pixman_fixed_t unit_x, \ 412 pixman_fixed_t max_vx, \ 413 pixman_bool_t zero_src) \ 414 { \ 415 if ((flags & SKIP_ZERO_SRC) && zero_src) \ 416 return; \ 417 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips ( \ 418 dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \ 419 } \ 420 \ 421 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op, \ 422 scaled_bilinear_scanline_mips_##name##_##op, \ 423 src_type, uint8_t, dst_type, COVER, \ 424 FLAG_HAVE_NON_SOLID_MASK) \ 425 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op, \ 426 scaled_bilinear_scanline_mips_##name##_##op, \ 427 src_type, uint8_t, dst_type, NONE, \ 428 FLAG_HAVE_NON_SOLID_MASK) \ 429 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op, \ 430 scaled_bilinear_scanline_mips_##name##_##op, \ 431 src_type, uint8_t, dst_type, PAD, \ 432 FLAG_HAVE_NON_SOLID_MASK) \ 433 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op, \ 434 scaled_bilinear_scanline_mips_##name##_##op, \ 435 src_type, uint8_t, dst_type, NORMAL, \ 436 FLAG_HAVE_NON_SOLID_MASK) 437 438 #endif //PIXMAN_MIPS_DSPR2_H 439