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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void PrepareSendToParent(const ResourceIdArray& resources, | 148 void PrepareSendToParent(const ResourceIdArray& resources, |
149 TransferableResourceArray* transferable_resources); | 149 TransferableResourceArray* transferable_resources); |
150 | 150 |
151 // Prepares resources to be transfered back to the child, moving them to | 151 // Prepares resources to be transfered back to the child, moving them to |
152 // mailboxes and serializing meta-data into TransferableResources. | 152 // mailboxes and serializing meta-data into TransferableResources. |
153 // Resources are removed from the ResourceProvider. Note: the resource IDs | 153 // Resources are removed from the ResourceProvider. Note: the resource IDs |
154 // passed are in the parent namespace and will be translated to the child | 154 // passed are in the parent namespace and will be translated to the child |
155 // namespace when returned. | 155 // namespace when returned. |
156 void PrepareSendToChild(int child, | 156 void PrepareSendToChild(int child, |
157 const ResourceIdArray& resources, | 157 const ResourceIdArray& resources, |
158 TransferableResourceArray* transferable_resources); | 158 ReturnedResourceArray* returned_resources); |
159 | 159 |
160 // Receives resources from a child, moving them from mailboxes. Resource IDs | 160 // Receives resources from a child, moving them from mailboxes. Resource IDs |
161 // passed are in the child namespace, and will be translated to the parent | 161 // passed are in the child namespace, and will be translated to the parent |
162 // namespace, added to the child->parent map. | 162 // namespace, added to the child->parent map. |
163 // NOTE: if the sync_point is set on any TransferableResource, this will | 163 // NOTE: if the sync_point is set on any TransferableResource, this will |
164 // wait on it. | 164 // wait on it. |
165 void ReceiveFromChild( | 165 void ReceiveFromChild( |
166 int child, const TransferableResourceArray& transferable_resources); | 166 int child, const TransferableResourceArray& transferable_resources); |
167 | 167 |
168 // Receives resources from the parent, moving them from mailboxes. Resource | 168 // Receives resources from the parent, moving them from mailboxes. Resource |
169 // IDs passed are in the child namespace. | 169 // IDs passed are in the child namespace. |
170 // NOTE: if the sync_point is set on any TransferableResource, this will | 170 // NOTE: if the sync_point is set on any TransferableResource, this will |
171 // wait on it. | 171 // wait on it. |
172 void ReceiveFromParent( | 172 void ReceiveFromParent(const ReturnedResourceArray& transferable_resources); |
173 const TransferableResourceArray& transferable_resources); | |
174 | 173 |
175 // The following lock classes are part of the ResourceProvider API and are | 174 // The following lock classes are part of the ResourceProvider API and are |
176 // needed to read and write the resource contents. The user must ensure | 175 // needed to read and write the resource contents. The user must ensure |
177 // that they only use GL locks on GL resources, etc, and this is enforced | 176 // that they only use GL locks on GL resources, etc, and this is enforced |
178 // by assertions. | 177 // by assertions. |
179 class CC_EXPORT ScopedReadLockGL { | 178 class CC_EXPORT ScopedReadLockGL { |
180 public: | 179 public: |
181 ScopedReadLockGL(ResourceProvider* resource_provider, | 180 ScopedReadLockGL(ResourceProvider* resource_provider, |
182 ResourceProvider::ResourceId resource_id); | 181 ResourceProvider::ResourceId resource_id); |
183 virtual ~ScopedReadLockGL(); | 182 virtual ~ScopedReadLockGL(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 bool ReadLockFenceHasPassed(Resource* resource) { | 385 bool ReadLockFenceHasPassed(Resource* resource) { |
387 return !resource->read_lock_fence.get() || | 386 return !resource->read_lock_fence.get() || |
388 resource->read_lock_fence->HasPassed(); | 387 resource->read_lock_fence->HasPassed(); |
389 } | 388 } |
390 | 389 |
391 explicit ResourceProvider(OutputSurface* output_surface, | 390 explicit ResourceProvider(OutputSurface* output_surface, |
392 int highp_threshold_min); | 391 int highp_threshold_min); |
393 | 392 |
394 void CleanUpGLIfNeeded(); | 393 void CleanUpGLIfNeeded(); |
395 | 394 |
| 395 Resource* GetResource(ResourceId id); |
396 const Resource* LockForRead(ResourceId id); | 396 const Resource* LockForRead(ResourceId id); |
397 void UnlockForRead(ResourceId id); | 397 void UnlockForRead(ResourceId id); |
398 const Resource* LockForWrite(ResourceId id); | 398 const Resource* LockForWrite(ResourceId id); |
399 void UnlockForWrite(ResourceId id); | 399 void UnlockForWrite(ResourceId id); |
400 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, | 400 static void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, |
401 const Resource* resource); | 401 const Resource* resource); |
402 | 402 |
403 void TransferResource(WebKit::WebGraphicsContext3D* context, | 403 void TransferResource(WebKit::WebGraphicsContext3D* context, |
404 ResourceId id, | 404 ResourceId id, |
405 TransferableResource* resource); | 405 TransferableResource* resource); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 base::ThreadChecker thread_checker_; | 443 base::ThreadChecker thread_checker_; |
444 | 444 |
445 scoped_refptr<Fence> current_read_lock_fence_; | 445 scoped_refptr<Fence> current_read_lock_fence_; |
446 | 446 |
447 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 447 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
448 }; | 448 }; |
449 | 449 |
450 } // namespace cc | 450 } // namespace cc |
451 | 451 |
452 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ | 452 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ |
OLD | NEW |