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

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

Issue 1714523005: WIP: backface visibility plumbing (not for review) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: still broken Created 4 years, 10 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/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/ObjectPaintProperties.h" 9 #include "core/paint/ObjectPaintProperties.h"
10 #include "core/paint/PaintLayer.h" 10 #include "core/paint/PaintLayer.h"
11 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 11 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 12 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
13 #include "platform/transforms/TransformationMatrix.h" 13 #include "platform/transforms/TransformationMatrix.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 // The context for layout tree walk. 17 // The context for layout tree walk.
18 // The walk will be done in the primary tree order (= DOM order), thus the conte xt will also be 18 // The walk will be done in the primary tree order (= DOM order), thus the conte xt will also be
19 // responsible for bookkeeping tree state in other order, for example, the most recent position 19 // responsible for bookkeeping tree state in other order, for example, the most recent position
20 // container seen. 20 // container seen.
21 struct PaintPropertyTreeBuilderContext { 21 struct PaintPropertyTreeBuilderContext {
22 PaintPropertyTreeBuilderContext() 22 PaintPropertyTreeBuilderContext()
23 : currentTransform(nullptr) 23 : currentTransform(nullptr)
24 , currentClip(nullptr) 24 , currentClip(nullptr)
25 , transformForOutOfFlowPositioned(nullptr) 25 , transformForOutOfFlowPositioned(nullptr)
26 , clipForOutOfFlowPositioned(nullptr) 26 , clipForOutOfFlowPositioned(nullptr)
27 , transformForFixedPositioned(nullptr) 27 , transformForFixedPositioned(nullptr)
28 , clipForFixedPositioned(nullptr) 28 , clipForFixedPositioned(nullptr)
29 , currentEffect(nullptr) { } 29 , currentEffect(nullptr)
30 , preserving3d(false)
31 , backfaceHidden(false) { }
30 32
31 // The combination of a transform and paint offset describes a linear space. 33 // The combination of a transform and paint offset describes a linear space.
32 // When a layout object recur to its children, the main context is expected to refer 34 // When a layout object recur to its children, the main context is expected to refer
33 // the object's border box, then the callee will derive its own border box b y translating 35 // the object's border box, then the callee will derive its own border box b y translating
34 // the space with its own layout location. 36 // the space with its own layout location.
35 TransformPaintPropertyNode* currentTransform; 37 TransformPaintPropertyNode* currentTransform;
36 LayoutPoint paintOffset; 38 LayoutPoint paintOffset;
37 // The clip node describes the accumulated raster clip for the current subtr ee. 39 // The clip node describes the accumulated raster clip for the current subtr ee.
38 // Note that the computed raster region in canvas space for a clip node is i ndependent from 40 // Note that the computed raster region in canvas space for a clip node is i ndependent from
39 // the transform and paint offset above. Also the actual raster region may b e affected 41 // the transform and paint offset above. Also the actual raster region may b e affected
(...skipping 12 matching lines...) Expand all
52 ClipPaintPropertyNode* clipForOutOfFlowPositioned; 54 ClipPaintPropertyNode* clipForOutOfFlowPositioned;
53 55
54 TransformPaintPropertyNode* transformForFixedPositioned; 56 TransformPaintPropertyNode* transformForFixedPositioned;
55 LayoutPoint paintOffsetForFixedPositioned; 57 LayoutPoint paintOffsetForFixedPositioned;
56 ClipPaintPropertyNode* clipForFixedPositioned; 58 ClipPaintPropertyNode* clipForFixedPositioned;
57 59
58 // The effect hierarchy is applied by the stacking context tree. It is guara nteed that every 60 // The effect hierarchy is applied by the stacking context tree. It is guara nteed that every
59 // DOM descendant is also a stacking context descendant. Therefore, we don't need extra 61 // DOM descendant is also a stacking context descendant. Therefore, we don't need extra
60 // bookkeeping for effect nodes and can generate the effect tree from a DOM- order traversal. 62 // bookkeeping for effect nodes and can generate the effect tree from a DOM- order traversal.
61 EffectPaintPropertyNode* currentEffect; 63 EffectPaintPropertyNode* currentEffect;
64
65 bool preserving3d;
66 bool backfaceHidden;
62 }; 67 };
63 68
64 void PaintPropertyTreeBuilder::buildPropertyTrees(FrameView& rootFrame) 69 void PaintPropertyTreeBuilder::buildPropertyTrees(FrameView& rootFrame)
65 { 70 {
66 walk(rootFrame, PaintPropertyTreeBuilderContext()); 71 walk(rootFrame, PaintPropertyTreeBuilderContext());
67 } 72 }
68 73
69 void PaintPropertyTreeBuilder::walk(FrameView& frameView, const PaintPropertyTre eBuilderContext& context) 74 void PaintPropertyTreeBuilder::walk(FrameView& frameView, const PaintPropertyTre eBuilderContext& context)
70 { 75 {
71 PaintPropertyTreeBuilderContext localContext(context); 76 PaintPropertyTreeBuilderContext localContext(context);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // Note: Currently only layer painter makes use of the pre-computed context. 320 // Note: Currently only layer painter makes use of the pre-computed context.
316 // This condition may be loosened with no adverse effects beside memory use. 321 // This condition may be loosened with no adverse effects beside memory use.
317 if (!object.hasLayer()) 322 if (!object.hasLayer())
318 return nullptr; 323 return nullptr;
319 324
320 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> recordedContext = ad optPtr(new ObjectPaintProperties::LocalBorderBoxProperties); 325 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> recordedContext = ad optPtr(new ObjectPaintProperties::LocalBorderBoxProperties);
321 recordedContext->paintOffset = context.paintOffset; 326 recordedContext->paintOffset = context.paintOffset;
322 recordedContext->properties.transform = context.currentTransform; 327 recordedContext->properties.transform = context.currentTransform;
323 recordedContext->properties.clip = context.currentClip; 328 recordedContext->properties.clip = context.currentClip;
324 recordedContext->properties.effect = context.currentEffect; 329 recordedContext->properties.effect = context.currentEffect;
330 recordedContext->properties.backfaceHidden = context.backfaceHidden;
325 return recordedContext.release(); 331 return recordedContext.release();
326 } 332 }
327 333
328 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre eBuilderContext& context) 334 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre eBuilderContext& context)
329 { 335 {
336
337 //fprintf(stderr, "walk trees, build propz.\n");
338 //if (object.node())
339 // object.node()->showTreeForThisInFlatTree();
340 //fprintf(stderr, "layout object %s\n\n", object.node() ? object.node()->nodeNam e().utf8().data() : "dunno");
341
330 PaintPropertyTreeBuilderContext localContext(context); 342 PaintPropertyTreeBuilderContext localContext(context);
331 343
344 fprintf(stderr, "walking into %s, context.preserving3d %d, context.backfaceH idden %d, object.preserves3d %d, object.backfacehidden %d\n",
345 object.debugName().utf8().data(),
346 localContext.preserving3d,
347 localContext.backfaceHidden,
348 object.styleRef().preserves3D(),
349 object.hasHiddenBackface());
350
351 localContext.preserving3d = object.styleRef().preserves3D();
352 if (localContext.preserving3d) {
353 if (object.hasTransformRelatedProperty())
354 localContext.backfaceHidden = object.hasHiddenBackface();
355 } else {
356 //if (object.hasTransformRelatedProperty())
357 localContext.backfaceHidden = false;
358 if (object.hasHiddenBackface())
359 localContext.backfaceHidden = true;
360 }
361
332 deriveBorderBoxFromContainerContext(object, localContext); 362 deriveBorderBoxFromContainerContext(object, localContext);
333 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); 363 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext);
334 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran sformIfNeeded(object, localContext); 364 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran sformIfNeeded(object, localContext);
335 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); 365 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext);
336 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext = recordTreeContextIfNeeded(object, localContext); 366 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext = recordTreeContextIfNeeded(object, localContext);
337 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli pIfNeeded(object, localContext); 367 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli pIfNeeded(object, localContext);
338 // TODO(trchen): Insert flattening transform here, as specified by 368 // TODO(trchen): Insert flattening transform here, as specified by
339 // http://www.w3.org/TR/css3-transforms/#transform-style-property 369 // http://www.w3.org/TR/css3-transforms/#transform-style-property
340 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe rspectiveIfNeeded(object, localContext); 370 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe rspectiveIfNeeded(object, localContext);
341 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr eateScrollTranslationIfNeeded(object, localContext); 371 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr eateScrollTranslationIfNeeded(object, localContext);
(...skipping 13 matching lines...) Expand all
355 object.clearObjectPaintProperties(); 385 object.clearObjectPaintProperties();
356 } 386 }
357 387
358 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne xtSibling()) { 388 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne xtSibling()) {
359 if (child->isBoxModelObject() || child->isSVG()) 389 if (child->isBoxModelObject() || child->isSVG())
360 walk(*child, localContext); 390 walk(*child, localContext);
361 } 391 }
362 } 392 }
363 393
364 } // namespace blink 394 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698