Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: cc/resources/resource_provider.h

Issue 1989453003: cc: Add ScopedReadLockGpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix aura typo Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // the resource). 158 // the resource).
159 void CopyToResource(ResourceId id, 159 void CopyToResource(ResourceId id,
160 const uint8_t* image, 160 const uint8_t* image,
161 const gfx::Size& image_size); 161 const gfx::Size& image_size);
162 162
163 // Generates sync tokesn for resources which need a sync token. 163 // Generates sync tokesn for resources which need a sync token.
164 void GenerateSyncTokenForResource(ResourceId resource_id); 164 void GenerateSyncTokenForResource(ResourceId resource_id);
165 void GenerateSyncTokenForResources(const ResourceIdArray& resource_ids); 165 void GenerateSyncTokenForResources(const ResourceIdArray& resource_ids);
166 166
167 // Creates accounting for a child. Returns a child ID. 167 // Creates accounting for a child. Returns a child ID.
168 int CreateChild(const ReturnCallback& return_callback); 168 int CreateChild(const ReturnCallback& return_callback,
169 int gpu_memory_buffer_client_id);
169 170
170 // Destroys accounting for the child, deleting all accounted resources. 171 // Destroys accounting for the child, deleting all accounted resources.
171 void DestroyChild(int child); 172 void DestroyChild(int child);
172 173
173 // Sets whether resources need sync points set on them when returned to this 174 // Sets whether resources need sync points set on them when returned to this
174 // child. Defaults to true. 175 // child. Defaults to true.
175 void SetChildNeedsSyncTokens(int child, bool needs_sync_tokens); 176 void SetChildNeedsSyncTokens(int child, bool needs_sync_tokens);
176 177
177 // Gets the child->parent resource ID map. 178 // Gets the child->parent resource ID map.
178 const ResourceIdMap& GetChildToParentMap(int child) const; 179 const ResourceIdMap& GetChildToParentMap(int child) const;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 326
326 private: 327 private:
327 ResourceProvider* resource_provider_; 328 ResourceProvider* resource_provider_;
328 ResourceProvider::Resource* resource_; 329 ResourceProvider::Resource* resource_;
329 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_; 330 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
330 base::ThreadChecker thread_checker_; 331 base::ThreadChecker thread_checker_;
331 332
332 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer); 333 DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpuMemoryBuffer);
333 }; 334 };
334 335
336 class CC_EXPORT ScopedReadLockGpuMemoryBuffer {
337 public:
338 ScopedReadLockGpuMemoryBuffer(ResourceProvider* resource_provider,
339 ResourceId resource_id);
340 ~ScopedReadLockGpuMemoryBuffer();
341
342 // This may return nullptr.
343 gfx::GpuMemoryBuffer* GetGpuMemoryBuffer() const;
344
345 // This returns the GL texture that is backed by a GL image bound to the
346 // resource's GpuMemoryBuffer.
347 unsigned GetTextureId() const;
348
349 private:
350 ResourceProvider* resource_provider_;
351 ResourceId resource_id_;
352 const ResourceProvider::Resource* resource_;
353 base::ThreadChecker thread_checker_;
354
355 DISALLOW_COPY_AND_ASSIGN(ScopedReadLockGpuMemoryBuffer);
356 };
357
335 class CC_EXPORT ScopedWriteLockGr { 358 class CC_EXPORT ScopedWriteLockGr {
336 public: 359 public:
337 ScopedWriteLockGr(ResourceProvider* resource_provider, 360 ScopedWriteLockGr(ResourceProvider* resource_provider,
338 ResourceId resource_id); 361 ResourceId resource_id);
339 ~ScopedWriteLockGr(); 362 ~ScopedWriteLockGr();
340 363
341 void InitSkSurface(bool use_distance_field_text, 364 void InitSkSurface(bool use_distance_field_text,
342 bool can_use_lcd_text, 365 bool can_use_lcd_text,
343 int msaa_sample_count); 366 int msaa_sample_count);
344 void ReleaseSkSurface(); 367 void ReleaseSkSurface();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 using ResourceMap = std::unordered_map<ResourceId, Resource>; 605 using ResourceMap = std::unordered_map<ResourceId, Resource>;
583 606
584 struct Child { 607 struct Child {
585 Child(); 608 Child();
586 Child(const Child& other); 609 Child(const Child& other);
587 ~Child(); 610 ~Child();
588 611
589 ResourceIdMap child_to_parent_map; 612 ResourceIdMap child_to_parent_map;
590 ResourceIdMap parent_to_child_map; 613 ResourceIdMap parent_to_child_map;
591 ReturnCallback return_callback; 614 ReturnCallback return_callback;
615 int gpu_memory_buffer_client_id;
592 bool marked_for_deletion; 616 bool marked_for_deletion;
593 bool needs_sync_tokens; 617 bool needs_sync_tokens;
594 }; 618 };
595 using ChildMap = std::unordered_map<int, Child>; 619 using ChildMap = std::unordered_map<int, Child>;
596 620
597 bool ReadLockFenceHasPassed(const Resource* resource) { 621 bool ReadLockFenceHasPassed(const Resource* resource) {
598 return !resource->read_lock_fence.get() || 622 return !resource->read_lock_fence.get() ||
599 resource->read_lock_fence->HasPassed(); 623 resource->read_lock_fence->HasPassed();
600 } 624 }
601 625
602 ResourceId CreateGLTexture(const gfx::Size& size, 626 ResourceId CreateGLTexture(const gfx::Size& size,
603 TextureHint hint, 627 TextureHint hint,
604 ResourceType type, 628 ResourceType type,
605 ResourceFormat format); 629 ResourceFormat format);
606 ResourceId CreateBitmap(const gfx::Size& size); 630 ResourceId CreateBitmap(const gfx::Size& size);
607 Resource* InsertResource(ResourceId id, Resource resource); 631 Resource* InsertResource(ResourceId id, Resource resource);
608 Resource* GetResource(ResourceId id); 632 Resource* GetResource(ResourceId id);
609 const Resource* LockForRead(ResourceId id); 633 const Resource* LockForRead(ResourceId id, bool create_gpu_memory_buffer);
610 void UnlockForRead(ResourceId id); 634 void UnlockForRead(ResourceId id);
611 Resource* LockForWrite(ResourceId id); 635 Resource* LockForWrite(ResourceId id);
612 void UnlockForWrite(Resource* resource); 636 void UnlockForWrite(Resource* resource);
613 637
614 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, 638 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap,
615 const Resource* resource); 639 const Resource* resource);
616 640
617 void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl, 641 void CreateMailboxAndBindResource(gpu::gles2::GLES2Interface* gl,
618 Resource* resource); 642 Resource* resource);
619 643
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 // A process-unique ID used for disambiguating memory dumps from different 705 // A process-unique ID used for disambiguating memory dumps from different
682 // resource providers. 706 // resource providers.
683 int tracing_id_; 707 int tracing_id_;
684 708
685 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 709 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
686 }; 710 };
687 711
688 } // namespace cc 712 } // namespace cc
689 713
690 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 714 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698