Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 // TODO(trchen): Can't omit effect node if we have 3D children. | 375 // TODO(trchen): Can't omit effect node if we have 3D children. |
| 376 // TODO(trchen): Can't omit effect node if we have blending children. | 376 // TODO(trchen): Can't omit effect node if we have blending children. |
| 377 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { | 377 if (object.needsPaintPropertyUpdate() || context.forceSubtreeUpdate) { |
| 378 bool effectNodeNeeded = false; | 378 bool effectNodeNeeded = false; |
| 379 | 379 |
| 380 float opacity = style.opacity(); | 380 float opacity = style.opacity(); |
| 381 if (opacity != 1.0f) | 381 if (opacity != 1.0f) |
| 382 effectNodeNeeded = true; | 382 effectNodeNeeded = true; |
| 383 | 383 |
| 384 CompositorFilterOperations filter; | 384 CompositorFilterOperations filter; |
| 385 #if DCHECK_IS_ON() | |
| 386 FilterOperations styleFilterOperations; | |
| 387 #endif | |
| 385 if (object.isSVG() && !object.isSVGRoot()) { | 388 if (object.isSVG() && !object.isSVGRoot()) { |
| 386 // TODO(trchen): SVG caches filters in SVGResources. Implement it. | 389 // TODO(trchen): SVG caches filters in SVGResources. Implement it. |
| 387 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { | 390 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { |
| 388 // TODO(trchen): Eliminate PaintLayer dependency. | 391 // TODO(trchen): Eliminate PaintLayer dependency. |
| 392 #if DCHECK_IS_ON() | |
| 393 filter = layer->createCompositorFilterOperationsForFilter( | |
| 394 style, &styleFilterOperations); | |
| 395 #else | |
| 389 filter = layer->createCompositorFilterOperationsForFilter(style); | 396 filter = layer->createCompositorFilterOperationsForFilter(style); |
| 397 #endif | |
| 390 } | 398 } |
| 391 | 399 |
| 392 const ClipPaintPropertyNode* outputClip = context.inputClipOfCurrentEffect; | 400 const ClipPaintPropertyNode* outputClip = context.inputClipOfCurrentEffect; |
| 393 // The CSS filter spec didn't specify how filters interact with overflow | 401 // The CSS filter spec didn't specify how filters interact with overflow |
| 394 // clips. The implementation here mimics the old Blink/WebKit behavior for | 402 // clips. The implementation here mimics the old Blink/WebKit behavior for |
| 395 // backward compatibility. | 403 // backward compatibility. |
| 396 // Basically the output of the filter will be affected by clips that applies | 404 // Basically the output of the filter will be affected by clips that applies |
| 397 // to the current element. The descendants that paints into the input of the | 405 // to the current element. The descendants that paints into the input of the |
| 398 // filter ignores any clips collected so far. For example: | 406 // filter ignores any clips collected so far. For example: |
| 399 // <div style="overflow:scroll"> | 407 // <div style="overflow:scroll"> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 415 // TODO(trchen): A filter may contain spatial operations such that an | 423 // TODO(trchen): A filter may contain spatial operations such that an |
| 416 // output pixel may depend on an input pixel outside of the output clip. | 424 // output pixel may depend on an input pixel outside of the output clip. |
| 417 // We should generate a special clip node to represent this expansion. | 425 // We should generate a special clip node to represent this expansion. |
| 418 } | 426 } |
| 419 | 427 |
| 420 if (effectNodeNeeded) { | 428 if (effectNodeNeeded) { |
| 421 auto& properties = object.getMutableForPainting().ensurePaintProperties(); | 429 auto& properties = object.getMutableForPainting().ensurePaintProperties(); |
| 422 context.forceSubtreeUpdate |= properties.updateEffect( | 430 context.forceSubtreeUpdate |= properties.updateEffect( |
| 423 context.currentEffect, context.current.transform, outputClip, | 431 context.currentEffect, context.current.transform, outputClip, |
| 424 std::move(filter), opacity); | 432 std::move(filter), opacity); |
| 433 #if DCHECK_IS_ON() | |
| 434 properties.setStyleFilterOperations(styleFilterOperations); | |
|
pdr.
2016/12/08 02:00:41
How much additional value will these checks give u
Xianzhu
2016/12/08 17:34:35
You are right. The little additional value is not
| |
| 435 #endif | |
| 425 } else { | 436 } else { |
| 426 if (auto* properties = object.getMutableForPainting().paintProperties()) | 437 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 427 context.forceSubtreeUpdate |= properties->clearEffect(); | 438 context.forceSubtreeUpdate |= properties->clearEffect(); |
| 428 } | 439 } |
| 429 } | 440 } |
| 430 | 441 |
| 431 const auto* properties = object.paintProperties(); | 442 const auto* properties = object.paintProperties(); |
| 432 if (properties && properties->effect()) { | 443 if (properties && properties->effect()) { |
| 433 context.currentEffect = properties->effect(); | 444 context.currentEffect = properties->effect(); |
| 434 if (!properties->effect()->filter().isEmpty()) { | 445 if (!properties->effect()->filter().isEmpty()) { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 #endif | 918 #endif |
| 908 | 919 |
| 909 updateOverflowClip(object, context); | 920 updateOverflowClip(object, context); |
| 910 updatePerspective(object, context); | 921 updatePerspective(object, context); |
| 911 updateSvgLocalToBorderBoxTransform(object, context); | 922 updateSvgLocalToBorderBoxTransform(object, context); |
| 912 updateScrollAndScrollTranslation(object, context); | 923 updateScrollAndScrollTranslation(object, context); |
| 913 updateOutOfFlowContext(object, context); | 924 updateOutOfFlowContext(object, context); |
| 914 } | 925 } |
| 915 | 926 |
| 916 } // namespace blink | 927 } // namespace blink |
| OLD | NEW |