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_allocator_dump.h" |
| 21 #include "base/trace_event/memory_dump_provider.h" |
20 #include "cc/base/cc_export.h" | 22 #include "cc/base/cc_export.h" |
21 #include "cc/base/resource_id.h" | 23 #include "cc/base/resource_id.h" |
22 #include "cc/output/context_provider.h" | 24 #include "cc/output/context_provider.h" |
23 #include "cc/output/output_surface.h" | 25 #include "cc/output/output_surface.h" |
24 #include "cc/resources/release_callback_impl.h" | 26 #include "cc/resources/release_callback_impl.h" |
25 #include "cc/resources/resource_format.h" | 27 #include "cc/resources/resource_format.h" |
26 #include "cc/resources/return_callback.h" | 28 #include "cc/resources/return_callback.h" |
27 #include "cc/resources/shared_bitmap.h" | 29 #include "cc/resources/shared_bitmap.h" |
28 #include "cc/resources/single_release_callback_impl.h" | 30 #include "cc/resources/single_release_callback_impl.h" |
29 #include "cc/resources/texture_mailbox.h" | 31 #include "cc/resources/texture_mailbox.h" |
(...skipping 20 matching lines...) Expand all Loading... |
50 } | 52 } |
51 | 53 |
52 namespace cc { | 54 namespace cc { |
53 class BlockingTaskRunner; | 55 class BlockingTaskRunner; |
54 class IdAllocator; | 56 class IdAllocator; |
55 class SharedBitmap; | 57 class SharedBitmap; |
56 class SharedBitmapManager; | 58 class SharedBitmapManager; |
57 | 59 |
58 // This class is not thread-safe and can only be called from the thread it was | 60 // This class is not thread-safe and can only be called from the thread it was |
59 // created on (in practice, the impl thread). | 61 // created on (in practice, the impl thread). |
60 class CC_EXPORT ResourceProvider { | 62 class CC_EXPORT ResourceProvider |
| 63 : public base::trace_event::MemoryDumpProvider { |
61 private: | 64 private: |
62 struct Resource; | 65 struct Resource; |
63 | 66 |
64 public: | 67 public: |
65 typedef std::vector<ResourceId> ResourceIdArray; | 68 typedef std::vector<ResourceId> ResourceIdArray; |
66 typedef base::hash_set<ResourceId> ResourceIdSet; | 69 typedef base::hash_set<ResourceId> ResourceIdSet; |
67 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; | 70 typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; |
68 enum TextureHint { | 71 enum TextureHint { |
69 TEXTURE_HINT_DEFAULT = 0x0, | 72 TEXTURE_HINT_DEFAULT = 0x0, |
70 TEXTURE_HINT_IMMUTABLE = 0x1, | 73 TEXTURE_HINT_IMMUTABLE = 0x1, |
71 TEXTURE_HINT_FRAMEBUFFER = 0x2, | 74 TEXTURE_HINT_FRAMEBUFFER = 0x2, |
72 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = | 75 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = |
73 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER | 76 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER |
74 }; | 77 }; |
75 enum ResourceType { | 78 enum ResourceType { |
76 RESOURCE_TYPE_GL_TEXTURE, | 79 RESOURCE_TYPE_GL_TEXTURE, |
77 RESOURCE_TYPE_BITMAP, | 80 RESOURCE_TYPE_BITMAP, |
78 }; | 81 }; |
79 | 82 |
80 static scoped_ptr<ResourceProvider> Create( | 83 static scoped_ptr<ResourceProvider> Create( |
81 OutputSurface* output_surface, | 84 OutputSurface* output_surface, |
82 SharedBitmapManager* shared_bitmap_manager, | 85 SharedBitmapManager* shared_bitmap_manager, |
83 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
84 BlockingTaskRunner* blocking_main_thread_task_runner, | 87 BlockingTaskRunner* blocking_main_thread_task_runner, |
85 int highp_threshold_min, | 88 int highp_threshold_min, |
86 bool use_rgba_4444_texture_format, | 89 bool use_rgba_4444_texture_format, |
87 size_t id_allocation_chunk_size, | 90 size_t id_allocation_chunk_size, |
88 bool use_persistent_map_for_gpu_memory_buffers); | 91 bool use_persistent_map_for_gpu_memory_buffers); |
89 virtual ~ResourceProvider(); | 92 ~ResourceProvider() override; |
90 | 93 |
91 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 94 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
92 | 95 |
93 int max_texture_size() const { return max_texture_size_; } | 96 int max_texture_size() const { return max_texture_size_; } |
94 ResourceFormat memory_efficient_texture_format() const { | 97 ResourceFormat memory_efficient_texture_format() const { |
95 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 98 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
96 } | 99 } |
97 ResourceFormat best_texture_format() const { return best_texture_format_; } | 100 ResourceFormat best_texture_format() const { return best_texture_format_; } |
98 ResourceFormat best_render_buffer_format() const { | 101 ResourceFormat best_render_buffer_format() const { |
99 return best_render_buffer_format_; | 102 return best_render_buffer_format_; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 void WaitSyncPointIfNeeded(ResourceId id); | 434 void WaitSyncPointIfNeeded(ResourceId id); |
432 | 435 |
433 void WaitReadLockIfNeeded(ResourceId id); | 436 void WaitReadLockIfNeeded(ResourceId id); |
434 | 437 |
435 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 438 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
436 | 439 |
437 OutputSurface* output_surface() { return output_surface_; } | 440 OutputSurface* output_surface() { return output_surface_; } |
438 | 441 |
439 void ValidateResource(ResourceId id) const; | 442 void ValidateResource(ResourceId id) const; |
440 | 443 |
| 444 // base::trace_event::MemoryDumpProvider implementation. |
| 445 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) override; |
| 446 |
441 protected: | 447 protected: |
442 ResourceProvider(OutputSurface* output_surface, | 448 ResourceProvider(OutputSurface* output_surface, |
443 SharedBitmapManager* shared_bitmap_manager, | 449 SharedBitmapManager* shared_bitmap_manager, |
444 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 450 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
445 BlockingTaskRunner* blocking_main_thread_task_runner, | 451 BlockingTaskRunner* blocking_main_thread_task_runner, |
446 int highp_threshold_min, | 452 int highp_threshold_min, |
447 bool use_rgba_4444_texture_format, | 453 bool use_rgba_4444_texture_format, |
448 size_t id_allocation_chunk_size, | 454 size_t id_allocation_chunk_size, |
449 bool use_persistent_map_for_gpu_memory_buffers); | 455 bool use_persistent_map_for_gpu_memory_buffers); |
450 void Initialize(); | 456 void Initialize(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 bool use_persistent_map_for_gpu_memory_buffers_; | 610 bool use_persistent_map_for_gpu_memory_buffers_; |
605 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. | 611 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. |
606 scoped_refptr<SynchronousFence> synchronous_fence_; | 612 scoped_refptr<SynchronousFence> synchronous_fence_; |
607 | 613 |
608 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 614 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
609 }; | 615 }; |
610 | 616 |
611 } // namespace cc | 617 } // namespace cc |
612 | 618 |
613 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 619 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |