Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 1 | /* |
| 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 Klein | ea23a04 | 2017-06-27 12:06:56 -0400 | [diff] [blame] | 15 | // Externally facing functions (start_pipeline) are called a little specially on Windows. |
Mike Klein | d6e1286 | 2017-08-28 12:18:26 -0400 | [diff] [blame] | 16 | #if defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__x86_64__) |
Mike Klein | ea23a04 | 2017-06-27 12:06:56 -0400 | [diff] [blame] | 17 | #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V. |
Mike Klein | d6e1286 | 2017-08-28 12:18:26 -0400 | [diff] [blame] | 18 | #elif defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__i386__) |
Mike Klein | ea23a04 | 2017-06-27 12:06:56 -0400 | [diff] [blame] | 19 | #define MAYBE_MSABI __attribute__((force_align_arg_pointer)) // Re-align stack 4 -> 16 bytes. |
Mike Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 20 | #else |
| 21 | #define MAYBE_MSABI |
| 22 | #endif |
| 23 | |
Mike Klein | d6e1286 | 2017-08-28 12:18:26 -0400 | [diff] [blame] | 24 | #if defined(JUMPER_IS_OFFLINE) && (defined(__aarch64__) || defined(__arm__)) |
Mike Klein | b7bf09c | 2017-03-31 14:15:56 -0400 | [diff] [blame] | 25 | // 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 Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 52 | |
Mike Klein | b561b76 | 2017-08-28 17:53:34 -0400 | [diff] [blame] | 53 | // When compiled with Clang on ARM, we'll have 8-bit NEON stages. |
Mike Klein | 9b2f69b | 2017-09-12 16:40:53 -0400 | [diff] [blame] | 54 | #if defined(__clang__) && defined(__ARM_NEON) |
| 55 | #define JUMPER_HAS_NEON_LOWP |
Mike Klein | b561b76 | 2017-08-28 17:53:34 -0400 | [diff] [blame] | 56 | #endif |
| 57 | |
Mike Klein | d4faecd | 2017-10-17 14:31:17 -0400 | [diff] [blame] | 58 | static const int SkJumper_kMaxStride = 16; |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 59 | |
Mike Klein | 968af43 | 2017-07-18 16:31:55 -0400 | [diff] [blame] | 60 | struct SkJumper_MemoryCtx { |
| 61 | void* pixels; |
| 62 | int stride; |
Mike Klein | dec4ea8 | 2017-04-06 15:04:05 -0400 | [diff] [blame] | 63 | }; |
| 64 | |
Mike Klein | f3b4e16 | 2017-09-22 15:32:59 -0400 | [diff] [blame] | 65 | struct SkJumper_GatherCtx { |
| 66 | void* pixels; |
| 67 | int stride; |
| 68 | float width, |
| 69 | height; |
| 70 | }; |
| 71 | |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 72 | // State shared by save_xy, accumulate, and bilinear_* / bicubic_*. |
| 73 | struct 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 Reed | 51e46d5 | 2017-06-23 14:21:25 -0400 | [diff] [blame] | 82 | struct SkJumper_TileCtx { |
| 83 | float scale; |
| 84 | float invScale; // cache of 1/scale |
| 85 | }; |
| 86 | |
Mike Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 87 | struct SkJumper_CallbackCtx { |
Mike Klein | c17dc24 | 2017-04-20 16:21:57 -0400 | [diff] [blame] | 88 | 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 Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 94 | }; |
| 95 | |
Mike Klein | a3735cd | 2017-04-17 13:19:05 -0400 | [diff] [blame] | 96 | struct SkJumper_LoadTablesCtx { |
| 97 | const void* src; |
| 98 | const float *r, *g, *b; |
| 99 | }; |
| 100 | |
Mike Klein | c7d9c0b | 2017-04-17 14:43:59 -0400 | [diff] [blame] | 101 | struct SkJumper_TableCtx { |
| 102 | const float* table; |
| 103 | int size; |
| 104 | }; |
| 105 | |
Mike Klein | 4437517 | 2017-04-17 19:32:05 -0400 | [diff] [blame] | 106 | // This should line up with the memory layout of SkColorSpaceTransferFn. |
| 107 | struct SkJumper_ParametricTransferFunction { |
| 108 | float G, A,B,C,D,E,F; |
| 109 | }; |
| 110 | |
Herb Derby | 4de1304 | 2017-05-15 10:49:39 -0400 | [diff] [blame] | 111 | struct SkJumper_GradientCtx { |
| 112 | size_t stopCount; |
| 113 | float* fs[4]; |
| 114 | float* bs[4]; |
| 115 | float* ts; |
| 116 | }; |
| 117 | |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 118 | struct SkJumper_2PtConicalCtx { |
Florin Malita | 9026fe1 | 2017-06-29 11:03:45 -0400 | [diff] [blame] | 119 | uint32_t fMask[SkJumper_kMaxStride]; |
| 120 | float fCoeffA, |
| 121 | fInvCoeffA, |
| 122 | fR0, |
| 123 | fDR; |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 124 | }; |
| 125 | |
Mike Klein | 1a2e3e1 | 2017-08-03 11:24:13 -0400 | [diff] [blame] | 126 | struct SkJumper_UniformColorCtx { |
| 127 | float r,g,b,a; |
Mike Klein | f757ae6 | 2017-09-15 14:57:02 -0400 | [diff] [blame] | 128 | uint16_t rgba[4]; // [0,255] in a 16-bit lane. |
Mike Klein | 1a2e3e1 | 2017-08-03 11:24:13 -0400 | [diff] [blame] | 129 | }; |
| 130 | |
Mike Klein | c2f876b | 2017-08-09 18:23:25 -0400 | [diff] [blame] | 131 | struct SkJumper_ColorLookupTableCtx { |
| 132 | const float* table; |
| 133 | int limits[4]; |
| 134 | }; |
| 135 | |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 136 | #endif//SkJumper_DEFINED |