OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "gpu/command_buffer/service/feature_info.h" | 14 #include "gpu/command_buffer/service/feature_info.h" |
15 #include "gpu/command_buffer/service/gl_utils.h" | 15 #include "gpu/command_buffer/service/gl_utils.h" |
16 #include "gpu/gpu_export.h" | 16 #include "gpu/gpu_export.h" |
17 | 17 |
18 namespace gpu { | 18 namespace gpu { |
19 | 19 |
20 namespace gles2 { | 20 namespace gles2 { |
21 | 21 |
22 class SamplerManager; | 22 class SamplerManager; |
23 | 23 |
24 struct SamplerState { | |
25 SamplerState(); | |
26 | |
27 GLenum min_filter; | |
28 GLenum mag_filter; | |
29 GLenum wrap_r; | |
30 GLenum wrap_s; | |
31 GLenum wrap_t; | |
32 GLenum compare_func; | |
33 GLenum compare_mode; | |
34 GLfloat max_lod; | |
35 GLfloat min_lod; | |
36 }; | |
37 | |
38 class GPU_EXPORT Sampler : public base::RefCounted<Sampler> { | 24 class GPU_EXPORT Sampler : public base::RefCounted<Sampler> { |
39 public: | 25 public: |
40 Sampler(SamplerManager* manager, GLuint service_id); | 26 Sampler(SamplerManager* manager, GLuint service_id); |
41 | 27 |
42 // The service side OpenGL id of the texture. | 28 // The service side OpenGL id of the texture. |
43 GLuint service_id() const { | 29 GLuint service_id() const { |
44 return service_id_; | 30 return service_id_; |
45 } | 31 } |
46 | 32 |
47 const SamplerState& sampler_state() const { | |
48 return sampler_state_; | |
49 } | |
50 | |
51 // Sampler parameters | 33 // Sampler parameters |
52 GLenum min_filter() const { | 34 GLenum min_filter() const { |
53 return sampler_state_.min_filter; | 35 return min_filter_; |
54 } | 36 } |
55 | 37 |
56 GLenum mag_filter() const { | 38 GLenum mag_filter() const { |
57 return sampler_state_.mag_filter; | 39 return mag_filter_; |
58 } | 40 } |
59 | 41 |
60 GLenum wrap_r() const { | 42 GLenum wrap_r() const { |
61 return sampler_state_.wrap_r; | 43 return wrap_r_; |
62 } | 44 } |
63 | 45 |
64 GLenum wrap_s() const { | 46 GLenum wrap_s() const { |
65 return sampler_state_.wrap_s; | 47 return wrap_s_; |
66 } | 48 } |
67 | 49 |
68 GLenum wrap_t() const { | 50 GLenum wrap_t() const { |
69 return sampler_state_.wrap_t; | 51 return wrap_t_; |
70 } | 52 } |
71 | 53 |
72 GLenum compare_func() const { | 54 GLenum compare_func() const { |
73 return sampler_state_.compare_func; | 55 return compare_func_; |
74 } | 56 } |
75 | 57 |
76 GLenum compare_mode() const { | 58 GLenum compare_mode() const { |
77 return sampler_state_.compare_mode; | 59 return compare_mode_; |
78 } | 60 } |
79 | 61 |
80 GLfloat max_lod() const { | 62 GLfloat max_lod() const { |
81 return sampler_state_.max_lod; | 63 return max_lod_; |
82 } | 64 } |
83 | 65 |
84 GLfloat min_lod() const { | 66 GLfloat min_lod() const { |
85 return sampler_state_.min_lod; | 67 return min_lod_; |
86 } | 68 } |
87 | 69 |
88 bool IsDeleted() const { | 70 bool IsDeleted() const { |
89 return deleted_; | 71 return deleted_; |
90 } | 72 } |
91 | 73 |
92 protected: | 74 protected: |
93 virtual ~Sampler(); | 75 virtual ~Sampler(); |
94 | 76 |
95 SamplerManager* manager() const { | 77 SamplerManager* manager() const { |
(...skipping 14 matching lines...) Expand all Loading... |
110 const FeatureInfo* feature_info, GLenum pname, GLint param); | 92 const FeatureInfo* feature_info, GLenum pname, GLint param); |
111 GLenum SetParameterf( | 93 GLenum SetParameterf( |
112 const FeatureInfo* feature_info, GLenum pname, GLfloat param); | 94 const FeatureInfo* feature_info, GLenum pname, GLfloat param); |
113 | 95 |
114 // The manager that owns this Sampler. | 96 // The manager that owns this Sampler. |
115 SamplerManager* manager_; | 97 SamplerManager* manager_; |
116 | 98 |
117 // The id of the texure | 99 // The id of the texure |
118 GLuint service_id_; | 100 GLuint service_id_; |
119 | 101 |
120 // Sampler parameters. | 102 // Texture parameters. |
121 SamplerState sampler_state_; | 103 GLenum min_filter_; |
| 104 GLenum mag_filter_; |
| 105 GLenum wrap_r_; |
| 106 GLenum wrap_s_; |
| 107 GLenum wrap_t_; |
| 108 GLenum compare_func_; |
| 109 GLenum compare_mode_; |
| 110 GLfloat max_lod_; |
| 111 GLfloat min_lod_; |
122 | 112 |
123 // True if deleted. | 113 // True if deleted. |
124 bool deleted_; | 114 bool deleted_; |
125 }; | 115 }; |
126 | 116 |
127 // This class keeps track of the samplers and their state. | 117 // This class keeps track of the samplers and their state. |
128 class GPU_EXPORT SamplerManager { | 118 class GPU_EXPORT SamplerManager { |
129 public: | 119 public: |
130 SamplerManager(FeatureInfo* feature_info); | 120 SamplerManager(FeatureInfo* feature_info); |
131 ~SamplerManager(); | 121 ~SamplerManager(); |
(...skipping 30 matching lines...) Expand all Loading... |
162 | 152 |
163 bool have_context_; | 153 bool have_context_; |
164 | 154 |
165 DISALLOW_COPY_AND_ASSIGN(SamplerManager); | 155 DISALLOW_COPY_AND_ASSIGN(SamplerManager); |
166 }; | 156 }; |
167 | 157 |
168 } // namespace gles2 | 158 } // namespace gles2 |
169 } // namespace gpu | 159 } // namespace gpu |
170 | 160 |
171 #endif // GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ | 161 #endif // GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ |
OLD | NEW |