| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_RESOURCES_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <deque> | 11 #include <deque> |
| 12 #include <memory> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <string> | 14 #include <string> |
| 14 #include <unordered_map> | 15 #include <unordered_map> |
| 15 #include <unordered_set> | 16 #include <unordered_set> |
| 16 #include <utility> | 17 #include <utility> |
| 17 #include <vector> | 18 #include <vector> |
| 18 | 19 |
| 19 #include "base/callback.h" | 20 #include "base/callback.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/memory/linked_ptr.h" | 22 #include "base/memory/linked_ptr.h" |
| 22 #include "base/memory/scoped_ptr.h" | |
| 23 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 24 #include "base/trace_event/memory_allocator_dump.h" | 24 #include "base/trace_event/memory_allocator_dump.h" |
| 25 #include "base/trace_event/memory_dump_provider.h" | 25 #include "base/trace_event/memory_dump_provider.h" |
| 26 #include "cc/base/cc_export.h" | 26 #include "cc/base/cc_export.h" |
| 27 #include "cc/base/resource_id.h" | 27 #include "cc/base/resource_id.h" |
| 28 #include "cc/output/context_provider.h" | 28 #include "cc/output/context_provider.h" |
| 29 #include "cc/output/output_surface.h" | 29 #include "cc/output/output_surface.h" |
| 30 #include "cc/resources/release_callback_impl.h" | 30 #include "cc/resources/release_callback_impl.h" |
| 31 #include "cc/resources/resource_format.h" | 31 #include "cc/resources/resource_format.h" |
| 32 #include "cc/resources/return_callback.h" | 32 #include "cc/resources/return_callback.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 TEXTURE_HINT_FRAMEBUFFER = 0x2, | 79 TEXTURE_HINT_FRAMEBUFFER = 0x2, |
| 80 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = | 80 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = |
| 81 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER | 81 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER |
| 82 }; | 82 }; |
| 83 enum ResourceType { | 83 enum ResourceType { |
| 84 RESOURCE_TYPE_GPU_MEMORY_BUFFER, | 84 RESOURCE_TYPE_GPU_MEMORY_BUFFER, |
| 85 RESOURCE_TYPE_GL_TEXTURE, | 85 RESOURCE_TYPE_GL_TEXTURE, |
| 86 RESOURCE_TYPE_BITMAP, | 86 RESOURCE_TYPE_BITMAP, |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 static scoped_ptr<ResourceProvider> Create( | 89 static std::unique_ptr<ResourceProvider> Create( |
| 90 OutputSurface* output_surface, | 90 OutputSurface* output_surface, |
| 91 SharedBitmapManager* shared_bitmap_manager, | 91 SharedBitmapManager* shared_bitmap_manager, |
| 92 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 92 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 93 BlockingTaskRunner* blocking_main_thread_task_runner, | 93 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 94 int highp_threshold_min, | 94 int highp_threshold_min, |
| 95 size_t id_allocation_chunk_size, | 95 size_t id_allocation_chunk_size, |
| 96 bool use_gpu_memory_buffer_resources, | 96 bool use_gpu_memory_buffer_resources, |
| 97 const std::vector<unsigned>& use_image_texture_targets); | 97 const std::vector<unsigned>& use_image_texture_targets); |
| 98 ~ResourceProvider() override; | 98 ~ResourceProvider() override; |
| 99 | 99 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 TextureHint hint, | 139 TextureHint hint, |
| 140 ResourceFormat format); | 140 ResourceFormat format); |
| 141 | 141 |
| 142 // Wraps an IOSurface into a GL resource. | 142 // Wraps an IOSurface into a GL resource. |
| 143 ResourceId CreateResourceFromIOSurface(const gfx::Size& size, | 143 ResourceId CreateResourceFromIOSurface(const gfx::Size& size, |
| 144 unsigned io_surface_id); | 144 unsigned io_surface_id); |
| 145 | 145 |
| 146 // Wraps an external texture mailbox into a GL resource. | 146 // Wraps an external texture mailbox into a GL resource. |
| 147 ResourceId CreateResourceFromTextureMailbox( | 147 ResourceId CreateResourceFromTextureMailbox( |
| 148 const TextureMailbox& mailbox, | 148 const TextureMailbox& mailbox, |
| 149 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl); | 149 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl); |
| 150 | 150 |
| 151 ResourceId CreateResourceFromTextureMailbox( | 151 ResourceId CreateResourceFromTextureMailbox( |
| 152 const TextureMailbox& mailbox, | 152 const TextureMailbox& mailbox, |
| 153 scoped_ptr<SingleReleaseCallbackImpl> release_callback_impl, | 153 std::unique_ptr<SingleReleaseCallbackImpl> release_callback_impl, |
| 154 bool read_lock_fences_enabled); | 154 bool read_lock_fences_enabled); |
| 155 | 155 |
| 156 void DeleteResource(ResourceId id); | 156 void DeleteResource(ResourceId id); |
| 157 | 157 |
| 158 // Update pixels from image, copying source_rect (in image) to dest_offset (in | 158 // Update pixels from image, copying source_rect (in image) to dest_offset (in |
| 159 // the resource). | 159 // the resource). |
| 160 void CopyToResource(ResourceId id, | 160 void CopyToResource(ResourceId id, |
| 161 const uint8_t* image, | 161 const uint8_t* image, |
| 162 const gfx::Size& image_size); | 162 const gfx::Size& image_size); |
| 163 | 163 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 public: | 320 public: |
| 321 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 321 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
| 322 ResourceId resource_id); | 322 ResourceId resource_id); |
| 323 ~ScopedWriteLockGpuMemoryBuffer(); | 323 ~ScopedWriteLockGpuMemoryBuffer(); |
| 324 | 324 |
| 325 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); | 325 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); |
| 326 | 326 |
| 327 private: | 327 private: |
| 328 ResourceProvider* resource_provider_; | 328 ResourceProvider* resource_provider_; |
| 329 ResourceProvider::Resource* resource_; | 329 ResourceProvider::Resource* resource_; |
| 330 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; | 330 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
| 331 base::ThreadChecker thread_checker_; | 331 base::ThreadChecker thread_checker_; |
| 332 | 332 |
| 333 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 333 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
| 334 }; | 334 }; |
| 335 | 335 |
| 336 class CC_EXPORT ScopedWriteLockGr { | 336 class CC_EXPORT ScopedWriteLockGr { |
| 337 public: | 337 public: |
| 338 ScopedWriteLockGr(ResourceProvider* resource_provider, | 338 ScopedWriteLockGr(ResourceProvider* resource_provider, |
| 339 ResourceId resource_id); | 339 ResourceId resource_id); |
| 340 ~ScopedWriteLockGr(); | 340 ~ScopedWriteLockGr(); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 ResourceFormat yuv_highbit_resource_format_; | 662 ResourceFormat yuv_highbit_resource_format_; |
| 663 int max_texture_size_; | 663 int max_texture_size_; |
| 664 ResourceFormat best_texture_format_; | 664 ResourceFormat best_texture_format_; |
| 665 ResourceFormat best_render_buffer_format_; | 665 ResourceFormat best_render_buffer_format_; |
| 666 | 666 |
| 667 base::ThreadChecker thread_checker_; | 667 base::ThreadChecker thread_checker_; |
| 668 | 668 |
| 669 scoped_refptr<Fence> current_read_lock_fence_; | 669 scoped_refptr<Fence> current_read_lock_fence_; |
| 670 | 670 |
| 671 const size_t id_allocation_chunk_size_; | 671 const size_t id_allocation_chunk_size_; |
| 672 scoped_ptr<IdAllocator> texture_id_allocator_; | 672 std::unique_ptr<IdAllocator> texture_id_allocator_; |
| 673 scoped_ptr<IdAllocator> buffer_id_allocator_; | 673 std::unique_ptr<IdAllocator> buffer_id_allocator_; |
| 674 | 674 |
| 675 bool use_sync_query_; | 675 bool use_sync_query_; |
| 676 std::vector<unsigned> use_image_texture_targets_; | 676 std::vector<unsigned> use_image_texture_targets_; |
| 677 | 677 |
| 678 // A process-unique ID used for disambiguating memory dumps from different | 678 // A process-unique ID used for disambiguating memory dumps from different |
| 679 // resource providers. | 679 // resource providers. |
| 680 int tracing_id_; | 680 int tracing_id_; |
| 681 | 681 |
| 682 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 682 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 683 }; | 683 }; |
| 684 | 684 |
| 685 } // namespace cc | 685 } // namespace cc |
| 686 | 686 |
| 687 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 687 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |