blob: 46344986cf417941c080ca3aad9db7af5cc9d968 [file] [log] [blame]
Mike Kleine1caee12017-02-15 13:31:12 -05001/*
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 Klein376fd312017-12-11 16:53:26 -050011#include <stddef.h>
12#include <stdint.h>
13
Mike Kleine1caee12017-02-15 13:31:12 -050014// 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 Kleinea23a042017-06-27 12:06:56 -040018// Externally facing functions (start_pipeline) are called a little specially on Windows.
Mike Kleind6e12862017-08-28 12:18:26 -040019#if defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__x86_64__)
Mike Kleinea23a042017-06-27 12:06:56 -040020 #define MAYBE_MSABI __attribute__((ms_abi)) // Use MS' ABI, not System V.
Mike Kleind6e12862017-08-28 12:18:26 -040021#elif defined(JUMPER_IS_OFFLINE) && defined(WIN) && defined(__i386__)
Mike Kleinea23a042017-06-27 12:06:56 -040022 #define MAYBE_MSABI __attribute__((force_align_arg_pointer)) // Re-align stack 4 -> 16 bytes.
Mike Klein7fee90c2017-04-07 16:55:09 -040023#else
24 #define MAYBE_MSABI
25#endif
26
Mike Klein376fd312017-12-11 16:53:26 -050027// 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 Kleinb7bf09c2017-03-31 14:15:56 -040031#else
Mike Klein376fd312017-12-11 16:53:26 -050032 #define ABI
Mike Kleinb7bf09c2017-03-31 14:15:56 -040033#endif
Mike Kleine1caee12017-02-15 13:31:12 -050034
Mike Klein376fd312017-12-11 16:53:26 -050035// 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 Klein9b2f69b2017-09-12 16:40:53 -040039#if defined(__clang__) && defined(__ARM_NEON)
40 #define JUMPER_HAS_NEON_LOWP
Mike Kleinb561b762017-08-28 17:53:34 -040041#endif
42
Mike Kleind4faecd2017-10-17 14:31:17 -040043static const int SkJumper_kMaxStride = 16;
Mike Klein0a904492017-04-12 12:52:48 -040044
Mike Klein968af432017-07-18 16:31:55 -040045struct SkJumper_MemoryCtx {
46 void* pixels;
47 int stride;
Mike Kleindec4ea82017-04-06 15:04:05 -040048};
49
Mike Kleinf3b4e162017-09-22 15:32:59 -040050struct SkJumper_GatherCtx {
Mike Klein2bbcda32017-12-11 16:09:40 +000051 void* pixels;
52 int stride;
53 float width,
54 height;
Mike Kleinf3b4e162017-09-22 15:32:59 -040055};
56
Mike Klein0a904492017-04-12 12:52:48 -040057// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
58struct 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 Reed51e46d52017-06-23 14:21:25 -040067struct SkJumper_TileCtx {
68 float scale;
69 float invScale; // cache of 1/scale
70};
71
Mike Klein7fee90c2017-04-07 16:55:09 -040072struct SkJumper_CallbackCtx {
Mike Kleinc17dc242017-04-20 16:21:57 -040073 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 Klein7fee90c2017-04-07 16:55:09 -040079};
80
Mike Kleina3735cd2017-04-17 13:19:05 -040081struct SkJumper_LoadTablesCtx {
82 const void* src;
83 const float *r, *g, *b;
84};
85
Mike Kleinc7d9c0b2017-04-17 14:43:59 -040086struct SkJumper_TableCtx {
87 const float* table;
88 int size;
89};
90
Mike Klein44375172017-04-17 19:32:05 -040091// This should line up with the memory layout of SkColorSpaceTransferFn.
92struct SkJumper_ParametricTransferFunction {
93 float G, A,B,C,D,E,F;
94};
95
Herb Derby4de13042017-05-15 10:49:39 -040096struct SkJumper_GradientCtx {
97 size_t stopCount;
98 float* fs[4];
99 float* bs[4];
100 float* ts;
101};
102
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400103struct SkJumper_2PtConicalCtx {
Florin Malita9026fe12017-06-29 11:03:45 -0400104 uint32_t fMask[SkJumper_kMaxStride];
105 float fCoeffA,
106 fInvCoeffA,
107 fR0,
108 fDR;
Florin Malitaa66ef2d2017-06-28 10:02:40 -0400109};
110
Mike Klein1a2e3e12017-08-03 11:24:13 -0400111struct SkJumper_UniformColorCtx {
112 float r,g,b,a;
Mike Kleinf757ae62017-09-15 14:57:02 -0400113 uint16_t rgba[4]; // [0,255] in a 16-bit lane.
Mike Klein1a2e3e12017-08-03 11:24:13 -0400114};
115
Mike Kleinc2f876b2017-08-09 18:23:25 -0400116struct SkJumper_ColorLookupTableCtx {
117 const float* table;
118 int limits[4];
119};
120
Mike Kleine1caee12017-02-15 13:31:12 -0500121#endif//SkJumper_DEFINED