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/program_manager.h" | 5 #include "gpu/command_buffer/service/program_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 25 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
27 #include "gpu/command_buffer/service/feature_info.h" | 27 #include "gpu/command_buffer/service/feature_info.h" |
28 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 28 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
29 #include "gpu/command_buffer/service/gpu_preferences.h" | 29 #include "gpu/command_buffer/service/gpu_preferences.h" |
30 #include "gpu/command_buffer/service/program_cache.h" | 30 #include "gpu/command_buffer/service/program_cache.h" |
| 31 #include "gpu/command_buffer/service/progress_reporter.h" |
31 #include "gpu/command_buffer/service/shader_manager.h" | 32 #include "gpu/command_buffer/service/shader_manager.h" |
32 #include "third_party/re2/src/re2/re2.h" | 33 #include "third_party/re2/src/re2/re2.h" |
33 #include "ui/gl/gl_version_info.h" | 34 #include "ui/gl/gl_version_info.h" |
34 | 35 |
35 using base::TimeDelta; | 36 using base::TimeDelta; |
36 using base::TimeTicks; | 37 using base::TimeTicks; |
37 | 38 |
38 namespace gpu { | 39 namespace gpu { |
39 namespace gles2 { | 40 namespace gles2 { |
40 | 41 |
(...skipping 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 Program::~Program() { | 2446 Program::~Program() { |
2446 if (manager_) { | 2447 if (manager_) { |
2447 if (manager_->have_context_) { | 2448 if (manager_->have_context_) { |
2448 glDeleteProgram(service_id()); | 2449 glDeleteProgram(service_id()); |
2449 } | 2450 } |
2450 manager_->StopTracking(this); | 2451 manager_->StopTracking(this); |
2451 manager_ = NULL; | 2452 manager_ = NULL; |
2452 } | 2453 } |
2453 } | 2454 } |
2454 | 2455 |
2455 ProgramManager::ProgramManager( | 2456 ProgramManager::ProgramManager(ProgramCache* program_cache, |
2456 ProgramCache* program_cache, | 2457 uint32_t max_varying_vectors, |
2457 uint32_t max_varying_vectors, | 2458 uint32_t max_draw_buffers, |
2458 uint32_t max_draw_buffers, | 2459 uint32_t max_dual_source_draw_buffers, |
2459 uint32_t max_dual_source_draw_buffers, | 2460 uint32_t max_vertex_attribs, |
2460 uint32_t max_vertex_attribs, | 2461 const GpuPreferences& gpu_preferences, |
2461 const GpuPreferences& gpu_preferences, | 2462 FeatureInfo* feature_info, |
2462 FeatureInfo* feature_info) | 2463 ProgressReporter* progress_reporter) |
2463 : program_count_(0), | 2464 : program_count_(0), |
2464 have_context_(true), | 2465 have_context_(true), |
2465 program_cache_(program_cache), | 2466 program_cache_(program_cache), |
2466 max_varying_vectors_(max_varying_vectors), | 2467 max_varying_vectors_(max_varying_vectors), |
2467 max_draw_buffers_(max_draw_buffers), | 2468 max_draw_buffers_(max_draw_buffers), |
2468 max_dual_source_draw_buffers_(max_dual_source_draw_buffers), | 2469 max_dual_source_draw_buffers_(max_dual_source_draw_buffers), |
2469 max_vertex_attribs_(max_vertex_attribs), | 2470 max_vertex_attribs_(max_vertex_attribs), |
2470 gpu_preferences_(gpu_preferences), | 2471 gpu_preferences_(gpu_preferences), |
2471 feature_info_(feature_info) {} | 2472 feature_info_(feature_info), |
| 2473 progress_reporter_(progress_reporter) {} |
2472 | 2474 |
2473 ProgramManager::~ProgramManager() { | 2475 ProgramManager::~ProgramManager() { |
2474 DCHECK(programs_.empty()); | 2476 DCHECK(programs_.empty()); |
2475 } | 2477 } |
2476 | 2478 |
2477 void ProgramManager::Destroy(bool have_context) { | 2479 void ProgramManager::Destroy(bool have_context) { |
2478 have_context_ = have_context; | 2480 have_context_ = have_context; |
2479 | 2481 |
2480 ProgramDeletionScopedUmaTimeAndRate scoped_histogram( | 2482 ProgramDeletionScopedUmaTimeAndRate scoped_histogram( |
2481 base::saturated_cast<int32_t>(programs_.size())); | 2483 base::saturated_cast<int32_t>(programs_.size())); |
2482 programs_.clear(); | 2484 while (!programs_.empty()) { |
| 2485 programs_.erase(programs_.begin()); |
| 2486 if (progress_reporter_) |
| 2487 progress_reporter_->ReportProgress(); |
| 2488 } |
2483 } | 2489 } |
2484 | 2490 |
2485 void ProgramManager::StartTracking(Program* /* program */) { | 2491 void ProgramManager::StartTracking(Program* /* program */) { |
2486 ++program_count_; | 2492 ++program_count_; |
2487 } | 2493 } |
2488 | 2494 |
2489 void ProgramManager::StopTracking(Program* /* program */) { | 2495 void ProgramManager::StopTracking(Program* /* program */) { |
2490 --program_count_; | 2496 --program_count_; |
2491 } | 2497 } |
2492 | 2498 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 DCHECK(program); | 2584 DCHECK(program); |
2579 program->ClearUniforms(&zero_); | 2585 program->ClearUniforms(&zero_); |
2580 } | 2586 } |
2581 | 2587 |
2582 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2588 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
2583 return index + element * 0x10000; | 2589 return index + element * 0x10000; |
2584 } | 2590 } |
2585 | 2591 |
2586 } // namespace gles2 | 2592 } // namespace gles2 |
2587 } // namespace gpu | 2593 } // namespace gpu |
OLD | NEW |