| 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 #include "gpu/command_buffer/service/sampler_manager.h" | 5 #include "gpu/command_buffer/service/sampler_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/service/error_state.h" | 10 #include "gpu/command_buffer/service/error_state.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 mag_filter(GL_LINEAR), | 23 mag_filter(GL_LINEAR), |
| 24 wrap_r(GL_REPEAT), | 24 wrap_r(GL_REPEAT), |
| 25 wrap_s(GL_REPEAT), | 25 wrap_s(GL_REPEAT), |
| 26 wrap_t(GL_REPEAT), | 26 wrap_t(GL_REPEAT), |
| 27 compare_func(GL_LEQUAL), | 27 compare_func(GL_LEQUAL), |
| 28 compare_mode(GL_NONE), | 28 compare_mode(GL_NONE), |
| 29 max_lod(1000.0f), | 29 max_lod(1000.0f), |
| 30 min_lod(-1000.0f) { | 30 min_lod(-1000.0f) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 Sampler::Sampler(SamplerManager* manager, GLuint service_id) | 33 Sampler::Sampler(SamplerManager* manager, GLuint client_id, GLuint service_id) |
| 34 : manager_(manager), | 34 : manager_(manager), |
| 35 client_id_(client_id), |
| 35 service_id_(service_id), | 36 service_id_(service_id), |
| 36 deleted_(false) { | 37 deleted_(false) { |
| 37 DCHECK(manager); | 38 DCHECK(manager); |
| 38 } | 39 } |
| 39 | 40 |
| 40 Sampler::~Sampler() { | 41 Sampler::~Sampler() { |
| 41 if (manager_->have_context_) { | 42 if (manager_->have_context_) { |
| 42 glDeleteSamplers(1, &service_id_); | 43 glDeleteSamplers(1, &service_id_); |
| 43 } | 44 } |
| 44 } | 45 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 while (!samplers_.empty()) { | 141 while (!samplers_.empty()) { |
| 141 Sampler* sampler = samplers_.begin()->second.get(); | 142 Sampler* sampler = samplers_.begin()->second.get(); |
| 142 sampler->MarkAsDeleted(); | 143 sampler->MarkAsDeleted(); |
| 143 samplers_.erase(samplers_.begin()); | 144 samplers_.erase(samplers_.begin()); |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 | 147 |
| 147 Sampler* SamplerManager::CreateSampler(GLuint client_id, GLuint service_id) { | 148 Sampler* SamplerManager::CreateSampler(GLuint client_id, GLuint service_id) { |
| 148 DCHECK_NE(0u, service_id); | 149 DCHECK_NE(0u, service_id); |
| 149 auto result = samplers_.insert(std::make_pair(client_id, | 150 auto result = samplers_.insert(std::make_pair(client_id, |
| 150 scoped_refptr<Sampler>(new Sampler(this, service_id)))); | 151 scoped_refptr<Sampler>(new Sampler(this, client_id, service_id)))); |
| 151 DCHECK(result.second); | 152 DCHECK(result.second); |
| 152 return result.first->second.get(); | 153 return result.first->second.get(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 Sampler* SamplerManager::GetSampler(GLuint client_id) { | 156 Sampler* SamplerManager::GetSampler(GLuint client_id) { |
| 156 SamplerMap::iterator it = samplers_.find(client_id); | 157 SamplerMap::iterator it = samplers_.find(client_id); |
| 157 return it != samplers_.end() ? it->second.get() : nullptr; | 158 return it != samplers_.end() ? it->second.get() : nullptr; |
| 158 } | 159 } |
| 159 | 160 |
| 160 void SamplerManager::RemoveSampler(GLuint client_id) { | 161 void SamplerManager::RemoveSampler(GLuint client_id) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 ERRORSTATE_SET_GL_ERROR_INVALID_PARAMI( | 201 ERRORSTATE_SET_GL_ERROR_INVALID_PARAMI( |
| 201 error_state, result, function_name, pname, param); | 202 error_state, result, function_name, pname, param); |
| 202 } | 203 } |
| 203 } else { | 204 } else { |
| 204 glSamplerParameterf(sampler->service_id(), pname, param); | 205 glSamplerParameterf(sampler->service_id(), pname, param); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 | 208 |
| 208 } // namespace gles2 | 209 } // namespace gles2 |
| 209 } // namespace gpu | 210 } // namespace gpu |
| OLD | NEW |