blob: d4e8ef4f37afe2c54fcc360a54b8c18366805528 [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 Klein968af432017-07-18 16:31:55 -040060struct SkJumper_MemoryCtx {
61 void* pixels;
62 int stride;
Mike Kleindec4ea82017-04-06 15:04:05 -040063};
64
Mike Klein0a904492017-04-12 12:52:48 -040065// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
66struct SkJumper_SamplerCtx {
67 float x[SkJumper_kMaxStride];
68 float y[SkJumper_kMaxStride];
69 float fx[SkJumper_kMaxStride];
70 float fy[SkJumper_kMaxStride];
71 float scalex[SkJumper_kMaxStride];
72 float scaley[SkJumper_kMaxStride];
73};
74
Mike Reed51e46d52017-06-23 14:21:25 -040075struct SkJumper_TileCtx {
76 float scale;
77 float invScale; // cache of 1/scale
78};
79
Mike Klein7fee90c2017-04-07 16:55:09 -040080struct SkJumper_CallbackCtx {
Mike Kleinc17dc242017-04-20 16:21:57 -040081 MAYBE_MSABI void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/);
82
83 // When called, fn() will have our active pixels available in rgba.
84 // When fn() returns, the pipeline will read back those active pixels from read_from.
85 float rgba[4*SkJumper_kMaxStride];
86 float* read_from = rgba;
Mike Klein7fee90c2017-04-07 16:55:09 -040087};
88
Mike Kleina3735cd2017-04-17 13:19:05 -040089struct SkJumper_LoadTablesCtx {
90 const void* src;
91 const float *r, *g, *b;
92};
93
Mike Kleinc7d9c0b2017-04-17 14:43:59 -040094struct SkJumper_TableCtx {
95 const float* table;
96 int size;
97};
98
Mike Klein44375172017-04-17 19:32:05 -040099// This should line up with the memory layout of SkColorSpaceTransferFn.
100struct SkJumper_ParametricTransferFunction {
101 float G, A,B,C,D,E,F;
102};
103
Herb Derby4de13042017-05-15 10:49:39 -0400104struct SkJumper_GradientCtx {
105 size_t stopCount;
106 float* fs[4];
107 float* bs[4];
108 float* ts;
109};
110
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400111struct SkJumper_2PtConicalCtx {
Florin Malita9026fe12017-06-29 11:03:45 -0400112 uint32_t fMask[SkJumper_kMaxStride];
113 float fCoeffA,
114 fInvCoeffA,
115 fR0,
116 fDR;
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400117};
118
Mike Klein1a2e3e12017-08-03 11:24:13 -0400119struct SkJumper_UniformColorCtx {
120 float r,g,b,a;
121 uint32_t rgba;
122};
123
Mike Kleinc2f876b2017-08-09 18:23:25 -0400124struct SkJumper_ColorLookupTableCtx {
125 const float* table;
126 int limits[4];
127};
128
Mike Kleine1caee12017-02-15 13:31:12 -0500129#endif//SkJumper_DEFINED