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

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

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added DCHECK for valid sync token before IPC conversions Created 5 years, 1 month 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 <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 bool ShallowFlushIfSupported(); 156 bool ShallowFlushIfSupported();
157 157
158 // Creates accounting for a child. Returns a child ID. 158 // Creates accounting for a child. Returns a child ID.
159 int CreateChild(const ReturnCallback& return_callback); 159 int CreateChild(const ReturnCallback& return_callback);
160 160
161 // Destroys accounting for the child, deleting all accounted resources. 161 // Destroys accounting for the child, deleting all accounted resources.
162 void DestroyChild(int child); 162 void DestroyChild(int child);
163 163
164 // Sets whether resources need sync points set on them when returned to this 164 // Sets whether resources need sync points set on them when returned to this
165 // child. Defaults to true. 165 // child. Defaults to true.
166 void SetChildNeedsSyncPoints(int child, bool needs_sync_points); 166 void SetChildNeedsSyncTokens(int child, bool needs_sync_tokens);
167 167
168 // Gets the child->parent resource ID map. 168 // Gets the child->parent resource ID map.
169 const ResourceIdMap& GetChildToParentMap(int child) const; 169 const ResourceIdMap& GetChildToParentMap(int child) const;
170 170
171 // Prepares resources to be transfered to the parent, moving them to 171 // Prepares resources to be transfered to the parent, moving them to
172 // mailboxes and serializing meta-data into TransferableResources. 172 // mailboxes and serializing meta-data into TransferableResources.
173 // Resources are not removed from the ResourceProvider, but are marked as 173 // Resources are not removed from the ResourceProvider, but are marked as
174 // "in use". 174 // "in use".
175 void PrepareSendToParent(const ResourceIdArray& resources, 175 void PrepareSendToParent(const ResourceIdArray& resources,
176 TransferableResourceArray* transferable_resources); 176 TransferableResourceArray* transferable_resources);
177 177
178 // Receives resources from a child, moving them from mailboxes. Resource IDs 178 // Receives resources from a child, moving them from mailboxes. Resource IDs
179 // passed are in the child namespace, and will be translated to the parent 179 // passed are in the child namespace, and will be translated to the parent
180 // namespace, added to the child->parent map. 180 // namespace, added to the child->parent map.
181 // This adds the resources to the working set in the ResourceProvider without 181 // This adds the resources to the working set in the ResourceProvider without
182 // declaring which resources are in use. Use DeclareUsedResourcesFromChild 182 // declaring which resources are in use. Use DeclareUsedResourcesFromChild
183 // after calling this method to do that. All calls to ReceiveFromChild should 183 // after calling this method to do that. All calls to ReceiveFromChild should
184 // be followed by a DeclareUsedResourcesFromChild. 184 // be followed by a DeclareUsedResourcesFromChild.
185 // NOTE: if the sync_point is set on any TransferableResource, this will 185 // NOTE: if the sync_token is set on any TransferableResource, this will
186 // wait on it. 186 // wait on it.
187 void ReceiveFromChild( 187 void ReceiveFromChild(
188 int child, const TransferableResourceArray& transferable_resources); 188 int child, const TransferableResourceArray& transferable_resources);
189 189
190 // Once a set of resources have been received, they may or may not be used. 190 // Once a set of resources have been received, they may or may not be used.
191 // This declares what set of resources are currently in use from the child, 191 // This declares what set of resources are currently in use from the child,
192 // releasing any other resources back to the child. 192 // releasing any other resources back to the child.
193 void DeclareUsedResourcesFromChild(int child, 193 void DeclareUsedResourcesFromChild(int child,
194 const ResourceIdSet& resources_from_child); 194 const ResourceIdSet& resources_from_child);
195 195
196 // Receives resources from the parent, moving them from mailboxes. Resource 196 // Receives resources from the parent, moving them from mailboxes. Resource
197 // IDs passed are in the child namespace. 197 // IDs passed are in the child namespace.
198 // NOTE: if the sync_point is set on any TransferableResource, this will 198 // NOTE: if the sync_token is set on any TransferableResource, this will
199 // wait on it. 199 // wait on it.
200 void ReceiveReturnsFromParent( 200 void ReceiveReturnsFromParent(
201 const ReturnedResourceArray& transferable_resources); 201 const ReturnedResourceArray& transferable_resources);
202 202
203 // The following lock classes are part of the ResourceProvider API and are 203 // The following lock classes are part of the ResourceProvider API and are
204 // needed to read and write the resource contents. The user must ensure 204 // needed to read and write the resource contents. The user must ensure
205 // that they only use GL locks on GL resources, etc, and this is enforced 205 // that they only use GL locks on GL resources, etc, and this is enforced
206 // by assertions. 206 // by assertions.
207 class CC_EXPORT ScopedReadLockGL { 207 class CC_EXPORT ScopedReadLockGL {
208 public: 208 public:
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // and has read fences enabled, the resource will not allow writes 406 // and has read fences enabled, the resource will not allow writes
407 // until this fence has passed. 407 // until this fence has passed.
408 void SetReadLockFence(Fence* fence) { current_read_lock_fence_ = fence; } 408 void SetReadLockFence(Fence* fence) { current_read_lock_fence_ = fence; }
409 409
410 // Indicates if we can currently lock this resource for write. 410 // Indicates if we can currently lock this resource for write.
411 bool CanLockForWrite(ResourceId id); 411 bool CanLockForWrite(ResourceId id);
412 412
413 // Indicates if this resource may be used for a hardware overlay plane. 413 // Indicates if this resource may be used for a hardware overlay plane.
414 bool IsOverlayCandidate(ResourceId id); 414 bool IsOverlayCandidate(ResourceId id);
415 415
416 void WaitSyncPointIfNeeded(ResourceId id); 416 void WaitSyncTokenIfNeeded(ResourceId id);
417 417
418 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); 418 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl);
419 419
420 OutputSurface* output_surface() { return output_surface_; } 420 OutputSurface* output_surface() { return output_surface_; }
421 421
422 void ValidateResource(ResourceId id) const; 422 void ValidateResource(ResourceId id) const;
423 423
424 GLenum GetImageTextureTarget(ResourceFormat format); 424 GLenum GetImageTextureTarget(ResourceFormat format);
425 425
426 // base::trace_event::MemoryDumpProvider implementation. 426 // base::trace_event::MemoryDumpProvider implementation.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 typedef base::hash_map<ResourceId, Resource> ResourceMap; 502 typedef base::hash_map<ResourceId, Resource> ResourceMap;
503 503
504 struct Child { 504 struct Child {
505 Child(); 505 Child();
506 ~Child(); 506 ~Child();
507 507
508 ResourceIdMap child_to_parent_map; 508 ResourceIdMap child_to_parent_map;
509 ResourceIdMap parent_to_child_map; 509 ResourceIdMap parent_to_child_map;
510 ReturnCallback return_callback; 510 ReturnCallback return_callback;
511 bool marked_for_deletion; 511 bool marked_for_deletion;
512 bool needs_sync_points; 512 bool needs_sync_tokens;
513 }; 513 };
514 typedef base::hash_map<int, Child> ChildMap; 514 typedef base::hash_map<int, Child> ChildMap;
515 515
516 bool ReadLockFenceHasPassed(const Resource* resource) { 516 bool ReadLockFenceHasPassed(const Resource* resource) {
517 return !resource->read_lock_fence.get() || 517 return !resource->read_lock_fence.get() ||
518 resource->read_lock_fence->HasPassed(); 518 resource->read_lock_fence->HasPassed();
519 } 519 }
520 520
521 ResourceId CreateGLTexture(const gfx::Size& size, 521 ResourceId CreateGLTexture(const gfx::Size& size,
522 GLenum target, 522 GLenum target,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // A process-unique ID used for disambiguating memory dumps from different 593 // A process-unique ID used for disambiguating memory dumps from different
594 // resource providers. 594 // resource providers.
595 int tracing_id_; 595 int tracing_id_;
596 596
597 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 597 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
598 }; 598 };
599 599
600 } // namespace cc 600 } // namespace cc
601 601
602 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 602 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698