• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Amber Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef SRC_SAMPLER_H_
16 #define SRC_SAMPLER_H_
17 
18 #include <cstdint>
19 #include <memory>
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 #include "amber/result.h"
25 #include "amber/value.h"
26 #include "src/format.h"
27 
28 namespace amber {
29 
30 enum class FilterType : int8_t { kUnknown = -1, kNearest = 0, kLinear = 1 };
31 
32 enum class AddressMode : int8_t {
33   kUnknown = -1,
34   kRepeat = 0,
35   kMirroredRepeat = 1,
36   kClampToEdge = 2,
37   kClampToBorder = 3,
38   kMirrorClampToEdge = 4
39 };
40 
41 enum class BorderColor : int8_t {
42   kUnknown = -1,
43   kFloatTransparentBlack = 0,
44   kIntTransparentBlack = 1,
45   kFloatOpaqueBlack = 2,
46   kIntOpaqueBlack = 3,
47   kFloatOpaqueWhite = 4,
48   kIntOpaqueWhite = 5
49 };
50 
51 class Sampler {
52  public:
53   Sampler();
54   ~Sampler();
55 
SetName(const std::string & name)56   void SetName(const std::string& name) { name_ = name; }
GetName()57   std::string GetName() const { return name_; }
58 
SetMagFilter(FilterType filter)59   void SetMagFilter(FilterType filter) { mag_filter_ = filter; }
GetMagFilter()60   FilterType GetMagFilter() const { return mag_filter_; }
61 
SetMinFilter(FilterType filter)62   void SetMinFilter(FilterType filter) { min_filter_ = filter; }
GetMinFilter()63   FilterType GetMinFilter() const { return min_filter_; }
64 
SetMipmapMode(FilterType filter)65   void SetMipmapMode(FilterType filter) { mipmap_mode_ = filter; }
GetMipmapMode()66   FilterType GetMipmapMode() const { return mipmap_mode_; }
67 
SetAddressModeU(AddressMode mode)68   void SetAddressModeU(AddressMode mode) { address_mode_u_ = mode; }
GetAddressModeU()69   AddressMode GetAddressModeU() const { return address_mode_u_; }
70 
SetAddressModeV(AddressMode mode)71   void SetAddressModeV(AddressMode mode) { address_mode_v_ = mode; }
GetAddressModeV()72   AddressMode GetAddressModeV() const { return address_mode_v_; }
73 
SetAddressModeW(AddressMode mode)74   void SetAddressModeW(AddressMode mode) { address_mode_w_ = mode; }
GetAddressModeW()75   AddressMode GetAddressModeW() const { return address_mode_w_; }
76 
SetBorderColor(BorderColor color)77   void SetBorderColor(BorderColor color) { border_color_ = color; }
GetBorderColor()78   BorderColor GetBorderColor() const { return border_color_; }
79 
SetMinLOD(float min_lod)80   void SetMinLOD(float min_lod) { min_lod_ = min_lod; }
GetMinLOD()81   float GetMinLOD() const { return min_lod_; }
82 
SetMaxLOD(float max_lod)83   void SetMaxLOD(float max_lod) { max_lod_ = max_lod; }
GetMaxLOD()84   float GetMaxLOD() const { return max_lod_; }
85 
SetNormalizedCoords(bool norm)86   void SetNormalizedCoords(bool norm) { normalized_coords_ = norm; }
GetNormalizedCoords()87   bool GetNormalizedCoords() const { return normalized_coords_; }
88 
89  private:
90   std::string name_;
91   FilterType min_filter_ = FilterType::kNearest;
92   FilterType mag_filter_ = FilterType::kNearest;
93   FilterType mipmap_mode_ = FilterType::kNearest;
94   AddressMode address_mode_u_ = AddressMode::kRepeat;
95   AddressMode address_mode_v_ = AddressMode::kRepeat;
96   AddressMode address_mode_w_ = AddressMode::kRepeat;
97   BorderColor border_color_ = BorderColor::kFloatTransparentBlack;
98   float min_lod_ = 0.0f;
99   float max_lod_ = 1.0f;
100   bool normalized_coords_ = true;
101 };
102 
103 }  // namespace amber
104 
105 #endif  // SRC_SAMPLER_H_
106