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

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/property_tree_builder.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 27 matching lines...) Expand all
38 #include "cc/trees/occlusion_tracker.h" 38 #include "cc/trees/occlusion_tracker.h"
39 #include "cc/trees/property_tree.h" 39 #include "cc/trees/property_tree.h"
40 #include "cc/trees/property_tree_builder.h" 40 #include "cc/trees/property_tree_builder.h"
41 #include "ui/gfx/geometry/box_f.h" 41 #include "ui/gfx/geometry/box_f.h"
42 #include "ui/gfx/geometry/point_conversions.h" 42 #include "ui/gfx/geometry/point_conversions.h"
43 #include "ui/gfx/geometry/size_conversions.h" 43 #include "ui/gfx/geometry/size_conversions.h"
44 #include "ui/gfx/geometry/vector2d_conversions.h" 44 #include "ui/gfx/geometry/vector2d_conversions.h"
45 45
46 namespace cc { 46 namespace cc {
47 47
48 namespace {
49
50 const uint32_t kMainLayerFlags =
51 LayerTreeMutation::MUTATION_OPACITY | LayerTreeMutation::MUTATION_TRANSFORM;
52 const uint32_t kScrollLayerFlags = LayerTreeMutation::MUTATION_SCROLL_LEFT |
53 LayerTreeMutation::MUTATION_SCROLL_TOP;
54
55 } // namespace
56
48 LayerTreeImpl::LayerTreeImpl( 57 LayerTreeImpl::LayerTreeImpl(
49 LayerTreeHostImpl* layer_tree_host_impl, 58 LayerTreeHostImpl* layer_tree_host_impl,
50 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, 59 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor,
51 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, 60 scoped_refptr<SyncedTopControls> top_controls_shown_ratio,
52 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) 61 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll)
53 : layer_tree_host_impl_(layer_tree_host_impl), 62 : layer_tree_host_impl_(layer_tree_host_impl),
54 source_frame_number_(-1), 63 source_frame_number_(-1),
55 is_first_frame_after_commit_tracker_(-1), 64 is_first_frame_after_commit_tracker_(-1),
56 hud_layer_(0), 65 hud_layer_(0),
57 background_color_(0), 66 background_color_(0),
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (hud_layer()) 361 if (hud_layer())
353 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( 362 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(
354 LayerTreeHostCommon::FindLayerInSubtree( 363 LayerTreeHostCommon::FindLayerInSubtree(
355 target_tree->root_layer(), hud_layer()->id()))); 364 target_tree->root_layer(), hud_layer()->id())));
356 else 365 else
357 target_tree->set_hud_layer(NULL); 366 target_tree->set_hud_layer(NULL);
358 367
359 target_tree->has_ever_been_drawn_ = false; 368 target_tree->has_ever_been_drawn_ = false;
360 } 369 }
361 370
371 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) {
372 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap",
373 "element_id", layer->element_id(), "layer_id", layer->id());
374 ElementLayers& layers = element_layers_map_[layer->element_id()];
375 if (layer->mutable_properties() & kMainLayerFlags) {
376 if (!layers.main || layer->IsActive())
377 layers.main = layer;
378 }
379 if (layer->mutable_properties() & kScrollLayerFlags) {
380 if (!layers.scroll || layer->IsActive()) {
381 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap scroll",
382 "element_id", layer->element_id(), "layer_id", layer->id());
383 layers.scroll = layer;
384 }
385 }
386 }
387
388 void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) {
389 TRACE_EVENT2("compositor-worker", "LayerTreeImpl::RemoveFromElementMap",
390 "element_id", layer->element_id(), "layer_id", layer->id());
391 ElementLayers& layers = element_layers_map_[layer->element_id()];
392 if (layer->mutable_properties() & kMainLayerFlags)
393 layers.main = nullptr;
394 if (layer->mutable_properties() & kScrollLayerFlags)
395 layers.scroll = nullptr;
396
397 if (!layers.main && !layers.scroll)
398 element_layers_map_.erase(layer->element_id());
399 }
400
401 bool LayerTreeImpl::GetMutableLayers(uint64_t element_id,
402 ElementLayers* element_layers) {
403 auto iter = element_layers_map_.find(element_id);
404 if (iter == element_layers_map_.end())
405 return false;
406
407 *element_layers = iter->second;
408 return true;
409 }
410
362 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { 411 LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const {
363 return InnerViewportScrollLayer() 412 return InnerViewportScrollLayer()
364 ? InnerViewportScrollLayer()->scroll_clip_layer() 413 ? InnerViewportScrollLayer()->scroll_clip_layer()
365 : NULL; 414 : NULL;
366 } 415 }
367 416
368 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { 417 LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const {
369 return OuterViewportScrollLayer() 418 return OuterViewportScrollLayer()
370 ? OuterViewportScrollLayer()->scroll_clip_layer() 419 ? OuterViewportScrollLayer()->scroll_clip_layer()
371 : NULL; 420 : NULL;
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 const gfx::BoxF& box, 1994 const gfx::BoxF& box,
1946 gfx::BoxF* bounds) const { 1995 gfx::BoxF* bounds) const {
1947 *bounds = gfx::BoxF(); 1996 *bounds = gfx::BoxF();
1948 return layer_tree_host_impl_->animation_host() 1997 return layer_tree_host_impl_->animation_host()
1949 ? layer_tree_host_impl_->animation_host() 1998 ? layer_tree_host_impl_->animation_host()
1950 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) 1999 ->TransformAnimationBoundsForBox(layer->id(), box, bounds)
1951 : true; 2000 : true;
1952 } 2001 }
1953 2002
1954 } // namespace cc 2003 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698