| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 virtual void Wait() = 0; | 351 virtual void Wait() = 0; |
| 352 | 352 |
| 353 protected: | 353 protected: |
| 354 friend class base::RefCounted<Fence>; | 354 friend class base::RefCounted<Fence>; |
| 355 virtual ~Fence() {} | 355 virtual ~Fence() {} |
| 356 | 356 |
| 357 private: | 357 private: |
| 358 DISALLOW_COPY_AND_ASSIGN(Fence); | 358 DISALLOW_COPY_AND_ASSIGN(Fence); |
| 359 }; | 359 }; |
| 360 | 360 |
| 361 class SynchronousFence : public ResourceProvider::Fence { |
| 362 public: |
| 363 explicit SynchronousFence(gpu::gles2::GLES2Interface* gl); |
| 364 |
| 365 // Overridden from Fence: |
| 366 void Set() override; |
| 367 bool HasPassed() override; |
| 368 void Wait() override; |
| 369 |
| 370 // Returns true if fence has been set but not yet synchornized. |
| 371 bool has_synchronized() const { return has_synchronized_; } |
| 372 |
| 373 private: |
| 374 ~SynchronousFence() override; |
| 375 |
| 376 void Synchronize(); |
| 377 |
| 378 gpu::gles2::GLES2Interface* gl_; |
| 379 bool has_synchronized_; |
| 380 |
| 381 DISALLOW_COPY_AND_ASSIGN(SynchronousFence); |
| 382 }; |
| 383 |
| 361 // Acquire pixel buffer for resource. The pixel buffer can be used to | 384 // Acquire pixel buffer for resource. The pixel buffer can be used to |
| 362 // set resource pixels without performing unnecessary copying. | 385 // set resource pixels without performing unnecessary copying. |
| 363 void AcquirePixelBuffer(ResourceId resource); | 386 void AcquirePixelBuffer(ResourceId resource); |
| 364 void ReleasePixelBuffer(ResourceId resource); | 387 void ReleasePixelBuffer(ResourceId resource); |
| 365 // Map/unmap the acquired pixel buffer. | 388 // Map/unmap the acquired pixel buffer. |
| 366 uint8_t* MapPixelBuffer(ResourceId id, int* stride); | 389 uint8_t* MapPixelBuffer(ResourceId id, int* stride); |
| 367 void UnmapPixelBuffer(ResourceId id); | 390 void UnmapPixelBuffer(ResourceId id); |
| 368 // Asynchronously update pixels from acquired pixel buffer. | 391 // Asynchronously update pixels from acquired pixel buffer. |
| 369 void BeginSetPixels(ResourceId id); | 392 void BeginSetPixels(ResourceId id); |
| 370 void ForceSetPixelsToComplete(ResourceId id); | 393 void ForceSetPixelsToComplete(ResourceId id); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 base::ThreadChecker thread_checker_; | 579 base::ThreadChecker thread_checker_; |
| 557 | 580 |
| 558 scoped_refptr<Fence> current_read_lock_fence_; | 581 scoped_refptr<Fence> current_read_lock_fence_; |
| 559 bool use_rgba_4444_texture_format_; | 582 bool use_rgba_4444_texture_format_; |
| 560 | 583 |
| 561 const size_t id_allocation_chunk_size_; | 584 const size_t id_allocation_chunk_size_; |
| 562 scoped_ptr<IdAllocator> texture_id_allocator_; | 585 scoped_ptr<IdAllocator> texture_id_allocator_; |
| 563 scoped_ptr<IdAllocator> buffer_id_allocator_; | 586 scoped_ptr<IdAllocator> buffer_id_allocator_; |
| 564 | 587 |
| 565 bool use_sync_query_; | 588 bool use_sync_query_; |
| 589 // Fence used for CopyResource if CHROMIUM_sync_query is not supported. |
| 590 scoped_refptr<SynchronousFence> synchronous_fence_; |
| 566 | 591 |
| 567 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 592 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 568 }; | 593 }; |
| 569 | 594 |
| 570 | 595 |
| 571 // TODO(epenner): Move these format conversions to resource_format.h | 596 // TODO(epenner): Move these format conversions to resource_format.h |
| 572 // once that builds on mac (npapi.h currently #includes OpenGL.h). | 597 // once that builds on mac (npapi.h currently #includes OpenGL.h). |
| 573 inline unsigned BitsPerPixel(ResourceFormat format) { | 598 inline unsigned BitsPerPixel(ResourceFormat format) { |
| 574 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | 599 DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
| 575 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { | 600 static const unsigned format_bits_per_pixel[RESOURCE_FORMAT_MAX + 1] = { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 return format_gl_data_format[format]; | 637 return format_gl_data_format[format]; |
| 613 } | 638 } |
| 614 | 639 |
| 615 inline GLenum GLInternalFormat(ResourceFormat format) { | 640 inline GLenum GLInternalFormat(ResourceFormat format) { |
| 616 return GLDataFormat(format); | 641 return GLDataFormat(format); |
| 617 } | 642 } |
| 618 | 643 |
| 619 } // namespace cc | 644 } // namespace cc |
| 620 | 645 |
| 621 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 646 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |