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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 }; | 753 }; |
753 | 754 |
754 TextureManager(MemoryTracker* memory_tracker, | 755 TextureManager(MemoryTracker* memory_tracker, |
755 FeatureInfo* feature_info, | 756 FeatureInfo* feature_info, |
756 GLsizei max_texture_size, | 757 GLsizei max_texture_size, |
757 GLsizei max_cube_map_texture_size, | 758 GLsizei max_cube_map_texture_size, |
758 GLsizei max_rectangle_texture_size, | 759 GLsizei max_rectangle_texture_size, |
759 GLsizei max_3d_texture_size, | 760 GLsizei max_3d_texture_size, |
760 GLsizei max_array_texture_layers, | 761 GLsizei max_array_texture_layers, |
761 bool use_default_textures, | 762 bool use_default_textures, |
762 ProgressReporter* progress_reporter); | 763 ProgressReporter* progress_reporter, |
| 764 ServiceDiscardableManager* discardable_manager); |
763 ~TextureManager() override; | 765 ~TextureManager() override; |
764 | 766 |
765 void set_framebuffer_manager(FramebufferManager* manager) { | 767 void set_framebuffer_manager(FramebufferManager* manager) { |
766 framebuffer_manager_ = manager; | 768 framebuffer_manager_ = manager; |
767 } | 769 } |
768 | 770 |
769 // Init the texture manager. | 771 // Init the texture manager. |
770 bool Initialize(); | 772 bool Initialize(); |
771 | 773 |
772 // Must call before destruction. | 774 // Must call before destruction. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 // Clear a specific level. | 897 // Clear a specific level. |
896 bool ClearTextureLevel( | 898 bool ClearTextureLevel( |
897 GLES2Decoder* decoder, TextureRef* ref, GLenum target, GLint level); | 899 GLES2Decoder* decoder, TextureRef* ref, GLenum target, GLint level); |
898 | 900 |
899 // Creates a new texture info. | 901 // Creates a new texture info. |
900 TextureRef* CreateTexture(GLuint client_id, GLuint service_id); | 902 TextureRef* CreateTexture(GLuint client_id, GLuint service_id); |
901 | 903 |
902 // Gets the texture info for the given texture. | 904 // Gets the texture info for the given texture. |
903 TextureRef* GetTexture(GLuint client_id) const; | 905 TextureRef* GetTexture(GLuint client_id) const; |
904 | 906 |
| 907 // Takes the TextureRef for the given texture out of the texture manager. |
| 908 scoped_refptr<TextureRef> TakeTexture(GLuint client_id); |
| 909 |
| 910 // Returns a TextureRef to the texture manager. |
| 911 void ReturnTexture(scoped_refptr<TextureRef> texture_ref); |
| 912 |
905 // Removes a texture info. | 913 // Removes a texture info. |
906 void RemoveTexture(GLuint client_id); | 914 void RemoveTexture(GLuint client_id); |
907 | 915 |
908 // Gets a Texture for a given service id (note: it assumes the texture object | 916 // Gets a Texture for a given service id (note: it assumes the texture object |
909 // is still mapped in this TextureManager). | 917 // is still mapped in this TextureManager). |
910 Texture* GetTextureForServiceId(GLuint service_id) const; | 918 Texture* GetTextureForServiceId(GLuint service_id) const; |
911 | 919 |
912 TextureRef* GetDefaultTextureInfo(GLenum target) { | 920 TextureRef* GetDefaultTextureInfo(GLenum target) { |
913 switch (target) { | 921 switch (target) { |
914 case GL_TEXTURE_2D: | 922 case GL_TEXTURE_2D: |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 | 1241 |
1234 std::vector<DestructionObserver*> destruction_observers_; | 1242 std::vector<DestructionObserver*> destruction_observers_; |
1235 | 1243 |
1236 uint32_t current_service_id_generation_; | 1244 uint32_t current_service_id_generation_; |
1237 | 1245 |
1238 // Used to notify the watchdog thread of progress during destruction, | 1246 // Used to notify the watchdog thread of progress during destruction, |
1239 // preventing time-outs when destruction takes a long time. May be null when | 1247 // preventing time-outs when destruction takes a long time. May be null when |
1240 // using in-process command buffer. | 1248 // using in-process command buffer. |
1241 ProgressReporter* progress_reporter_; | 1249 ProgressReporter* progress_reporter_; |
1242 | 1250 |
| 1251 ServiceDiscardableManager* discardable_manager_; |
| 1252 |
1243 DISALLOW_COPY_AND_ASSIGN(TextureManager); | 1253 DISALLOW_COPY_AND_ASSIGN(TextureManager); |
1244 }; | 1254 }; |
1245 | 1255 |
1246 // This class records texture upload time when in scope. | 1256 // This class records texture upload time when in scope. |
1247 class ScopedTextureUploadTimer { | 1257 class ScopedTextureUploadTimer { |
1248 public: | 1258 public: |
1249 explicit ScopedTextureUploadTimer(DecoderTextureState* texture_state); | 1259 explicit ScopedTextureUploadTimer(DecoderTextureState* texture_state); |
1250 ~ScopedTextureUploadTimer(); | 1260 ~ScopedTextureUploadTimer(); |
1251 | 1261 |
1252 private: | 1262 private: |
1253 DecoderTextureState* texture_state_; | 1263 DecoderTextureState* texture_state_; |
1254 base::TimeTicks begin_time_; | 1264 base::TimeTicks begin_time_; |
1255 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 1265 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
1256 }; | 1266 }; |
1257 | 1267 |
1258 } // namespace gles2 | 1268 } // namespace gles2 |
1259 } // namespace gpu | 1269 } // namespace gpu |
1260 | 1270 |
1261 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 1271 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |