| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 Bitmap, | 76 Bitmap, |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 static scoped_ptr<ResourceProvider> Create( | 79 static scoped_ptr<ResourceProvider> Create( |
| 80 OutputSurface* output_surface, | 80 OutputSurface* output_surface, |
| 81 SharedBitmapManager* shared_bitmap_manager, | 81 SharedBitmapManager* shared_bitmap_manager, |
| 82 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 82 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 83 BlockingTaskRunner* blocking_main_thread_task_runner, | 83 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 84 int highp_threshold_min, | 84 int highp_threshold_min, |
| 85 bool use_rgba_4444_texture_format, | 85 bool use_rgba_4444_texture_format, |
| 86 size_t id_allocation_chunk_size, | 86 size_t id_allocation_chunk_size); |
| 87 bool use_distance_field_text); | |
| 88 virtual ~ResourceProvider(); | 87 virtual ~ResourceProvider(); |
| 89 | 88 |
| 90 void InitializeSoftware(); | 89 void InitializeSoftware(); |
| 91 void InitializeGL(); | 90 void InitializeGL(); |
| 92 | 91 |
| 93 void DidLoseOutputSurface() { lost_output_surface_ = true; } | 92 void DidLoseOutputSurface() { lost_output_surface_ = true; } |
| 94 | 93 |
| 95 int max_texture_size() const { return max_texture_size_; } | 94 int max_texture_size() const { return max_texture_size_; } |
| 96 ResourceFormat memory_efficient_texture_format() const { | 95 ResourceFormat memory_efficient_texture_format() const { |
| 97 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; | 96 return use_rgba_4444_texture_format_ ? RGBA_4444 : best_texture_format_; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 320 |
| 322 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 321 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
| 323 }; | 322 }; |
| 324 | 323 |
| 325 class CC_EXPORT ScopedWriteLockGr { | 324 class CC_EXPORT ScopedWriteLockGr { |
| 326 public: | 325 public: |
| 327 ScopedWriteLockGr(ResourceProvider* resource_provider, | 326 ScopedWriteLockGr(ResourceProvider* resource_provider, |
| 328 ResourceProvider::ResourceId resource_id); | 327 ResourceProvider::ResourceId resource_id); |
| 329 ~ScopedWriteLockGr(); | 328 ~ScopedWriteLockGr(); |
| 330 | 329 |
| 331 SkSurface* sk_surface() { return sk_surface_; } | 330 SkSurface* GetSkSurface(bool use_distance_field_text); |
| 332 | 331 |
| 333 private: | 332 private: |
| 334 ResourceProvider* resource_provider_; | 333 ResourceProvider* resource_provider_; |
| 335 ResourceProvider::ResourceId resource_id_; | 334 ResourceProvider::ResourceId resource_id_; |
| 336 SkSurface* sk_surface_; | |
| 337 | 335 |
| 338 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr); | 336 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGr); |
| 339 }; | 337 }; |
| 340 | 338 |
| 341 class Fence : public base::RefCounted<Fence> { | 339 class Fence : public base::RefCounted<Fence> { |
| 342 public: | 340 public: |
| 343 Fence() {} | 341 Fence() {} |
| 344 | 342 |
| 345 virtual void Set() = 0; | 343 virtual void Set() = 0; |
| 346 virtual bool HasPassed() = 0; | 344 virtual bool HasPassed() = 0; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 return !resource->read_lock_fence.get() || | 479 return !resource->read_lock_fence.get() || |
| 482 resource->read_lock_fence->HasPassed(); | 480 resource->read_lock_fence->HasPassed(); |
| 483 } | 481 } |
| 484 | 482 |
| 485 ResourceProvider(OutputSurface* output_surface, | 483 ResourceProvider(OutputSurface* output_surface, |
| 486 SharedBitmapManager* shared_bitmap_manager, | 484 SharedBitmapManager* shared_bitmap_manager, |
| 487 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 485 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 488 BlockingTaskRunner* blocking_main_thread_task_runner, | 486 BlockingTaskRunner* blocking_main_thread_task_runner, |
| 489 int highp_threshold_min, | 487 int highp_threshold_min, |
| 490 bool use_rgba_4444_texture_format, | 488 bool use_rgba_4444_texture_format, |
| 491 size_t id_allocation_chunk_size, | 489 size_t id_allocation_chunk_size); |
| 492 bool use_distance_field_text); | |
| 493 | 490 |
| 494 void CleanUpGLIfNeeded(); | 491 void CleanUpGLIfNeeded(); |
| 495 | 492 |
| 496 Resource* GetResource(ResourceId id); | 493 Resource* GetResource(ResourceId id); |
| 497 const Resource* LockForRead(ResourceId id); | 494 const Resource* LockForRead(ResourceId id); |
| 498 void UnlockForRead(ResourceId id); | 495 void UnlockForRead(ResourceId id); |
| 499 const Resource* LockForWrite(ResourceId id); | 496 const Resource* LockForWrite(ResourceId id); |
| 500 void UnlockForWrite(ResourceId id); | 497 void UnlockForWrite(ResourceId id); |
| 501 const Resource* LockForWriteToGpuMemoryBuffer(ResourceId id); | 498 const Resource* LockForWriteToGpuMemoryBuffer(ResourceId id); |
| 502 void UnlockForWriteToGpuMemoryBuffer(ResourceId id); | 499 void UnlockForWriteToGpuMemoryBuffer(ResourceId id); |
| 503 const Resource* LockForWriteToSkSurface(ResourceId id); | 500 void LockForWriteToSkSurface(ResourceId id); |
| 504 void UnlockForWriteToSkSurface(ResourceId id); | 501 void UnlockForWriteToSkSurface(ResourceId id); |
| 505 | 502 |
| 506 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 503 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 507 const Resource* resource); | 504 const Resource* resource); |
| 508 | 505 |
| 509 void TransferResource(gpu::gles2::GLES2Interface* gl, | 506 void TransferResource(gpu::gles2::GLES2Interface* gl, |
| 510 ResourceId id, | 507 ResourceId id, |
| 511 TransferableResource* resource); | 508 TransferableResource* resource); |
| 512 enum DeleteStyle { | 509 enum DeleteStyle { |
| 513 Normal, | 510 Normal, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 552 |
| 556 scoped_refptr<Fence> current_read_lock_fence_; | 553 scoped_refptr<Fence> current_read_lock_fence_; |
| 557 bool use_rgba_4444_texture_format_; | 554 bool use_rgba_4444_texture_format_; |
| 558 | 555 |
| 559 const size_t id_allocation_chunk_size_; | 556 const size_t id_allocation_chunk_size_; |
| 560 scoped_ptr<IdAllocator> texture_id_allocator_; | 557 scoped_ptr<IdAllocator> texture_id_allocator_; |
| 561 scoped_ptr<IdAllocator> buffer_id_allocator_; | 558 scoped_ptr<IdAllocator> buffer_id_allocator_; |
| 562 | 559 |
| 563 bool use_sync_query_; | 560 bool use_sync_query_; |
| 564 | 561 |
| 565 bool use_distance_field_text_; | |
| 566 | |
| 567 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 562 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 568 }; | 563 }; |
| 569 | 564 |
| 570 | 565 |
| 571 // TODO(epenner): Move these format conversions to resource_format.h | 566 // TODO(epenner): Move these format conversions to resource_format.h |
| 572 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 567 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
| 573 inline unsigned BitsPerPixel(ResourceFormat format) { | 568 inline unsigned BitsPerPixel(ResourceFormat format) { |
| 574 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 569 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 575 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 570 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
| 576 32, // RGBA_8888 | 571 32, // RGBA_8888 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 return format_gl_data_format[format]; | 607 return format_gl_data_format[format]; |
| 613 } | 608 } |
| 614 | 609 |
| 615 inline GLenum GLInternalFormat(ResourceFormat format) { | 610 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 616 return GLDataFormat(format); | 611 return GLDataFormat(format); |
| 617 } | 612 } |
| 618 | 613 |
| 619 } // namespace cc | 614 } // namespace cc |
| 620 | 615 |
| 621 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 616 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |