OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <algorithm> | 10 #include <algorithm> |
8 #include <string> | 11 #include <string> |
9 | 12 |
10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
11 #include "gpu/command_buffer/common/value_state.h" | 14 #include "gpu/command_buffer/common/value_state.h" |
12 #include "gpu/command_buffer/service/buffer_manager.h" | 15 #include "gpu/command_buffer/service/buffer_manager.h" |
13 #include "gpu/command_buffer/service/framebuffer_manager.h" | 16 #include "gpu/command_buffer/service/framebuffer_manager.h" |
14 #include "gpu/command_buffer/service/gpu_switches.h" | 17 #include "gpu/command_buffer/service/gpu_switches.h" |
15 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 18 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
16 #include "gpu/command_buffer/service/path_manager.h" | 19 #include "gpu/command_buffer/service/path_manager.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (!subscription_ref_set_.get()) | 80 if (!subscription_ref_set_.get()) |
78 subscription_ref_set_ = new SubscriptionRefSet(); | 81 subscription_ref_set_ = new SubscriptionRefSet(); |
79 if (!pending_valuebuffer_state_.get()) | 82 if (!pending_valuebuffer_state_.get()) |
80 pending_valuebuffer_state_ = new ValueStateMap(); | 83 pending_valuebuffer_state_ = new ValueStateMap(); |
81 if (!feature_info.get()) | 84 if (!feature_info.get()) |
82 feature_info_ = new FeatureInfo; | 85 feature_info_ = new FeatureInfo; |
83 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); | 86 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); |
84 } | 87 } |
85 } | 88 } |
86 | 89 |
87 static void GetIntegerv(GLenum pname, uint32* var) { | 90 static void GetIntegerv(GLenum pname, uint32_t* var) { |
88 GLint value = 0; | 91 GLint value = 0; |
89 glGetIntegerv(pname, &value); | 92 glGetIntegerv(pname, &value); |
90 *var = value; | 93 *var = value; |
91 } | 94 } |
92 | 95 |
93 bool ContextGroup::Initialize(GLES2Decoder* decoder, | 96 bool ContextGroup::Initialize(GLES2Decoder* decoder, |
94 ContextType context_type, | 97 ContextType context_type, |
95 const DisallowedFeatures& disallowed_features) { | 98 const DisallowedFeatures& disallowed_features) { |
96 if (HaveContexts()) { | 99 if (HaveContexts()) { |
97 if (context_type != feature_info_->context_type()) { | 100 if (context_type != feature_info_->context_type()) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 LOG(ERROR) << "ContextGroup::Initialize failed because too few " | 272 LOG(ERROR) << "ContextGroup::Initialize failed because too few " |
270 << "uniforms or varyings supported."; | 273 << "uniforms or varyings supported."; |
271 return false; | 274 return false; |
272 } | 275 } |
273 | 276 |
274 // Some shaders in Skia need more than the min available vertex and | 277 // Some shaders in Skia need more than the min available vertex and |
275 // fragment shader uniform vectors in case of OSMesa GL Implementation | 278 // fragment shader uniform vectors in case of OSMesa GL Implementation |
276 if (feature_info_->workarounds().max_fragment_uniform_vectors) { | 279 if (feature_info_->workarounds().max_fragment_uniform_vectors) { |
277 max_fragment_uniform_vectors_ = std::min( | 280 max_fragment_uniform_vectors_ = std::min( |
278 max_fragment_uniform_vectors_, | 281 max_fragment_uniform_vectors_, |
279 static_cast<uint32>( | 282 static_cast<uint32_t>( |
280 feature_info_->workarounds().max_fragment_uniform_vectors)); | 283 feature_info_->workarounds().max_fragment_uniform_vectors)); |
281 } | 284 } |
282 if (feature_info_->workarounds().max_varying_vectors) { | 285 if (feature_info_->workarounds().max_varying_vectors) { |
283 max_varying_vectors_ = std::min( | 286 max_varying_vectors_ = |
284 max_varying_vectors_, | 287 std::min(max_varying_vectors_, |
285 static_cast<uint32>(feature_info_->workarounds().max_varying_vectors)); | 288 static_cast<uint32_t>( |
| 289 feature_info_->workarounds().max_varying_vectors)); |
286 } | 290 } |
287 if (feature_info_->workarounds().max_vertex_uniform_vectors) { | 291 if (feature_info_->workarounds().max_vertex_uniform_vectors) { |
288 max_vertex_uniform_vectors_ = | 292 max_vertex_uniform_vectors_ = |
289 std::min(max_vertex_uniform_vectors_, | 293 std::min(max_vertex_uniform_vectors_, |
290 static_cast<uint32>( | 294 static_cast<uint32_t>( |
291 feature_info_->workarounds().max_vertex_uniform_vectors)); | 295 feature_info_->workarounds().max_vertex_uniform_vectors)); |
292 } | 296 } |
293 | 297 |
294 path_manager_.reset(new PathManager()); | 298 path_manager_.reset(new PathManager()); |
295 | 299 |
296 program_manager_.reset( | 300 program_manager_.reset( |
297 new ProgramManager(program_cache_, max_varying_vectors_, | 301 new ProgramManager(program_cache_, max_varying_vectors_, |
298 max_dual_source_draw_buffers_, feature_info_.get())); | 302 max_dual_source_draw_buffers_, feature_info_.get())); |
299 | 303 |
300 if (!texture_manager_->Initialize()) { | 304 if (!texture_manager_->Initialize()) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 390 } |
387 | 391 |
388 if (valuebuffer_manager_ != NULL) { | 392 if (valuebuffer_manager_ != NULL) { |
389 valuebuffer_manager_->Destroy(); | 393 valuebuffer_manager_->Destroy(); |
390 valuebuffer_manager_.reset(); | 394 valuebuffer_manager_.reset(); |
391 } | 395 } |
392 | 396 |
393 memory_tracker_ = NULL; | 397 memory_tracker_ = NULL; |
394 } | 398 } |
395 | 399 |
396 uint32 ContextGroup::GetMemRepresented() const { | 400 uint32_t ContextGroup::GetMemRepresented() const { |
397 uint32 total = 0; | 401 uint32_t total = 0; |
398 if (buffer_manager_.get()) | 402 if (buffer_manager_.get()) |
399 total += buffer_manager_->mem_represented(); | 403 total += buffer_manager_->mem_represented(); |
400 if (renderbuffer_manager_.get()) | 404 if (renderbuffer_manager_.get()) |
401 total += renderbuffer_manager_->mem_represented(); | 405 total += renderbuffer_manager_->mem_represented(); |
402 if (texture_manager_.get()) | 406 if (texture_manager_.get()) |
403 total += texture_manager_->mem_represented(); | 407 total += texture_manager_->mem_represented(); |
404 return total; | 408 return total; |
405 } | 409 } |
406 | 410 |
407 void ContextGroup::LoseContexts(error::ContextLostReason reason) { | 411 void ContextGroup::LoseContexts(error::ContextLostReason reason) { |
(...skipping 10 matching lines...) Expand all Loading... |
418 | 422 |
419 bool ContextGroup::CheckGLFeature(GLint min_required, GLint* v) { | 423 bool ContextGroup::CheckGLFeature(GLint min_required, GLint* v) { |
420 GLint value = *v; | 424 GLint value = *v; |
421 if (enforce_gl_minimums_) { | 425 if (enforce_gl_minimums_) { |
422 value = std::min(min_required, value); | 426 value = std::min(min_required, value); |
423 } | 427 } |
424 *v = value; | 428 *v = value; |
425 return value >= min_required; | 429 return value >= min_required; |
426 } | 430 } |
427 | 431 |
428 bool ContextGroup::CheckGLFeatureU(GLint min_required, uint32* v) { | 432 bool ContextGroup::CheckGLFeatureU(GLint min_required, uint32_t* v) { |
429 GLint value = *v; | 433 GLint value = *v; |
430 if (enforce_gl_minimums_) { | 434 if (enforce_gl_minimums_) { |
431 value = std::min(min_required, value); | 435 value = std::min(min_required, value); |
432 } | 436 } |
433 *v = value; | 437 *v = value; |
434 return value >= min_required; | 438 return value >= min_required; |
435 } | 439 } |
436 | 440 |
437 bool ContextGroup::QueryGLFeature( | 441 bool ContextGroup::QueryGLFeature( |
438 GLenum pname, GLint min_required, GLint* v) { | 442 GLenum pname, GLint min_required, GLint* v) { |
439 GLint value = 0; | 443 GLint value = 0; |
440 glGetIntegerv(pname, &value); | 444 glGetIntegerv(pname, &value); |
441 *v = value; | 445 *v = value; |
442 return CheckGLFeature(min_required, v); | 446 return CheckGLFeature(min_required, v); |
443 } | 447 } |
444 | 448 |
445 bool ContextGroup::QueryGLFeatureU( | 449 bool ContextGroup::QueryGLFeatureU(GLenum pname, |
446 GLenum pname, GLint min_required, uint32* v) { | 450 GLint min_required, |
447 uint32 value = 0; | 451 uint32_t* v) { |
| 452 uint32_t value = 0; |
448 GetIntegerv(pname, &value); | 453 GetIntegerv(pname, &value); |
449 bool result = CheckGLFeatureU(min_required, &value); | 454 bool result = CheckGLFeatureU(min_required, &value); |
450 *v = value; | 455 *v = value; |
451 return result; | 456 return result; |
452 } | 457 } |
453 | 458 |
454 bool ContextGroup::GetBufferServiceId( | 459 bool ContextGroup::GetBufferServiceId( |
455 GLuint client_id, GLuint* service_id) const { | 460 GLuint client_id, GLuint* service_id) const { |
456 Buffer* buffer = buffer_manager_->GetBuffer(client_id); | 461 Buffer* buffer = buffer_manager_->GetBuffer(client_id); |
457 if (!buffer) | 462 if (!buffer) |
458 return false; | 463 return false; |
459 *service_id = buffer->service_id(); | 464 *service_id = buffer->service_id(); |
460 return true; | 465 return true; |
461 } | 466 } |
462 | 467 |
463 } // namespace gles2 | 468 } // namespace gles2 |
464 } // namespace gpu | 469 } // namespace gpu |
OLD | NEW |