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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PropertyTreeManager.cpp

Issue 2643203002: Rewrite blink->cc scroll offset logic for SPV2 (Closed)
Patch Set: Created 3 years, 11 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 | « third_party/WebKit/Source/platform/graphics/compositing/PropertyTreeManager.h ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "platform/graphics/compositing/PropertyTreeManager.h" 5 #include "platform/graphics/compositing/PropertyTreeManager.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/trees/clip_node.h" 8 #include "cc/trees/clip_node.h"
9 #include "cc/trees/effect_node.h" 9 #include "cc/trees/effect_node.h"
10 #include "cc/trees/property_tree.h" 10 #include "cc/trees/property_tree.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 scrollNode->userScrollableVertical(); 265 scrollNode->userScrollableVertical();
266 compositorNode.transform_id = 266 compositorNode.transform_id =
267 ensureCompositorTransformNode(scrollNode->scrollOffsetTranslation()); 267 ensureCompositorTransformNode(scrollNode->scrollOffsetTranslation());
268 compositorNode.main_thread_scrolling_reasons = 268 compositorNode.main_thread_scrolling_reasons =
269 scrollNode->mainThreadScrollingReasons(); 269 scrollNode->mainThreadScrollingReasons();
270 270
271 auto result = m_scrollNodeMap.set(scrollNode, id); 271 auto result = m_scrollNodeMap.set(scrollNode, id);
272 DCHECK(result.isNewEntry); 272 DCHECK(result.isNewEntry);
273 scrollTree().set_needs_update(true); 273 scrollTree().set_needs_update(true);
274 274
275 // Blink creates a 2d transform node just for scroll offset whereas cc's
276 // transform node has a special scroll offset field. To handle this we
277 // adjust the compositor transform node to remove the 2d scroll translation
278 // and instead set a scroll offset.
279 cc::TransformNode& compositorTransformNode =
280 *transformTree().Node(compositorNode.transform_id);
281 DCHECK(compositorTransformNode.local.IsIdentityOr2DTranslation());
282 compositorTransformNode.local.MakeIdentity();
283 auto* scrollOffsetTransform = scrollNode->scrollOffsetTranslation();
284 auto scrollOffset = scrollOffsetTransform->matrix().to2DTranslation();
285 compositorTransformNode.scroll_offset =
286 gfx::ScrollOffset(-scrollOffset.width(), -scrollOffset.height());
287 compositorTransformNode.scrolls = true;
288
275 return id; 289 return id;
276 } 290 }
277 291
278 void PropertyTreeManager::updateScrollOffset(int layerId, int scrollId) {
279 cc::ScrollNode& scrollNode = *scrollTree().Node(scrollId);
280 cc::TransformNode& transformNode =
281 *transformTree().Node(scrollNode.transform_id);
282
283 transformNode.scrolls = true;
284
285 // Blink creates a 2d transform node just for scroll offset whereas cc's
286 // transform node has a special scroll offset field. To handle this we
287 // adjust cc's transform node to remove the 2d scroll translation and
288 // let the cc scroll tree update the cc scroll offset.
289 DCHECK(transformNode.local.IsIdentityOr2DTranslation());
290 auto offset = transformNode.local.To2dTranslation();
291 transformNode.local.MakeIdentity();
292 scrollTree().SetScrollOffset(layerId,
ajuma 2017/01/20 21:35:48 With this removed, is the scroll offset getting se
293 gfx::ScrollOffset(-offset.x(), -offset.y()));
294 scrollTree().set_needs_update(true);
295 }
296
297 int PropertyTreeManager::switchToEffectNode( 292 int PropertyTreeManager::switchToEffectNode(
298 const EffectPaintPropertyNode& nextEffect) { 293 const EffectPaintPropertyNode& nextEffect) {
299 const EffectPaintPropertyNode* ancestor = 294 const EffectPaintPropertyNode* ancestor =
300 GeometryMapper::lowestCommonAncestor(currentEffectNode(), &nextEffect); 295 GeometryMapper::lowestCommonAncestor(currentEffectNode(), &nextEffect);
301 DCHECK(ancestor) << "Malformed effect tree. All nodes must be descendant of " 296 DCHECK(ancestor) << "Malformed effect tree. All nodes must be descendant of "
302 "EffectPaintPropertyNode::root()."; 297 "EffectPaintPropertyNode::root().";
303 while (currentEffectNode() != ancestor) 298 while (currentEffectNode() != ancestor)
304 m_effectStack.pop_back(); 299 m_effectStack.pop_back();
305 300
306 // Now the current effect is the lowest common ancestor of previous effect 301 // Now the current effect is the lowest common ancestor of previous effect
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 m_effectStack.push_back(BlinkEffectAndCcIdPair{nextEffect, effectNode.id}); 374 m_effectStack.push_back(BlinkEffectAndCcIdPair{nextEffect, effectNode.id});
380 375
381 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber); 376 dummyLayer->set_property_tree_sequence_number(kPropertyTreeSequenceNumber);
382 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId); 377 dummyLayer->SetTransformTreeIndex(kSecondaryRootNodeId);
383 dummyLayer->SetClipTreeIndex(outputClipId); 378 dummyLayer->SetClipTreeIndex(outputClipId);
384 dummyLayer->SetEffectTreeIndex(effectNode.id); 379 dummyLayer->SetEffectTreeIndex(effectNode.id);
385 dummyLayer->SetScrollTreeIndex(kRealRootNodeId); 380 dummyLayer->SetScrollTreeIndex(kRealRootNodeId);
386 } 381 }
387 382
388 } // namespace blink 383 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/compositing/PropertyTreeManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698