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 | |
Mike Klein | 376fd31 | 2017-12-11 16:53:26 -0500 | [diff] [blame] | 11 | #include <stddef.h> |
| 12 | #include <stdint.h> |
| 13 | |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 14 | // 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 | |
Mike Klein | ea23a04 | 2017-06-27 12:06:56 -0400 | [diff] [blame] | 18 | // Externally facing functions (start_pipeline) are called a little specially on Windows. |
Mike Klein | d6e1286 | 2017-08-28 12:18:26 -0400 | [diff] [blame] | 19 | #if defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__x86_64__) |
Mike Klein | ea23a04 | 2017-06-27 12:06:56 -0400 | [diff] [blame] | 20 | #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V. |
Mike Klein | d6e1286 | 2017-08-28 12:18:26 -0400 | [diff] [blame] | 21 | #elif defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__i386__) |
Mike Klein | ea23a04 | 2017-06-27 12:06:56 -0400 | [diff] [blame] | 22 | #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] | 23 | #else |
| 24 | #define MAYBE_MSABI |
| 25 | #endif |
| 26 | |
Mike Klein | 376fd31 | 2017-12-11 16:53:26 -0500 | [diff] [blame] | 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"))) |
Mike Klein | b7bf09c | 2017-03-31 14:15:56 -0400 | [diff] [blame] | 31 | #else |
Mike Klein | 376fd31 | 2017-12-11 16:53:26 -0500 | [diff] [blame] | 32 | #define ABI |
Mike Klein | b7bf09c | 2017-03-31 14:15:56 -0400 | [diff] [blame] | 33 | #endif |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 34 | |
Mike Klein | 376fd31 | 2017-12-11 16:53:26 -0500 | [diff] [blame] | 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.) |
Mike Klein | 9b2f69b | 2017-09-12 16:40:53 -0400 | [diff] [blame] | 39 | #if defined(__clang__) && defined(__ARM_NEON) |
| 40 | #define JUMPER_HAS_NEON_LOWP |
Mike Klein | b561b76 | 2017-08-28 17:53:34 -0400 | [diff] [blame] | 41 | #endif |
| 42 | |
Mike Klein | d4faecd | 2017-10-17 14:31:17 -0400 | [diff] [blame] | 43 | static const int SkJumper_kMaxStride = 16; |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 44 | |
Mike Klein | 968af43 | 2017-07-18 16:31:55 -0400 | [diff] [blame] | 45 | struct SkJumper_MemoryCtx { |
| 46 | void* pixels; |
| 47 | int stride; |
Mike Klein | dec4ea8 | 2017-04-06 15:04:05 -0400 | [diff] [blame] | 48 | }; |
| 49 | |
Mike Klein | f3b4e16 | 2017-09-22 15:32:59 -0400 | [diff] [blame] | 50 | struct SkJumper_GatherCtx { |
Mike Klein | 1fa9c43 | 2017-12-11 09:59:47 -0500 | [diff] [blame] | 51 | const void* pixels; |
| 52 | int stride; |
| 53 | float width; |
| 54 | float height; |
Mike Klein | f3b4e16 | 2017-09-22 15:32:59 -0400 | [diff] [blame] | 55 | }; |
| 56 | |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 57 | // State shared by save_xy, accumulate, and bilinear_* / bicubic_*. |
| 58 | struct 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 Reed | 51e46d5 | 2017-06-23 14:21:25 -0400 | [diff] [blame] | 67 | struct SkJumper_TileCtx { |
| 68 | float scale; |
| 69 | float invScale; // cache of 1/scale |
| 70 | }; |
| 71 | |
Mike Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 72 | struct SkJumper_CallbackCtx { |
Mike Klein | c17dc24 | 2017-04-20 16:21:57 -0400 | [diff] [blame] | 73 | MAYBE_MSABI void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/); |
| 74 | |
| 75 | // When called, fn() will have our active pixels available in rgba. |
| 76 | // When fn() returns, the pipeline will read back those active pixels from read_from. |
| 77 | float rgba[4*SkJumper_kMaxStride]; |
| 78 | float* read_from = rgba; |
Mike Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 79 | }; |
| 80 | |
Mike Klein | a3735cd | 2017-04-17 13:19:05 -0400 | [diff] [blame] | 81 | struct SkJumper_LoadTablesCtx { |
| 82 | const void* src; |
| 83 | const float *r, *g, *b; |
| 84 | }; |
| 85 | |
Mike Klein | c7d9c0b | 2017-04-17 14:43:59 -0400 | [diff] [blame] | 86 | struct SkJumper_TableCtx { |
| 87 | const float* table; |
| 88 | int size; |
| 89 | }; |
| 90 | |
Mike Klein | 4437517 | 2017-04-17 19:32:05 -0400 | [diff] [blame] | 91 | // This should line up with the memory layout of SkColorSpaceTransferFn. |
| 92 | struct SkJumper_ParametricTransferFunction { |
| 93 | float G, A,B,C,D,E,F; |
| 94 | }; |
| 95 | |
Herb Derby | 4de1304 | 2017-05-15 10:49:39 -0400 | [diff] [blame] | 96 | struct SkJumper_GradientCtx { |
| 97 | size_t stopCount; |
| 98 | float* fs[4]; |
| 99 | float* bs[4]; |
| 100 | float* ts; |
| 101 | }; |
| 102 | |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 103 | struct SkJumper_2PtConicalCtx { |
Florin Malita | 9026fe1 | 2017-06-29 11:03:45 -0400 | [diff] [blame] | 104 | uint32_t fMask[SkJumper_kMaxStride]; |
Yuqian Li | d3b743a | 2018-01-09 11:47:45 -0500 | [diff] [blame] | 105 | float fP0, |
Yuqian Li | d208a88 | 2018-01-04 10:08:42 -0500 | [diff] [blame] | 106 | fP1; |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 107 | }; |
| 108 | |
Mike Klein | 1a2e3e1 | 2017-08-03 11:24:13 -0400 | [diff] [blame] | 109 | struct SkJumper_UniformColorCtx { |
| 110 | float r,g,b,a; |
Mike Klein | f757ae6 | 2017-09-15 14:57:02 -0400 | [diff] [blame] | 111 | uint16_t rgba[4]; // [0,255] in a 16-bit lane. |
Mike Klein | 1a2e3e1 | 2017-08-03 11:24:13 -0400 | [diff] [blame] | 112 | }; |
| 113 | |
Mike Klein | c2f876b | 2017-08-09 18:23:25 -0400 | [diff] [blame] | 114 | struct SkJumper_ColorLookupTableCtx { |
| 115 | const float* table; |
| 116 | int limits[4]; |
| 117 | }; |
| 118 | |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 119 | #endif//SkJumper_DEFINED |