| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 Bitmap, | 79 Bitmap, |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 static scoped_ptr<ResourceProvider> Create( | 82 static scoped_ptr<ResourceProvider> Create( |
| 83 OutputSurface* output_surface, | 83 OutputSurface* output_surface, |
| 84 SharedBitmapManager* shared_bitmap_manager, | 84 SharedBitmapManager* shared_bitmap_manager, |
| 85 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 85 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 86 BlockingTaskRunner* blocking_main_thread_task_runner, | 86 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 87 int highp_threshold_min, | 87 int highp_threshold_min, |
| 88 bool use_rgba_4444_texture_format, | 88 bool use_rgba_4444_texture_format, |
| 89 bool use_worker_context_for_gr, |
| 89 size_t id_allocation_chunk_size); | 90 size_t id_allocation_chunk_size); |
| 90 virtual ~ResourceProvider(); | 91 virtual ~ResourceProvider(); |
| 91 | 92 |
| 92 void InitializeSoftware(); | 93 void InitializeSoftware(); |
| 93 void InitializeGL(); | 94 void InitializeGL(); |
| 94 | 95 |
| 95 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 96 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| 96 | 97 |
| 97 int max_texture_size() const { return max_texture_size_; } | 98 int max_texture_size() const { return max_texture_size_; } |
| 98 ResourceFormat memory_efficient_texture_format() const { | 99 ResourceFormat memory_efficient_texture_format() const { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 gfx::Size size_; | 326 gfx::Size size_; |
| 326 ResourceFormat format_; | 327 ResourceFormat format_; |
| 327 base::ThreadChecker thread_checker_; | 328 base::ThreadChecker thread_checker_; |
| 328 | 329 |
| 329 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 330 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
| 330 }; | 331 }; |
| 331 | 332 |
| 332 class CC_EXPORT ScopedWriteLockGr { | 333 class CC_EXPORT ScopedWriteLockGr { |
| 333 public: | 334 public: |
| 334 ScopedWriteLockGr(ResourceProvider* resource_provider, | 335 ScopedWriteLockGr(ResourceProvider* resource_provider, |
| 335 ResourceProvider::ResourceId resource_id, | 336 ResourceProvider::ResourceId resource_id); |
| 336 bool use_distance_field_text, | |
| 337 bool can_use_lcd_text, | |
| 338 int msaa_sample_count); | |
| 339 ~ScopedWriteLockGr(); | 337 ~ScopedWriteLockGr(); |
| 340 | 338 |
| 341 SkSurface* get_sk_surface() { return sk_surface_.get(); } | 339 SkSurface* GetSkSurface(bool use_distance_field_text, |
| 340 bool can_use_lcd_text, |
| 341 int msaa_sample_count); |
| 342 | 342 |
| 343 private: | 343 private: |
| 344 ResourceProvider* resource_provider_; | 344 ResourceProvider* resource_provider_; |
| 345 ResourceProvider::Resource* resource_; | 345 ResourceProvider::Resource* resource_; |
| 346 base::ThreadChecker thread_checker_; | 346 base::ThreadChecker thread_checker_; |
| 347 skia::RefPtr<SkSurface> sk_surface_; | 347 skia::RefPtr<SkSurface> sk_surface_; |
| 348 | 348 |
| 349 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr); | 349 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr); |
| 350 }; | 350 }; |
| 351 | 351 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 419 |
| 420 // Copy pixels from source to destination. | 420 // Copy pixels from source to destination. |
| 421 void CopyResource(ResourceId source_id, ResourceId dest_id); | 421 void CopyResource(ResourceId source_id, ResourceId dest_id); |
| 422 | 422 |
| 423 void WaitSyncPointIfNeeded(ResourceId id); | 423 void WaitSyncPointIfNeeded(ResourceId id); |
| 424 | 424 |
| 425 void WaitReadLockIfNeeded(ResourceId id); | 425 void WaitReadLockIfNeeded(ResourceId id); |
| 426 | 426 |
| 427 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | 427 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
| 428 | 428 |
| 429 OutputSurface* output_surface() { return output_surface_; } |
| 430 |
| 429 private: | 431 private: |
| 430 struct Resource { | 432 struct Resource { |
| 431 enum Origin { Internal, External, Delegated }; | 433 enum Origin { Internal, External, Delegated }; |
| 432 | 434 |
| 433 Resource(); | 435 Resource(); |
| 434 ~Resource(); | 436 ~Resource(); |
| 435 Resource(unsigned texture_id, | 437 Resource(unsigned texture_id, |
| 436 const gfx::Size& size, | 438 const gfx::Size& size, |
| 437 Origin origin, | 439 Origin origin, |
| 438 GLenum target, | 440 GLenum target, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 return !resource->read_lock_fence.get() || | 519 return !resource->read_lock_fence.get() || |
| 518 resource->read_lock_fence->HasPassed(); | 520 resource->read_lock_fence->HasPassed(); |
| 519 } | 521 } |
| 520 | 522 |
| 521 ResourceProvider(OutputSurface* output_surface, | 523 ResourceProvider(OutputSurface* output_surface, |
| 522 SharedBitmapManager* shared_bitmap_manager, | 524 SharedBitmapManager* shared_bitmap_manager, |
| 523 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 525 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 524 BlockingTaskRunner* blocking_main_thread_task_runner, | 526 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 525 int highp_threshold_min, | 527 int highp_threshold_min, |
| 526 bool use_rgba_4444_texture_format, | 528 bool use_rgba_4444_texture_format, |
| 529 bool use_worker_context_for_gr, |
| 527 size_t id_allocation_chunk_size); | 530 size_t id_allocation_chunk_size); |
| 528 | 531 |
| 529 void CleanUpGLIfNeeded(); | 532 void CleanUpGLIfNeeded(); |
| 530 | 533 |
| 531 Resource* GetResource(ResourceId id); | 534 Resource* GetResource(ResourceId id); |
| 532 const Resource* LockForRead(ResourceId id); | 535 const Resource* LockForRead(ResourceId id); |
| 533 void UnlockForRead(ResourceId id); | 536 void UnlockForRead(ResourceId id); |
| 534 Resource* LockForWrite(ResourceId id); | 537 Resource* LockForWrite(ResourceId id); |
| 535 void UnlockForWrite(Resource* resource); | 538 void UnlockForWrite(Resource* resource); |
| 536 | 539 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 bool use_compressed_texture_etc1_; | 583 bool use_compressed_texture_etc1_; |
| 581 ResourceFormat yuv_resource_format_; | 584 ResourceFormat yuv_resource_format_; |
| 582 scoped_ptr<TextureUploader> texture_uploader_; | 585 scoped_ptr<TextureUploader> texture_uploader_; |
| 583 int max_texture_size_; | 586 int max_texture_size_; |
| 584 ResourceFormat best_texture_format_; | 587 ResourceFormat best_texture_format_; |
| 585 | 588 |
| 586 base::ThreadChecker thread_checker_; | 589 base::ThreadChecker thread_checker_; |
| 587 | 590 |
| 588 scoped_refptr<Fence> current_read_lock_fence_; | 591 scoped_refptr<Fence> current_read_lock_fence_; |
| 589 bool use_rgba_4444_texture_format_; | 592 bool use_rgba_4444_texture_format_; |
| 593 bool use_worker_context_for_gr_; |
| 590 | 594 |
| 591 const size_t id_allocation_chunk_size_; | 595 const size_t id_allocation_chunk_size_; |
| 592 scoped_ptr<IdAllocator> texture_id_allocator_; | 596 scoped_ptr<IdAllocator> texture_id_allocator_; |
| 593 scoped_ptr<IdAllocator> buffer_id_allocator_; | 597 scoped_ptr<IdAllocator> buffer_id_allocator_; |
| 594 | 598 |
| 595 bool use_sync_query_; | 599 bool use_sync_query_; |
| 596 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. | 600 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. |
| 597 scoped_refptr<SynchronousFence> synchronous_fence_; | 601 scoped_refptr<SynchronousFence> synchronous_fence_; |
| 598 | 602 |
| 599 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 603 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 return format_gl_data_format[format]; | 654 return format_gl_data_format[format]; |
| 651 } | 655 } |
| 652 | 656 |
| 653 inline GLenum GLInternalFormat(ResourceFormat format) { | 657 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 654 return GLDataFormat(format); | 658 return GLDataFormat(format); |
| 655 } | 659 } |
| 656 | 660 |
| 657 } // namespace cc | 661 } // namespace cc |
| 658 | 662 |
| 659 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 663 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |