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