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

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

Issue 24078024: cc: Return resources to child compositor via a Callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deletechild: No AndReceiveAck needed, change STP Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.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 <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
18 #include "cc/base/cc_export.h" 19 #include "cc/base/cc_export.h"
19 #include "cc/output/context_provider.h" 20 #include "cc/output/context_provider.h"
20 #include "cc/output/output_surface.h" 21 #include "cc/output/output_surface.h"
21 #include "cc/resources/release_callback.h" 22 #include "cc/resources/release_callback.h"
22 #include "cc/resources/resource_format.h" 23 #include "cc/resources/resource_format.h"
24 #include "cc/resources/return_callback.h"
23 #include "cc/resources/single_release_callback.h" 25 #include "cc/resources/single_release_callback.h"
24 #include "cc/resources/texture_mailbox.h" 26 #include "cc/resources/texture_mailbox.h"
25 #include "cc/resources/transferable_resource.h" 27 #include "cc/resources/transferable_resource.h"
26 #include "third_party/khronos/GLES2/gl2.h" 28 #include "third_party/khronos/GLES2/gl2.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "third_party/skia/include/core/SkCanvas.h" 30 #include "third_party/skia/include/core/SkCanvas.h"
29 #include "ui/gfx/size.h" 31 #include "ui/gfx/size.h"
30 32
31 namespace WebKit { class WebGraphicsContext3D; } 33 namespace WebKit { class WebGraphicsContext3D; }
32 34
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 139
138 // Finish all context operations, causing any pending callbacks to be 140 // Finish all context operations, causing any pending callbacks to be
139 // scheduled. 141 // scheduled.
140 void Finish(); 142 void Finish();
141 143
142 // Only flush the command buffer if supported. 144 // Only flush the command buffer if supported.
143 // Returns true if the shallow flush occurred, false otherwise. 145 // Returns true if the shallow flush occurred, false otherwise.
144 bool ShallowFlushIfSupported(); 146 bool ShallowFlushIfSupported();
145 147
146 // Creates accounting for a child. Returns a child ID. 148 // Creates accounting for a child. Returns a child ID.
147 int CreateChild(); 149 int CreateChild(const ReturnCallback& return_callback);
148 150
149 // Destroys accounting for the child, deleting all accounted resources. 151 // Destroys accounting for the child, deleting all accounted resources.
150 void DestroyChild(int child); 152 void DestroyChild(int child);
151 153
152 // Gets the child->parent resource ID map. 154 // Gets the child->parent resource ID map.
153 const ResourceIdMap& GetChildToParentMap(int child) const; 155 const ResourceIdMap& GetChildToParentMap(int child) const;
154 156
155 // Prepares resources to be transfered to the parent, moving them to 157 // Prepares resources to be transfered to the parent, moving them to
156 // mailboxes and serializing meta-data into TransferableResources. 158 // mailboxes and serializing meta-data into TransferableResources.
157 // Resources are not removed from the ResourceProvider, but are marked as 159 // Resources are not removed from the ResourceProvider, but are marked as
158 // "in use". 160 // "in use".
159 void PrepareSendToParent(const ResourceIdArray& resources, 161 void PrepareSendToParent(const ResourceIdArray& resources,
160 TransferableResourceArray* transferable_resources); 162 TransferableResourceArray* transferable_resources);
161 163
162 // Prepares resources to be transfered back to the child, moving them to
163 // mailboxes and serializing meta-data into TransferableResources.
164 // Resources are removed from the ResourceProvider. Note: the resource IDs
165 // passed are in the parent namespace and will be translated to the child
166 // namespace when returned.
167 void PrepareSendReturnsToChild(int child,
168 const ResourceIdArray& resources,
169 ReturnedResourceArray* returned_resources);
170
171 // Receives resources from a child, moving them from mailboxes. Resource IDs 164 // Receives resources from a child, moving them from mailboxes. Resource IDs
172 // passed are in the child namespace, and will be translated to the parent 165 // passed are in the child namespace, and will be translated to the parent
173 // namespace, added to the child->parent map. 166 // namespace, added to the child->parent map.
167 // This adds the resources to the working set in the ResourceProvider without
168 // declaring which resources are in use. Use DeclareUsedResourcesFromChild
169 // after calling this method to do that. All calls to ReceiveFromChild should
170 // be followed by a DeclareUsedResourcesFromChild.
174 // NOTE: if the sync_point is set on any TransferableResource, this will 171 // NOTE: if the sync_point is set on any TransferableResource, this will
175 // wait on it. 172 // wait on it.
176 void ReceiveFromChild( 173 void ReceiveFromChild(
177 int child, const TransferableResourceArray& transferable_resources); 174 int child, const TransferableResourceArray& transferable_resources);
178 175
176 // Once a set of resources have been received, they may or may not be used.
177 // This declares what set of resources are currently in use from the child,
178 // releasing any other resources back to the child.
179 void DeclareUsedResourcesFromChild(
180 int child,
181 const ResourceIdArray& resources_from_child);
182
179 // Receives resources from the parent, moving them from mailboxes. Resource 183 // Receives resources from the parent, moving them from mailboxes. Resource
180 // IDs passed are in the child namespace. 184 // IDs passed are in the child namespace.
181 // NOTE: if the sync_point is set on any TransferableResource, this will 185 // NOTE: if the sync_point is set on any TransferableResource, this will
182 // wait on it. 186 // wait on it.
183 void ReceiveReturnsFromParent( 187 void ReceiveReturnsFromParent(
184 const ReturnedResourceArray& transferable_resources); 188 const ReturnedResourceArray& transferable_resources);
185 189
186 // The following lock classes are part of the ResourceProvider API and are 190 // The following lock classes are part of the ResourceProvider API and are
187 // needed to read and write the resource contents. The user must ensure 191 // needed to read and write the resource contents. The user must ensure
188 // that they only use GL locks on GL resources, etc, and this is enforced 192 // that they only use GL locks on GL resources, etc, and this is enforced
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 GLenum filter, 356 GLenum filter,
353 GLenum texture_pool, 357 GLenum texture_pool,
354 GLint wrap_mode, 358 GLint wrap_mode,
355 TextureUsageHint hint, 359 TextureUsageHint hint,
356 ResourceFormat format); 360 ResourceFormat format);
357 Resource(uint8_t* pixels, 361 Resource(uint8_t* pixels,
358 gfx::Size size, 362 gfx::Size size,
359 GLenum filter, 363 GLenum filter,
360 GLint wrap_mode); 364 GLint wrap_mode);
361 365
366 int child_id;
362 unsigned gl_id; 367 unsigned gl_id;
363 // Pixel buffer used for set pixels without unnecessary copying. 368 // Pixel buffer used for set pixels without unnecessary copying.
364 unsigned gl_pixel_buffer_id; 369 unsigned gl_pixel_buffer_id;
365 // Query used to determine when asynchronous set pixels complete. 370 // Query used to determine when asynchronous set pixels complete.
366 unsigned gl_upload_query_id; 371 unsigned gl_upload_query_id;
367 TextureMailbox mailbox; 372 TextureMailbox mailbox;
368 ReleaseCallback release_callback; 373 ReleaseCallback release_callback;
369 uint8_t* pixels; 374 uint8_t* pixels;
370 uint8_t* pixel_buffer; 375 uint8_t* pixel_buffer;
371 int lock_for_read_count; 376 int lock_for_read_count;
(...skipping 13 matching lines...) Expand all
385 GLenum filter; 390 GLenum filter;
386 GLenum target; 391 GLenum target;
387 unsigned image_id; 392 unsigned image_id;
388 GLenum texture_pool; 393 GLenum texture_pool;
389 GLint wrap_mode; 394 GLint wrap_mode;
390 TextureUsageHint hint; 395 TextureUsageHint hint;
391 ResourceType type; 396 ResourceType type;
392 ResourceFormat format; 397 ResourceFormat format;
393 }; 398 };
394 typedef base::hash_map<ResourceId, Resource> ResourceMap; 399 typedef base::hash_map<ResourceId, Resource> ResourceMap;
400
401 static bool CompareResourceMapIteratorsByChildId(
402 const std::pair<ReturnedResource, ResourceMap::iterator>& a,
403 const std::pair<ReturnedResource, ResourceMap::iterator>& b);
404
395 struct Child { 405 struct Child {
396 Child(); 406 Child();
397 ~Child(); 407 ~Child();
398 408
399 ResourceIdMap child_to_parent_map; 409 ResourceIdMap child_to_parent_map;
400 ResourceIdMap parent_to_child_map; 410 ResourceIdMap parent_to_child_map;
411 ReturnCallback return_callback;
412 ResourceIdSet in_use_resources;
401 }; 413 };
402 typedef base::hash_map<int, Child> ChildMap; 414 typedef base::hash_map<int, Child> ChildMap;
403 415
404 bool ReadLockFenceHasPassed(Resource* resource) { 416 bool ReadLockFenceHasPassed(Resource* resource) {
405 return !resource->read_lock_fence.get() || 417 return !resource->read_lock_fence.get() ||
406 resource->read_lock_fence->HasPassed(); 418 resource->read_lock_fence->HasPassed();
407 } 419 }
408 420
409 ResourceProvider(OutputSurface* output_surface, 421 ResourceProvider(OutputSurface* output_surface,
410 int highp_threshold_min, 422 int highp_threshold_min,
(...skipping 10 matching lines...) Expand all
421 const Resource* resource); 433 const Resource* resource);
422 434
423 void TransferResource(WebKit::WebGraphicsContext3D* context, 435 void TransferResource(WebKit::WebGraphicsContext3D* context,
424 ResourceId id, 436 ResourceId id,
425 TransferableResource* resource); 437 TransferableResource* resource);
426 enum DeleteStyle { 438 enum DeleteStyle {
427 Normal, 439 Normal,
428 ForShutdown, 440 ForShutdown,
429 }; 441 };
430 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); 442 void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style);
443 void DeleteAndReturnUnusedResourcesToChild(Child* child_info,
444 DeleteStyle style,
445 const ResourceIdArray& unused);
431 void LazyCreate(Resource* resource); 446 void LazyCreate(Resource* resource);
432 void LazyAllocate(Resource* resource); 447 void LazyAllocate(Resource* resource);
433 448
434 // Binds the given GL resource to a texture target for sampling using the 449 // Binds the given GL resource to a texture target for sampling using the
435 // specified filter for both minification and magnification. The resource 450 // specified filter for both minification and magnification. The resource
436 // must be locked for reading. 451 // must be locked for reading.
437 void BindForSampling(ResourceProvider::ResourceId resource_id, 452 void BindForSampling(ResourceProvider::ResourceId resource_id,
438 GLenum target, 453 GLenum target,
439 GLenum unit, 454 GLenum unit,
440 GLenum filter); 455 GLenum filter);
(...skipping 24 matching lines...) Expand all
465 480
466 scoped_refptr<Fence> current_read_lock_fence_; 481 scoped_refptr<Fence> current_read_lock_fence_;
467 bool use_rgba_4444_texture_format_; 482 bool use_rgba_4444_texture_format_;
468 483
469 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); 484 DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
470 }; 485 };
471 486
472 } // namespace cc 487 } // namespace cc
473 488
474 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_ 489 #endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698