| 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 <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
| 20 #include "base/trace_event/memory_dump_provider.h" |
| 20 #include "cc/base/cc_export.h" | 21 #include "cc/base/cc_export.h" |
| 21 #include "cc/base/resource_id.h" | 22 #include "cc/base/resource_id.h" |
| 22 #include "cc/output/context_provider.h" | 23 #include "cc/output/context_provider.h" |
| 23 #include "cc/output/output_surface.h" | 24 #include "cc/output/output_surface.h" |
| 24 #include "cc/resources/release_callback_impl.h" | 25 #include "cc/resources/release_callback_impl.h" |
| 25 #include "cc/resources/resource_format.h" | 26 #include "cc/resources/resource_format.h" |
| 26 #include "cc/resources/return_callback.h" | 27 #include "cc/resources/return_callback.h" |
| 27 #include "cc/resources/shared_bitmap.h" | 28 #include "cc/resources/shared_bitmap.h" |
| 28 #include "cc/resources/single_release_callback_impl.h" | 29 #include "cc/resources/single_release_callback_impl.h" |
| 29 #include "cc/resources/texture_mailbox.h" | 30 #include "cc/resources/texture_mailbox.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 } | 51 } |
| 51 | 52 |
| 52 namespace cc { | 53 namespace cc { |
| 53 class BlockingTaskRunner; | 54 class BlockingTaskRunner; |
| 54 class IdAllocator; | 55 class IdAllocator; |
| 55 class SharedBitmap; | 56 class SharedBitmap; |
| 56 class SharedBitmapManager; | 57 class SharedBitmapManager; |
| 57 | 58 |
| 58 // This class is not thread-safe and can only be called from the thread it was | 59 // This class is not thread-safe and can only be called from the thread it was |
| 59 // created on (in practice, the impl thread). | 60 // created on (in practice, the impl thread). |
| 60 class CC_EXPORT ResourceProvider { | 61 class CC_EXPORT ResourceProvider |
| 62 : public base::trace_event::MemoryDumpProvider { |
| 61 private: | 63 private: |
| 62 struct Resource; | 64 struct Resource; |
| 63 | 65 |
| 64 public: | 66 public: |
| 65 typedef std::vector<ResourceId> ResourceIdArray; | 67 typedef std::vector<ResourceId> ResourceIdArray; |
| 66 typedef base::hash_set<ResourceId> ResourceIdSet; | 68 typedef base::hash_set<ResourceId> ResourceIdSet; |
| 67 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 69 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
| 68 enum TextureHint { | 70 enum TextureHint { |
| 69 TEXTURE_HINT_DEFAULT = 0x0, | 71 TEXTURE_HINT_DEFAULT = 0x0, |
| 70 TEXTURE_HINT_IMMUTABLE = 0x1, | 72 TEXTURE_HINT_IMMUTABLE = 0x1, |
| 71 TEXTURE_HINT_FRAMEBUFFER = 0x2, | 73 TEXTURE_HINT_FRAMEBUFFER = 0x2, |
| 72 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = | 74 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = |
| 73 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER | 75 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER |
| 74 }; | 76 }; |
| 75 enum ResourceType { | 77 enum ResourceType { |
| 76 RESOURCE_TYPE_GL_TEXTURE, | 78 RESOURCE_TYPE_GL_TEXTURE, |
| 77 RESOURCE_TYPE_BITMAP, | 79 RESOURCE_TYPE_BITMAP, |
| 78 }; | 80 }; |
| 79 | 81 |
| 80 static scoped_ptr<ResourceProvider> Create( | 82 static scoped_ptr<ResourceProvider> Create( |
| 81 OutputSurface* output_surface, | 83 OutputSurface* output_surface, |
| 82 SharedBitmapManager* shared_bitmap_manager, | 84 SharedBitmapManager* shared_bitmap_manager, |
| 83 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 85 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 84 BlockingTaskRunner* blocking_main_thread_task_runner, | 86 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 85 int highp_threshold_min, | 87 int highp_threshold_min, |
| 86 bool use_rgba_4444_texture_format, | 88 bool use_rgba_4444_texture_format, |
| 87 size_t id_allocation_chunk_size, | 89 size_t id_allocation_chunk_size, |
| 88 bool use_persistent_map_for_gpu_memory_buffers); | 90 bool use_persistent_map_for_gpu_memory_buffers); |
| 89 virtual ~ResourceProvider(); | 91 ~ResourceProvider() override; |
| 90 | 92 |
| 91 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 93 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| 92 | 94 |
| 93 int max_texture_size() const { return max_texture_size_; } | 95 int max_texture_size() const { return max_texture_size_; } |
| 94 ResourceFormat memory_efficient_texture_format() const { | 96 ResourceFormat memory_efficient_texture_format() const { |
| 95 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 97 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
| 96 } | 98 } |
| 97 ResourceFormat best_texture_format() const { return best_texture_format_; } | 99 ResourceFormat best_texture_format() const { return best_texture_format_; } |
| 98 ResourceFormat best_render_buffer_format() const { | 100 ResourceFormat best_render_buffer_format() const { |
| 99 return best_render_buffer_format_; | 101 return best_render_buffer_format_; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 void WaitSyncPointIfNeeded(ResourceId id); | 432 void WaitSyncPointIfNeeded(ResourceId id); |
| 431 | 433 |
| 432 void WaitReadLockIfNeeded(ResourceId id); | 434 void WaitReadLockIfNeeded(ResourceId id); |
| 433 | 435 |
| 434 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 436 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
| 435 | 437 |
| 436 OutputSurface* output_surface() { return output_surface_; } | 438 OutputSurface* output_surface() { return output_surface_; } |
| 437 | 439 |
| 438 void ValidateResource(ResourceId id) const; | 440 void ValidateResource(ResourceId id) const; |
| 439 | 441 |
| 442 // base::trace_event::MemoryDumpProvider implementation. |
| 443 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; |
| 444 |
| 440 protected: | 445 protected: |
| 441 ResourceProvider(OutputSurface* output_surface, | 446 ResourceProvider(OutputSurface* output_surface, |
| 442 SharedBitmapManager* shared_bitmap_manager, | 447 SharedBitmapManager* shared_bitmap_manager, |
| 443 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 448 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 444 BlockingTaskRunner* blocking_main_thread_task_runner, | 449 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 445 int highp_threshold_min, | 450 int highp_threshold_min, |
| 446 bool use_rgba_4444_texture_format, | 451 bool use_rgba_4444_texture_format, |
| 447 size_t id_allocation_chunk_size, | 452 size_t id_allocation_chunk_size, |
| 448 bool use_persistent_map_for_gpu_memory_buffers); | 453 bool use_persistent_map_for_gpu_memory_buffers); |
| 449 void Initialize(); | 454 void Initialize(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 return format_gl_data_format[format]; | 663 return format_gl_data_format[format]; |
| 659 } | 664 } |
| 660 | 665 |
| 661 inline GLenum GLInternalFormat(ResourceFormat format) { | 666 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 662 return GLDataFormat(format); | 667 return GLDataFormat(format); |
| 663 } | 668 } |
| 664 | 669 |
| 665 } // namespace cc | 670 } // namespace cc |
| 666 | 671 |
| 667 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 672 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |