| 1 | // LAF OS Library |
| 2 | // Copyright (c) 2022 Igara Studio S.A. |
| 3 | // |
| 4 | // This file is released under the terms of the MIT license. |
| 5 | // Read LICENSE.txt for more information. |
| 6 | |
| 7 | #ifndef OS_SAMPLING_H_INCLUDED |
| 8 | #define OS_SAMPLING_H_INCLUDED |
| 9 | #pragma once |
| 10 | |
| 11 | #pragma push_macro("None") |
| 12 | #undef None // Undefine the X11 None macro |
| 13 | |
| 14 | namespace os { |
| 15 | |
| 16 | // Same as SkSamplingOptions struct |
| 17 | struct Sampling { |
| 18 | enum class Filter { Nearest, Linear }; |
| 19 | enum class Mipmap { None, Nearest, Linear }; |
| 20 | struct Cubic { |
| 21 | float B, C; |
| 22 | static constexpr Cubic Mitchell() { return { 1/3.0f, 1/3.0f }; } |
| 23 | static constexpr Cubic CatmullRom() { return { 0.0f, 1/2.0f }; } |
| 24 | }; |
| 25 | |
| 26 | bool useCubic = false; |
| 27 | Cubic cubic = { 0, 0 }; |
| 28 | Filter filter = Filter::Nearest; |
| 29 | Mipmap mipmap = Mipmap::None; |
| 30 | |
| 31 | Sampling() = default; |
| 32 | Sampling(const Sampling&) = default; |
| 33 | Sampling& operator=(const Sampling&) = default; |
| 34 | Sampling(Filter f, Mipmap m = Mipmap::None) |
| 35 | : filter(f), mipmap(m) { } |
| 36 | Sampling(Cubic c) |
| 37 | : useCubic(true), cubic(c) { } |
| 38 | }; |
| 39 | |
| 40 | } // namespace os |
| 41 | |
| 42 | #pragma pop_macro("None") |
| 43 | |
| 44 | #endif |
| 45 | |