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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2604973002: Move computation of 3D descendants to the descendant-dependent flags walk. (Closed)
Patch Set: none 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
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 "core/paint/PaintPropertyTreeBuilder.h" 5 #include "core/paint/PaintPropertyTreeBuilder.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutInline.h" 10 #include "core/layout/LayoutInline.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 } 299 }
300 300
301 if (object.paintProperties() && object.paintProperties()->transform()) { 301 if (object.paintProperties() && object.paintProperties()->transform()) {
302 context.current.transform = object.paintProperties()->transform(); 302 context.current.transform = object.paintProperties()->transform();
303 context.current.shouldFlattenInheritedTransform = false; 303 context.current.shouldFlattenInheritedTransform = false;
304 context.current.renderingContextID = 0; 304 context.current.renderingContextID = 0;
305 } 305 }
306 } 306 }
307 307
308 static CompositingReasons compositingReasonsForTransform( 308 static CompositingReasons compositingReasonsForTransform(const LayoutBox& box) {
309 const LayoutObject& object) { 309 const ComputedStyle& style = box.styleRef();
310 CompositingReasons compositingReasons = CompositingReasonNone; 310 CompositingReasons compositingReasons = CompositingReasonNone;
311 if (CompositingReasonFinder::requiresCompositingForTransform(object)) 311 if (CompositingReasonFinder::requiresCompositingForTransform(box))
312 compositingReasons |= CompositingReason3DTransform; 312 compositingReasons |= CompositingReason3DTransform;
313 313
314 if (CompositingReasonFinder::requiresCompositingForTransformAnimation( 314 if (CompositingReasonFinder::requiresCompositingForTransformAnimation(style))
315 object.styleRef()))
316 compositingReasons |= CompositingReasonActiveAnimation; 315 compositingReasons |= CompositingReasonActiveAnimation;
317 316
318 if (object.styleRef().hasWillChangeCompositingHint() && 317 if (style.hasWillChangeCompositingHint() &&
319 !object.styleRef().subtreeWillChangeContents()) 318 !style.subtreeWillChangeContents())
320 compositingReasons |= CompositingReasonWillChangeCompositingHint; 319 compositingReasons |= CompositingReasonWillChangeCompositingHint;
321 320
322 if (object.isBoxModelObject()) { 321 if (box.hasLayer() && box.layer()->has3DTransformedDescendant()) {
323 const LayoutBoxModelObject* box = toLayoutBoxModelObject(&object); 322 if (style.hasPerspective())
324 if (box->hasLayer()) { 323 compositingReasons |= CompositingReasonPerspectiveWith3DDescendants;
325 // TODO(chrishtr): move this to the descendant-dependent flags recursion 324 if (style.usedTransformStyle3D() == TransformStyle3DPreserve3D)
326 // PaintLayer::updateDescendantDependentFlags. 325 compositingReasons |= CompositingReasonPreserve3DWith3DDescendants;
327 box->layer()->update3DTransformedDescendantStatus();
328
329 if (box->layer()->has3DTransformedDescendant())
330 compositingReasons |= CompositingReason3DTransform;
331 }
332 } 326 }
333 327
334 return compositingReasons; 328 return compositingReasons;
335 } 329 }
336 330
337 static FloatPoint3D transformOrigin(const LayoutBox& box) { 331 static FloatPoint3D transformOrigin(const LayoutBox& box) {
338 const ComputedStyle& style = box.styleRef(); 332 const ComputedStyle& style = box.styleRef();
339 // Transform origin has no effect without a transform or motion path. 333 // Transform origin has no effect without a transform or motion path.
340 if (!style.hasTransform()) 334 if (!style.hasTransform())
341 return FloatPoint3D(); 335 return FloatPoint3D();
342 FloatSize borderBoxSize(box.size()); 336 FloatSize borderBoxSize(box.size());
343 return FloatPoint3D( 337 return FloatPoint3D(
344 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), 338 floatValueForLength(style.transformOriginX(), borderBoxSize.width()),
345 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), 339 floatValueForLength(style.transformOriginY(), borderBoxSize.height()),
346 style.transformOriginZ()); 340 style.transformOriginZ());
347 } 341 }
348 342
349 void PaintPropertyTreeBuilder::updateTransform( 343 void PaintPropertyTreeBuilder::updateTransform(
350 const LayoutObject& object, 344 const LayoutObject& object,
351 PaintPropertyTreeBuilderContext& context) { 345 PaintPropertyTreeBuilderContext& context) {
352 if (object.isSVG() && !object.isSVGRoot()) { 346 if (object.isSVG() && !object.isSVGRoot()) {
353 updateTransformForNonRootSVG(object, context); 347 updateTransformForNonRootSVG(object, context);
354 return; 348 return;
355 } 349 }
356 350
357 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { 351 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) {
358 const ComputedStyle& style = object.styleRef(); 352 const ComputedStyle& style = object.styleRef();
359 353
360 CompositingReasons compositingReasons =
361 compositingReasonsForTransform(object);
362
363 // A transform node is allocated for transforms, preserves-3d and any 354 // A transform node is allocated for transforms, preserves-3d and any
364 // direct compositing reason. The latter is required because this is the 355 // direct compositing reason. The latter is required because this is the
365 // only way to represent compositing both an element and its stacking 356 // only way to represent compositing both an element and its stacking
366 // descendants. 357 // descendants.
367 if (object.isBox() && (style.hasTransform() || style.preserves3D() || 358 bool hasTransform = false;
368 compositingReasons != CompositingReasonNone)) { 359 if (object.isBox()) {
369 auto& box = toLayoutBox(object); 360 auto& box = toLayoutBox(object);
370 TransformationMatrix matrix;
371 style.applyTransform(
372 matrix, box.size(), ComputedStyle::ExcludeTransformOrigin,
373 ComputedStyle::IncludeMotionPath,
374 ComputedStyle::IncludeIndependentTransformProperties);
375 361
376 // TODO(trchen): transform-style should only be respected if a PaintLayer 362 CompositingReasons compositingReasons =
377 // is created. 363 compositingReasonsForTransform(box);
378 // If a node with transform-style: preserve-3d does not exist in an
379 // existing rendering context, it establishes a new one.
380 unsigned renderingContextID = context.current.renderingContextID;
381 if (style.preserves3D() && !renderingContextID)
382 renderingContextID = PtrHash<const LayoutObject>::hash(&object);
383 364
384 auto& properties = object.getMutableForPainting().ensurePaintProperties(); 365 if (style.hasTransform() || style.preserves3D() ||
385 context.forceSubtreeUpdate |= properties.updateTransform( 366 compositingReasons != CompositingReasonNone) {
386 context.current.transform, matrix, transformOrigin(box), 367 TransformationMatrix matrix;
387 context.current.shouldFlattenInheritedTransform, renderingContextID, 368 style.applyTransform(
388 compositingReasons); 369 matrix, box.size(), ComputedStyle::ExcludeTransformOrigin,
389 } else { 370 ComputedStyle::IncludeMotionPath,
371 ComputedStyle::IncludeIndependentTransformProperties);
372
373 // TODO(trchen): transform-style should only be respected if a
374 // PaintLayer
375 // is created.
376 // If a node with transform-style: preserve-3d does not exist in an
377 // existing rendering context, it establishes a new one.
378 unsigned renderingContextID = context.current.renderingContextID;
379 if (style.preserves3D() && !renderingContextID)
380 renderingContextID = PtrHash<const LayoutObject>::hash(&object);
381
382 auto& properties =
383 object.getMutableForPainting().ensurePaintProperties();
384 context.forceSubtreeUpdate |= properties.updateTransform(
385 context.current.transform, matrix, transformOrigin(box),
386 context.current.shouldFlattenInheritedTransform, renderingContextID,
387 compositingReasons);
388 hasTransform = true;
389 }
390 }
391 if (!hasTransform) {
390 if (auto* properties = object.getMutableForPainting().paintProperties()) 392 if (auto* properties = object.getMutableForPainting().paintProperties())
391 context.forceSubtreeUpdate |= properties->clearTransform(); 393 context.forceSubtreeUpdate |= properties->clearTransform();
392 } 394 }
393 } 395 }
394 396
395 const auto* properties = object.paintProperties(); 397 const auto* properties = object.paintProperties();
396 if (properties && properties->transform()) { 398 if (properties && properties->transform()) {
397 context.current.transform = properties->transform(); 399 context.current.transform = properties->transform();
398 if (object.styleRef().preserves3D()) { 400 if (object.styleRef().preserves3D()) {
399 context.current.renderingContextID = 401 context.current.renderingContextID =
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 updateOverflowClip(object, context); 990 updateOverflowClip(object, context);
989 updatePerspective(object, context); 991 updatePerspective(object, context);
990 updateSvgLocalToBorderBoxTransform(object, context); 992 updateSvgLocalToBorderBoxTransform(object, context);
991 updateScrollAndScrollTranslation(object, context); 993 updateScrollAndScrollTranslation(object, context);
992 updateOutOfFlowContext(object, context); 994 updateOutOfFlowContext(object, context);
993 995
994 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate(); 996 context.forceSubtreeUpdate |= object.subtreeNeedsPaintPropertyUpdate();
995 } 997 }
996 998
997 } // namespace blink 999 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698