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

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

Issue 2117853004: cc: Compute sublayer scale from effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "comments" Created 4 years, 5 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
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 replica_mask_layer_id(-1) {} 507 replica_mask_layer_id(-1) {}
508 508
509 EffectNodeData::EffectNodeData(const EffectNodeData& other) = default; 509 EffectNodeData::EffectNodeData(const EffectNodeData& other) = default;
510 510
511 bool EffectNodeData::operator==(const EffectNodeData& other) const { 511 bool EffectNodeData::operator==(const EffectNodeData& other) const {
512 return opacity == other.opacity && 512 return opacity == other.opacity &&
513 screen_space_opacity == other.screen_space_opacity && 513 screen_space_opacity == other.screen_space_opacity &&
514 has_render_surface == other.has_render_surface && 514 has_render_surface == other.has_render_surface &&
515 has_copy_request == other.has_copy_request && 515 has_copy_request == other.has_copy_request &&
516 background_filters == other.background_filters && 516 background_filters == other.background_filters &&
517 sublayer_scale == other.sublayer_scale &&
517 hidden_by_backface_visibility == other.hidden_by_backface_visibility && 518 hidden_by_backface_visibility == other.hidden_by_backface_visibility &&
518 double_sided == other.double_sided && is_drawn == other.is_drawn && 519 double_sided == other.double_sided && is_drawn == other.is_drawn &&
519 subtree_hidden == other.subtree_hidden && 520 subtree_hidden == other.subtree_hidden &&
520 has_potential_opacity_animation == 521 has_potential_opacity_animation ==
521 other.has_potential_opacity_animation && 522 other.has_potential_opacity_animation &&
522 is_currently_animating_opacity == 523 is_currently_animating_opacity ==
523 other.is_currently_animating_opacity && 524 other.is_currently_animating_opacity &&
524 effect_changed == other.effect_changed && 525 effect_changed == other.effect_changed &&
525 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && 526 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree &&
526 transform_id == other.transform_id && clip_id == other.clip_id && 527 transform_id == other.transform_id && clip_id == other.clip_id &&
(...skipping 16 matching lines...) Expand all
543 data->set_has_potential_opacity_animation(has_potential_opacity_animation); 544 data->set_has_potential_opacity_animation(has_potential_opacity_animation);
544 data->set_is_currently_animating_opacity(is_currently_animating_opacity); 545 data->set_is_currently_animating_opacity(is_currently_animating_opacity);
545 data->set_effect_changed(effect_changed); 546 data->set_effect_changed(effect_changed);
546 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); 547 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree);
547 data->set_transform_id(transform_id); 548 data->set_transform_id(transform_id);
548 data->set_clip_id(clip_id); 549 data->set_clip_id(clip_id);
549 data->set_target_id(target_id); 550 data->set_target_id(target_id);
550 data->set_mask_layer_id(mask_layer_id); 551 data->set_mask_layer_id(mask_layer_id);
551 data->set_replica_layer_id(replica_layer_id); 552 data->set_replica_layer_id(replica_layer_id);
552 data->set_replica_mask_layer_id(replica_mask_layer_id); 553 data->set_replica_mask_layer_id(replica_mask_layer_id);
554 Vector2dFToProto(sublayer_scale, data->mutable_sublayer_scale());
553 } 555 }
554 556
555 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { 557 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) {
556 DCHECK(proto.has_effect_node_data()); 558 DCHECK(proto.has_effect_node_data());
557 const proto::EffectNodeData& data = proto.effect_node_data(); 559 const proto::EffectNodeData& data = proto.effect_node_data();
558 560
559 opacity = data.opacity(); 561 opacity = data.opacity();
560 screen_space_opacity = data.screen_space_opacity(); 562 screen_space_opacity = data.screen_space_opacity();
561 has_render_surface = data.has_render_surface(); 563 has_render_surface = data.has_render_surface();
562 has_copy_request = data.has_copy_request(); 564 has_copy_request = data.has_copy_request();
563 hidden_by_backface_visibility = data.hidden_by_backface_visibility(); 565 hidden_by_backface_visibility = data.hidden_by_backface_visibility();
564 double_sided = data.double_sided(); 566 double_sided = data.double_sided();
565 is_drawn = data.is_drawn(); 567 is_drawn = data.is_drawn();
566 subtree_hidden = data.subtree_hidden(); 568 subtree_hidden = data.subtree_hidden();
567 has_potential_opacity_animation = data.has_potential_opacity_animation(); 569 has_potential_opacity_animation = data.has_potential_opacity_animation();
568 is_currently_animating_opacity = data.is_currently_animating_opacity(); 570 is_currently_animating_opacity = data.is_currently_animating_opacity();
569 effect_changed = data.effect_changed(); 571 effect_changed = data.effect_changed();
570 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); 572 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree();
571 transform_id = data.transform_id(); 573 transform_id = data.transform_id();
572 clip_id = data.clip_id(); 574 clip_id = data.clip_id();
573 target_id = data.target_id(); 575 target_id = data.target_id();
574 mask_layer_id = data.mask_layer_id(); 576 mask_layer_id = data.mask_layer_id();
575 replica_layer_id = data.replica_layer_id(); 577 replica_layer_id = data.replica_layer_id();
576 replica_mask_layer_id = data.replica_mask_layer_id(); 578 replica_mask_layer_id = data.replica_mask_layer_id();
579 sublayer_scale = ProtoToVector2dF(data.sublayer_scale());
577 } 580 }
578 581
579 void EffectNodeData::AsValueInto(base::trace_event::TracedValue* value) const { 582 void EffectNodeData::AsValueInto(base::trace_event::TracedValue* value) const {
580 value->SetDouble("opacity", opacity); 583 value->SetDouble("opacity", opacity);
581 value->SetBoolean("has_render_surface", has_render_surface); 584 value->SetBoolean("has_render_surface", has_render_surface);
582 value->SetBoolean("has_copy_request", has_copy_request); 585 value->SetBoolean("has_copy_request", has_copy_request);
583 value->SetBoolean("double_sided", double_sided); 586 value->SetBoolean("double_sided", double_sided);
584 value->SetBoolean("is_drawn", is_drawn); 587 value->SetBoolean("is_drawn", is_drawn);
585 value->SetBoolean("has_potential_opacity_animation", 588 value->SetBoolean("has_potential_opacity_animation",
586 has_potential_opacity_animation); 589 has_potential_opacity_animation);
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 node->data.hidden_by_backface_visibility = 1414 node->data.hidden_by_backface_visibility =
1412 transform_node->data.local.IsBackFaceVisible(); 1415 transform_node->data.local.IsBackFaceVisible();
1413 } 1416 }
1414 return; 1417 return;
1415 } 1418 }
1416 } 1419 }
1417 } 1420 }
1418 node->data.hidden_by_backface_visibility = false; 1421 node->data.hidden_by_backface_visibility = false;
1419 } 1422 }
1420 1423
1424 void EffectTree::UpdateSublayerScale(EffectNode* effect_node) {
1425 if (!effect_node->data.has_render_surface ||
1426 effect_node->data.transform_id == 0) {
1427 effect_node->data.sublayer_scale = gfx::Vector2dF(1.0f, 1.0f);
1428 return;
1429 }
1430
1431 TransformTree& transform_tree = property_trees()->transform_tree;
1432 float layer_scale_factor = transform_tree.device_scale_factor() *
1433 transform_tree.device_transform_scale_factor();
1434 TransformNode* transform_node =
1435 transform_tree.Node(effect_node->data.transform_id);
1436 if (transform_node->data.in_subtree_of_page_scale_layer)
1437 layer_scale_factor *= transform_tree.page_scale_factor();
1438 effect_node->data.sublayer_scale =
1439 MathUtil::ComputeTransform2dScaleComponents(
1440 transform_tree.ToScreen(transform_node->id), layer_scale_factor);
1441 }
1442
1421 void EffectTree::UpdateEffects(int id) { 1443 void EffectTree::UpdateEffects(int id) {
1422 EffectNode* node = Node(id); 1444 EffectNode* node = Node(id);
1423 EffectNode* parent_node = parent(node); 1445 EffectNode* parent_node = parent(node);
1424 1446
1425 UpdateOpacities(node, parent_node); 1447 UpdateOpacities(node, parent_node);
1426 UpdateIsDrawn(node, parent_node); 1448 UpdateIsDrawn(node, parent_node);
1427 UpdateEffectChanged(node, parent_node); 1449 UpdateEffectChanged(node, parent_node);
1428 UpdateBackfaceVisibility(node, parent_node); 1450 UpdateBackfaceVisibility(node, parent_node);
1451 UpdateSublayerScale(node);
1429 } 1452 }
1430 1453
1431 void EffectTree::AddCopyRequest(int node_id, 1454 void EffectTree::AddCopyRequest(int node_id,
1432 std::unique_ptr<CopyOutputRequest> request) { 1455 std::unique_ptr<CopyOutputRequest> request) {
1433 copy_requests_.insert(std::make_pair(node_id, std::move(request))); 1456 copy_requests_.insert(std::make_pair(node_id, std::move(request)));
1434 } 1457 }
1435 1458
1436 void EffectTree::PushCopyRequestsTo(EffectTree* other_tree) { 1459 void EffectTree::PushCopyRequestsTo(EffectTree* other_tree) {
1437 // If other_tree still has copy requests, this means there was a commit 1460 // If other_tree still has copy requests, this means there was a commit
1438 // without a draw. This only happens in some edge cases during lost context or 1461 // without a draw. This only happens in some edge cases during lost context or
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 cached_data_.property_tree_update_number = 0; 2473 cached_data_.property_tree_update_number = 0;
2451 cached_data_.animation_scales = std::vector<AnimationScaleData>( 2474 cached_data_.animation_scales = std::vector<AnimationScaleData>(
2452 transform_tree.nodes().size(), AnimationScaleData()); 2475 transform_tree.nodes().size(), AnimationScaleData());
2453 } 2476 }
2454 2477
2455 void PropertyTrees::UpdateCachedNumber() { 2478 void PropertyTrees::UpdateCachedNumber() {
2456 cached_data_.property_tree_update_number++; 2479 cached_data_.property_tree_update_number++;
2457 } 2480 }
2458 2481
2459 } // namespace cc 2482 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698