blob: 75eeffeb0aa08ad5daec29a9e7c779574d005299 [file] [log] [blame]
mtklein8317a182015-07-30 07:30:16 -07001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkTypes.h"
Mike Reed63559a52020-06-02 11:34:24 -040012#include "include/private/SkOpts_spi.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/core/SkRasterPipeline.h"
14#include "src/core/SkXfermodePriv.h"
mtklein490b6152015-07-31 11:50:27 -070015
Mike Kleina2187bf2018-11-16 12:22:05 -050016struct SkBitmapProcState;
Mike Kleinec370972020-03-05 10:15:35 -060017namespace skvm { struct InterpreterInstruction; }
mtklein8317a182015-07-30 07:30:16 -070018
19namespace SkOpts {
20 // Call to replace pointers to portable functions with pointers to CPU-specific functions.
21 // Thread-safe and idempotent.
mtklein05db63b2016-04-19 12:42:24 -070022 // Called by SkGraphics::Init().
mtklein8317a182015-07-30 07:30:16 -070023 void Init();
24
mtkleinf684a782015-07-30 09:29:37 -070025 // Declare function pointers here...
26
mtklein490b6152015-07-31 11:50:27 -070027 // May return nullptr if we haven't specialized the given Mode.
Mike Reedce9514c2017-06-11 22:14:14 -040028 extern SkXfermode* (*create_xfermode)(SkBlendMode);
mtkleindce5ce42015-08-04 08:49:21 -070029
mtklein49779832015-08-10 12:58:17 -070030 extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int);
Mike Kleinc33e6dc2019-04-10 11:44:42 -050031 extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor);
mtkleinb4a7dc92016-03-23 06:29:12 -070032 extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU);
mtklein2d141ba2015-08-18 09:43:28 -070033
mtklein8bf7b792016-01-22 07:42:53 -080034 // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}.
Mike Klein6e78ae52018-09-19 13:37:16 -040035 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
mtkleina525cb12016-02-09 08:18:10 -080048
Mike Klein87db0012017-05-23 12:20:38 -040049 extern void (*memset16)(uint16_t[], uint16_t, int);
Brian Osman417d2992019-11-18 17:19:42 -050050 extern void SK_SPI(*memset32)(uint32_t[], uint32_t, int);
Mike Klein87db0012017-05-23 12:20:38 -040051 extern void (*memset64)(uint64_t[], uint64_t, int);
52
Mike Reeddbc3caa2019-05-20 16:10:55 -040053 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 Reed3a8ff232019-07-10 12:16:39 -040057 extern float (*cubic_solver)(float, float, float, float);
58
mtklein4e976072016-08-08 09:06:27 -070059 static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) {
60 return hash_fn(data, bytes, seed);
61 }
Mike Klein1b9b7d52018-02-27 10:37:40 -050062
Mike Kleina2187bf2018-11-16 12:22:05 -050063 // SkBitmapProcState optimized Shader, Sample, or Matrix procs.
Mike Kleina2187bf2018-11-16 12:22:05 -050064 extern void (*S32_alpha_D32_filter_DX)(const SkBitmapProcState&,
65 const uint32_t* xy, int count, SkPMColor*);
Mike Klein37bc8f92019-10-21 13:10:07 -050066 extern void (*S32_alpha_D32_filter_DXDY)(const SkBitmapProcState&,
67 const uint32_t* xy, int count, SkPMColor*);
Mike Kleina2187bf2018-11-16 12:22:05 -050068
Mike Klein1b9b7d52018-02-27 10:37:40 -050069#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 Klein68c50d02019-05-29 12:57:54 -050079
Mike Kleinec370972020-03-05 10:15:35 -060080 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 Stilesa6841be2020-08-06 14:11:56 -040083} // namespace SkOpts
mtklein8317a182015-07-30 07:30:16 -070084
85#endif//SkOpts_DEFINED