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

Side by Side Diff: cc/delegated_renderer_layer_impl.cc

Issue 12328118: cc: DelegatedRendererLayer creates a ChildId with the ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/delegated_renderer_layer_impl.h ('k') | cc/layer_tree_host_impl.h » ('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/delegated_renderer_layer_impl.h" 5 #include "cc/delegated_renderer_layer_impl.h"
6 6
7 #include "cc/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/layer_tree_impl.h"
8 #include "cc/math_util.h" 9 #include "cc/math_util.h"
9 #include "cc/quad_sink.h" 10 #include "cc/quad_sink.h"
10 #include "cc/render_pass_draw_quad.h" 11 #include "cc/render_pass_draw_quad.h"
11 #include "cc/render_pass_sink.h" 12 #include "cc/render_pass_sink.h"
12 13
13 namespace cc { 14 namespace cc {
14 15
15 DelegatedRendererLayerImpl::DelegatedRendererLayerImpl( 16 DelegatedRendererLayerImpl::DelegatedRendererLayerImpl(
16 LayerTreeImpl* tree_impl, int id) 17 LayerTreeImpl* tree_impl, int id)
17 : LayerImpl(tree_impl, id) { 18 : LayerImpl(tree_impl, id),
19 child_id_(0) {
18 } 20 }
19 21
20 DelegatedRendererLayerImpl::~DelegatedRendererLayerImpl() { 22 DelegatedRendererLayerImpl::~DelegatedRendererLayerImpl() {
21 ClearRenderPasses(); 23 ClearRenderPasses();
24 ClearChildId();
22 } 25 }
23 26
24 bool DelegatedRendererLayerImpl::hasDelegatedContent() const { 27 bool DelegatedRendererLayerImpl::hasDelegatedContent() const {
25 return !render_passes_in_draw_order_.empty(); 28 return !render_passes_in_draw_order_.empty();
26 } 29 }
27 30
28 bool DelegatedRendererLayerImpl::hasContributingDelegatedRenderPasses() const { 31 bool DelegatedRendererLayerImpl::hasContributingDelegatedRenderPasses() const {
29 // The root RenderPass for the layer is merged with its target 32 // The root RenderPass for the layer is merged with its target
30 // RenderPass in each frame. So we only have extra RenderPasses 33 // RenderPass in each frame. So we only have extra RenderPasses
31 // to merge when we have a non-root RenderPass present. 34 // to merge when we have a non-root RenderPass present.
(...skipping 21 matching lines...) Expand all
53 if (!render_passes_in_draw_order_.empty()) 56 if (!render_passes_in_draw_order_.empty())
54 render_passes_in_draw_order_.back()->damage_rect.Union(old_root_damage); 57 render_passes_in_draw_order_.back()->damage_rect.Union(old_root_damage);
55 } 58 }
56 59
57 void DelegatedRendererLayerImpl::ClearRenderPasses() { 60 void DelegatedRendererLayerImpl::ClearRenderPasses() {
58 // FIXME: Release the resources back to the nested compositor. 61 // FIXME: Release the resources back to the nested compositor.
59 render_passes_index_by_id_.clear(); 62 render_passes_index_by_id_.clear();
60 render_passes_in_draw_order_.clear(); 63 render_passes_in_draw_order_.clear();
61 } 64 }
62 65
63 scoped_ptr<LayerImpl> DelegatedRendererLayerImpl::createLayerImpl(LayerTreeImpl* treeImpl) 66 scoped_ptr<LayerImpl> DelegatedRendererLayerImpl::createLayerImpl(
64 { 67 LayerTreeImpl* treeImpl) {
65 return DelegatedRendererLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>( ); 68 return DelegatedRendererLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>();
66 } 69 }
67 70
68 void DelegatedRendererLayerImpl::didLoseOutputSurface() { 71 void DelegatedRendererLayerImpl::didLoseOutputSurface() {
69 ClearRenderPasses(); 72 ClearRenderPasses();
73 ClearChildId();
70 } 74 }
71 75
72 static inline int IndexToId(int index) { return index + 1; } 76 static inline int IndexToId(int index) { return index + 1; }
73 static inline int IdToIndex(int id) { return id - 1; } 77 static inline int IdToIndex(int id) { return id - 1; }
74 78
75 RenderPass::Id DelegatedRendererLayerImpl::firstContributingRenderPassId() 79 RenderPass::Id DelegatedRendererLayerImpl::firstContributingRenderPassId()
76 const { 80 const {
77 return RenderPass::Id(id(), IndexToId(0)); 81 return RenderPass::Id(id(), IndexToId(0));
78 } 82 }
79 83
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 DCHECK(output_quad.get()); 225 DCHECK(output_quad.get());
222 226
223 quad_sink->append(output_quad.Pass(), *append_quads_data); 227 quad_sink->append(output_quad.Pass(), *append_quads_data);
224 } 228 }
225 } 229 }
226 230
227 const char* DelegatedRendererLayerImpl::layerTypeAsString() const { 231 const char* DelegatedRendererLayerImpl::layerTypeAsString() const {
228 return "DelegatedRendererLayer"; 232 return "DelegatedRendererLayer";
229 } 233 }
230 234
235 void DelegatedRendererLayerImpl::CreateChildIdIfNeeded() {
236 if (child_id_)
237 return;
238
239 ResourceProvider* resource_provider = layerTreeImpl()->resource_provider();
240 child_id_ = resource_provider->createChild();
241 }
242
243 void DelegatedRendererLayerImpl::ClearChildId() {
244 if (!child_id_)
245 return;
246
247 ResourceProvider* resource_provider = layerTreeImpl()->resource_provider();
248 resource_provider->destroyChild(child_id_);
249 child_id_ = 0;
250 }
251
231 } // namespace cc 252 } // namespace cc
OLDNEW
« no previous file with comments | « cc/delegated_renderer_layer_impl.h ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698