| 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 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 ResourceProvider( | 90 ResourceProvider( |
| 91 ContextProvider* compositor_context_provider, | 91 ContextProvider* compositor_context_provider, |
| 92 SharedBitmapManager* shared_bitmap_manager, | 92 SharedBitmapManager* shared_bitmap_manager, |
| 93 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 93 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 94 BlockingTaskRunner* blocking_main_thread_task_runner, | 94 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 95 int highp_threshold_min, | 95 int highp_threshold_min, |
| 96 size_t id_allocation_chunk_size, | 96 size_t id_allocation_chunk_size, |
| 97 bool delegated_sync_points_required, | 97 bool delegated_sync_points_required, |
| 98 bool use_gpu_memory_buffer_resources, | 98 bool use_gpu_memory_buffer_resources, |
| 99 bool enable_color_correct_rendering, |
| 99 const BufferToTextureTargetMap& buffer_to_texture_target_map); | 100 const BufferToTextureTargetMap& buffer_to_texture_target_map); |
| 100 ~ResourceProvider() override; | 101 ~ResourceProvider() override; |
| 101 | 102 |
| 102 void Initialize(); | 103 void Initialize(); |
| 103 | 104 |
| 104 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 105 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| 105 | 106 |
| 106 int max_texture_size() const { return max_texture_size_; } | 107 int max_texture_size() const { return max_texture_size_; } |
| 107 ResourceFormat best_texture_format() const { return best_texture_format_; } | 108 ResourceFormat best_texture_format() const { return best_texture_format_; } |
| 108 ResourceFormat best_render_buffer_format() const { | 109 ResourceFormat best_render_buffer_format() const { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 public: | 269 public: |
| 269 ScopedWriteLockGL(ResourceProvider* resource_provider, | 270 ScopedWriteLockGL(ResourceProvider* resource_provider, |
| 270 ResourceId resource_id, | 271 ResourceId resource_id, |
| 271 bool create_mailbox); | 272 bool create_mailbox); |
| 272 ~ScopedWriteLockGL(); | 273 ~ScopedWriteLockGL(); |
| 273 | 274 |
| 274 unsigned texture_id() const { return texture_id_; } | 275 unsigned texture_id() const { return texture_id_; } |
| 275 GLenum target() const { return target_; } | 276 GLenum target() const { return target_; } |
| 276 ResourceFormat format() const { return format_; } | 277 ResourceFormat format() const { return format_; } |
| 277 const gfx::Size& size() const { return size_; } | 278 const gfx::Size& size() const { return size_; } |
| 279 sk_sp<SkColorSpace> sk_color_space() const { return sk_color_space_; } |
| 278 | 280 |
| 279 const TextureMailbox& mailbox() const { return mailbox_; } | 281 const TextureMailbox& mailbox() const { return mailbox_; } |
| 280 | 282 |
| 281 void set_sync_token(const gpu::SyncToken& sync_token) { | 283 void set_sync_token(const gpu::SyncToken& sync_token) { |
| 282 sync_token_ = sync_token; | 284 sync_token_ = sync_token; |
| 283 } | 285 } |
| 284 | 286 |
| 285 void set_synchronized(bool synchronized) { synchronized_ = synchronized; } | 287 void set_synchronized(bool synchronized) { synchronized_ = synchronized; } |
| 286 | 288 |
| 287 private: | 289 private: |
| 288 ResourceProvider* resource_provider_; | 290 ResourceProvider* resource_provider_; |
| 289 ResourceId resource_id_; | 291 ResourceId resource_id_; |
| 290 unsigned texture_id_; | 292 unsigned texture_id_; |
| 291 GLenum target_; | 293 GLenum target_; |
| 292 ResourceFormat format_; | 294 ResourceFormat format_; |
| 293 gfx::Size size_; | 295 gfx::Size size_; |
| 294 TextureMailbox mailbox_; | 296 TextureMailbox mailbox_; |
| 295 gpu::SyncToken sync_token_; | 297 gpu::SyncToken sync_token_; |
| 296 bool synchronized_; | 298 bool synchronized_; |
| 297 base::ThreadChecker thread_checker_; | 299 base::ThreadChecker thread_checker_; |
| 300 sk_sp<SkColorSpace> sk_color_space_; |
| 298 | 301 |
| 299 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); | 302 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL); |
| 300 }; | 303 }; |
| 301 | 304 |
| 302 class CC_EXPORT ScopedTextureProvider { | 305 class CC_EXPORT ScopedTextureProvider { |
| 303 public: | 306 public: |
| 304 ScopedTextureProvider(gpu::gles2::GLES2Interface* gl, | 307 ScopedTextureProvider(gpu::gles2::GLES2Interface* gl, |
| 305 ScopedWriteLockGL* resource_lock, | 308 ScopedWriteLockGL* resource_lock, |
| 306 bool use_mailbox); | 309 bool use_mailbox); |
| 307 ~ScopedTextureProvider(); | 310 ~ScopedTextureProvider(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 }; | 378 }; |
| 376 | 379 |
| 377 class CC_EXPORT ScopedWriteLockSoftware { | 380 class CC_EXPORT ScopedWriteLockSoftware { |
| 378 public: | 381 public: |
| 379 ScopedWriteLockSoftware(ResourceProvider* resource_provider, | 382 ScopedWriteLockSoftware(ResourceProvider* resource_provider, |
| 380 ResourceId resource_id); | 383 ResourceId resource_id); |
| 381 ~ScopedWriteLockSoftware(); | 384 ~ScopedWriteLockSoftware(); |
| 382 | 385 |
| 383 SkBitmap& sk_bitmap() { return sk_bitmap_; } | 386 SkBitmap& sk_bitmap() { return sk_bitmap_; } |
| 384 bool valid() const { return !!sk_bitmap_.getPixels(); } | 387 bool valid() const { return !!sk_bitmap_.getPixels(); } |
| 388 sk_sp<SkColorSpace> sk_color_space() const { return sk_color_space_; } |
| 385 | 389 |
| 386 private: | 390 private: |
| 387 ResourceProvider* resource_provider_; | 391 ResourceProvider* resource_provider_; |
| 388 ResourceId resource_id_; | 392 ResourceId resource_id_; |
| 389 SkBitmap sk_bitmap_; | 393 SkBitmap sk_bitmap_; |
| 394 sk_sp<SkColorSpace> sk_color_space_; |
| 390 base::ThreadChecker thread_checker_; | 395 base::ThreadChecker thread_checker_; |
| 391 | 396 |
| 392 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); | 397 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockSoftware); |
| 393 }; | 398 }; |
| 394 | 399 |
| 395 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer { | 400 class CC_EXPORT ScopedWriteLockGpuMemoryBuffer { |
| 396 public: | 401 public: |
| 397 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, | 402 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, |
| 398 ResourceId resource_id); | 403 ResourceId resource_id); |
| 399 ~ScopedWriteLockGpuMemoryBuffer(); | 404 ~ScopedWriteLockGpuMemoryBuffer(); |
| 400 | |
| 401 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); | 405 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer(); |
| 406 sk_sp<SkColorSpace> sk_color_space() const { return sk_color_space_; } |
| 402 | 407 |
| 403 private: | 408 private: |
| 404 ResourceProvider* resource_provider_; | 409 ResourceProvider* resource_provider_; |
| 405 ResourceId resource_id_; | 410 ResourceId resource_id_; |
| 406 ResourceFormat format_; | 411 ResourceFormat format_; |
| 407 gfx::BufferUsage usage_; | 412 gfx::BufferUsage usage_; |
| 408 gfx::Size size_; | 413 gfx::Size size_; |
| 409 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; | 414 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
| 415 sk_sp<SkColorSpace> sk_color_space_; |
| 410 base::ThreadChecker thread_checker_; | 416 base::ThreadChecker thread_checker_; |
| 411 | 417 |
| 412 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 418 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
| 413 }; | 419 }; |
| 414 | 420 |
| 415 class Fence : public base::RefCounted<Fence> { | 421 class Fence : public base::RefCounted<Fence> { |
| 416 public: | 422 public: |
| 417 Fence() {} | 423 Fence() {} |
| 418 | 424 |
| 419 virtual void Set() = 0; | 425 virtual void Set() = 0; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 const gfx::ColorSpace& color_space); | 634 const gfx::ColorSpace& color_space); |
| 629 ResourceId CreateBitmap(const gfx::Size& size, | 635 ResourceId CreateBitmap(const gfx::Size& size, |
| 630 const gfx::ColorSpace& color_space); | 636 const gfx::ColorSpace& color_space); |
| 631 Resource* InsertResource(ResourceId id, Resource resource); | 637 Resource* InsertResource(ResourceId id, Resource resource); |
| 632 Resource* GetResource(ResourceId id); | 638 Resource* GetResource(ResourceId id); |
| 633 const Resource* LockForRead(ResourceId id); | 639 const Resource* LockForRead(ResourceId id); |
| 634 void UnlockForRead(ResourceId id); | 640 void UnlockForRead(ResourceId id); |
| 635 Resource* LockForWrite(ResourceId id); | 641 Resource* LockForWrite(ResourceId id); |
| 636 void UnlockForWrite(Resource* resource); | 642 void UnlockForWrite(Resource* resource); |
| 637 | 643 |
| 638 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 644 void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 639 const Resource* resource); | 645 const Resource* resource); |
| 640 | 646 |
| 641 void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl, | 647 void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl, |
| 642 Resource* resource); | 648 Resource* resource); |
| 643 | 649 |
| 644 void TransferResource(Resource* source, | 650 void TransferResource(Resource* source, |
| 645 ResourceId id, | 651 ResourceId id, |
| 646 TransferableResource* resource); | 652 TransferableResource* resource); |
| 647 enum DeleteStyle { | 653 enum DeleteStyle { |
| 648 NORMAL, | 654 NORMAL, |
| 649 FOR_SHUTDOWN, | 655 FOR_SHUTDOWN, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 660 void BindImageForSampling(Resource* resource); | 666 void BindImageForSampling(Resource* resource); |
| 661 // Binds the given GL resource to a texture target for sampling using the | 667 // Binds the given GL resource to a texture target for sampling using the |
| 662 // specified filter for both minification and magnification. Returns the | 668 // specified filter for both minification and magnification. Returns the |
| 663 // texture target used. The resource must be locked for reading. | 669 // texture target used. The resource must be locked for reading. |
| 664 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); | 670 GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); |
| 665 | 671 |
| 666 // Returns null if we do not have a ContextProvider. | 672 // Returns null if we do not have a ContextProvider. |
| 667 gpu::gles2::GLES2Interface* ContextGL() const; | 673 gpu::gles2::GLES2Interface* ContextGL() const; |
| 668 bool IsGLContextLost() const; | 674 bool IsGLContextLost() const; |
| 669 | 675 |
| 676 // Returns null if |enable_color_correct_rendering_| is false. |
| 677 sk_sp<SkColorSpace> GetResourceSkColorSpace(const Resource* resource) const; |
| 678 |
| 670 ContextProvider* compositor_context_provider_; | 679 ContextProvider* compositor_context_provider_; |
| 671 SharedBitmapManager* shared_bitmap_manager_; | 680 SharedBitmapManager* shared_bitmap_manager_; |
| 672 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 681 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 673 BlockingTaskRunner* blocking_main_thread_task_runner_; | 682 BlockingTaskRunner* blocking_main_thread_task_runner_; |
| 674 bool lost_output_surface_; | 683 bool lost_output_surface_; |
| 675 int highp_threshold_min_; | 684 int highp_threshold_min_; |
| 676 ResourceId next_id_; | 685 ResourceId next_id_; |
| 677 ResourceMap resources_; | 686 ResourceMap resources_; |
| 678 int next_child_; | 687 int next_child_; |
| 679 ChildMap children_; | 688 ChildMap children_; |
| 680 | 689 |
| 681 const bool delegated_sync_points_required_; | 690 const bool delegated_sync_points_required_; |
| 682 | 691 |
| 683 ResourceType default_resource_type_; | 692 ResourceType default_resource_type_; |
| 684 bool use_texture_storage_ext_; | 693 bool use_texture_storage_ext_; |
| 685 bool use_texture_format_bgra_; | 694 bool use_texture_format_bgra_; |
| 686 bool use_texture_usage_hint_; | 695 bool use_texture_usage_hint_; |
| 687 bool use_compressed_texture_etc1_; | 696 bool use_compressed_texture_etc1_; |
| 688 ResourceFormat yuv_resource_format_; | 697 ResourceFormat yuv_resource_format_; |
| 689 ResourceFormat yuv_highbit_resource_format_; | 698 ResourceFormat yuv_highbit_resource_format_; |
| 690 int max_texture_size_; | 699 int max_texture_size_; |
| 691 ResourceFormat best_texture_format_; | 700 ResourceFormat best_texture_format_; |
| 692 ResourceFormat best_render_buffer_format_; | 701 ResourceFormat best_render_buffer_format_; |
| 702 const bool enable_color_correct_rendering_ = false; |
| 693 | 703 |
| 694 base::ThreadChecker thread_checker_; | 704 base::ThreadChecker thread_checker_; |
| 695 | 705 |
| 696 scoped_refptr<Fence> current_read_lock_fence_; | 706 scoped_refptr<Fence> current_read_lock_fence_; |
| 697 | 707 |
| 698 const size_t id_allocation_chunk_size_; | 708 const size_t id_allocation_chunk_size_; |
| 699 std::unique_ptr<IdAllocator> texture_id_allocator_; | 709 std::unique_ptr<IdAllocator> texture_id_allocator_; |
| 700 std::unique_ptr<IdAllocator> buffer_id_allocator_; | 710 std::unique_ptr<IdAllocator> buffer_id_allocator_; |
| 701 | 711 |
| 702 bool use_sync_query_; | 712 bool use_sync_query_; |
| 703 BufferToTextureTargetMap buffer_to_texture_target_map_; | 713 BufferToTextureTargetMap buffer_to_texture_target_map_; |
| 704 | 714 |
| 705 // A process-unique ID used for disambiguating memory dumps from different | 715 // A process-unique ID used for disambiguating memory dumps from different |
| 706 // resource providers. | 716 // resource providers. |
| 707 int tracing_id_; | 717 int tracing_id_; |
| 708 | 718 |
| 709 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 719 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 710 }; | 720 }; |
| 711 | 721 |
| 712 } // namespace cc | 722 } // namespace cc |
| 713 | 723 |
| 714 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 724 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |