blob: e7bf9b2403b83481288ecb3bf1027d8fee01ce2f [file] [log] [blame]
Mike Kleine1caee12017-02-15 13:31:12 -05001/*
2 * Copyright 2017 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 SkJumper_DEFINED
9#define SkJumper_DEFINED
10
Mike Klein376fd312017-12-11 16:53:26 -050011#include <stddef.h>
12#include <stdint.h>
13
Mike Klein5cc94cc2018-03-07 17:04:18 +000014// This file contains definitions shared by SkJumper.cpp (compiled normally as part of Skia)
15// and SkJumper_stages.cpp (compiled into Skia _and_ offline into SkJumper_generated.h).
16// Keep it simple!
17
18// Externally facing functions (start_pipeline) are called a little specially on Windows.
19#if defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__x86_64__)
20 #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V.
21#elif defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__i386__)
22 #define MAYBE_MSABI __attribute__((force_align_arg_pointer)) // Re-align stack 4 -> 16 bytes.
23#else
24 #define MAYBE_MSABI
25#endif
26
27// Any custom ABI to use for all non-externally-facing stage functions.
28#if defined(__ARM_NEON) && defined(__arm__)
29 // This lets us pass vectors more efficiently on 32-bit ARM.
30 #define ABI __attribute__((pcs("aapcs-vfp")))
31#else
32 #define ABI
33#endif
34
35// On ARM we expect that you're using Clang if you want SkJumper to be fast.
36// If you are, the baseline float stages will use NEON, and lowp stages will
37// also be available. (If somehow you're building for ARM not using Clang,
38// you'll get scalar baseline stages and no lowp support.)
39#if defined(__clang__) && defined(__ARM_NEON)
40 #define JUMPER_HAS_NEON_LOWP
41#endif
Mike Kleinb561b762017-08-28 17:53:34 -040042
Mike Kleind4faecd2017-10-17 14:31:17 -040043static const int SkJumper_kMaxStride = 16;
Mike Klein0a904492017-04-12 12:52:48 -040044
Mike Klein968af432017-07-18 16:31:55 -040045struct SkJumper_MemoryCtx {
46 void* pixels;
47 int stride;
Mike Kleindec4ea82017-04-06 15:04:05 -040048};
49
Mike Kleinf3b4e162017-09-22 15:32:59 -040050struct SkJumper_GatherCtx {
Mike Klein1fa9c432017-12-11 09:59:47 -050051 const void* pixels;
52 int stride;
53 float width;
54 float height;
Mike Kleinf3b4e162017-09-22 15:32:59 -040055};
56
Mike Klein0a904492017-04-12 12:52:48 -040057// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
58struct SkJumper_SamplerCtx {
59 float x[SkJumper_kMaxStride];
60 float y[SkJumper_kMaxStride];
61 float fx[SkJumper_kMaxStride];
62 float fy[SkJumper_kMaxStride];
63 float scalex[SkJumper_kMaxStride];
64 float scaley[SkJumper_kMaxStride];
65};
66
Mike Reed51e46d52017-06-23 14:21:25 -040067struct SkJumper_TileCtx {
68 float scale;
69 float invScale; // cache of 1/scale
70};
71
Mike Reeddfc0e912018-02-16 12:40:18 -050072struct SkJumper_DecalTileCtx {
73 uint32_t mask[SkJumper_kMaxStride];
74 float limit_x;
75 float limit_y;
76};
77
Mike Klein7fee90c2017-04-07 16:55:09 -040078struct SkJumper_CallbackCtx {
Mike Klein5cc94cc2018-03-07 17:04:18 +000079 MAYBE_MSABI void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/);
Mike Kleinc17dc242017-04-20 16:21:57 -040080
81 // When called, fn() will have our active pixels available in rgba.
82 // When fn() returns, the pipeline will read back those active pixels from read_from.
83 float rgba[4*SkJumper_kMaxStride];
84 float* read_from = rgba;
Mike Klein7fee90c2017-04-07 16:55:09 -040085};
86
Mike Kleina3735cd2017-04-17 13:19:05 -040087struct SkJumper_LoadTablesCtx {
88 const void* src;
89 const float *r, *g, *b;
90};
91
Mike Kleinc7d9c0b2017-04-17 14:43:59 -040092struct SkJumper_TableCtx {
93 const float* table;
94 int size;
95};
96
Brian Osman2c711332018-03-06 14:28:41 -050097struct SkJumper_ByteTablesRGBCtx {
98 const uint8_t *r, *g, *b;
99 int n;
100};
101
Mike Klein44375172017-04-17 19:32:05 -0400102// This should line up with the memory layout of SkColorSpaceTransferFn.
103struct SkJumper_ParametricTransferFunction {
104 float G, A,B,C,D,E,F;
105};
106
Herb Derby4de13042017-05-15 10:49:39 -0400107struct SkJumper_GradientCtx {
108 size_t stopCount;
109 float* fs[4];
110 float* bs[4];
111 float* ts;
112};
113
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400114struct SkJumper_2PtConicalCtx {
Florin Malita9026fe12017-06-29 11:03:45 -0400115 uint32_t fMask[SkJumper_kMaxStride];
Yuqian Lid3b743a2018-01-09 11:47:45 -0500116 float fP0,
Yuqian Lid208a882018-01-04 10:08:42 -0500117 fP1;
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400118};
119
Mike Klein1a2e3e12017-08-03 11:24:13 -0400120struct SkJumper_UniformColorCtx {
121 float r,g,b,a;
Mike Kleinf757ae62017-09-15 14:57:02 -0400122 uint16_t rgba[4]; // [0,255] in a 16-bit lane.
Mike Klein1a2e3e12017-08-03 11:24:13 -0400123};
124
Mike Kleinc2f876b2017-08-09 18:23:25 -0400125struct SkJumper_ColorLookupTableCtx {
126 const float* table;
127 int limits[4];
128};
129
Mike Kleine1caee12017-02-15 13:31:12 -0500130#endif//SkJumper_DEFINED