| 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_IMAGE_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IMAGE_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_IMAGE_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_IMAGE_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "gpu/command_buffer/service/gpu_memory_buffer_manager.h" | |
| 12 #include "gpu/gpu_export.h" | 11 #include "gpu/gpu_export.h" |
| 13 | 12 |
| 14 namespace gfx { | 13 namespace gfx { |
| 15 class GLImage; | 14 class GLImage; |
| 16 } | 15 } |
| 17 | 16 |
| 18 namespace gpu { | 17 namespace gpu { |
| 19 namespace gles2 { | 18 namespace gles2 { |
| 20 | 19 |
| 21 // Interface used by the cmd decoder to lookup images. | 20 // This class keeps track of the images and their state. |
| 22 class GPU_EXPORT ImageManager | 21 class GPU_EXPORT ImageManager { |
| 23 : public GpuMemoryBufferManagerInterface, | |
| 24 public base::RefCounted<ImageManager> { | |
| 25 public: | 22 public: |
| 26 ImageManager(); | 23 ImageManager(); |
| 24 ~ImageManager(); |
| 27 | 25 |
| 28 // Overridden from GpuMemoryBufferManagerInterface: | 26 void AddImage(gfx::GLImage* image, int32 service_id); |
| 29 virtual void RegisterGpuMemoryBuffer(int32 id, | |
| 30 gfx::GpuMemoryBufferHandle buffer, | |
| 31 size_t width, | |
| 32 size_t height, | |
| 33 unsigned internalformat) OVERRIDE; | |
| 34 virtual void UnregisterGpuMemoryBuffer(int32 id) OVERRIDE; | |
| 35 | |
| 36 void AddImage(gfx::GLImage* gl_image, int32 service_id); | |
| 37 void RemoveImage(int32 service_id); | 27 void RemoveImage(int32 service_id); |
| 38 gfx::GLImage* LookupImage(int32 service_id); | 28 gfx::GLImage* LookupImage(int32 service_id); |
| 39 | 29 |
| 40 // For Android specific workaround. | |
| 41 void SetReleaseAfterUse(); | |
| 42 | |
| 43 private: | 30 private: |
| 44 friend class base::RefCounted<ImageManager>; | |
| 45 | |
| 46 virtual ~ImageManager(); | |
| 47 | |
| 48 typedef base::hash_map<uint32, scoped_refptr<gfx::GLImage> > GLImageMap; | 31 typedef base::hash_map<uint32, scoped_refptr<gfx::GLImage> > GLImageMap; |
| 49 GLImageMap gl_images_; | 32 GLImageMap images_; |
| 50 bool release_after_use_; | |
| 51 | 33 |
| 52 DISALLOW_COPY_AND_ASSIGN(ImageManager); | 34 DISALLOW_COPY_AND_ASSIGN(ImageManager); |
| 53 }; | 35 }; |
| 54 | 36 |
| 55 } // namespage gles2 | 37 } // namespage gles2 |
| 56 } // namespace gpu | 38 } // namespace gpu |
| 57 | 39 |
| 58 #endif // GPU_COMMAND_BUFFER_SERVICE_IMAGE_MANAGER_H_ | 40 #endif // GPU_COMMAND_BUFFER_SERVICE_IMAGE_MANAGER_H_ |
| OLD | NEW |