• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkOpts_DEFINED
9 #define SkOpts_DEFINED
10 
11 #include "SkConvolver.h"
12 #include "SkRasterPipeline.h"
13 #include "SkTypes.h"
14 #include "SkXfermodePriv.h"
15 
16 struct ProcCoeff;
17 
18 namespace SkOpts {
19     // Call to replace pointers to portable functions with pointers to CPU-specific functions.
20     // Thread-safe and idempotent.
21     // Called by SkGraphics::Init().
22     void Init();
23 
24     // Declare function pointers here...
25 
26     // May return nullptr if we haven't specialized the given Mode.
27     extern SkXfermode* (*create_xfermode)(SkBlendMode);
28 
29     typedef void (*BoxBlur)(const SkPMColor*, int, const SkIRect& srcBounds, SkPMColor*, int, int, int, int, int);
30     extern BoxBlur box_blur_xx, box_blur_xy, box_blur_yx;
31 
32     typedef void (*Morph)(const SkPMColor*, SkPMColor*, int, int, int, int, int);
33     extern Morph dilate_x, dilate_y, erode_x, erode_y;
34 
35     extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int);
36     extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor);
37     extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU);
38 
39     // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}.
40     typedef void (*Swizzle_8888)(uint32_t*, const void*, int);
41     extern Swizzle_8888 RGBA_to_BGRA,          // i.e. just swap RB
42                         RGBA_to_rgbA,          // i.e. just premultiply
43                         RGBA_to_bgrA,          // i.e. swap RB and premultiply
44                         RGB_to_RGB1,           // i.e. insert an opaque alpha
45                         RGB_to_BGR1,           // i.e. swap RB and insert an opaque alpha
46                         gray_to_RGB1,          // i.e. expand to color channels + an opaque alpha
47                         grayA_to_RGBA,         // i.e. expand to color channels
48                         grayA_to_rgbA,         // i.e. expand to color channels and premultiply
49                         inverted_CMYK_to_RGB1, // i.e. convert color space
50                         inverted_CMYK_to_BGR1; // i.e. convert color space
51 
52     // Blend ndst src pixels over dst, where both src and dst point to sRGB pixels (RGBA or BGRA).
53     // If nsrc < ndst, we loop over src to create a pattern.
54     extern void (*srcover_srgb_srgb)(uint32_t* dst, const uint32_t* src, int ndst, int nsrc);
55 
56     extern void (*memset16)(uint16_t[], uint16_t, int);
57     extern void (*memset32)(uint32_t[], uint32_t, int);
58     extern void (*memset64)(uint64_t[], uint64_t, int);
59 
60     // The fastest high quality 32-bit hash we can provide on this platform.
61     extern uint32_t (*hash_fn)(const void*, size_t, uint32_t seed);
62     static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) {
63         return hash_fn(data, bytes, seed);
64     }
65 
66     extern void (*convolve_vertically)(const SkConvolutionFilter1D::ConvolutionFixed* filter_values,
67                                        int filter_length, unsigned char* const* source_data_rows,
68                                        int pixel_width, unsigned char* out_row, bool has_alpha);
69     extern void (*convolve_4_rows_horizontally)(const unsigned char* src_data[4],
70                                                 const SkConvolutionFilter1D& filter,
71                                                 unsigned char* out_row[4], size_t out_row_bytes);
72     extern void (*convolve_horizontally)(const unsigned char* src_data, const SkConvolutionFilter1D& filter,
73                                          unsigned char* out_row, bool has_alpha);
74 }
75 
76 #endif//SkOpts_DEFINED
77