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

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

Issue 2508203004: Add hints for potential overlay promotion on android. (Closed)
Patch Set: cleanup 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
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_set| 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_set);
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 // TODO(liberato): be sure that this is sent via IPC.
485 bool IsBackedBySurfaceTexture(ResourceId id);
486 #endif
487
474 void WaitSyncTokenIfNeeded(ResourceId id); 488 void WaitSyncTokenIfNeeded(ResourceId id);
475 489
476 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); 490 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl);
477 491
478 void ValidateResource(ResourceId id) const; 492 void ValidateResource(ResourceId id) const;
479 493
480 GLenum GetImageTextureTarget(gfx::BufferUsage usage, ResourceFormat format); 494 GLenum GetImageTextureTarget(gfx::BufferUsage usage, ResourceFormat format);
481 495
482 // base::trace_event::MemoryDumpProvider implementation. 496 // base::trace_event::MemoryDumpProvider implementation.
483 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, 497 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 int imported_count; 581 int imported_count;
568 int exported_count; 582 int exported_count;
569 bool dirty_image : 1; 583 bool dirty_image : 1;
570 bool locked_for_write : 1; 584 bool locked_for_write : 1;
571 bool lost : 1; 585 bool lost : 1;
572 bool marked_for_deletion : 1; 586 bool marked_for_deletion : 1;
573 bool allocated : 1; 587 bool allocated : 1;
574 bool read_lock_fences_enabled : 1; 588 bool read_lock_fences_enabled : 1;
575 bool has_shared_bitmap_id : 1; 589 bool has_shared_bitmap_id : 1;
576 bool is_overlay_candidate : 1; 590 bool is_overlay_candidate : 1;
591 #if defined(OS_ANDROID)
592 // Indicates whether this resource may not be overlayed on Android, since
593 // it's not backed by a SurfaceView. This may be set in combination with
594 // |is_overlay_candidate|, to find out if switching the resource to a
595 // a SurfaceView would result in overlay promotion. It's good to find this
596 // out in advance, since one has no fallback path for displaying a
597 // SurfaceView except via promoting it to an overlay. Ideally, one _could_
598 // promote SurfaceTexture via the overlay path, even if one ended up just
599 // drawing a quad in the compositor. However, for now, we use this flag to
600 // refuse to promote so that the compositor will draw the quad.
601 bool is_backed_by_surface_texture : 1;
602 // Indicates that this resource would like a promotion hint.
603 bool wants_promotion_hint : 1;
604 #endif
577 scoped_refptr<Fence> read_lock_fence; 605 scoped_refptr<Fence> read_lock_fence;
578 gfx::Size size; 606 gfx::Size size;
579 Origin origin; 607 Origin origin;
580 GLenum target; 608 GLenum target;
581 // TODO(skyostil): Use a separate sampler object for filter state. 609 // TODO(skyostil): Use a separate sampler object for filter state.
582 GLenum original_filter; 610 GLenum original_filter;
583 GLenum filter; 611 GLenum filter;
584 unsigned image_id; 612 unsigned image_id;
585 unsigned bound_image_id; 613 unsigned bound_image_id;
586 TextureHint hint; 614 TextureHint hint;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 // A process-unique ID used for disambiguating memory dumps from different 739 // A process-unique ID used for disambiguating memory dumps from different
712 // resource providers. 740 // resource providers.
713 int tracing_id_; 741 int tracing_id_;
714 742
715 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 743 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
716 }; 744 };
717 745
718 } // namespace cc 746 } // namespace cc
719 747
720 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 748 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698