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 <memory> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <unordered_map> | 15 #include <unordered_map> |
16 #include <unordered_set> | 16 #include <unordered_set> |
17 #include <utility> | 17 #include <utility> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/callback.h" | 20 #include "base/callback.h" |
21 #include "base/macros.h" | 21 #include "base/macros.h" |
22 #include "base/memory/linked_ptr.h" | 22 #include "base/memory/linked_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/output/renderer_settings.h" |
30 #include "cc/resources/release_callback_impl.h" | 31 #include "cc/resources/release_callback_impl.h" |
31 #include "cc/resources/resource_format.h" | 32 #include "cc/resources/resource_format.h" |
32 #include "cc/resources/return_callback.h" | 33 #include "cc/resources/return_callback.h" |
33 #include "cc/resources/shared_bitmap.h" | 34 #include "cc/resources/shared_bitmap.h" |
34 #include "cc/resources/single_release_callback_impl.h" | 35 #include "cc/resources/single_release_callback_impl.h" |
35 #include "cc/resources/texture_mailbox.h" | 36 #include "cc/resources/texture_mailbox.h" |
36 #include "cc/resources/transferable_resource.h" | 37 #include "cc/resources/transferable_resource.h" |
37 #include "third_party/khronos/GLES2/gl2.h" | 38 #include "third_party/khronos/GLES2/gl2.h" |
38 #include "third_party/khronos/GLES2/gl2ext.h" | 39 #include "third_party/khronos/GLES2/gl2ext.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 TEXTURE_HINT_FRAMEBUFFER = 0x2, | 79 TEXTURE_HINT_FRAMEBUFFER = 0x2, |
79 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = | 80 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = |
80 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER | 81 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER |
81 }; | 82 }; |
82 enum ResourceType { | 83 enum ResourceType { |
83 RESOURCE_TYPE_GPU_MEMORY_BUFFER, | 84 RESOURCE_TYPE_GPU_MEMORY_BUFFER, |
84 RESOURCE_TYPE_GL_TEXTURE, | 85 RESOURCE_TYPE_GL_TEXTURE, |
85 RESOURCE_TYPE_BITMAP, | 86 RESOURCE_TYPE_BITMAP, |
86 }; | 87 }; |
87 | 88 |
88 ResourceProvider(ContextProvider* compositor_context_provider, | 89 ResourceProvider( |
89 SharedBitmapManager* shared_bitmap_manager, | 90 ContextProvider* compositor_context_provider, |
90 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 91 SharedBitmapManager* shared_bitmap_manager, |
91 BlockingTaskRunner* blocking_main_thread_task_runner, | 92 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
92 int highp_threshold_min, | 93 BlockingTaskRunner* blocking_main_thread_task_runner, |
93 size_t id_allocation_chunk_size, | 94 int highp_threshold_min, |
94 bool delegated_sync_points_required, | 95 size_t id_allocation_chunk_size, |
95 bool use_gpu_memory_buffer_resources, | 96 bool delegated_sync_points_required, |
96 const std::vector<unsigned>& use_image_texture_targets); | 97 bool use_gpu_memory_buffer_resources, |
| 98 const BufferToTextureTargetMap& buffer_to_texture_target_map); |
97 ~ResourceProvider() override; | 99 ~ResourceProvider() override; |
98 | 100 |
99 void Initialize(); | 101 void Initialize(); |
100 | 102 |
101 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 103 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
102 | 104 |
103 int max_texture_size() const { return max_texture_size_; } | 105 int max_texture_size() const { return max_texture_size_; } |
104 ResourceFormat best_texture_format() const { return best_texture_format_; } | 106 ResourceFormat best_texture_format() const { return best_texture_format_; } |
105 ResourceFormat best_render_buffer_format() const { | 107 ResourceFormat best_render_buffer_format() const { |
106 return best_render_buffer_format_; | 108 return best_render_buffer_format_; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 470 |
469 // Indicates if this resource may be used for a hardware overlay plane. | 471 // Indicates if this resource may be used for a hardware overlay plane. |
470 bool IsOverlayCandidate(ResourceId id); | 472 bool IsOverlayCandidate(ResourceId id); |
471 | 473 |
472 void WaitSyncTokenIfNeeded(ResourceId id); | 474 void WaitSyncTokenIfNeeded(ResourceId id); |
473 | 475 |
474 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 476 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
475 | 477 |
476 void ValidateResource(ResourceId id) const; | 478 void ValidateResource(ResourceId id) const; |
477 | 479 |
478 GLenum GetImageTextureTarget(ResourceFormat format); | 480 GLenum GetImageTextureTarget(gfx::BufferUsage usage, ResourceFormat format); |
479 | 481 |
480 // base::trace_event::MemoryDumpProvider implementation. | 482 // base::trace_event::MemoryDumpProvider implementation. |
481 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 483 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
482 base::trace_event::ProcessMemoryDump* pmd) override; | 484 base::trace_event::ProcessMemoryDump* pmd) override; |
483 | 485 |
484 int tracing_id() const { return tracing_id_; } | 486 int tracing_id() const { return tracing_id_; } |
485 | 487 |
486 private: | 488 private: |
487 struct Resource { | 489 struct Resource { |
488 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; | 490 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 | 687 |
686 base::ThreadChecker thread_checker_; | 688 base::ThreadChecker thread_checker_; |
687 | 689 |
688 scoped_refptr<Fence> current_read_lock_fence_; | 690 scoped_refptr<Fence> current_read_lock_fence_; |
689 | 691 |
690 const size_t id_allocation_chunk_size_; | 692 const size_t id_allocation_chunk_size_; |
691 std::unique_ptr<IdAllocator> texture_id_allocator_; | 693 std::unique_ptr<IdAllocator> texture_id_allocator_; |
692 std::unique_ptr<IdAllocator> buffer_id_allocator_; | 694 std::unique_ptr<IdAllocator> buffer_id_allocator_; |
693 | 695 |
694 bool use_sync_query_; | 696 bool use_sync_query_; |
695 std::vector<unsigned> use_image_texture_targets_; | 697 BufferToTextureTargetMap buffer_to_texture_target_map_; |
696 | 698 |
697 // A process-unique ID used for disambiguating memory dumps from different | 699 // A process-unique ID used for disambiguating memory dumps from different |
698 // resource providers. | 700 // resource providers. |
699 int tracing_id_; | 701 int tracing_id_; |
700 | 702 |
701 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 703 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
702 }; | 704 }; |
703 | 705 |
704 } // namespace cc | 706 } // namespace cc |
705 | 707 |
706 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 708 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |