• 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 "SkRasterPipeline.h"
12 #include "SkTypes.h"
13 #include "SkXfermodePriv.h"
14 
15 struct SkBitmapProcState;
16 
17 namespace SkOpts {
18     // Call to replace pointers to portable functions with pointers to CPU-specific functions.
19     // Thread-safe and idempotent.
20     // Called by SkGraphics::Init().
21     void Init();
22 
23     // Declare function pointers here...
24 
25     // May return nullptr if we haven't specialized the given Mode.
26     extern SkXfermode* (*create_xfermode)(SkBlendMode);
27 
28     extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int);
29     extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU);
30 
31     // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}.
32     typedef void (*Swizzle_8888_u32)(uint32_t*, const uint32_t*, int);
33     extern Swizzle_8888_u32 RGBA_to_BGRA,          // i.e. just swap RB
34                             RGBA_to_rgbA,          // i.e. just premultiply
35                             RGBA_to_bgrA,          // i.e. swap RB and premultiply
36                             inverted_CMYK_to_RGB1, // i.e. convert color space
37                             inverted_CMYK_to_BGR1; // i.e. convert color space
38 
39     typedef void (*Swizzle_8888_u8)(uint32_t*, const uint8_t*, int);
40     extern Swizzle_8888_u8 RGB_to_RGB1,     // i.e. insert an opaque alpha
41                            RGB_to_BGR1,     // i.e. swap RB and insert an opaque alpha
42                            gray_to_RGB1,    // i.e. expand to color channels + an opaque alpha
43                            grayA_to_RGBA,   // i.e. expand to color channels
44                            grayA_to_rgbA;   // i.e. expand to color channels and premultiply
45 
46     extern void (*memset16)(uint16_t[], uint16_t, int);
47     extern void SK_API (*memset32)(uint32_t[], uint32_t, int);
48     extern void (*memset64)(uint64_t[], uint64_t, int);
49 
50     // The fastest high quality 32-bit hash we can provide on this platform.
51     extern uint32_t (*hash_fn)(const void*, size_t, uint32_t seed);
52     static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) {
53         return hash_fn(data, bytes, seed);
54     }
55 
56     // SkBitmapProcState optimized Shader, Sample, or Matrix procs.
57     // This is the only one that can use anything past SSE2/NEON.
58     extern void (*S32_alpha_D32_filter_DX)(const SkBitmapProcState&,
59                                            const uint32_t* xy, int count, SkPMColor*);
60 
61 #define M(st) +1
62     // We can't necessarily express the type of SkJumper stage functions here,
63     // so we just use this void(*)(void) as a stand-in.
64     using StageFn = void(*)(void);
65     extern StageFn stages_highp[SK_RASTER_PIPELINE_STAGES(M)], just_return_highp;
66     extern StageFn stages_lowp [SK_RASTER_PIPELINE_STAGES(M)], just_return_lowp;
67 
68     extern void (*start_pipeline_highp)(size_t,size_t,size_t,size_t, void**);
69     extern void (*start_pipeline_lowp )(size_t,size_t,size_t,size_t, void**);
70 #undef M
71 }
72 
73 #endif//SkOpts_DEFINED
74