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 #include <stddef.h> 12 #include <stdint.h> 13 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 18 // Externally facing functions (start_pipeline) are called a little specially on Windows. 19 #if defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__x86_64__) 20 #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V. 21 #elif defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__i386__) 22 #define MAYBE_MSABI __attribute__((force_align_arg_pointer)) // Re-align stack 4 -> 16 bytes. 23 #else 24 #define MAYBE_MSABI 25 #endif 26 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"))) 31 #else 32 #define ABI 33 #endif 34 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.) 39 #if defined(__clang__) && defined(__ARM_NEON) 40 #define JUMPER_HAS_NEON_LOWP 41 #endif 42 43 static const int SkJumper_kMaxStride = 16; 44 45 struct SkJumper_MemoryCtx { 46 void* pixels; 47 int stride; 48 }; 49 50 struct SkJumper_GatherCtx { 51 const void* pixels; 52 int stride; 53 float width; 54 float height; 55 }; 56 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 67 struct SkJumper_TileCtx { 68 float scale; 69 float invScale; // cache of 1/scale 70 }; 71 72 struct SkJumper_DecalTileCtx { 73 uint32_t mask[SkJumper_kMaxStride]; 74 float limit_x; 75 float limit_y; 76 }; 77 78 struct SkJumper_CallbackCtx { 79 MAYBE_MSABI void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/); 80 81 // When called, fn() will have our active pixels available in rgba. 82 // When fn() returns, the pipeline will read back those active pixels from read_from. 83 float rgba[4*SkJumper_kMaxStride]; 84 float* read_from = rgba; 85 }; 86 87 struct SkJumper_LoadTablesCtx { 88 const void* src; 89 const float *r, *g, *b; 90 }; 91 92 struct SkJumper_TableCtx { 93 const float* table; 94 int size; 95 }; 96 97 // This should line up with the memory layout of SkColorSpaceTransferFn. 98 struct SkJumper_ParametricTransferFunction { 99 float G, A,B,C,D,E,F; 100 }; 101 102 struct SkJumper_GradientCtx { 103 size_t stopCount; 104 float* fs[4]; 105 float* bs[4]; 106 float* ts; 107 }; 108 109 struct SkJumper_2PtConicalCtx { 110 uint32_t fMask[SkJumper_kMaxStride]; 111 float fP0, 112 fP1; 113 }; 114 115 struct SkJumper_UniformColorCtx { 116 float r,g,b,a; 117 uint16_t rgba[4]; // [0,255] in a 16-bit lane. 118 }; 119 120 struct SkJumper_ColorLookupTableCtx { 121 const float* table; 122 int limits[4]; 123 }; 124 125 #endif//SkJumper_DEFINED 126