| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ResourceProvider* resource_provider_; | 376 ResourceProvider* resource_provider_; |
| 377 ResourceId resource_id_; | 377 ResourceId resource_id_; |
| 378 ResourceFormat format_; | 378 ResourceFormat format_; |
| 379 gfx::Size size_; | 379 gfx::Size size_; |
| 380 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; | 380 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; |
| 381 base::ThreadChecker thread_checker_; | 381 base::ThreadChecker thread_checker_; |
| 382 | 382 |
| 383 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); | 383 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 class CC_EXPORT ScopedReadLockGpuMemoryBuffer { | |
| 387 public: | |
| 388 ScopedReadLockGpuMemoryBuffer(ResourceProvider* resource_provider, | |
| 389 ResourceId resource_id); | |
| 390 ~ScopedReadLockGpuMemoryBuffer(); | |
| 391 | |
| 392 ResourceId resource_id() const { return resource_id_; } | |
| 393 | |
| 394 // This may return nullptr. | |
| 395 gfx::GpuMemoryBuffer* gpu_memory_buffer() const { | |
| 396 return gpu_memory_buffer_; | |
| 397 } | |
| 398 | |
| 399 // This returns the GL texture that is backed by a GL image bound to the | |
| 400 // resource's GpuMemoryBuffer. | |
| 401 unsigned texture_id() const { return texture_id_; } | |
| 402 | |
| 403 private: | |
| 404 ResourceProvider* resource_provider_; | |
| 405 ResourceId resource_id_; | |
| 406 gfx::GpuMemoryBuffer* gpu_memory_buffer_; | |
| 407 unsigned texture_id_; | |
| 408 base::ThreadChecker thread_checker_; | |
| 409 | |
| 410 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGpuMemoryBuffer); | |
| 411 }; | |
| 412 | |
| 413 class Fence : public base::RefCounted<Fence> { | 386 class Fence : public base::RefCounted<Fence> { |
| 414 public: | 387 public: |
| 415 Fence() {} | 388 Fence() {} |
| 416 | 389 |
| 417 virtual void Set() = 0; | 390 virtual void Set() = 0; |
| 418 virtual bool HasPassed() = 0; | 391 virtual bool HasPassed() = 0; |
| 419 virtual void Wait() = 0; | 392 virtual void Wait() = 0; |
| 420 | 393 |
| 421 protected: | 394 protected: |
| 422 friend class base::RefCounted<Fence>; | 395 friend class base::RefCounted<Fence>; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 resource->read_lock_fence->HasPassed(); | 600 resource->read_lock_fence->HasPassed(); |
| 628 } | 601 } |
| 629 | 602 |
| 630 ResourceId CreateGLTexture(const gfx::Size& size, | 603 ResourceId CreateGLTexture(const gfx::Size& size, |
| 631 TextureHint hint, | 604 TextureHint hint, |
| 632 ResourceType type, | 605 ResourceType type, |
| 633 ResourceFormat format); | 606 ResourceFormat format); |
| 634 ResourceId CreateBitmap(const gfx::Size& size); | 607 ResourceId CreateBitmap(const gfx::Size& size); |
| 635 Resource* InsertResource(ResourceId id, Resource resource); | 608 Resource* InsertResource(ResourceId id, Resource resource); |
| 636 Resource* GetResource(ResourceId id); | 609 Resource* GetResource(ResourceId id); |
| 637 const Resource* LockForRead(ResourceId id, bool create_gpu_memory_buffer); | 610 const Resource* LockForRead(ResourceId id); |
| 638 void UnlockForRead(ResourceId id); | 611 void UnlockForRead(ResourceId id); |
| 639 Resource* LockForWrite(ResourceId id); | 612 Resource* LockForWrite(ResourceId id); |
| 640 void UnlockForWrite(Resource* resource); | 613 void UnlockForWrite(Resource* resource); |
| 641 | 614 |
| 642 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 615 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
| 643 const Resource* resource); | 616 const Resource* resource); |
| 644 | 617 |
| 645 void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl, | 618 void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl, |
| 646 Resource* resource); | 619 Resource* resource); |
| 647 | 620 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 // A process-unique ID used for disambiguating memory dumps from different | 682 // A process-unique ID used for disambiguating memory dumps from different |
| 710 // resource providers. | 683 // resource providers. |
| 711 int tracing_id_; | 684 int tracing_id_; |
| 712 | 685 |
| 713 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 686 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 714 }; | 687 }; |
| 715 | 688 |
| 716 } // namespace cc | 689 } // namespace cc |
| 717 | 690 |
| 718 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 691 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
| OLD | NEW |