| OLD | NEW |
| 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 "core/paint/PaintLayerPainter.h" | 5 #include "core/paint/PaintLayerPainter.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrameView.h" | 7 #include "core/frame/LocalFrameView.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/paint/ClipPathClipper.h" | 9 #include "core/paint/ClipPathClipper.h" |
| 10 #include "core/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 !is_painting_overlay_scrollbars; | 417 !is_painting_overlay_scrollbars; |
| 418 | 418 |
| 419 PaintLayerFragments layer_fragments; | 419 PaintLayerFragments layer_fragments; |
| 420 if (should_paint_content || should_paint_self_outline || | 420 if (should_paint_content || should_paint_self_outline || |
| 421 is_painting_overlay_scrollbars) { | 421 is_painting_overlay_scrollbars) { |
| 422 // Collect the fragments. This will compute the clip rectangles and paint | 422 // Collect the fragments. This will compute the clip rectangles and paint |
| 423 // offsets for each layer fragment. | 423 // offsets for each layer fragment. |
| 424 ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects) | 424 ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects) |
| 425 ? kUncachedClipRects | 425 ? kUncachedClipRects |
| 426 : kPaintingClipRects; | 426 : kPaintingClipRects; |
| 427 #ifndef NDEBUG |
| 428 static bool shown_once = false; |
| 429 if (!shown_once) { |
| 430 showLayerTree(&paint_layer_); |
| 431 shown_once = true; |
| 432 } |
| 433 #endif |
| 427 LayoutPoint offset_to_clipper; | 434 LayoutPoint offset_to_clipper; |
| 428 PaintLayer* paint_layer_for_fragments = &paint_layer_; | 435 const PaintLayer* paint_layer_for_fragments = &paint_layer_; |
| 429 if (paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase) { | 436 if (paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase) { |
| 430 // Compute fragments and their clips with respect to the clipping | 437 // Compute fragments and their clips with respect to the outermost |
| 431 // container. The paint rect is in this layer's space, so convert it | 438 // clipping container. This handles nested border radius by including |
| 432 // to the clipper's layer's space. The rootLayer is also changed to | 439 // all of them in the mask. |
| 433 // the clipper's layer to simplify coordinate system adjustments. | 440 // |
| 434 // The change to rootLayer must persist to correctly record the clips. | 441 // The paint rect is in this layer's space, so convert it to the clipper's |
| 442 // layer's space. The rootLayer is also changed to the clipper's layer to |
| 443 // simplify coordinate system adjustments. The change to rootLayer must |
| 444 // persist to correctly record the clips. |
| 435 paint_layer_for_fragments = | 445 paint_layer_for_fragments = |
| 436 paint_layer_.ClippingContainer()->EnclosingLayer(); | 446 paint_layer_.ClippingContainer()->EnclosingLayer(); |
| 447 while (const PaintLayer* new_clip_root = |
| 448 paint_layer_for_fragments->ClippingContainer() |
| 449 ->EnclosingLayer()) { |
| 450 paint_layer_for_fragments = new_clip_root; |
| 451 } |
| 437 local_painting_info.root_layer = paint_layer_for_fragments; | 452 local_painting_info.root_layer = paint_layer_for_fragments; |
| 438 paint_layer_.ConvertToLayerCoords(local_painting_info.root_layer, | 453 paint_layer_.ConvertToLayerCoords(local_painting_info.root_layer, |
| 439 offset_to_clipper); | 454 offset_to_clipper); |
| 440 local_painting_info.paint_dirty_rect.MoveBy(offset_to_clipper); | 455 local_painting_info.paint_dirty_rect.MoveBy(offset_to_clipper); |
| 441 } | 456 } |
| 442 | 457 |
| 443 PaintLayer::GeometryMapperOption geometry_mapper_option = | 458 PaintLayer::GeometryMapperOption geometry_mapper_option = |
| 444 PaintLayer::kDoNotUseGeometryMapper; | 459 PaintLayer::kDoNotUseGeometryMapper; |
| 445 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | 460 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 446 geometry_mapper_option = PaintLayer::kUseGeometryMapper; | 461 geometry_mapper_option = PaintLayer::kUseGeometryMapper; |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 // The ancestor is the thing that needs to clip, so do not include | 1013 // The ancestor is the thing that needs to clip, so do not include |
| 999 // this layer's clips. | 1014 // this layer's clips. |
| 1000 clipping_rule = LayerClipRecorder::kDoNotIncludeSelfForBorderRadius; | 1015 clipping_rule = LayerClipRecorder::kDoNotIncludeSelfForBorderRadius; |
| 1001 break; | 1016 break; |
| 1002 } | 1017 } |
| 1003 default: | 1018 default: |
| 1004 clipping_rule = LayerClipRecorder::kIncludeSelfForBorderRadius; | 1019 clipping_rule = LayerClipRecorder::kIncludeSelfForBorderRadius; |
| 1005 break; | 1020 break; |
| 1006 } | 1021 } |
| 1007 | 1022 |
| 1008 // TODO(schenney): Nested border-radius clips are not applied to composited | |
| 1009 // children, probably due to an incorrect clipRoot. | |
| 1010 // https://bugs.chromium.org/p/chromium/issues/detail?id=672561 | |
| 1011 clip_recorder.emplace(context, paint_layer_.GetLayoutObject(), clip_type, | 1023 clip_recorder.emplace(context, paint_layer_.GetLayoutObject(), clip_type, |
| 1012 clip_rect, painting_info.root_layer, | 1024 clip_rect, painting_info.root_layer, |
| 1013 fragment.pagination_offset, paint_flags, | 1025 fragment.pagination_offset, paint_flags, |
| 1014 clipping_rule); | 1026 clipping_rule); |
| 1015 } | 1027 } |
| 1016 | 1028 |
| 1017 // If we are painting a mask for any reason and we have already processed the | 1029 // If we are painting a mask for any reason and we have already processed the |
| 1018 // clips, there is no need to go through the remaining painting pipeline. | 1030 // clips, there is no need to go through the remaining painting pipeline. |
| 1019 // We know that the mask just needs the area bounded by the clip rects to be | 1031 // We know that the mask just needs the area bounded by the clip rects to be |
| 1020 // filled with black. | 1032 // filled with black. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 context, layout_object, kPaintPhaseClippingMask)) | 1266 context, layout_object, kPaintPhaseClippingMask)) |
| 1255 return; | 1267 return; |
| 1256 | 1268 |
| 1257 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); | 1269 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); |
| 1258 LayoutObjectDrawingRecorder drawing_recorder( | 1270 LayoutObjectDrawingRecorder drawing_recorder( |
| 1259 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); | 1271 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); |
| 1260 context.FillRect(snapped_clip_rect, Color::kBlack); | 1272 context.FillRect(snapped_clip_rect, Color::kBlack); |
| 1261 } | 1273 } |
| 1262 | 1274 |
| 1263 } // namespace blink | 1275 } // namespace blink |
| OLD | NEW |