| 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_for_gpu_memory_buffers() const { |
| 102 return use_persistent_map_for_gpu_memory_buffers_; |
| 103 } |
| 100 size_t num_resources() const { return resources_.size(); } | 104 size_t num_resources() const { return resources_.size(); } |
| 101 | 105 |
| 102 // Checks whether a resource is in use by a consumer. | 106 // Checks whether a resource is in use by a consumer. |
| 103 bool InUseByConsumer(ResourceId id); | 107 bool InUseByConsumer(ResourceId id); |
| 104 | 108 |
| 105 bool IsLost(ResourceId id); | 109 bool IsLost(ResourceId id); |
| 106 bool AllowOverlay(ResourceId id); | 110 bool AllowOverlay(ResourceId id); |
| 107 | 111 |
| 108 // Producer interface. | 112 // Producer interface. |
| 109 | 113 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 443 |
| 440 void ValidateResource(ResourceId id) const; | 444 void ValidateResource(ResourceId id) const; |
| 441 | 445 |
| 442 protected: | 446 protected: |
| 443 ResourceProvider(OutputSurface* output_surface, | 447 ResourceProvider(OutputSurface* output_surface, |
| 444 SharedBitmapManager* shared_bitmap_manager, | 448 SharedBitmapManager* shared_bitmap_manager, |
| 445 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 449 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 446 BlockingTaskRunner* blocking_main_thread_task_runner, | 450 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 447 int highp_threshold_min, | 451 int highp_threshold_min, |
| 448 bool use_rgba_4444_texture_format, | 452 bool use_rgba_4444_texture_format, |
| 449 size_t id_allocation_chunk_size); | 453 size_t id_allocation_chunk_size, |
| 454 bool use_persistent_map_for_gpu_memory_buffers); |
| 450 void Initialize(); | 455 void Initialize(); |
| 451 | 456 |
| 452 private: | 457 private: |
| 453 struct Resource { | 458 struct Resource { |
| 454 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; | 459 enum Origin { INTERNAL, EXTERNAL, DELEGATED }; |
| 455 | 460 |
| 456 ~Resource(); | 461 ~Resource(); |
| 457 Resource(unsigned texture_id, | 462 Resource(unsigned texture_id, |
| 458 const gfx::Size& size, | 463 const gfx::Size& size, |
| 459 Origin origin, | 464 Origin origin, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 base::ThreadChecker thread_checker_; | 600 base::ThreadChecker thread_checker_; |
| 596 | 601 |
| 597 scoped_refptr<Fence> current_read_lock_fence_; | 602 scoped_refptr<Fence> current_read_lock_fence_; |
| 598 bool use_rgba_4444_texture_format_; | 603 bool use_rgba_4444_texture_format_; |
| 599 | 604 |
| 600 const size_t id_allocation_chunk_size_; | 605 const size_t id_allocation_chunk_size_; |
| 601 scoped_ptr<IdAllocator> texture_id_allocator_; | 606 scoped_ptr<IdAllocator> texture_id_allocator_; |
| 602 scoped_ptr<IdAllocator> buffer_id_allocator_; | 607 scoped_ptr<IdAllocator> buffer_id_allocator_; |
| 603 | 608 |
| 604 bool use_sync_query_; | 609 bool use_sync_query_; |
| 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 // TODO(epenner): Move these format conversions to resource_format.h | 617 // TODO(epenner): Move these format conversions to resource_format.h |
| 612 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 618 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
| 613 inline unsigned BitsPerPixel(ResourceFormat format) { | 619 inline unsigned BitsPerPixel(ResourceFormat format) { |
| 614 switch (format) { | 620 switch (format) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 return format_gl_data_format[format]; | 665 return format_gl_data_format[format]; |
| 660 } | 666 } |
| 661 | 667 |
| 662 inline GLenum GLInternalFormat(ResourceFormat format) { | 668 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 663 return GLDataFormat(format); | 669 return GLDataFormat(format); |
| 664 } | 670 } |
| 665 | 671 |
| 666 } // namespace cc | 672 } // namespace cc |
| 667 | 673 |
| 668 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 674 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |