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> |
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 GLint max_texture_size, | 1886 GLint max_texture_size, |
1887 GLint max_cube_map_texture_size, | 1887 GLint max_cube_map_texture_size, |
1888 GLint max_rectangle_texture_size, | 1888 GLint max_rectangle_texture_size, |
1889 GLint max_3d_texture_size, | 1889 GLint max_3d_texture_size, |
1890 GLint max_array_texture_layers, | 1890 GLint max_array_texture_layers, |
1891 bool use_default_textures, | 1891 bool use_default_textures, |
1892 ProgressReporter* progress_reporter) | 1892 ProgressReporter* progress_reporter) |
1893 : memory_type_tracker_(new MemoryTypeTracker(memory_tracker)), | 1893 : memory_type_tracker_(new MemoryTypeTracker(memory_tracker)), |
1894 memory_tracker_(memory_tracker), | 1894 memory_tracker_(memory_tracker), |
1895 feature_info_(feature_info), | 1895 feature_info_(feature_info), |
1896 framebuffer_manager_(NULL), | |
1897 max_texture_size_(max_texture_size), | 1896 max_texture_size_(max_texture_size), |
1898 max_cube_map_texture_size_(max_cube_map_texture_size), | 1897 max_cube_map_texture_size_(max_cube_map_texture_size), |
1899 max_rectangle_texture_size_(max_rectangle_texture_size), | 1898 max_rectangle_texture_size_(max_rectangle_texture_size), |
1900 max_3d_texture_size_(max_3d_texture_size), | 1899 max_3d_texture_size_(max_3d_texture_size), |
1901 max_array_texture_layers_(max_array_texture_layers), | 1900 max_array_texture_layers_(max_array_texture_layers), |
1902 max_levels_(ComputeMipMapCount(GL_TEXTURE_2D, | 1901 max_levels_(ComputeMipMapCount(GL_TEXTURE_2D, |
1903 max_texture_size, | 1902 max_texture_size, |
1904 max_texture_size, | 1903 max_texture_size, |
1905 0)), | 1904 0)), |
1906 max_cube_map_levels_(ComputeMipMapCount(GL_TEXTURE_CUBE_MAP, | 1905 max_cube_map_levels_(ComputeMipMapCount(GL_TEXTURE_CUBE_MAP, |
(...skipping 10 matching lines...) Expand all Loading... |
1917 num_images_(0), | 1916 num_images_(0), |
1918 texture_count_(0), | 1917 texture_count_(0), |
1919 have_context_(true), | 1918 have_context_(true), |
1920 current_service_id_generation_(0), | 1919 current_service_id_generation_(0), |
1921 progress_reporter_(progress_reporter) { | 1920 progress_reporter_(progress_reporter) { |
1922 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { | 1921 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { |
1923 black_texture_ids_[ii] = 0; | 1922 black_texture_ids_[ii] = 0; |
1924 } | 1923 } |
1925 } | 1924 } |
1926 | 1925 |
| 1926 void TextureManager::AddFramebufferManager( |
| 1927 FramebufferManager* framebuffer_manager) { |
| 1928 framebuffer_managers_.push_back(framebuffer_manager); |
| 1929 } |
| 1930 |
| 1931 void TextureManager::RemoveFramebufferManager( |
| 1932 FramebufferManager* framebuffer_manager) { |
| 1933 for (unsigned int i = 0; i < framebuffer_managers_.size(); ++i) { |
| 1934 if (framebuffer_managers_[i] == framebuffer_manager) { |
| 1935 std::swap(framebuffer_managers_[i], framebuffer_managers_.back()); |
| 1936 framebuffer_managers_.pop_back(); |
| 1937 return; |
| 1938 } |
| 1939 } |
| 1940 NOTREACHED(); |
| 1941 } |
| 1942 |
1927 bool TextureManager::Initialize() { | 1943 bool TextureManager::Initialize() { |
1928 // Reset PIXEL_UNPACK_BUFFER to avoid unrelated GL error on some GL drivers. | 1944 // Reset PIXEL_UNPACK_BUFFER to avoid unrelated GL error on some GL drivers. |
1929 if (feature_info_->gl_version_info().is_es3_capable) { | 1945 if (feature_info_->gl_version_info().is_es3_capable) { |
1930 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); | 1946 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); |
1931 } | 1947 } |
1932 | 1948 |
1933 // TODO(gman): The default textures have to be real textures, not the 0 | 1949 // TODO(gman): The default textures have to be real textures, not the 0 |
1934 // texture because we simulate non shared resources on top of shared | 1950 // texture because we simulate non shared resources on top of shared |
1935 // resources and all contexts that share resource share the same default | 1951 // resources and all contexts that share resource share the same default |
1936 // texture. | 1952 // texture. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2325 num_uncleared_mips_ += delta; | 2341 num_uncleared_mips_ += delta; |
2326 DCHECK_GE(num_uncleared_mips_, 0); | 2342 DCHECK_GE(num_uncleared_mips_, 0); |
2327 } | 2343 } |
2328 | 2344 |
2329 void TextureManager::UpdateNumImages(int delta) { | 2345 void TextureManager::UpdateNumImages(int delta) { |
2330 num_images_ += delta; | 2346 num_images_ += delta; |
2331 DCHECK_GE(num_images_, 0); | 2347 DCHECK_GE(num_images_, 0); |
2332 } | 2348 } |
2333 | 2349 |
2334 void TextureManager::IncFramebufferStateChangeCount() { | 2350 void TextureManager::IncFramebufferStateChangeCount() { |
2335 if (framebuffer_manager_) | 2351 for (unsigned int i = 0; i < framebuffer_managers_.size(); ++i) { |
2336 framebuffer_manager_->IncFramebufferStateChangeCount(); | 2352 framebuffer_managers_[i]->IncFramebufferStateChangeCount(); |
| 2353 } |
2337 } | 2354 } |
2338 | 2355 |
2339 bool TextureManager::ValidateTextureParameters( | 2356 bool TextureManager::ValidateTextureParameters( |
2340 ErrorState* error_state, const char* function_name, bool tex_image_call, | 2357 ErrorState* error_state, const char* function_name, bool tex_image_call, |
2341 GLenum format, GLenum type, GLint internal_format, GLint level) { | 2358 GLenum format, GLenum type, GLint internal_format, GLint level) { |
2342 const Validators* validators = feature_info_->validators(); | 2359 const Validators* validators = feature_info_->validators(); |
2343 if (!validators->texture_format.IsValid(format)) { | 2360 if (!validators->texture_format.IsValid(format)) { |
2344 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( | 2361 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( |
2345 error_state, function_name, format, "format"); | 2362 error_state, function_name, format, "format"); |
2346 return false; | 2363 return false; |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3684 uint32_t TextureManager::GetServiceIdGeneration() const { | 3701 uint32_t TextureManager::GetServiceIdGeneration() const { |
3685 return current_service_id_generation_; | 3702 return current_service_id_generation_; |
3686 } | 3703 } |
3687 | 3704 |
3688 void TextureManager::IncrementServiceIdGeneration() { | 3705 void TextureManager::IncrementServiceIdGeneration() { |
3689 current_service_id_generation_++; | 3706 current_service_id_generation_++; |
3690 } | 3707 } |
3691 | 3708 |
3692 } // namespace gles2 | 3709 } // namespace gles2 |
3693 } // namespace gpu | 3710 } // namespace gpu |
OLD | NEW |