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

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

Issue 2508203004: Add hints for potential overlay promotion on android. (Closed)
Patch Set: rebased Created 4 years 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 | « cc/output/overlay_strategy_underlay.cc ('k') | 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // This class is not thread-safe and can only be called from the thread it was 58 // This class is not thread-safe and can only be called from the thread it was
59 // created on (in practice, the impl thread). 59 // created on (in practice, the impl thread).
60 class CC_EXPORT ResourceProvider 60 class CC_EXPORT ResourceProvider
61 : public base::trace_event::MemoryDumpProvider { 61 : public base::trace_event::MemoryDumpProvider {
62 private: 62 private:
63 struct Resource; 63 struct Resource;
64 64
65 public: 65 public:
66 using ResourceIdArray = std::vector<ResourceId>; 66 using ResourceIdArray = std::vector<ResourceId>;
67 using ResourceIdSet = std::unordered_set<ResourceId>;
68 using ResourceIdMap = std::unordered_map<ResourceId, ResourceId>; 67 using ResourceIdMap = std::unordered_map<ResourceId, ResourceId>;
69 enum TextureHint { 68 enum TextureHint {
70 TEXTURE_HINT_DEFAULT = 0x0, 69 TEXTURE_HINT_DEFAULT = 0x0,
71 TEXTURE_HINT_IMMUTABLE = 0x1, 70 TEXTURE_HINT_IMMUTABLE = 0x1,
72 TEXTURE_HINT_FRAMEBUFFER = 0x2, 71 TEXTURE_HINT_FRAMEBUFFER = 0x2,
73 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER = 72 TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER =
74 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER 73 TEXTURE_HINT_IMMUTABLE | TEXTURE_HINT_FRAMEBUFFER
75 }; 74 };
76 enum ResourceType { 75 enum ResourceType {
77 RESOURCE_TYPE_GPU_MEMORY_BUFFER, 76 RESOURCE_TYPE_GPU_MEMORY_BUFFER,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void DeclareUsedResourcesFromChild(int child, 199 void DeclareUsedResourcesFromChild(int child,
201 const ResourceIdSet& resources_from_child); 200 const ResourceIdSet& resources_from_child);
202 201
203 // Receives resources from the parent, moving them from mailboxes. Resource 202 // Receives resources from the parent, moving them from mailboxes. Resource
204 // IDs passed are in the child namespace. 203 // IDs passed are in the child namespace.
205 // NOTE: if the sync_token is set on any TransferableResource, this will 204 // NOTE: if the sync_token is set on any TransferableResource, this will
206 // wait on it. 205 // wait on it.
207 void ReceiveReturnsFromParent( 206 void ReceiveReturnsFromParent(
208 const ReturnedResourceArray& transferable_resources); 207 const ReturnedResourceArray& transferable_resources);
209 208
209 #if defined(OS_ANDROID)
210 // Send an overlay promotion hint to all resources that requested it via
211 // |want_promotion_hint|. |promotable_hints| contains all the resources that
212 // should be told that they're promotable. Others will be told that they're
213 // not promotable right now.
214 void SendPromotionHints(const ResourceIdSet& promotable_hints);
215 #endif
216
210 // The following lock classes are part of the ResourceProvider API and are 217 // The following lock classes are part of the ResourceProvider API and are
211 // needed to read and write the resource contents. The user must ensure 218 // needed to read and write the resource contents. The user must ensure
212 // that they only use GL locks on GL resources, etc, and this is enforced 219 // that they only use GL locks on GL resources, etc, and this is enforced
213 // by assertions. 220 // by assertions.
214 class CC_EXPORT ScopedReadLockGL { 221 class CC_EXPORT ScopedReadLockGL {
215 public: 222 public:
216 ScopedReadLockGL(ResourceProvider* resource_provider, 223 ScopedReadLockGL(ResourceProvider* resource_provider,
217 ResourceId resource_id); 224 ResourceId resource_id);
218 ~ScopedReadLockGL(); 225 ~ScopedReadLockGL();
219 226
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 // and has read fences enabled, the resource will not allow writes 471 // and has read fences enabled, the resource will not allow writes
465 // until this fence has passed. 472 // until this fence has passed.
466 void SetReadLockFence(Fence* fence) { current_read_lock_fence_ = fence; } 473 void SetReadLockFence(Fence* fence) { current_read_lock_fence_ = fence; }
467 474
468 // Indicates if we can currently lock this resource for write. 475 // Indicates if we can currently lock this resource for write.
469 bool CanLockForWrite(ResourceId id); 476 bool CanLockForWrite(ResourceId id);
470 477
471 // Indicates if this resource may be used for a hardware overlay plane. 478 // Indicates if this resource may be used for a hardware overlay plane.
472 bool IsOverlayCandidate(ResourceId id); 479 bool IsOverlayCandidate(ResourceId id);
473 480
481 #if defined(OS_ANDROID)
482 // Indicates if this resource is backed by an Android SurfaceTexture, and thus
483 // can't really be promoted to an overlay.
484 bool IsBackedBySurfaceTexture(ResourceId id);
485
486 // Indicates if this resource wants to receive promotion hints.
487 bool WantsPromotionHint(ResourceId id);
488
489 // Return the number of resources that request promotion hints.
490 size_t CountPromotionHintRequestsForTesting();
491 #endif
492
474 void WaitSyncTokenIfNeeded(ResourceId id); 493 void WaitSyncTokenIfNeeded(ResourceId id);
475 494
476 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); 495 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl);
477 496
478 void ValidateResource(ResourceId id) const; 497 void ValidateResource(ResourceId id) const;
479 498
480 GLenum GetImageTextureTarget(gfx::BufferUsage usage, ResourceFormat format); 499 GLenum GetImageTextureTarget(gfx::BufferUsage usage, ResourceFormat format);
481 500
482 // base::trace_event::MemoryDumpProvider implementation. 501 // base::trace_event::MemoryDumpProvider implementation.
483 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 502 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 int imported_count; 586 int imported_count;
568 int exported_count; 587 int exported_count;
569 bool dirty_image : 1; 588 bool dirty_image : 1;
570 bool locked_for_write : 1; 589 bool locked_for_write : 1;
571 bool lost : 1; 590 bool lost : 1;
572 bool marked_for_deletion : 1; 591 bool marked_for_deletion : 1;
573 bool allocated : 1; 592 bool allocated : 1;
574 bool read_lock_fences_enabled : 1; 593 bool read_lock_fences_enabled : 1;
575 bool has_shared_bitmap_id : 1; 594 bool has_shared_bitmap_id : 1;
576 bool is_overlay_candidate : 1; 595 bool is_overlay_candidate : 1;
596 #if defined(OS_ANDROID)
597 // Indicates whether this resource may not be overlayed on Android, since
598 // it's not backed by a SurfaceView. This may be set in combination with
599 // |is_overlay_candidate|, to find out if switching the resource to a
600 // a SurfaceView would result in overlay promotion. It's good to find this
601 // out in advance, since one has no fallback path for displaying a
602 // SurfaceView except via promoting it to an overlay. Ideally, one _could_
603 // promote SurfaceTexture via the overlay path, even if one ended up just
604 // drawing a quad in the compositor. However, for now, we use this flag to
605 // refuse to promote so that the compositor will draw the quad.
606 bool is_backed_by_surface_texture : 1;
607 // Indicates that this resource would like a promotion hint.
608 bool wants_promotion_hint : 1;
609 #endif
577 scoped_refptr<Fence> read_lock_fence; 610 scoped_refptr<Fence> read_lock_fence;
578 gfx::Size size; 611 gfx::Size size;
579 Origin origin; 612 Origin origin;
580 GLenum target; 613 GLenum target;
581 // TODO(skyostil): Use a separate sampler object for filter state. 614 // TODO(skyostil): Use a separate sampler object for filter state.
582 GLenum original_filter; 615 GLenum original_filter;
583 GLenum filter; 616 GLenum filter;
584 unsigned image_id; 617 unsigned image_id;
585 unsigned bound_image_id; 618 unsigned bound_image_id;
586 TextureHint hint; 619 TextureHint hint;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 const size_t id_allocation_chunk_size_; 737 const size_t id_allocation_chunk_size_;
705 std::unique_ptr<IdAllocator> texture_id_allocator_; 738 std::unique_ptr<IdAllocator> texture_id_allocator_;
706 std::unique_ptr<IdAllocator> buffer_id_allocator_; 739 std::unique_ptr<IdAllocator> buffer_id_allocator_;
707 740
708 bool use_sync_query_; 741 bool use_sync_query_;
709 BufferToTextureTargetMap buffer_to_texture_target_map_; 742 BufferToTextureTargetMap buffer_to_texture_target_map_;
710 743
711 // A process-unique ID used for disambiguating memory dumps from different 744 // A process-unique ID used for disambiguating memory dumps from different
712 // resource providers. 745 // resource providers.
713 int tracing_id_; 746 int tracing_id_;
747 #if defined(OS_ANDROID)
748 // Set of resource Ids that would like to be notified about promotion hints.
749 ResourceIdSet wants_promotion_hints_set_;
750 #endif
714 751
715 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 752 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
716 }; 753 };
717 754
718 } // namespace cc 755 } // namespace cc
719 756
720 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 757 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/output/overlay_strategy_underlay.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698