Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 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 | |
Mike Klein | 376fd31 | 2017-12-11 16:53:26 -0500 | [diff] [blame] | 11 | #include <stddef.h> |
| 12 | #include <stdint.h> |
| 13 | |
Mike Klein | 1b9b7d5 | 2018-02-27 10:37:40 -0500 | [diff] [blame] | 14 | // 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 Klein | b561b76 | 2017-08-28 17:53:34 -0400 | [diff] [blame] | 19 | |
Mike Klein | d4faecd | 2017-10-17 14:31:17 -0400 | [diff] [blame] | 20 | static const int SkJumper_kMaxStride = 16; |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 21 | |
Mike Klein | 968af43 | 2017-07-18 16:31:55 -0400 | [diff] [blame] | 22 | struct SkJumper_MemoryCtx { |
| 23 | void* pixels; |
| 24 | int stride; |
Mike Klein | dec4ea8 | 2017-04-06 15:04:05 -0400 | [diff] [blame] | 25 | }; |
| 26 | |
Mike Klein | f3b4e16 | 2017-09-22 15:32:59 -0400 | [diff] [blame] | 27 | struct SkJumper_GatherCtx { |
Mike Klein | 1fa9c43 | 2017-12-11 09:59:47 -0500 | [diff] [blame] | 28 | const void* pixels; |
| 29 | int stride; |
| 30 | float width; |
| 31 | float height; |
Mike Klein | f3b4e16 | 2017-09-22 15:32:59 -0400 | [diff] [blame] | 32 | }; |
| 33 | |
Mike Klein | 0a90449 | 2017-04-12 12:52:48 -0400 | [diff] [blame] | 34 | // State shared by save_xy, accumulate, and bilinear_* / bicubic_*. |
| 35 | struct 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 Reed | 51e46d5 | 2017-06-23 14:21:25 -0400 | [diff] [blame] | 44 | struct SkJumper_TileCtx { |
| 45 | float scale; |
| 46 | float invScale; // cache of 1/scale |
| 47 | }; |
| 48 | |
Mike Reed | dfc0e91 | 2018-02-16 12:40:18 -0500 | [diff] [blame] | 49 | struct SkJumper_DecalTileCtx { |
| 50 | uint32_t mask[SkJumper_kMaxStride]; |
| 51 | float limit_x; |
| 52 | float limit_y; |
| 53 | }; |
| 54 | |
Mike Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 55 | struct SkJumper_CallbackCtx { |
Mike Klein | 1b9b7d5 | 2018-02-27 10:37:40 -0500 | [diff] [blame] | 56 | void (*fn)(SkJumper_CallbackCtx* self, int active_pixels/*<= SkJumper_kMaxStride*/); |
Mike Klein | c17dc24 | 2017-04-20 16:21:57 -0400 | [diff] [blame] | 57 | |
| 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 Klein | 7fee90c | 2017-04-07 16:55:09 -0400 | [diff] [blame] | 62 | }; |
| 63 | |
Mike Klein | 4437517 | 2017-04-17 19:32:05 -0400 | [diff] [blame] | 64 | // This should line up with the memory layout of SkColorSpaceTransferFn. |
| 65 | struct SkJumper_ParametricTransferFunction { |
| 66 | float G, A,B,C,D,E,F; |
| 67 | }; |
| 68 | |
Herb Derby | 4de1304 | 2017-05-15 10:49:39 -0400 | [diff] [blame] | 69 | struct SkJumper_GradientCtx { |
| 70 | size_t stopCount; |
| 71 | float* fs[4]; |
| 72 | float* bs[4]; |
| 73 | float* ts; |
| 74 | }; |
| 75 | |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 76 | struct SkJumper_2PtConicalCtx { |
Florin Malita | 9026fe1 | 2017-06-29 11:03:45 -0400 | [diff] [blame] | 77 | uint32_t fMask[SkJumper_kMaxStride]; |
Yuqian Li | d3b743a | 2018-01-09 11:47:45 -0500 | [diff] [blame] | 78 | float fP0, |
Yuqian Li | d208a88 | 2018-01-04 10:08:42 -0500 | [diff] [blame] | 79 | fP1; |
Florin Malita | a66ef2d | 2017-06-28 10:02:40 -0400 | [diff] [blame] | 80 | }; |
| 81 | |
Mike Klein | 1a2e3e1 | 2017-08-03 11:24:13 -0400 | [diff] [blame] | 82 | struct SkJumper_UniformColorCtx { |
| 83 | float r,g,b,a; |
Mike Klein | f757ae6 | 2017-09-15 14:57:02 -0400 | [diff] [blame] | 84 | uint16_t rgba[4]; // [0,255] in a 16-bit lane. |
Mike Klein | 1a2e3e1 | 2017-08-03 11:24:13 -0400 | [diff] [blame] | 85 | }; |
| 86 | |
Mike Klein | e1caee1 | 2017-02-15 13:31:12 -0500 | [diff] [blame] | 87 | #endif//SkJumper_DEFINED |