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

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

Issue 2467043002: cc/blimp: Eliminate Layer updates for common cases. (Closed)
Patch Set: test update 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
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.
49 // 3) Also updates a transparent layer's subtree when it will be skipped while
50 // drawing on the client.
51 if (layer->opacity() == 0.f && layer->background_filters().IsEmpty())
52 return false;
53
54 return true;
55 }
56
32 } // namespace 57 } // namespace
33 58
34 LayerTreeHostRemote::InitParams::InitParams() = default; 59 LayerTreeHostRemote::InitParams::InitParams() = default;
35 60
36 LayerTreeHostRemote::InitParams::~InitParams() = default; 61 LayerTreeHostRemote::InitParams::~InitParams() = default;
37 62
38 LayerTreeHostRemote::LayerTreeHostRemote(InitParams* params) 63 LayerTreeHostRemote::LayerTreeHostRemote(InitParams* params)
39 : LayerTreeHostRemote( 64 : LayerTreeHostRemote(
40 params, 65 params,
41 base::MakeUnique<LayerTree>(std::move(params->animation_host), 66 base::MakeUnique<LayerTree>(std::move(params->animation_host),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 381
357 current_pipeline_stage_ = FramePipelineStage::UPDATE_LAYERS; 382 current_pipeline_stage_ = FramePipelineStage::UPDATE_LAYERS;
358 LayerList layer_list; 383 LayerList layer_list;
359 if (max_pipeline_stage_for_current_frame_ >= 384 if (max_pipeline_stage_for_current_frame_ >=
360 FramePipelineStage::UPDATE_LAYERS) { 385 FramePipelineStage::UPDATE_LAYERS) {
361 // Pull updates for all layers from the client. 386 // Pull updates for all layers from the client.
362 // TODO(khushalsagar): Investigate the data impact from updating all the 387 // TODO(khushalsagar): Investigate the data impact from updating all the
363 // layers. See crbug.com/650885. 388 // layers. See crbug.com/650885.
364 LayerTreeHostCommon::CallFunctionForEveryLayer( 389 LayerTreeHostCommon::CallFunctionForEveryLayer(
365 layer_tree_.get(), [&layer_list](Layer* layer) { 390 layer_tree_.get(), [&layer_list](Layer* layer) {
391 if (!ShouldUpdateLayer(layer))
392 return;
366 layer->SavePaintProperties(); 393 layer->SavePaintProperties();
367 layer_list.push_back(layer); 394 layer_list.push_back(layer);
368 }); 395 });
369 396
370 bool content_is_suitable_for_gpu = false; 397 bool content_is_suitable_for_gpu = false;
371 bool layers_updated = 398 bool layers_updated =
372 layer_tree_->UpdateLayers(layer_list, &content_is_suitable_for_gpu); 399 layer_tree_->UpdateLayers(layer_list, &content_is_suitable_for_gpu);
373 400
374 // If pulling layer updates resulted in any content updates, we need to go 401 // If pulling layer updates resulted in any content updates, we need to go
375 // till the commit stage. 402 // 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); 520 layer_tree_host_proto->mutable_layer_updates(), inputs_only);
494 layer_tree_->LayersThatShouldPushProperties().clear(); 521 layer_tree_->LayersThatShouldPushProperties().clear();
495 522
496 std::vector<PictureData> pictures = 523 std::vector<PictureData> pictures =
497 engine_picture_cache_->CalculateCacheUpdateAndFlush(); 524 engine_picture_cache_->CalculateCacheUpdateAndFlush();
498 proto::PictureDataVectorToSkPicturesProto( 525 proto::PictureDataVectorToSkPicturesProto(
499 pictures, layer_tree_host_proto->mutable_pictures()); 526 pictures, layer_tree_host_proto->mutable_pictures());
500 } 527 }
501 528
502 } // namespace cc 529 } // namespace cc
OLDNEW
« no previous file with comments | « cc/blimp/compositor_state_deserializer_unittest.cc ('k') | cc/blimp/layer_tree_host_remote_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698