• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CallbackCtx {
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;
79 };
80 
81 struct SkJumper_LoadTablesCtx {
82     const void* src;
83     const float *r, *g, *b;
84 };
85 
86 struct SkJumper_TableCtx {
87     const float* table;
88     int          size;
89 };
90 
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 
96 struct SkJumper_GradientCtx {
97     size_t stopCount;
98     float* fs[4];
99     float* bs[4];
100     float* ts;
101 };
102 
103 struct SkJumper_2PtConicalCtx {
104     uint32_t fMask[SkJumper_kMaxStride];
105     float    fP0,
106              fP1;
107 };
108 
109 struct SkJumper_UniformColorCtx {
110     float r,g,b,a;
111     uint16_t rgba[4];  // [0,255] in a 16-bit lane.
112 };
113 
114 struct SkJumper_ColorLookupTableCtx {
115     const float* table;
116     int limits[4];
117 };
118 
119 #endif//SkJumper_DEFINED
120