blob: b6fa17c88ae1bab192dc2fb8aeb849ce5291a526 [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
11// This file contains definitions shared by SkJumper.cpp (compiled normally as part of Skia)
12// and SkJumper_stages.cpp (compiled into Skia _and_ offline into SkJumper_generated.h).
13// Keep it simple!
14
Mike Kleinea23a042017-06-27 12:06:56 -040015// Externally facing functions (start_pipeline) are called a little specially on Windows.
16#if defined(JUMPER) && defined(WIN) && defined(__x86_64__)
17 #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V.
18#elif defined(JUMPER) && defined(WIN) && defined(__i386__)
19 #define MAYBE_MSABI __attribute__((force_align_arg_pointer)) // Re-align stack 4 -> 16 bytes.
Mike Klein7fee90c2017-04-07 16:55:09 -040020#else
21 #define MAYBE_MSABI
22#endif
23
Mike Klein3b805582017-04-06 13:44:03 -040024#if defined(JUMPER) && (defined(__aarch64__) || defined(__arm__))
Mike Kleinb7bf09c2017-03-31 14:15:56 -040025 // To reduce SkJumper's dependency on the Android NDK,
26 // we provide what we need from <string.h>, <stdint.h>, and <stddef.h> ourselves.
27 #define memcpy __builtin_memcpy
28
29 using int8_t = signed char;
30 using uint8_t = unsigned char;
31 using int16_t = signed short;
32 using uint16_t = unsigned short;
33 using int32_t = signed int;
34 using uint32_t = unsigned int;
35 #if defined(__aarch64__)
36 using int64_t = signed long;
37 using uint64_t = unsigned long;
38 using size_t = uint64_t;
39 #else
40 using int64_t = signed long long;
41 using uint64_t = unsigned long long;
42 using size_t = uint32_t;
43 #endif
44
45 // Now pretend we've included <stdint.h> (or it'll be included again by <arm_neon.h>).
46 #define __CLANG_STDINT_H
47 #define _STDINT_H_
48#else
49 #include <string.h>
50 #include <stdint.h>
51#endif
Mike Kleine1caee12017-02-15 13:31:12 -050052
Mike Klein0a904492017-04-12 12:52:48 -040053static const int SkJumper_kMaxStride = 8;
54
Mike Kleine1caee12017-02-15 13:31:12 -050055struct SkJumper_constants {
Mike Klein5d7f2b52017-05-20 13:21:59 -040056 float iota_F [SkJumper_kMaxStride]; // 0,1,2,3,4,...
57 uint32_t iota_U32[SkJumper_kMaxStride]; // 0,1,2,3,4,...
Mike Kleine1caee12017-02-15 13:31:12 -050058};
59
Mike Klein994ef972017-04-12 11:51:11 -040060struct SkJumper_GatherCtx {
Mike Kleindec4ea82017-04-06 15:04:05 -040061 const void* pixels;
62 const uint32_t* ctable;
63 int stride;
64};
65
Mike Klein0a904492017-04-12 12:52:48 -040066// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
67struct SkJumper_SamplerCtx {
68 float x[SkJumper_kMaxStride];
69 float y[SkJumper_kMaxStride];
70 float fx[SkJumper_kMaxStride];
71 float fy[SkJumper_kMaxStride];
72 float scalex[SkJumper_kMaxStride];
73 float scaley[SkJumper_kMaxStride];
74};
75
Mike Reed51e46d52017-06-23 14:21:25 -040076struct SkJumper_TileCtx {
77 float scale;
78 float invScale; // cache of 1/scale
79};
80
Mike Klein7fee90c2017-04-07 16:55:09 -040081struct SkJumper_CallbackCtx {
Mike Kleinc17dc242017-04-20 16:21:57 -040082 MAYBE_MSABI void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/);
83
84 // When called, fn() will have our active pixels available in rgba.
85 // When fn() returns, the pipeline will read back those active pixels from read_from.
86 float rgba[4*SkJumper_kMaxStride];
87 float* read_from = rgba;
Mike Klein7fee90c2017-04-07 16:55:09 -040088};
89
Mike Kleina3735cd2017-04-17 13:19:05 -040090struct SkJumper_LoadTablesCtx {
91 const void* src;
92 const float *r, *g, *b;
93};
94
Mike Kleinc7d9c0b2017-04-17 14:43:59 -040095struct SkJumper_TableCtx {
96 const float* table;
97 int size;
98};
99
Mike Klein44375172017-04-17 19:32:05 -0400100// This should line up with the memory layout of SkColorSpaceTransferFn.
101struct SkJumper_ParametricTransferFunction {
102 float G, A,B,C,D,E,F;
103};
104
Herb Derby4de13042017-05-15 10:49:39 -0400105struct SkJumper_GradientCtx {
106 size_t stopCount;
107 float* fs[4];
108 float* bs[4];
109 float* ts;
110};
111
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400112struct SkJumper_2PtConicalCtx {
Florin Malita9026fe12017-06-29 11:03:45 -0400113 uint32_t fMask[SkJumper_kMaxStride];
114 float fCoeffA,
115 fInvCoeffA,
116 fR0,
117 fDR;
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400118};
119
Mike Kleine1caee12017-02-15 13:31:12 -0500120#endif//SkJumper_DEFINED