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

Side by Side Diff: cc/blimp/layer_tree_host_remote.cc

Issue 2467043002: cc/blimp: Eliminate Layer updates for common cases. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/blimp/layer_tree_host_remote.h" 5 #include "cc/blimp/layer_tree_host_remote.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 11 matching lines...) Expand all
22 #include "cc/trees/task_runner_provider.h" 22 #include "cc/trees/task_runner_provider.h"
23 #include "ui/gfx/geometry/scroll_offset.h" 23 #include "ui/gfx/geometry/scroll_offset.h"
24 24
25 namespace cc { 25 namespace cc {
26 namespace { 26 namespace {
27 // We use a 16ms default frame interval because the rate at which the engine 27 // We use a 16ms default frame interval because the rate at which the engine
28 // produces main frames doesn't matter. 28 // produces main frames doesn't matter.
29 base::TimeDelta kDefaultFrameInterval = base::TimeDelta::FromMilliseconds(16); 29 base::TimeDelta kDefaultFrameInterval = base::TimeDelta::FromMilliseconds(16);
30 30
31 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; 31 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number;
32
33 bool ShouldUpdateLayer(Layer* layer) {
34 // If the embedder has marked the layer as non-drawable.
35 if (!layer->DrawsContent())
36 return false;
37
38 // If the layer bounds are empty.
39 if (layer->bounds().IsEmpty())
40 return false;
41
42 // If the layer is transparent and has no background filters applied.
43 // See EffectTree::UpdateIsDrawn for the logic details.
44 // A few things have been ignored:
45 // 1) We don't support threaded animations at the moment, so the opacity can
46 // not change on the client.
47 // 2) This does not account for layer hiding its subtree, but that is never
48 // used by the renderer.
ajuma 2016/11/01 19:27:58 It's true that the renderer never uses the HideLay
Khushal 2016/11/01 21:09:01 You're right, thanks! I've added that in the comme
ajuma 2016/11/01 21:37:07 Right, a mask layer shouldn't have children, the m
Khushal 2016/11/01 21:42:23 Ohh, makes sense. Would it be a good idea to add a
ajuma 2016/11/01 21:47:20 Yes, that's an excellent idea!
Khushal 2016/11/01 23:21:00 Done. :)
49 if (layer->opacity() == 0.f && layer->background_filters().IsEmpty())
50 return false;
51
52 return true;
53 }
54
32 } // namespace 55 } // namespace
33 56
34 LayerTreeHostRemote::InitParams::InitParams() = default; 57 LayerTreeHostRemote::InitParams::InitParams() = default;
35 58
36 LayerTreeHostRemote::InitParams::~InitParams() = default; 59 LayerTreeHostRemote::InitParams::~InitParams() = default;
37 60
38 LayerTreeHostRemote::LayerTreeHostRemote(InitParams* params) 61 LayerTreeHostRemote::LayerTreeHostRemote(InitParams* params)
39 : LayerTreeHostRemote( 62 : LayerTreeHostRemote(
40 params, 63 params,
41 base::MakeUnique<LayerTree>(std::move(params->animation_host), 64 base::MakeUnique<LayerTree>(std::move(params->animation_host),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 379
357 current_pipeline_stage_ = FramePipelineStage::UPDATE_LAYERS; 380 current_pipeline_stage_ = FramePipelineStage::UPDATE_LAYERS;
358 LayerList layer_list; 381 LayerList layer_list;
359 if (max_pipeline_stage_for_current_frame_ >= 382 if (max_pipeline_stage_for_current_frame_ >=
360 FramePipelineStage::UPDATE_LAYERS) { 383 FramePipelineStage::UPDATE_LAYERS) {
361 // Pull updates for all layers from the client. 384 // Pull updates for all layers from the client.
362 // TODO(khushalsagar): Investigate the data impact from updating all the 385 // TODO(khushalsagar): Investigate the data impact from updating all the
363 // layers. See crbug.com/650885. 386 // layers. See crbug.com/650885.
364 LayerTreeHostCommon::CallFunctionForEveryLayer( 387 LayerTreeHostCommon::CallFunctionForEveryLayer(
365 layer_tree_.get(), [&layer_list](Layer* layer) { 388 layer_tree_.get(), [&layer_list](Layer* layer) {
389 if (!ShouldUpdateLayer(layer))
390 return;
366 layer->SavePaintProperties(); 391 layer->SavePaintProperties();
367 layer_list.push_back(layer); 392 layer_list.push_back(layer);
368 }); 393 });
369 394
370 bool content_is_suitable_for_gpu = false; 395 bool content_is_suitable_for_gpu = false;
371 bool layers_updated = 396 bool layers_updated =
372 layer_tree_->UpdateLayers(layer_list, &content_is_suitable_for_gpu); 397 layer_tree_->UpdateLayers(layer_list, &content_is_suitable_for_gpu);
373 398
374 // If pulling layer updates resulted in any content updates, we need to go 399 // If pulling layer updates resulted in any content updates, we need to go
375 // till the commit stage. 400 // till the commit stage.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 layer_tree_host_proto->mutable_layer_updates(), inputs_only); 518 layer_tree_host_proto->mutable_layer_updates(), inputs_only);
494 layer_tree_->LayersThatShouldPushProperties().clear(); 519 layer_tree_->LayersThatShouldPushProperties().clear();
495 520
496 std::vector<PictureData> pictures = 521 std::vector<PictureData> pictures =
497 engine_picture_cache_->CalculateCacheUpdateAndFlush(); 522 engine_picture_cache_->CalculateCacheUpdateAndFlush();
498 proto::PictureDataVectorToSkPicturesProto( 523 proto::PictureDataVectorToSkPicturesProto(
499 pictures, layer_tree_host_proto->mutable_pictures()); 524 pictures, layer_tree_host_proto->mutable_pictures());
500 } 525 }
501 526
502 } // namespace cc 527 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698