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> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "cc/resources/return_callback.h" | 28 #include "cc/resources/return_callback.h" |
29 #include "cc/resources/shared_bitmap.h" | 29 #include "cc/resources/shared_bitmap.h" |
30 #include "cc/resources/single_release_callback_impl.h" | 30 #include "cc/resources/single_release_callback_impl.h" |
31 #include "cc/resources/texture_mailbox.h" | 31 #include "cc/resources/texture_mailbox.h" |
32 #include "cc/resources/transferable_resource.h" | 32 #include "cc/resources/transferable_resource.h" |
33 #include "third_party/khronos/GLES2/gl2.h" | 33 #include "third_party/khronos/GLES2/gl2.h" |
34 #include "third_party/khronos/GLES2/gl2ext.h" | 34 #include "third_party/khronos/GLES2/gl2ext.h" |
35 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
36 #include "third_party/skia/include/core/SkCanvas.h" | 36 #include "third_party/skia/include/core/SkCanvas.h" |
37 #include "ui/gfx/geometry/size.h" | 37 #include "ui/gfx/geometry/size.h" |
38 #include "ui/gfx/gpu_memory_buffer.h" | |
39 | 38 |
40 class GrContext; | 39 class GrContext; |
41 | 40 |
42 namespace gpu { | 41 namespace gpu { |
43 class GpuMemoryBufferManager; | 42 class GpuMemoryBufferManager; |
44 namespace gles { | 43 namespace gles { |
45 class GLES2Interface; | 44 class GLES2Interface; |
46 } | 45 } |
47 } | 46 } |
48 | 47 |
49 namespace gfx { | 48 namespace gfx { |
| 49 class GpuMemoryBuffer; |
50 class Rect; | 50 class Rect; |
51 class Vector2d; | 51 class Vector2d; |
52 } | 52 } |
53 | 53 |
54 namespace cc { | 54 namespace cc { |
55 class BlockingTaskRunner; | 55 class BlockingTaskRunner; |
56 class IdAllocator; | 56 class IdAllocator; |
57 class SharedBitmap; | 57 class SharedBitmap; |
58 class SharedBitmapManager; | 58 class SharedBitmapManager; |
59 | 59 |
(...skipping 20 matching lines...) Expand all Loading... |
80 RESOURCE_TYPE_BITMAP, | 80 RESOURCE_TYPE_BITMAP, |
81 }; | 81 }; |
82 | 82 |
83 static scoped_ptr<ResourceProvider> Create( | 83 static scoped_ptr<ResourceProvider> Create( |
84 OutputSurface* output_surface, | 84 OutputSurface* output_surface, |
85 SharedBitmapManager* shared_bitmap_manager, | 85 SharedBitmapManager* shared_bitmap_manager, |
86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 86 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
87 BlockingTaskRunner* blocking_main_thread_task_runner, | 87 BlockingTaskRunner* blocking_main_thread_task_runner, |
88 int highp_threshold_min, | 88 int highp_threshold_min, |
89 bool use_rgba_4444_texture_format, | 89 bool use_rgba_4444_texture_format, |
90 size_t id_allocation_chunk_size); | 90 size_t id_allocation_chunk_size, |
| 91 bool use_persistent_map_for_gpu_memory_buffers); |
91 ~ResourceProvider() override; | 92 ~ResourceProvider() override; |
92 | 93 |
93 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 94 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
94 | 95 |
95 int max_texture_size() const { return max_texture_size_; } | 96 int max_texture_size() const { return max_texture_size_; } |
96 ResourceFormat memory_efficient_texture_format() const { | 97 ResourceFormat memory_efficient_texture_format() const { |
97 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 98 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
98 } | 99 } |
99 ResourceFormat best_texture_format() const { return best_texture_format_; } | 100 ResourceFormat best_texture_format() const { return best_texture_format_; } |
100 ResourceFormat best_render_buffer_format() const { | 101 ResourceFormat best_render_buffer_format() const { |
101 return best_render_buffer_format_; | 102 return best_render_buffer_format_; |
102 } | 103 } |
103 ResourceFormat yuv_resource_format() const { return yuv_resource_format_; } | 104 ResourceFormat yuv_resource_format() const { return yuv_resource_format_; } |
104 bool use_sync_query() const { return use_sync_query_; } | 105 bool use_sync_query() const { return use_sync_query_; } |
105 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() { | 106 bool use_persistent_map_for_gpu_memory_buffers() const { |
106 return gpu_memory_buffer_manager_; | 107 return use_persistent_map_for_gpu_memory_buffers_; |
107 } | 108 } |
108 size_t num_resources() const { return resources_.size(); } | 109 size_t num_resources() const { return resources_.size(); } |
109 | 110 |
110 // Checks whether a resource is in use by a consumer. | 111 // Checks whether a resource is in use by a consumer. |
111 bool InUseByConsumer(ResourceId id); | 112 bool InUseByConsumer(ResourceId id); |
112 | 113 |
113 bool IsLost(ResourceId id); | 114 bool IsLost(ResourceId id); |
114 | 115 |
115 void LoseResourceForTesting(ResourceId id); | 116 void LoseResourceForTesting(ResourceId id); |
116 void EnableReadLockFencesForTesting(ResourceId id); | 117 void EnableReadLockFencesForTesting(ResourceId id); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 GLenum TargetForTesting(ResourceId id); | 419 GLenum TargetForTesting(ResourceId id); |
419 | 420 |
420 // Sets the current read fence. If a resource is locked for read | 421 // Sets the current read fence. If a resource is locked for read |
421 // and has read fences enabled, the resource will not allow writes | 422 // and has read fences enabled, the resource will not allow writes |
422 // until this fence has passed. | 423 // until this fence has passed. |
423 void SetReadLockFence(Fence* fence) { current_read_lock_fence_ = fence; } | 424 void SetReadLockFence(Fence* fence) { current_read_lock_fence_ = fence; } |
424 | 425 |
425 // Indicates if we can currently lock this resource for write. | 426 // Indicates if we can currently lock this resource for write. |
426 bool CanLockForWrite(ResourceId id); | 427 bool CanLockForWrite(ResourceId id); |
427 | 428 |
| 429 // Copy |rect| pixels from source to destination. |
| 430 void CopyResource(ResourceId source_id, |
| 431 ResourceId dest_id, |
| 432 const gfx::Rect& rect); |
| 433 |
428 void WaitSyncPointIfNeeded(ResourceId id); | 434 void WaitSyncPointIfNeeded(ResourceId id); |
429 | 435 |
| 436 void WaitReadLockIfNeeded(ResourceId id); |
| 437 |
430 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 438 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
431 | 439 |
432 OutputSurface* output_surface() { return output_surface_; } | 440 OutputSurface* output_surface() { return output_surface_; } |
433 | 441 |
434 void ValidateResource(ResourceId id) const; | 442 void ValidateResource(ResourceId id) const; |
435 | 443 |
436 // base::trace_event::MemoryDumpProvider implementation. | 444 // base::trace_event::MemoryDumpProvider implementation. |
437 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 445 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
438 base::trace_event::ProcessMemoryDump* pmd) override; | 446 base::trace_event::ProcessMemoryDump* pmd) override; |
439 | 447 |
440 protected: | 448 protected: |
441 ResourceProvider(OutputSurface* output_surface, | 449 ResourceProvider(OutputSurface* output_surface, |
442 SharedBitmapManager* shared_bitmap_manager, | 450 SharedBitmapManager* shared_bitmap_manager, |
443 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 451 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
444 BlockingTaskRunner* blocking_main_thread_task_runner, | 452 BlockingTaskRunner* blocking_main_thread_task_runner, |
445 int highp_threshold_min, | 453 int highp_threshold_min, |
446 bool use_rgba_4444_texture_format, | 454 bool use_rgba_4444_texture_format, |
447 size_t id_allocation_chunk_size); | 455 size_t id_allocation_chunk_size, |
| 456 bool use_persistent_map_for_gpu_memory_buffers); |
448 void Initialize(); | 457 void Initialize(); |
449 | 458 |
450 private: | 459 private: |
451 struct Resource { | 460 struct Resource { |
452 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; | 461 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; |
453 | 462 |
454 ~Resource(); | 463 ~Resource(); |
455 Resource(unsigned texture_id, | 464 Resource(unsigned texture_id, |
456 const gfx::Size& size, | 465 const gfx::Size& size, |
457 Origin origin, | 466 Origin origin, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 base::ThreadChecker thread_checker_; | 601 base::ThreadChecker thread_checker_; |
593 | 602 |
594 scoped_refptr<Fence> current_read_lock_fence_; | 603 scoped_refptr<Fence> current_read_lock_fence_; |
595 bool use_rgba_4444_texture_format_; | 604 bool use_rgba_4444_texture_format_; |
596 | 605 |
597 const size_t id_allocation_chunk_size_; | 606 const size_t id_allocation_chunk_size_; |
598 scoped_ptr<IdAllocator> texture_id_allocator_; | 607 scoped_ptr<IdAllocator> texture_id_allocator_; |
599 scoped_ptr<IdAllocator> buffer_id_allocator_; | 608 scoped_ptr<IdAllocator> buffer_id_allocator_; |
600 | 609 |
601 bool use_sync_query_; | 610 bool use_sync_query_; |
| 611 bool use_persistent_map_for_gpu_memory_buffers_; |
| 612 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. |
| 613 scoped_refptr<SynchronousFence> synchronous_fence_; |
602 | 614 |
603 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 615 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
604 }; | 616 }; |
605 | 617 |
606 } // namespace cc | 618 } // namespace cc |
607 | 619 |
608 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 620 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |