| 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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bits.h" | 14 #include "base/bits.h" |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "base/trace_event/memory_dump_manager.h" | 20 #include "base/trace_event/memory_dump_manager.h" |
| 21 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 21 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 22 #include "gpu/command_buffer/service/context_state.h" | 22 #include "gpu/command_buffer/service/context_state.h" |
| 23 #include "gpu/command_buffer/service/error_state.h" | 23 #include "gpu/command_buffer/service/error_state.h" |
| 24 #include "gpu/command_buffer/service/feature_info.h" | 24 #include "gpu/command_buffer/service/feature_info.h" |
| 25 #include "gpu/command_buffer/service/framebuffer_manager.h" | 25 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 26 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 26 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
| 27 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 27 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 28 #include "gpu/command_buffer/service/mailbox_manager.h" | 28 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 29 #include "gpu/command_buffer/service/memory_tracking.h" | 29 #include "gpu/command_buffer/service/memory_tracking.h" |
| 30 #include "gpu/command_buffer/service/progress_reporter.h" |
| 30 #include "ui/gl/gl_context.h" | 31 #include "ui/gl/gl_context.h" |
| 31 #include "ui/gl/gl_implementation.h" | 32 #include "ui/gl/gl_implementation.h" |
| 32 #include "ui/gl/gl_state_restorer.h" | 33 #include "ui/gl/gl_state_restorer.h" |
| 33 #include "ui/gl/gl_version_info.h" | 34 #include "ui/gl/gl_version_info.h" |
| 34 #include "ui/gl/trace_util.h" | 35 #include "ui/gl/trace_util.h" |
| 35 | 36 |
| 36 namespace gpu { | 37 namespace gpu { |
| 37 namespace gles2 { | 38 namespace gles2 { |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 DCHECK_EQ(0, num_unsafe_textures_); | 355 DCHECK_EQ(0, num_unsafe_textures_); |
| 355 DCHECK_EQ(0, num_uncleared_mips_); | 356 DCHECK_EQ(0, num_uncleared_mips_); |
| 356 DCHECK_EQ(0, num_images_); | 357 DCHECK_EQ(0, num_images_); |
| 357 | 358 |
| 358 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 359 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 359 this); | 360 this); |
| 360 } | 361 } |
| 361 | 362 |
| 362 void TextureManager::Destroy(bool have_context) { | 363 void TextureManager::Destroy(bool have_context) { |
| 363 have_context_ = have_context; | 364 have_context_ = have_context; |
| 364 textures_.clear(); | 365 |
| 366 while (!textures_.empty()) { |
| 367 textures_.erase(textures_.begin()); |
| 368 progress_reporter_->ReportProgress(); |
| 369 } |
| 365 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { | 370 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { |
| 366 default_textures_[ii] = NULL; | 371 default_textures_[ii] = NULL; |
| 372 progress_reporter_->ReportProgress(); |
| 367 } | 373 } |
| 368 | 374 |
| 369 if (have_context) { | 375 if (have_context) { |
| 370 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); | 376 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); |
| 371 } | 377 } |
| 372 | 378 |
| 373 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); | 379 DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented()); |
| 374 } | 380 } |
| 375 | 381 |
| 376 TextureBase::TextureBase(GLuint service_id) | 382 TextureBase::TextureBase(GLuint service_id) |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 force_context_lost_ = true; | 1785 force_context_lost_ = true; |
| 1780 } | 1786 } |
| 1781 | 1787 |
| 1782 TextureManager::TextureManager(MemoryTracker* memory_tracker, | 1788 TextureManager::TextureManager(MemoryTracker* memory_tracker, |
| 1783 FeatureInfo* feature_info, | 1789 FeatureInfo* feature_info, |
| 1784 GLint max_texture_size, | 1790 GLint max_texture_size, |
| 1785 GLint max_cube_map_texture_size, | 1791 GLint max_cube_map_texture_size, |
| 1786 GLint max_rectangle_texture_size, | 1792 GLint max_rectangle_texture_size, |
| 1787 GLint max_3d_texture_size, | 1793 GLint max_3d_texture_size, |
| 1788 GLint max_array_texture_layers, | 1794 GLint max_array_texture_layers, |
| 1789 bool use_default_textures) | 1795 bool use_default_textures, |
| 1796 ProgressReporter* progress_reporter) |
| 1790 : memory_type_tracker_(new MemoryTypeTracker(memory_tracker)), | 1797 : memory_type_tracker_(new MemoryTypeTracker(memory_tracker)), |
| 1791 memory_tracker_(memory_tracker), | 1798 memory_tracker_(memory_tracker), |
| 1792 feature_info_(feature_info), | 1799 feature_info_(feature_info), |
| 1793 framebuffer_manager_(NULL), | 1800 framebuffer_manager_(NULL), |
| 1794 max_texture_size_(max_texture_size), | 1801 max_texture_size_(max_texture_size), |
| 1795 max_cube_map_texture_size_(max_cube_map_texture_size), | 1802 max_cube_map_texture_size_(max_cube_map_texture_size), |
| 1796 max_rectangle_texture_size_(max_rectangle_texture_size), | 1803 max_rectangle_texture_size_(max_rectangle_texture_size), |
| 1797 max_3d_texture_size_(max_3d_texture_size), | 1804 max_3d_texture_size_(max_3d_texture_size), |
| 1798 max_array_texture_layers_(max_array_texture_layers), | 1805 max_array_texture_layers_(max_array_texture_layers), |
| 1799 max_levels_(ComputeMipMapCount(GL_TEXTURE_2D, | 1806 max_levels_(ComputeMipMapCount(GL_TEXTURE_2D, |
| 1800 max_texture_size, | 1807 max_texture_size, |
| 1801 max_texture_size, | 1808 max_texture_size, |
| 1802 0)), | 1809 0)), |
| 1803 max_cube_map_levels_(ComputeMipMapCount(GL_TEXTURE_CUBE_MAP, | 1810 max_cube_map_levels_(ComputeMipMapCount(GL_TEXTURE_CUBE_MAP, |
| 1804 max_cube_map_texture_size, | 1811 max_cube_map_texture_size, |
| 1805 max_cube_map_texture_size, | 1812 max_cube_map_texture_size, |
| 1806 0)), | 1813 0)), |
| 1807 max_3d_levels_(ComputeMipMapCount(GL_TEXTURE_3D, | 1814 max_3d_levels_(ComputeMipMapCount(GL_TEXTURE_3D, |
| 1808 max_3d_texture_size, | 1815 max_3d_texture_size, |
| 1809 max_3d_texture_size, | 1816 max_3d_texture_size, |
| 1810 max_3d_texture_size)), | 1817 max_3d_texture_size)), |
| 1811 use_default_textures_(use_default_textures), | 1818 use_default_textures_(use_default_textures), |
| 1812 num_unsafe_textures_(0), | 1819 num_unsafe_textures_(0), |
| 1813 num_uncleared_mips_(0), | 1820 num_uncleared_mips_(0), |
| 1814 num_images_(0), | 1821 num_images_(0), |
| 1815 texture_count_(0), | 1822 texture_count_(0), |
| 1816 have_context_(true), | 1823 have_context_(true), |
| 1817 current_service_id_generation_(0) { | 1824 current_service_id_generation_(0), |
| 1825 progress_reporter_(progress_reporter) { |
| 1826 DCHECK(progress_reporter_); |
| 1818 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { | 1827 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { |
| 1819 black_texture_ids_[ii] = 0; | 1828 black_texture_ids_[ii] = 0; |
| 1820 } | 1829 } |
| 1821 } | 1830 } |
| 1822 | 1831 |
| 1823 bool TextureManager::Initialize() { | 1832 bool TextureManager::Initialize() { |
| 1824 // Reset PIXEL_UNPACK_BUFFER to avoid unrelated GL error on some GL drivers. | 1833 // Reset PIXEL_UNPACK_BUFFER to avoid unrelated GL error on some GL drivers. |
| 1825 if (feature_info_->gl_version_info().is_es3_capable) { | 1834 if (feature_info_->gl_version_info().is_es3_capable) { |
| 1826 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | 1835 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); |
| 1827 } | 1836 } |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3467 uint32_t TextureManager::GetServiceIdGeneration() const { | 3476 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3468 return current_service_id_generation_; | 3477 return current_service_id_generation_; |
| 3469 } | 3478 } |
| 3470 | 3479 |
| 3471 void TextureManager::IncrementServiceIdGeneration() { | 3480 void TextureManager::IncrementServiceIdGeneration() { |
| 3472 current_service_id_generation_++; | 3481 current_service_id_generation_++; |
| 3473 } | 3482 } |
| 3474 | 3483 |
| 3475 } // namespace gles2 | 3484 } // namespace gles2 |
| 3476 } // namespace gpu | 3485 } // namespace gpu |
| OLD | NEW |