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 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. 20 #else 21 #define MAYBE_MSABI 22 #endif 23 24 #if defined(JUMPER) && (defined(__aarch64__) || defined(__arm__)) 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 52 53 static const int SkJumper_kMaxStride = 8; 54 55 struct SkJumper_constants { 56 float iota_F [SkJumper_kMaxStride]; // 0,1,2,3,4,... 57 uint32_t iota_U32[SkJumper_kMaxStride]; // 0,1,2,3,4,... 58 }; 59 60 struct SkJumper_MemoryCtx { 61 void* pixels; 62 int stride; 63 }; 64 65 // State shared by save_xy, accumulate, and bilinear_* / bicubic_*. 66 struct 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 75 struct SkJumper_TileCtx { 76 float scale; 77 float invScale; // cache of 1/scale 78 }; 79 80 struct SkJumper_CallbackCtx { 81 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; 87 }; 88 89 struct SkJumper_LoadTablesCtx { 90 const void* src; 91 const float *r, *g, *b; 92 }; 93 94 struct SkJumper_TableCtx { 95 const float* table; 96 int size; 97 }; 98 99 // This should line up with the memory layout of SkColorSpaceTransferFn. 100 struct SkJumper_ParametricTransferFunction { 101 float G, A,B,C,D,E,F; 102 }; 103 104 struct SkJumper_GradientCtx { 105 size_t stopCount; 106 float* fs[4]; 107 float* bs[4]; 108 float* ts; 109 }; 110 111 struct SkJumper_2PtConicalCtx { 112 uint32_t fMask[SkJumper_kMaxStride]; 113 float fCoeffA, 114 fInvCoeffA, 115 fR0, 116 fDR; 117 }; 118 119 #endif//SkJumper_DEFINED 120