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

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

Issue 23023005: cc: refcount resources as we send them to the parent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 4 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 | « no previous file | cc/output/delegating_renderer_unittest.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 #include "cc/layers/delegated_renderer_layer.h" 5 #include "cc/layers/delegated_renderer_layer.h"
6 6
7 #include "cc/layers/delegated_renderer_layer_client.h" 7 #include "cc/layers/delegated_renderer_layer_client.h"
8 #include "cc/layers/delegated_renderer_layer_impl.h" 8 #include "cc/layers/delegated_renderer_layer_impl.h"
9 #include "cc/output/delegated_frame_data.h" 9 #include "cc/output/delegated_frame_data.h"
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) { 61 void DelegatedRendererLayer::SetDisplaySize(gfx::Size size) {
62 if (display_size_ == size) 62 if (display_size_ == size)
63 return; 63 return;
64 display_size_ = size; 64 display_size_ = size;
65 SetNeedsCommit(); 65 SetNeedsCommit();
66 } 66 }
67 67
68 void DelegatedRendererLayer::SetFrameData( 68 void DelegatedRendererLayer::SetFrameData(
69 scoped_ptr<DelegatedFrameData> new_frame_data) { 69 scoped_ptr<DelegatedFrameData> new_frame_data) {
70 if (frame_data_) { 70 if (frame_data_) {
71 // Copy the resources from the last provided frame into the new frame, as 71 // Copy the resources from the last provided frame into the unused resources
72 // it may use resources that were transferred in the last frame. 72 // list, as the new frame will provide its own resources.
73 new_frame_data->resource_list.insert(new_frame_data->resource_list.end(), 73 unused_resources_for_child_compositor_.insert(
74 frame_data_->resource_list.begin(), 74 unused_resources_for_child_compositor_.end(),
75 frame_data_->resource_list.end()); 75 frame_data_->resource_list.begin(),
76 frame_data_->resource_list.end());
76 } 77 }
77 frame_data_ = new_frame_data.Pass(); 78 frame_data_ = new_frame_data.Pass();
78 if (!frame_data_->render_pass_list.empty()) { 79 if (!frame_data_->render_pass_list.empty()) {
79 RenderPass* root_pass = frame_data_->render_pass_list.back(); 80 RenderPass* root_pass = frame_data_->render_pass_list.back();
80 damage_in_frame_.Union(root_pass->damage_rect); 81 damage_in_frame_.Union(root_pass->damage_rect);
81 frame_size_ = root_pass->output_rect.size(); 82 frame_size_ = root_pass->output_rect.size();
82
83 // TODO(danakj): This could be optimized to only add resources to the
84 // frame_data_ if they are actually used in the frame. For now, it will
85 // cause the parent (this layer) to hold onto some resources it doesn't
86 // need to for an extra frame.
87 for (size_t i = 0; i < unused_resources_for_child_compositor_.size(); ++i) {
88 frame_data_->resource_list.push_back(
89 unused_resources_for_child_compositor_[i]);
90 }
91 unused_resources_for_child_compositor_.clear();
92 } else { 83 } else {
93 frame_size_ = gfx::Size(); 84 frame_size_ = gfx::Size();
94 } 85 }
95 SetNeedsCommit(); 86 SetNeedsCommit();
96 } 87 }
97 88
98 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor( 89 void DelegatedRendererLayer::TakeUnusedResourcesForChildCompositor(
99 TransferableResourceArray* array) { 90 TransferableResourceArray* array) {
100 DCHECK(array->empty()); 91 DCHECK(array->empty());
101 array->clear(); 92 array->clear();
102 93
103 array->swap(unused_resources_for_child_compositor_); 94 array->swap(unused_resources_for_child_compositor_);
104 } 95 }
105 96
106 bool DelegatedRendererLayer::BlocksPendingCommit() const { 97 bool DelegatedRendererLayer::BlocksPendingCommit() const {
107 // The active frame needs to be replaced and resources returned before the 98 // The active frame needs to be replaced and resources returned before the
108 // commit is called complete. This is true even whenever there may be 99 // commit is called complete. This is true even whenever there may be
109 // resources to return, regardless of if the layer will draw in its new 100 // resources to return, regardless of if the layer will draw in its new
110 // state. 101 // state.
111 return true; 102 return true;
112 } 103 }
113 104
114 } // namespace cc 105 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698