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 <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "gpu/command_buffer/service/feature_info.h" | 19 #include "gpu/command_buffer/service/feature_info.h" |
20 #include "gpu/command_buffer/service/gl_utils.h" | 20 #include "gpu/command_buffer/service/gl_utils.h" |
21 #include "gpu/command_buffer/service/memory_tracking.h" | 21 #include "gpu/command_buffer/service/memory_tracking.h" |
22 #include "gpu/command_buffer/service/sampler_manager.h" | 22 #include "gpu/command_buffer/service/sampler_manager.h" |
23 #include "gpu/gpu_export.h" | 23 #include "gpu/gpu_export.h" |
24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
25 #include "ui/gl/gl_image.h" | 25 #include "ui/gl/gl_image.h" |
26 | 26 |
| 27 namespace gl { |
| 28 class GLStreamTextureImage; |
| 29 } |
| 30 |
27 namespace gpu { | 31 namespace gpu { |
28 namespace gles2 { | 32 namespace gles2 { |
29 | 33 |
30 class GLES2Decoder; | 34 class GLES2Decoder; |
31 struct ContextState; | 35 struct ContextState; |
32 struct DecoderFramebufferState; | 36 struct DecoderFramebufferState; |
33 class Display; | 37 class Display; |
34 class ErrorState; | 38 class ErrorState; |
35 class FeatureInfo; | 39 class FeatureInfo; |
36 class FramebufferManager; | 40 class FramebufferManager; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Get the type of a level. Returns false if level does not exist. | 164 // Get the type of a level. Returns false if level does not exist. |
161 bool GetLevelType( | 165 bool GetLevelType( |
162 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; | 166 GLint target, GLint level, GLenum* type, GLenum* internal_format) const; |
163 | 167 |
164 // Set the image for a particular level. | 168 // Set the image for a particular level. |
165 void SetLevelImage(GLenum target, | 169 void SetLevelImage(GLenum target, |
166 GLint level, | 170 GLint level, |
167 gl::GLImage* image, | 171 gl::GLImage* image, |
168 ImageState state); | 172 ImageState state); |
169 | 173 |
| 174 // Set the GLStreamTextureImage for a particular level. This is identical |
| 175 // to SetLevelImage, but it also permits GetLevelStreamTextureImage to return |
| 176 // the image. |
| 177 void SetLevelStreamTextureImage(GLenum target, |
| 178 GLint level, |
| 179 gl::GLStreamTextureImage* image, |
| 180 ImageState state); |
| 181 |
170 // Get the image associated with a particular level. Returns NULL if level | 182 // Get the image associated with a particular level. Returns NULL if level |
171 // does not exist. | 183 // does not exist. |
172 gl::GLImage* GetLevelImage(GLint target, | 184 gl::GLImage* GetLevelImage(GLint target, |
173 GLint level, | 185 GLint level, |
174 ImageState* state) const; | 186 ImageState* state) const; |
175 gl::GLImage* GetLevelImage(GLint target, GLint level) const; | 187 gl::GLImage* GetLevelImage(GLint target, GLint level) const; |
176 | 188 |
| 189 // Like GetLevelImage, but will return NULL if the image wasn't set via |
| 190 // a call to SetLevelStreamTextureImage. |
| 191 gl::GLStreamTextureImage* GetLevelStreamTextureImage(GLint target, |
| 192 GLint level) const; |
| 193 |
177 bool HasImages() const { | 194 bool HasImages() const { |
178 return has_images_; | 195 return has_images_; |
179 } | 196 } |
180 | 197 |
181 // Returns true of the given dimensions are inside the dimensions of the | 198 // Returns true of the given dimensions are inside the dimensions of the |
182 // level. | 199 // level. |
183 bool ValidForTexture( | 200 bool ValidForTexture( |
184 GLint target, | 201 GLint target, |
185 GLint level, | 202 GLint level, |
186 GLint xoffset, | 203 GLint xoffset, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 GLenum target; | 286 GLenum target; |
270 GLint level; | 287 GLint level; |
271 GLenum internal_format; | 288 GLenum internal_format; |
272 GLsizei width; | 289 GLsizei width; |
273 GLsizei height; | 290 GLsizei height; |
274 GLsizei depth; | 291 GLsizei depth; |
275 GLint border; | 292 GLint border; |
276 GLenum format; | 293 GLenum format; |
277 GLenum type; | 294 GLenum type; |
278 scoped_refptr<gl::GLImage> image; | 295 scoped_refptr<gl::GLImage> image; |
| 296 scoped_refptr<gl::GLStreamTextureImage> stream_texture_image; |
279 ImageState image_state; | 297 ImageState image_state; |
280 uint32_t estimated_size; | 298 uint32_t estimated_size; |
281 bool internal_workaround; | 299 bool internal_workaround; |
282 }; | 300 }; |
283 | 301 |
284 struct FaceInfo { | 302 struct FaceInfo { |
285 FaceInfo(); | 303 FaceInfo(); |
286 ~FaceInfo(); | 304 ~FaceInfo(); |
287 | 305 |
288 // This is relative to base_level and max_level of a texture. | 306 // This is relative to base_level and max_level of a texture. |
289 GLsizei num_mip_levels; | 307 GLsizei num_mip_levels; |
290 // This contains slots for all levels starting at 0. | 308 // This contains slots for all levels starting at 0. |
291 std::vector<LevelInfo> level_infos; | 309 std::vector<LevelInfo> level_infos; |
292 }; | 310 }; |
293 | 311 |
| 312 // Helper for SetLevel*Image. |stream_texture_image| may be null. |
| 313 void SetLevelImageInternal(GLenum target, |
| 314 GLint level, |
| 315 gl::GLImage* image, |
| 316 gl::GLStreamTextureImage* stream_texture_image, |
| 317 ImageState state); |
| 318 |
| 319 // Helper for GetLevel*Image. Returns the LevelInfo for |target| and |level| |
| 320 // if it's set, else NULL. |
| 321 const LevelInfo* GetLevelInfo(GLint target, GLint level) const; |
| 322 |
294 // Set the info for a particular level. | 323 // Set the info for a particular level. |
295 void SetLevelInfo(GLenum target, | 324 void SetLevelInfo(GLenum target, |
296 GLint level, | 325 GLint level, |
297 GLenum internal_format, | 326 GLenum internal_format, |
298 GLsizei width, | 327 GLsizei width, |
299 GLsizei height, | 328 GLsizei height, |
300 GLsizei depth, | 329 GLsizei depth, |
301 GLint border, | 330 GLint border, |
302 GLenum format, | 331 GLenum format, |
303 GLenum type, | 332 GLenum type, |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 size_t mem_represented() const { | 873 size_t mem_represented() const { |
845 return memory_type_tracker_->GetMemRepresented(); | 874 return memory_type_tracker_->GetMemRepresented(); |
846 } | 875 } |
847 | 876 |
848 void SetLevelImage(TextureRef* ref, | 877 void SetLevelImage(TextureRef* ref, |
849 GLenum target, | 878 GLenum target, |
850 GLint level, | 879 GLint level, |
851 gl::GLImage* image, | 880 gl::GLImage* image, |
852 Texture::ImageState state); | 881 Texture::ImageState state); |
853 | 882 |
| 883 void SetLevelStreamTextureImage(TextureRef* ref, |
| 884 GLenum target, |
| 885 GLint level, |
| 886 gl::GLStreamTextureImage* image, |
| 887 Texture::ImageState state); |
| 888 |
854 size_t GetSignatureSize() const; | 889 size_t GetSignatureSize() const; |
855 | 890 |
856 void AddToSignature( | 891 void AddToSignature( |
857 TextureRef* ref, | 892 TextureRef* ref, |
858 GLenum target, | 893 GLenum target, |
859 GLint level, | 894 GLint level, |
860 std::string* signature) const; | 895 std::string* signature) const; |
861 | 896 |
862 void AddObserver(DestructionObserver* observer) { | 897 void AddObserver(DestructionObserver* observer) { |
863 destruction_observers_.push_back(observer); | 898 destruction_observers_.push_back(observer); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 private: | 1098 private: |
1064 DecoderTextureState* texture_state_; | 1099 DecoderTextureState* texture_state_; |
1065 base::TimeTicks begin_time_; | 1100 base::TimeTicks begin_time_; |
1066 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); | 1101 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); |
1067 }; | 1102 }; |
1068 | 1103 |
1069 } // namespace gles2 | 1104 } // namespace gles2 |
1070 } // namespace gpu | 1105 } // namespace gpu |
1071 | 1106 |
1072 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ | 1107 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ |
OLD | NEW |