gfx/cairo/libpixman/src/pixman-mips-dspr2.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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@mips.com)
    30  */
    32 #ifndef PIXMAN_MIPS_DSPR2_H
    33 #define PIXMAN_MIPS_DSPR2_H
    35 #include "pixman-private.h"
    36 #include "pixman-inlines.h"
    38 #define SKIP_ZERO_SRC  1
    39 #define SKIP_ZERO_MASK 2
    40 #define DO_FAST_MEMCPY 3
    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);
    49 /****************************************************************/
    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 }
    88 /****************************************************************/
    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 }
   124 /*******************************************************************/
   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 }
   166 /*******************************************************************/
   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 }
   209 /************************************************************************/
   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 }
   249 /*****************************************************************************/
   251 #define PIXMAN_MIPS_BIND_SCALED_NEAREST_SRC_A8_DST(flags, 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                                                    const uint8_t *  mask,     \
   258                                                    int32_t          w,        \
   259                                                    pixman_fixed_t   vx,       \
   260                                                    pixman_fixed_t   unit_x);  \
   261                                                                               \
   262 static force_inline void                                                      \
   263 scaled_nearest_scanline_mips_##name##_##op (const uint8_t *  mask,            \
   264                                             dst_type *       pd,              \
   265                                             const src_type * ps,              \
   266                                             int32_t          w,               \
   267                                             pixman_fixed_t   vx,              \
   268                                             pixman_fixed_t   unit_x,          \
   269                                             pixman_fixed_t   max_vx,          \
   270                                             pixman_bool_t    zero_src)        \
   271 {                                                                             \
   272     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
   273         return;                                                               \
   274     pixman_scaled_nearest_scanline_##name##_##op##_asm_mips (pd, ps,          \
   275                                                              mask, w,         \
   276                                                              vx, unit_x);     \
   277 }                                                                             \
   278                                                                               \
   279 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_cover_##op,                       \
   280                               scaled_nearest_scanline_mips_##name##_##op,     \
   281                               src_type, uint8_t, dst_type, COVER, TRUE, FALSE)\
   282 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_none_##op,                        \
   283                               scaled_nearest_scanline_mips_##name##_##op,     \
   284                               src_type, uint8_t, dst_type, NONE, TRUE, FALSE) \
   285 FAST_NEAREST_MAINLOOP_COMMON (mips_##name##_pad_##op,                         \
   286                               scaled_nearest_scanline_mips_##name##_##op,     \
   287                               src_type, uint8_t, dst_type, PAD, TRUE, FALSE)
   289 /* Provide entries for the fast path table */
   290 #define PIXMAN_MIPS_SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func)             \
   291     SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func),                     \
   292     SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func),                      \
   293     SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func)
   295 /****************************************************************************/
   297 #define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_DST(flags, name, op,            \
   298                                                  src_type, dst_type)         \
   299 void                                                                         \
   300 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips(                    \
   301                                              dst_type *       dst,           \
   302                                              const src_type * src_top,       \
   303                                              const src_type * src_bottom,    \
   304                                              int32_t          w,             \
   305                                              int              wt,            \
   306                                              int              wb,            \
   307                                              pixman_fixed_t   vx,            \
   308                                              pixman_fixed_t   unit_x);       \
   309 static force_inline void                                                     \
   310 scaled_bilinear_scanline_mips_##name##_##op (dst_type *       dst,           \
   311                                              const uint32_t * mask,          \
   312                                              const src_type * src_top,       \
   313                                              const src_type * src_bottom,    \
   314                                              int32_t          w,             \
   315                                              int              wt,            \
   316                                              int              wb,            \
   317                                              pixman_fixed_t   vx,            \
   318                                              pixman_fixed_t   unit_x,        \
   319                                              pixman_fixed_t   max_vx,        \
   320                                              pixman_bool_t    zero_src)      \
   321 {                                                                            \
   322     if ((flags & SKIP_ZERO_SRC) && zero_src)                                 \
   323         return;                                                              \
   324     pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (dst, src_top,  \
   325                                                               src_bottom, w, \
   326                                                               wt, wb,        \
   327                                                               vx, unit_x);   \
   328 }                                                                            \
   329                                                                              \
   330 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op,                     \
   331                        scaled_bilinear_scanline_mips_##name##_##op,          \
   332                        src_type, uint32_t, dst_type, COVER, FLAG_NONE)       \
   333 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op,                      \
   334                        scaled_bilinear_scanline_mips_##name##_##op,          \
   335                        src_type, uint32_t, dst_type, NONE, FLAG_NONE)        \
   336 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op,                       \
   337                        scaled_bilinear_scanline_mips_##name##_##op,          \
   338                        src_type, uint32_t, dst_type, PAD, FLAG_NONE)         \
   339 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op,                    \
   340                        scaled_bilinear_scanline_mips_##name##_##op,          \
   341                        src_type, uint32_t, dst_type, NORMAL,                 \
   342                        FLAG_NONE)
   344 /*****************************************************************************/
   346 #define PIXMAN_MIPS_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, name, op,          \
   347                                                 src_type, dst_type)           \
   348 void                                                                          \
   349 pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (                    \
   350                                              dst_type *       dst,            \
   351                                              const uint8_t *  mask,           \
   352                                              const src_type * top,            \
   353                                              const src_type * bottom,         \
   354                                              int              wt,             \
   355                                              int              wb,             \
   356                                              pixman_fixed_t   x,              \
   357                                              pixman_fixed_t   ux,             \
   358                                              int              width);         \
   359                                                                               \
   360 static force_inline void                                                      \
   361 scaled_bilinear_scanline_mips_##name##_##op (dst_type *       dst,            \
   362                                              const uint8_t *  mask,           \
   363                                              const src_type * src_top,        \
   364                                              const src_type * src_bottom,     \
   365                                              int32_t          w,              \
   366                                              int              wt,             \
   367                                              int              wb,             \
   368                                              pixman_fixed_t   vx,             \
   369                                              pixman_fixed_t   unit_x,         \
   370                                              pixman_fixed_t   max_vx,         \
   371                                              pixman_bool_t    zero_src)       \
   372 {                                                                             \
   373     if ((flags & SKIP_ZERO_SRC) && zero_src)                                  \
   374         return;                                                               \
   375     pixman_scaled_bilinear_scanline_##name##_##op##_asm_mips (                \
   376                       dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
   377 }                                                                             \
   378                                                                               \
   379 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_cover_##op,                      \
   380                        scaled_bilinear_scanline_mips_##name##_##op,           \
   381                        src_type, uint8_t, dst_type, COVER,                    \
   382                        FLAG_HAVE_NON_SOLID_MASK)                              \
   383 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_none_##op,                       \
   384                        scaled_bilinear_scanline_mips_##name##_##op,           \
   385                        src_type, uint8_t, dst_type, NONE,                     \
   386                        FLAG_HAVE_NON_SOLID_MASK)                              \
   387 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_pad_##op,                        \
   388                        scaled_bilinear_scanline_mips_##name##_##op,           \
   389                        src_type, uint8_t, dst_type, PAD,                      \
   390                        FLAG_HAVE_NON_SOLID_MASK)                              \
   391 FAST_BILINEAR_MAINLOOP_COMMON (mips_##name##_normal_##op,                     \
   392                        scaled_bilinear_scanline_mips_##name##_##op,           \
   393                        src_type, uint8_t, dst_type, NORMAL,                   \
   394                        FLAG_HAVE_NON_SOLID_MASK)
   396 #endif //PIXMAN_MIPS_DSPR2_H

mercurial