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 |
24 class GPU_EXPORT Sampler : public base::RefCounted<Sampler> { | 38 class GPU_EXPORT Sampler : public base::RefCounted<Sampler> { |
25 public: | 39 public: |
26 Sampler(SamplerManager* manager, GLuint service_id); | 40 Sampler(SamplerManager* manager, GLuint service_id); |
27 | 41 |
28 // The service side OpenGL id of the texture. | 42 // The service side OpenGL id of the texture. |
29 GLuint service_id() const { | 43 GLuint service_id() const { |
30 return service_id_; | 44 return service_id_; |
31 } | 45 } |
32 | 46 |
| 47 const SamplerState& sampler_state() const { |
| 48 return sampler_state_; |
| 49 } |
| 50 |
33 // Sampler parameters | 51 // Sampler parameters |
34 GLenum min_filter() const { | 52 GLenum min_filter() const { |
35 return min_filter_; | 53 return sampler_state_.min_filter; |
36 } | 54 } |
37 | 55 |
38 GLenum mag_filter() const { | 56 GLenum mag_filter() const { |
39 return mag_filter_; | 57 return sampler_state_.mag_filter; |
40 } | 58 } |
41 | 59 |
42 GLenum wrap_r() const { | 60 GLenum wrap_r() const { |
43 return wrap_r_; | 61 return sampler_state_.wrap_r; |
44 } | 62 } |
45 | 63 |
46 GLenum wrap_s() const { | 64 GLenum wrap_s() const { |
47 return wrap_s_; | 65 return sampler_state_.wrap_s; |
48 } | 66 } |
49 | 67 |
50 GLenum wrap_t() const { | 68 GLenum wrap_t() const { |
51 return wrap_t_; | 69 return sampler_state_.wrap_t; |
52 } | 70 } |
53 | 71 |
54 GLenum compare_func() const { | 72 GLenum compare_func() const { |
55 return compare_func_; | 73 return sampler_state_.compare_func; |
56 } | 74 } |
57 | 75 |
58 GLenum compare_mode() const { | 76 GLenum compare_mode() const { |
59 return compare_mode_; | 77 return sampler_state_.compare_mode; |
60 } | 78 } |
61 | 79 |
62 GLfloat max_lod() const { | 80 GLfloat max_lod() const { |
63 return max_lod_; | 81 return sampler_state_.max_lod; |
64 } | 82 } |
65 | 83 |
66 GLfloat min_lod() const { | 84 GLfloat min_lod() const { |
67 return min_lod_; | 85 return sampler_state_.min_lod; |
68 } | 86 } |
69 | 87 |
70 bool IsDeleted() const { | 88 bool IsDeleted() const { |
71 return deleted_; | 89 return deleted_; |
72 } | 90 } |
73 | 91 |
74 protected: | 92 protected: |
75 virtual ~Sampler(); | 93 virtual ~Sampler(); |
76 | 94 |
77 SamplerManager* manager() const { | 95 SamplerManager* manager() const { |
(...skipping 14 matching lines...) Expand all Loading... |
92 const FeatureInfo* feature_info, GLenum pname, GLint param); | 110 const FeatureInfo* feature_info, GLenum pname, GLint param); |
93 GLenum SetParameterf( | 111 GLenum SetParameterf( |
94 const FeatureInfo* feature_info, GLenum pname, GLfloat param); | 112 const FeatureInfo* feature_info, GLenum pname, GLfloat param); |
95 | 113 |
96 // The manager that owns this Sampler. | 114 // The manager that owns this Sampler. |
97 SamplerManager* manager_; | 115 SamplerManager* manager_; |
98 | 116 |
99 // The id of the texure | 117 // The id of the texure |
100 GLuint service_id_; | 118 GLuint service_id_; |
101 | 119 |
102 // Texture parameters. | 120 // Sampler parameters. |
103 GLenum min_filter_; | 121 SamplerState sampler_state_; |
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_; | |
112 | 122 |
113 // True if deleted. | 123 // True if deleted. |
114 bool deleted_; | 124 bool deleted_; |
115 }; | 125 }; |
116 | 126 |
117 // This class keeps track of the samplers and their state. | 127 // This class keeps track of the samplers and their state. |
118 class GPU_EXPORT SamplerManager { | 128 class GPU_EXPORT SamplerManager { |
119 public: | 129 public: |
120 SamplerManager(FeatureInfo* feature_info); | 130 SamplerManager(FeatureInfo* feature_info); |
121 ~SamplerManager(); | 131 ~SamplerManager(); |
(...skipping 30 matching lines...) Expand all Loading... |
152 | 162 |
153 bool have_context_; | 163 bool have_context_; |
154 | 164 |
155 DISALLOW_COPY_AND_ASSIGN(SamplerManager); | 165 DISALLOW_COPY_AND_ASSIGN(SamplerManager); |
156 }; | 166 }; |
157 | 167 |
158 } // namespace gles2 | 168 } // namespace gles2 |
159 } // namespace gpu | 169 } // namespace gpu |
160 | 170 |
161 #endif // GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ | 171 #endif // GPU_COMMAND_BUFFER_SERVICE_SAMPLER_MANAGER_H_ |
OLD | NEW |