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

Side by Side Diff: cc/layers/delegated_frame_resource_collection.cc

Issue 26023004: aura: Allow delegated frames to be used by more than one impl layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: frameprovider: are_layers_attached checks Created 7 years, 2 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_frame_resource_collection.h ('k') | cc/layers/delegated_renderer_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/layers/delegated_frame_resource_collection.h"
6
7 #include "base/bind.h"
8 #include "cc/trees/blocking_task_runner.h"
9
10 namespace cc {
11
12 DelegatedFrameResourceCollection::DelegatedFrameResourceCollection()
13 : client_(NULL), main_thread_runner_(BlockingTaskRunner::current()) {
14 DCHECK(main_thread_checker_.CalledOnValidThread());
15 }
16
17 DelegatedFrameResourceCollection::~DelegatedFrameResourceCollection() {
18 DCHECK(main_thread_checker_.CalledOnValidThread());
19 }
20
21 void DelegatedFrameResourceCollection::SetClient(
22 DelegatedFrameResourceCollectionClient* client) {
23 client_ = client;
24 }
25
26 void DelegatedFrameResourceCollection::TakeUnusedResourcesForChildCompositor(
27 ReturnedResourceArray* array) {
28 DCHECK(main_thread_checker_.CalledOnValidThread());
29 DCHECK(array->empty());
30 array->swap(returned_resources_for_child_compositor_);
31 }
32
33 void DelegatedFrameResourceCollection::ReceivedResources(
34 const TransferableResourceArray& resources) {
35 DCHECK(main_thread_checker_.CalledOnValidThread());
36 for (size_t i = 0; i < resources.size(); ++i)
37 resource_id_ref_count_map_[resources[i].id].refs_to_return++;
38 }
39
40 void DelegatedFrameResourceCollection::UnrefResources(
41 const ReturnedResourceArray& returned) {
42 DCHECK(main_thread_checker_.CalledOnValidThread());
43
44 ReturnedResourceArray to_return;
45
46 for (size_t i = 0; i < returned.size(); ++i) {
47 ResourceIdRefCountMap::iterator it =
48 resource_id_ref_count_map_.find(returned[i].id);
49 DCHECK(it != resource_id_ref_count_map_.end());
50 DCHECK_GE(it->second.refs_to_wait_for, returned[i].count);
51 it->second.refs_to_wait_for -= returned[i].count;
52 if (it->second.refs_to_wait_for == 0) {
53 to_return.push_back(returned[i]);
54 to_return.back().count = it->second.refs_to_return;
55 resource_id_ref_count_map_.erase(it);
56 }
57 }
58
59 if (to_return.empty())
60 return;
61
62 returned_resources_for_child_compositor_.insert(
63 returned_resources_for_child_compositor_.end(),
64 to_return.begin(),
65 to_return.end());
66 if (client_)
67 client_->UnusedResourcesAreAvailable();
68 }
69
70 void DelegatedFrameResourceCollection::RefResources(
71 const TransferableResourceArray& resources) {
72 DCHECK(main_thread_checker_.CalledOnValidThread());
73 for (size_t i = 0; i < resources.size(); ++i)
74 resource_id_ref_count_map_[resources[i].id].refs_to_wait_for++;
75 }
76
77 ReturnCallback
78 DelegatedFrameResourceCollection::GetReturnResourcesCallbackForImplThread() {
79 return base::Bind(
80 &DelegatedFrameResourceCollection::UnrefResourcesOnImplThread,
81 this,
82 main_thread_runner_);
83 }
84
85 void DelegatedFrameResourceCollection::UnrefResourcesOnImplThread(
86 scoped_refptr<BlockingTaskRunner> main_thread_runner,
87 const ReturnedResourceArray& returned) {
88 main_thread_runner->PostTask(
89 FROM_HERE,
90 base::Bind(
91 &DelegatedFrameResourceCollection::UnrefResources, this, returned));
92 }
93
94 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_frame_resource_collection.h ('k') | cc/layers/delegated_renderer_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698