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. |
| 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 Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 20 | #else |
| 21 | #define MAYBE_MSABI |
| 22 | #endif |
| 23 | |
Mike Klein | 3b80558 | 2017-04-06 13:44:03 -0400 | [diff] [blame] | 24 | #if defined(JUMPER) && (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 | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 53 | static const int SkJumper_kMaxStride = 8; |
| 54 | |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 55 | struct SkJumper_constants { |
Mike Klein | 5d7f2b5 | 2017-05-20 13:21:59 -0400 | [diff] [blame] | 56 | float iota_F [SkJumper_kMaxStride]; // 0,1,2,3,4,... |
| 57 | uint32_t iota_U32[SkJumper_kMaxStride]; // 0,1,2,3,4,... |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 58 | }; |
| 59 | |
Mike Klein | 994ef97 | 2017-04-12 11:51:11 -0400 | [diff] [blame] | 60 | struct SkJumper_GatherCtx { |
Mike Klein | dec4ea8 | 2017-04-06 15:04:05 -0400 | [diff] [blame] | 61 | const void* pixels; |
| 62 | const uint32_t* ctable; |
| 63 | int stride; |
| 64 | }; |
| 65 | |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 66 | // State shared by save_xy, accumulate, and bilinear_* / bicubic_*. |
| 67 | struct 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 Reed | 51e46d5 | 2017-06-23 14:21:25 -0400 | [diff] [blame] | 76 | struct SkJumper_TileCtx { |
| 77 | float scale; |
| 78 | float invScale; // cache of 1/scale |
| 79 | }; |
| 80 | |
Mike Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 81 | struct SkJumper_CallbackCtx { |
Mike Klein | c17dc24 | 2017-04-20 16:21:57 -0400 | [diff] [blame] | 82 | 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 Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 88 | }; |
| 89 | |
Mike Klein | a3735cd | 2017-04-17 13:19:05 -0400 | [diff] [blame] | 90 | struct SkJumper_LoadTablesCtx { |
| 91 | const void* src; |
| 92 | const float *r, *g, *b; |
| 93 | }; |
| 94 | |
Mike Klein | c7d9c0b | 2017-04-17 14:43:59 -0400 | [diff] [blame] | 95 | struct SkJumper_TableCtx { |
| 96 | const float* table; |
| 97 | int size; |
| 98 | }; |
| 99 | |
Mike Klein | 4437517 | 2017-04-17 19:32:05 -0400 | [diff] [blame] | 100 | // This should line up with the memory layout of SkColorSpaceTransferFn. |
| 101 | struct SkJumper_ParametricTransferFunction { |
| 102 | float G, A,B,C,D,E,F; |
| 103 | }; |
| 104 | |
Herb Derby | 4de1304 | 2017-05-15 10:49:39 -0400 | [diff] [blame] | 105 | struct SkJumper_GradientCtx { |
| 106 | size_t stopCount; |
| 107 | float* fs[4]; |
| 108 | float* bs[4]; |
| 109 | float* ts; |
| 110 | }; |
| 111 | |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 112 | struct SkJumper_2PtConicalCtx { |
Florin Malita | 9026fe1 | 2017-06-29 11:03:45 -0400 | [diff] [blame] | 113 | uint32_t fMask[SkJumper_kMaxStride]; |
| 114 | float fCoeffA, |
| 115 | fInvCoeffA, |
| 116 | fR0, |
| 117 | fDR; |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 118 | }; |
| 119 | |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 120 | #endif//SkJumper_DEFINED |