blob: a826c5a4128c81276703de788e44e22949ced06b [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 Klein1b9b7d52018-02-27 10:37:40 -050014// This file contains definitions shared by SkJumper.cpp/SkJumper_stages.cpp
15// and the rest of Skia. It is important to keep the interface to SkJumper
16// limited and simple to avoid serious ODR violation pitfalls, especially when
17// using Microsoft's <math.h> and similar headers with inline-but-not-static
18// function definitions.
Mike Kleinb561b762017-08-28 17:53:34 -040019
Mike Kleind4faecd2017-10-17 14:31:17 -040020static const int SkJumper_kMaxStride = 16;
Mike Klein0a904492017-04-12 12:52:48 -040021
Mike Klein968af432017-07-18 16:31:55 -040022struct SkJumper_MemoryCtx {
23 void* pixels;
24 int stride;
Mike Kleindec4ea82017-04-06 15:04:05 -040025};
26
Mike Kleinf3b4e162017-09-22 15:32:59 -040027struct SkJumper_GatherCtx {
Mike Klein1fa9c432017-12-11 09:59:47 -050028 const void* pixels;
29 int stride;
30 float width;
31 float height;
Mike Kleinf3b4e162017-09-22 15:32:59 -040032};
33
Mike Klein0a904492017-04-12 12:52:48 -040034// State shared by save_xy, accumulate, and bilinear_* / bicubic_*.
35struct SkJumper_SamplerCtx {
36 float x[SkJumper_kMaxStride];
37 float y[SkJumper_kMaxStride];
38 float fx[SkJumper_kMaxStride];
39 float fy[SkJumper_kMaxStride];
40 float scalex[SkJumper_kMaxStride];
41 float scaley[SkJumper_kMaxStride];
42};
43
Mike Reed51e46d52017-06-23 14:21:25 -040044struct SkJumper_TileCtx {
45 float scale;
46 float invScale; // cache of 1/scale
47};
48
Mike Reeddfc0e912018-02-16 12:40:18 -050049struct SkJumper_DecalTileCtx {
50 uint32_t mask[SkJumper_kMaxStride];
51 float limit_x;
52 float limit_y;
53};
54
Mike Klein7fee90c2017-04-07 16:55:09 -040055struct SkJumper_CallbackCtx {
Mike Klein1b9b7d52018-02-27 10:37:40 -050056 void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/);
Mike Kleinc17dc242017-04-20 16:21:57 -040057
58 // When called, fn() will have our active pixels available in rgba.
59 // When fn() returns, the pipeline will read back those active pixels from read_from.
60 float rgba[4*SkJumper_kMaxStride];
61 float* read_from = rgba;
Mike Klein7fee90c2017-04-07 16:55:09 -040062};
63
Mike Klein44375172017-04-17 19:32:05 -040064// This should line up with the memory layout of SkColorSpaceTransferFn.
65struct SkJumper_ParametricTransferFunction {
66 float G, A,B,C,D,E,F;
67};
68
Herb Derby4de13042017-05-15 10:49:39 -040069struct SkJumper_GradientCtx {
70 size_t stopCount;
71 float* fs[4];
72 float* bs[4];
73 float* ts;
74};
75
Florin Malitaa66ef2d2017-06-28 10:02:40 -040076struct SkJumper_2PtConicalCtx {
Florin Malita9026fe12017-06-29 11:03:45 -040077 uint32_t fMask[SkJumper_kMaxStride];
Yuqian Lid3b743a2018-01-09 11:47:45 -050078 float fP0,
Yuqian Lid208a882018-01-04 10:08:42 -050079 fP1;
Florin Malitaa66ef2d2017-06-28 10:02:40 -040080};
81
Mike Klein1a2e3e12017-08-03 11:24:13 -040082struct SkJumper_UniformColorCtx {
83 float r,g,b,a;
Mike Kleinf757ae62017-09-15 14:57:02 -040084 uint16_t rgba[4]; // [0,255] in a 16-bit lane.
Mike Klein1a2e3e12017-08-03 11:24:13 -040085};
86
Mike Kleine1caee12017-02-15 13:31:12 -050087#endif//SkJumper_DEFINED