Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 RESOURCE_TYPE_BITMAP, | 78 RESOURCE_TYPE_BITMAP, |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 static scoped_ptr<ResourceProvider> Create( | 81 static scoped_ptr<ResourceProvider> Create( |
| 82 OutputSurface* output_surface, | 82 OutputSurface* output_surface, |
| 83 SharedBitmapManager* shared_bitmap_manager, | 83 SharedBitmapManager* shared_bitmap_manager, |
| 84 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 84 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 85 BlockingTaskRunner* blocking_main_thread_task_runner, | 85 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 86 int highp_threshold_min, | 86 int highp_threshold_min, |
| 87 bool use_rgba_4444_texture_format, | 87 bool use_rgba_4444_texture_format, |
| 88 size_t id_allocation_chunk_size); | 88 size_t id_allocation_chunk_size, |
| 89 bool use_persistent_map_for_gpu_memory_buffers); | |
| 89 virtual ~ResourceProvider(); | 90 virtual ~ResourceProvider(); |
| 90 | 91 |
| 91 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 92 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| 92 | 93 |
| 93 int max_texture_size() const { return max_texture_size_; } | 94 int max_texture_size() const { return max_texture_size_; } |
| 94 ResourceFormat memory_efficient_texture_format() const { | 95 ResourceFormat memory_efficient_texture_format() const { |
| 95 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 96 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
| 96 } | 97 } |
| 97 ResourceFormat best_texture_format() const { return best_texture_format_; } | 98 ResourceFormat best_texture_format() const { return best_texture_format_; } |
| 98 ResourceFormat yuv_resource_format() const { return yuv_resource_format_; } | 99 ResourceFormat yuv_resource_format() const { return yuv_resource_format_; } |
| 99 bool use_sync_query() const { return use_sync_query_; } | 100 bool use_sync_query() const { return use_sync_query_; } |
| 101 bool use_persistent_map() const { return use_persistent_map_; } | |
| 100 size_t num_resources() const { return resources_.size(); } | 102 size_t num_resources() const { return resources_.size(); } |
| 101 | 103 |
| 102 // Checks whether a resource is in use by a consumer. | 104 // Checks whether a resource is in use by a consumer. |
| 103 bool InUseByConsumer(ResourceId id); | 105 bool InUseByConsumer(ResourceId id); |
| 104 | 106 |
| 105 bool IsLost(ResourceId id); | 107 bool IsLost(ResourceId id); |
| 106 bool AllowOverlay(ResourceId id); | 108 bool AllowOverlay(ResourceId id); |
| 107 | 109 |
| 108 // Producer interface. | 110 // Producer interface. |
| 109 | 111 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 | 441 |
| 440 void ValidateResource(ResourceId id) const; | 442 void ValidateResource(ResourceId id) const; |
| 441 | 443 |
| 442 protected: | 444 protected: |
| 443 ResourceProvider(OutputSurface* output_surface, | 445 ResourceProvider(OutputSurface* output_surface, |
| 444 SharedBitmapManager* shared_bitmap_manager, | 446 SharedBitmapManager* shared_bitmap_manager, |
| 445 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 447 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 446 BlockingTaskRunner* blocking_main_thread_task_runner, | 448 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 447 int highp_threshold_min, | 449 int highp_threshold_min, |
| 448 bool use_rgba_4444_texture_format, | 450 bool use_rgba_4444_texture_format, |
| 449 size_t id_allocation_chunk_size); | 451 size_t id_allocation_chunk_size, |
| 452 bool use_persistent_map); | |
| 450 void Initialize(); | 453 void Initialize(); |
| 451 | 454 |
| 452 private: | 455 private: |
| 453 struct Resource { | 456 struct Resource { |
| 454 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; | 457 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; |
| 455 | 458 |
| 456 ~Resource(); | 459 ~Resource(); |
| 457 Resource(unsigned texture_id, | 460 Resource(unsigned texture_id, |
| 458 const gfx::Size& size, | 461 const gfx::Size& size, |
| 459 Origin origin, | 462 Origin origin, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 base::ThreadChecker thread_checker_; | 598 base::ThreadChecker thread_checker_; |
| 596 | 599 |
| 597 scoped_refptr<Fence> current_read_lock_fence_; | 600 scoped_refptr<Fence> current_read_lock_fence_; |
| 598 bool use_rgba_4444_texture_format_; | 601 bool use_rgba_4444_texture_format_; |
| 599 | 602 |
| 600 const size_t id_allocation_chunk_size_; | 603 const size_t id_allocation_chunk_size_; |
| 601 scoped_ptr<IdAllocator> texture_id_allocator_; | 604 scoped_ptr<IdAllocator> texture_id_allocator_; |
| 602 scoped_ptr<IdAllocator> buffer_id_allocator_; | 605 scoped_ptr<IdAllocator> buffer_id_allocator_; |
| 603 | 606 |
| 604 bool use_sync_query_; | 607 bool use_sync_query_; |
| 608 bool use_persistent_map_; | |
|
reveman
2015/05/28 05:07:25
There are 4 different ways of referring to this in
danakj
2015/05/28 18:54:47
I think I disagree. The workerpool isn't being tol
| |
| 605 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. | 609 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. |
| 606 scoped_refptr<SynchronousFence> synchronous_fence_; | 610 scoped_refptr<SynchronousFence> synchronous_fence_; |
| 607 | 611 |
| 608 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 612 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 609 }; | 613 }; |
| 610 | 614 |
| 611 // TODO(epenner): Move these format conversions to resource_format.h | 615 // TODO(epenner): Move these format conversions to resource_format.h |
| 612 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 616 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
| 613 inline unsigned BitsPerPixel(ResourceFormat format) { | 617 inline unsigned BitsPerPixel(ResourceFormat format) { |
| 614 switch (format) { | 618 switch (format) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 return format_gl_data_format[format]; | 663 return format_gl_data_format[format]; |
| 660 } | 664 } |
| 661 | 665 |
| 662 inline GLenum GLInternalFormat(ResourceFormat format) { | 666 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 663 return GLDataFormat(format); | 667 return GLDataFormat(format); |
| 664 } | 668 } |
| 665 | 669 |
| 666 } // namespace cc | 670 } // namespace cc |
| 667 | 671 |
| 668 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 672 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |