blob: ea08e0d1ca355ae626fc91f75d7d8fa931b2f098 [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.
Mike Kleind6e12862017-08-28 12:18:26 -040016#if defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__x86_64__)
Mike Kleinea23a042017-06-27 12:06:56 -040017 #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V.
Mike Kleind6e12862017-08-28 12:18:26 -040018#elif defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__i386__)
Mike Kleinea23a042017-06-27 12:06:56 -040019 #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 Kleind6e12862017-08-28 12:18:26 -040024#if defined(JUMPER_IS_OFFLINE) && (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 Kleinb561b762017-08-28 17:53:34 -040053// When compiled with Clang on ARM, we'll have 8-bit NEON stages.
Mike Klein9b2f69b2017-09-12 16:40:53 -040054#if defined(__clang__) && defined(__ARM_NEON)
55 #define JUMPER_HAS_NEON_LOWP
Mike Kleinb561b762017-08-28 17:53:34 -040056#endif
57
Mike Kleind4faecd2017-10-17 14:31:17 -040058static const int SkJumper_kMaxStride = 16;
Mike Klein0a904492017-04-12 12:52:48 -040059
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 Kleinf3b4e162017-09-22 15:32:59 -040065struct SkJumper_GatherCtx {
66 void* pixels;
67 int stride;
68 float width,
69 height;
70};
71
Mike Klein0a904492017-04-12 12:52:48 -040072// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
73struct SkJumper_SamplerCtx {
74 float x[SkJumper_kMaxStride];
75 float y[SkJumper_kMaxStride];
76 float fx[SkJumper_kMaxStride];
77 float fy[SkJumper_kMaxStride];
78 float scalex[SkJumper_kMaxStride];
79 float scaley[SkJumper_kMaxStride];
80};
81
Mike Reed51e46d52017-06-23 14:21:25 -040082struct SkJumper_TileCtx {
83 float scale;
84 float invScale; // cache of 1/scale
85};
86
Mike Klein7fee90c2017-04-07 16:55:09 -040087struct SkJumper_CallbackCtx {
Mike Kleinc17dc242017-04-20 16:21:57 -040088 MAYBE_MSABI void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/);
89
90 // When called, fn() will have our active pixels available in rgba.
91 // When fn() returns, the pipeline will read back those active pixels from read_from.
92 float rgba[4*SkJumper_kMaxStride];
93 float* read_from = rgba;
Mike Klein7fee90c2017-04-07 16:55:09 -040094};
95
Mike Kleina3735cd2017-04-17 13:19:05 -040096struct SkJumper_LoadTablesCtx {
97 const void* src;
98 const float *r, *g, *b;
99};
100
Mike Kleinc7d9c0b2017-04-17 14:43:59 -0400101struct SkJumper_TableCtx {
102 const float* table;
103 int size;
104};
105
Mike Klein44375172017-04-17 19:32:05 -0400106// This should line up with the memory layout of SkColorSpaceTransferFn.
107struct SkJumper_ParametricTransferFunction {
108 float G, A,B,C,D,E,F;
109};
110
Herb Derby4de13042017-05-15 10:49:39 -0400111struct SkJumper_GradientCtx {
112 size_t stopCount;
113 float* fs[4];
114 float* bs[4];
115 float* ts;
116};
117
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400118struct SkJumper_2PtConicalCtx {
Florin Malita9026fe12017-06-29 11:03:45 -0400119 uint32_t fMask[SkJumper_kMaxStride];
120 float fCoeffA,
121 fInvCoeffA,
122 fR0,
123 fDR;
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400124};
125
Mike Klein1a2e3e12017-08-03 11:24:13 -0400126struct SkJumper_UniformColorCtx {
127 float r,g,b,a;
Mike Kleinf757ae62017-09-15 14:57:02 -0400128 uint16_t rgba[4]; // [0,255] in a 16-bit lane.
Mike Klein1a2e3e12017-08-03 11:24:13 -0400129};
130
Mike Kleinc2f876b2017-08-09 18:23:25 -0400131struct SkJumper_ColorLookupTableCtx {
132 const float* table;
133 int limits[4];
134};
135
Mike Kleine1caee12017-02-15 13:31:12 -0500136#endif//SkJumper_DEFINED