mtklein | 8317a18 | 2015-07-30 07:30:16 -0700 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkTypes.h" |
Mike Reed | 63559a5 | 2020-06-02 11:34:24 -0400 | [diff] [blame] | 12 | #include "include/private/SkOpts_spi.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/core/SkRasterPipeline.h" |
| 14 | #include "src/core/SkXfermodePriv.h" |
mtklein | 490b615 | 2015-07-31 11:50:27 -0700 | [diff] [blame] | 15 | |
Mike Klein | a2187bf | 2018-11-16 12:22:05 -0500 | [diff] [blame] | 16 | struct SkBitmapProcState; |
Mike Klein | ec37097 | 2020-03-05 10:15:35 -0600 | [diff] [blame] | 17 | namespace skvm { struct InterpreterInstruction; } |
mtklein | 8317a18 | 2015-07-30 07:30:16 -0700 | [diff] [blame] | 18 | |
| 19 | namespace SkOpts { |
| 20 | // Call to replace pointers to portable functions with pointers to CPU-specific functions. |
| 21 | // Thread-safe and idempotent. |
mtklein | 05db63b | 2016-04-19 12:42:24 -0700 | [diff] [blame] | 22 | // Called by SkGraphics::Init(). |
mtklein | 8317a18 | 2015-07-30 07:30:16 -0700 | [diff] [blame] | 23 | void Init(); |
| 24 | |
mtklein | f684a78 | 2015-07-30 09:29:37 -0700 | [diff] [blame] | 25 | // Declare function pointers here... |
| 26 | |
mtklein | 490b615 | 2015-07-31 11:50:27 -0700 | [diff] [blame] | 27 | // May return nullptr if we haven't specialized the given Mode. |
Mike Reed | ce9514c | 2017-06-11 22:14:14 -0400 | [diff] [blame] | 28 | extern SkXfermode* (*create_xfermode)(SkBlendMode); |
mtklein | dce5ce4 | 2015-08-04 08:49:21 -0700 | [diff] [blame] | 29 | |
mtklein | 4977983 | 2015-08-10 12:58:17 -0700 | [diff] [blame] | 30 | extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int); |
Mike Klein | c33e6dc | 2019-04-10 11:44:42 -0500 | [diff] [blame] | 31 | extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor); |
mtklein | b4a7dc9 | 2016-03-23 06:29:12 -0700 | [diff] [blame] | 32 | extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU); |
mtklein | 2d141ba | 2015-08-18 09:43:28 -0700 | [diff] [blame] | 33 | |
mtklein | 8bf7b79 | 2016-01-22 07:42:53 -0800 | [diff] [blame] | 34 | // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}. |
Mike Klein | 6e78ae5 | 2018-09-19 13:37:16 -0400 | [diff] [blame] | 35 | typedef void (*Swizzle_8888_u32)(uint32_t*, const uint32_t*, int); |
| 36 | extern Swizzle_8888_u32 RGBA_to_BGRA, // i.e. just swap RB |
| 37 | RGBA_to_rgbA, // i.e. just premultiply |
| 38 | RGBA_to_bgrA, // i.e. swap RB and premultiply |
| 39 | inverted_CMYK_to_RGB1, // i.e. convert color space |
| 40 | inverted_CMYK_to_BGR1; // i.e. convert color space |
| 41 | |
| 42 | typedef void (*Swizzle_8888_u8)(uint32_t*, const uint8_t*, int); |
| 43 | extern Swizzle_8888_u8 RGB_to_RGB1, // i.e. insert an opaque alpha |
| 44 | RGB_to_BGR1, // i.e. swap RB and insert an opaque alpha |
| 45 | gray_to_RGB1, // i.e. expand to color channels + an opaque alpha |
| 46 | grayA_to_RGBA, // i.e. expand to color channels |
| 47 | grayA_to_rgbA; // i.e. expand to color channels and premultiply |
mtklein | a525cb1 | 2016-02-09 08:18:10 -0800 | [diff] [blame] | 48 | |
Mike Klein | 87db001 | 2017-05-23 12:20:38 -0400 | [diff] [blame] | 49 | extern void (*memset16)(uint16_t[], uint16_t, int); |
Brian Osman | 417d299 | 2019-11-18 17:19:42 -0500 | [diff] [blame] | 50 | extern void SK_SPI(*memset32)(uint32_t[], uint32_t, int); |
Mike Klein | 87db001 | 2017-05-23 12:20:38 -0400 | [diff] [blame] | 51 | extern void (*memset64)(uint64_t[], uint64_t, int); |
| 52 | |
Mike Reed | dbc3caa | 2019-05-20 16:10:55 -0400 | [diff] [blame] | 53 | extern void (*rect_memset16)(uint16_t[], uint16_t, int, size_t, int); |
| 54 | extern void (*rect_memset32)(uint32_t[], uint32_t, int, size_t, int); |
| 55 | extern void (*rect_memset64)(uint64_t[], uint64_t, int, size_t, int); |
| 56 | |
Mike Reed | 3a8ff23 | 2019-07-10 12:16:39 -0400 | [diff] [blame] | 57 | extern float (*cubic_solver)(float, float, float, float); |
| 58 | |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 59 | static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) { |
| 60 | return hash_fn(data, bytes, seed); |
| 61 | } |
Mike Klein | 1b9b7d5 | 2018-02-27 10:37:40 -0500 | [diff] [blame] | 62 | |
Mike Klein | a2187bf | 2018-11-16 12:22:05 -0500 | [diff] [blame] | 63 | // SkBitmapProcState optimized Shader, Sample, or Matrix procs. |
Mike Klein | a2187bf | 2018-11-16 12:22:05 -0500 | [diff] [blame] | 64 | extern void (*S32_alpha_D32_filter_DX)(const SkBitmapProcState&, |
| 65 | const uint32_t* xy, int count, SkPMColor*); |
Mike Klein | 37bc8f9 | 2019-10-21 13:10:07 -0500 | [diff] [blame] | 66 | extern void (*S32_alpha_D32_filter_DXDY)(const SkBitmapProcState&, |
| 67 | const uint32_t* xy, int count, SkPMColor*); |
Mike Klein | a2187bf | 2018-11-16 12:22:05 -0500 | [diff] [blame] | 68 | |
Mike Klein | 1b9b7d5 | 2018-02-27 10:37:40 -0500 | [diff] [blame] | 69 | #define M(st) +1 |
| 70 | // We can't necessarily express the type of SkJumper stage functions here, |
| 71 | // so we just use this void(*)(void) as a stand-in. |
| 72 | using StageFn = void(*)(void); |
| 73 | extern StageFn stages_highp[SK_RASTER_PIPELINE_STAGES(M)], just_return_highp; |
| 74 | extern StageFn stages_lowp [SK_RASTER_PIPELINE_STAGES(M)], just_return_lowp; |
| 75 | |
| 76 | extern void (*start_pipeline_highp)(size_t,size_t,size_t,size_t, void**); |
| 77 | extern void (*start_pipeline_lowp )(size_t,size_t,size_t,size_t, void**); |
| 78 | #undef M |
Mike Klein | 68c50d0 | 2019-05-29 12:57:54 -0500 | [diff] [blame] | 79 | |
Mike Klein | ec37097 | 2020-03-05 10:15:35 -0600 | [diff] [blame] | 80 | extern void (*interpret_skvm)(const skvm::InterpreterInstruction insts[], int ninsts, |
| 81 | int nregs, int loop, const int strides[], int nargs, |
| 82 | int n, void* args[]); |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame^] | 83 | } // namespace SkOpts |
mtklein | 8317a18 | 2015-07-30 07:30:16 -0700 | [diff] [blame] | 84 | |
| 85 | #endif//SkOpts_DEFINED |