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