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 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <list> | 12 #include <list> |
13 #include <memory> | 13 #include <memory> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/containers/hash_tables.h" | 18 #include "base/containers/hash_tables.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
21 #include "gpu/command_buffer/service/feature_info.h" | 21 #include "gpu/command_buffer/service/feature_info.h" |
22 #include "gpu/command_buffer/service/gl_utils.h" | 22 #include "gpu/command_buffer/service/gl_utils.h" |
23 #include "gpu/command_buffer/service/memory_tracking.h" | 23 #include "gpu/command_buffer/service/memory_tracking.h" |
24 #include "gpu/command_buffer/service/sampler_manager.h" | 24 #include "gpu/command_buffer/service/sampler_manager.h" |
25 #include "gpu/gpu_export.h" | 25 #include "gpu/gpu_export.h" |
26 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
27 #include "ui/gl/gl_image.h" | 27 #include "ui/gl/gl_image.h" |
28 | 28 |
29 namespace gpu { | 29 namespace gpu { |
| 30 class ServiceDiscardableManager; |
| 31 |
30 namespace gles2 { | 32 namespace gles2 { |
31 | |
32 class GLES2Decoder; | 33 class GLES2Decoder; |
33 class GLStreamTextureImage; | 34 class GLStreamTextureImage; |
34 struct ContextState; | 35 struct ContextState; |
35 struct DecoderFramebufferState; | 36 struct DecoderFramebufferState; |
36 class ErrorState; | 37 class ErrorState; |
37 class FeatureInfo; | 38 class FeatureInfo; |
38 class FramebufferManager; | 39 class FramebufferManager; |
39 class MailboxManager; | 40 class MailboxManager; |
40 class ProgressReporter; | 41 class ProgressReporter; |
41 class Texture; | 42 class Texture; |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 }; | 749 }; |
749 | 750 |
750 TextureManager(MemoryTracker* memory_tracker, | 751 TextureManager(MemoryTracker* memory_tracker, |
751 FeatureInfo* feature_info, | 752 FeatureInfo* feature_info, |
752 GLsizei max_texture_size, | 753 GLsizei max_texture_size, |
753 GLsizei max_cube_map_texture_size, | 754 GLsizei max_cube_map_texture_size, |
754 GLsizei max_rectangle_texture_size, | 755 GLsizei max_rectangle_texture_size, |
755 GLsizei max_3d_texture_size, | 756 GLsizei max_3d_texture_size, |
756 GLsizei max_array_texture_layers, | 757 GLsizei max_array_texture_layers, |
757 bool use_default_textures, | 758 bool use_default_textures, |
758 ProgressReporter* progress_reporter); | 759 ProgressReporter* progress_reporter, |
| 760 ServiceDiscardableManager* discardable_manager); |
759 ~TextureManager() override; | 761 ~TextureManager() override; |
760 | 762 |
761 void AddFramebufferManager(FramebufferManager* framebuffer_manager); | 763 void AddFramebufferManager(FramebufferManager* framebuffer_manager); |
762 void RemoveFramebufferManager(FramebufferManager* framebuffer_manager); | 764 void RemoveFramebufferManager(FramebufferManager* framebuffer_manager); |
763 | 765 |
764 // Init the texture manager. | 766 // Init the texture manager. |
765 bool Initialize(); | 767 bool Initialize(); |
766 | 768 |
767 // Must call before destruction. | 769 // Must call before destruction. |
768 void Destroy(bool have_context); | 770 void Destroy(bool have_context); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 // Clear a specific level. | 892 // Clear a specific level. |
891 bool ClearTextureLevel( | 893 bool ClearTextureLevel( |
892 GLES2Decoder* decoder, TextureRef* ref, GLenum target, GLint level); | 894 GLES2Decoder* decoder, TextureRef* ref, GLenum target, GLint level); |
893 | 895 |
894 // Creates a new texture info. | 896 // Creates a new texture info. |
895 TextureRef* CreateTexture(GLuint client_id, GLuint service_id); | 897 TextureRef* CreateTexture(GLuint client_id, GLuint service_id); |
896 | 898 |
897 // Gets the texture info for the given texture. | 899 // Gets the texture info for the given texture. |
898 TextureRef* GetTexture(GLuint client_id) const; | 900 TextureRef* GetTexture(GLuint client_id) const; |
899 | 901 |
| 902 // Takes the TextureRef for the given texture out of the texture manager. |
| 903 scoped_refptr<TextureRef> TakeTexture(GLuint client_id); |
| 904 |
| 905 // Returns a TextureRef to the texture manager. |
| 906 void ReturnTexture(scoped_refptr<TextureRef> texture_ref); |
| 907 |
900 // Removes a texture info. | 908 // Removes a texture info. |
901 void RemoveTexture(GLuint client_id); | 909 void RemoveTexture(GLuint client_id); |
902 | 910 |
903 // Gets a Texture for a given service id (note: it assumes the texture object | 911 // Gets a Texture for a given service id (note: it assumes the texture object |
904 // is still mapped in this TextureManager). | 912 // is still mapped in this TextureManager). |
905 Texture* GetTextureForServiceId(GLuint service_id) const; | 913 Texture* GetTextureForServiceId(GLuint service_id) const; |
906 | 914 |
907 TextureRef* GetDefaultTextureInfo(GLenum target) { | 915 TextureRef* GetDefaultTextureInfo(GLenum target) { |
908 switch (target) { | 916 switch (target) { |
909 case GL_TEXTURE_2D: | 917 case GL_TEXTURE_2D: |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 | 1236 |
1229 std::vector<DestructionObserver*> destruction_observers_; | 1237 std::vector<DestructionObserver*> destruction_observers_; |
1230 | 1238 |
1231 uint32_t current_service_id_generation_; | 1239 uint32_t current_service_id_generation_; |
1232 | 1240 |
1233 // Used to notify the watchdog thread of progress during destruction, | 1241 // Used to notify the watchdog thread of progress during destruction, |
1234 // preventing time-outs when destruction takes a long time. May be null when | 1242 // preventing time-outs when destruction takes a long time. May be null when |
1235 // using in-process command buffer. | 1243 // using in-process command buffer. |
1236 ProgressReporter* progress_reporter_; | 1244 ProgressReporter* progress_reporter_; |
1237 | 1245 |
| 1246 ServiceDiscardableManager* discardable_manager_; |
| 1247 |
1238 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 1248 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
1239 }; | 1249 }; |
1240 | 1250 |
1241 } // namespace gles2 | 1251 } // namespace gles2 |
1242 } // namespace gpu | 1252 } // namespace gpu |
1243 | 1253 |
1244 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 1254 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |