| 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/LocalFrame.h" | 7 #include "core/frame/LocalFrame.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 29 matching lines...) Expand all Loading... |
| 40 !layer.IsRootLayer() && !layer.GetLayoutObject().IsDocumentElement()) | 40 !layer.IsRootLayer() && !layer.GetLayoutObject().IsDocumentElement()) |
| 41 return true; | 41 return true; |
| 42 | 42 |
| 43 return false; | 43 return false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PaintLayerPainter::Paint(GraphicsContext& context, | 46 void PaintLayerPainter::Paint(GraphicsContext& context, |
| 47 const LayoutRect& damage_rect, | 47 const LayoutRect& damage_rect, |
| 48 const GlobalPaintFlags global_paint_flags, | 48 const GlobalPaintFlags global_paint_flags, |
| 49 PaintLayerFlags paint_flags) { | 49 PaintLayerFlags paint_flags) { |
| 50 DCHECK(paint_layer_.GetCompositingState() != kPaintsIntoOwnBacking || |
| 51 paint_layer_.SubpixelAccumulation().IsZero()); |
| 50 PaintLayerPaintingInfo painting_info( | 52 PaintLayerPaintingInfo painting_info( |
| 51 &paint_layer_, LayoutRect(EnclosingIntRect(damage_rect)), | 53 &paint_layer_, LayoutRect(EnclosingIntRect(damage_rect)), |
| 52 global_paint_flags, LayoutSize()); | 54 global_paint_flags, LayoutSize()); |
| 53 if (ShouldPaintLayerInSoftwareMode(global_paint_flags, paint_flags)) | 55 if (ShouldPaintLayerInSoftwareMode(global_paint_flags, paint_flags)) |
| 54 Paint(context, painting_info, paint_flags); | 56 Paint(context, painting_info, paint_flags); |
| 55 } | 57 } |
| 56 | 58 |
| 57 static ShouldRespectOverflowClipType ShouldRespectOverflowClip( | 59 static ShouldRespectOverflowClipType ShouldRespectOverflowClip( |
| 58 PaintLayerFlags paint_flags, | 60 PaintLayerFlags paint_flags, |
| 59 const LayoutObject& layout_object) { | 61 const LayoutObject& layout_object) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if (paint_layer_.GetLayoutObject().View()->GetFrame() && | 324 if (paint_layer_.GetLayoutObject().View()->GetFrame() && |
| 323 paint_layer_.GetLayoutObject() | 325 paint_layer_.GetLayoutObject() |
| 324 .View() | 326 .View() |
| 325 ->GetFrame() | 327 ->GetFrame() |
| 326 ->ShouldThrottleRendering()) | 328 ->ShouldThrottleRendering()) |
| 327 return result; | 329 return result; |
| 328 | 330 |
| 329 // Ensure our lists are up to date. | 331 // Ensure our lists are up to date. |
| 330 paint_layer_.StackingNode()->UpdateLayerListsIfNeeded(); | 332 paint_layer_.StackingNode()->UpdateLayerListsIfNeeded(); |
| 331 | 333 |
| 332 LayoutSize subpixel_accumulation = | |
| 333 paint_layer_.GetCompositingState() == kPaintsIntoOwnBacking | |
| 334 ? paint_layer_.SubpixelAccumulation() | |
| 335 : painting_info_arg.sub_pixel_accumulation; | |
| 336 ShouldRespectOverflowClipType respect_overflow_clip = | 334 ShouldRespectOverflowClipType respect_overflow_clip = |
| 337 ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject()); | 335 ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject()); |
| 338 | 336 |
| 339 Optional<SubsequenceRecorder> subsequence_recorder; | 337 Optional<SubsequenceRecorder> subsequence_recorder; |
| 340 bool should_clear_empty_paint_phase_flags = false; | 338 bool should_clear_empty_paint_phase_flags = false; |
| 341 if (ShouldCreateSubsequence(paint_layer_, context, painting_info_arg, | 339 if (ShouldCreateSubsequence(paint_layer_, context, painting_info_arg, |
| 342 paint_flags)) { | 340 paint_flags)) { |
| 343 if (!ShouldRepaintSubsequence(paint_layer_, painting_info_arg, | 341 if (!ShouldRepaintSubsequence(paint_layer_, painting_info_arg, |
| 344 respect_overflow_clip, subpixel_accumulation, | 342 respect_overflow_clip, |
| 343 painting_info_arg.sub_pixel_accumulation, |
| 345 should_clear_empty_paint_phase_flags) && | 344 should_clear_empty_paint_phase_flags) && |
| 346 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, | 345 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, |
| 347 paint_layer_)) | 346 paint_layer_)) |
| 348 return result; | 347 return result; |
| 349 DCHECK(paint_layer_.SupportsSubsequenceCaching()); | 348 DCHECK(paint_layer_.SupportsSubsequenceCaching()); |
| 350 subsequence_recorder.emplace(context, paint_layer_); | 349 subsequence_recorder.emplace(context, paint_layer_); |
| 351 } else { | 350 } else { |
| 352 should_clear_empty_paint_phase_flags = true; | 351 should_clear_empty_paint_phase_flags = true; |
| 353 } | 352 } |
| 354 | 353 |
| 355 if (should_clear_empty_paint_phase_flags) { | 354 if (should_clear_empty_paint_phase_flags) { |
| 356 paint_layer_.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); | 355 paint_layer_.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); |
| 357 paint_layer_.SetPreviousPaintPhaseFloatEmpty(false); | 356 paint_layer_.SetPreviousPaintPhaseFloatEmpty(false); |
| 358 paint_layer_.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); | 357 paint_layer_.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); |
| 359 } | 358 } |
| 360 | 359 |
| 361 PaintLayerPaintingInfo painting_info = painting_info_arg; | 360 PaintLayerPaintingInfo painting_info = painting_info_arg; |
| 362 | 361 |
| 363 LayoutPoint offset_from_root; | 362 LayoutPoint offset_from_root; |
| 364 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, offset_from_root); | 363 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, offset_from_root); |
| 365 offset_from_root.Move(subpixel_accumulation); | 364 offset_from_root.Move(painting_info_arg.sub_pixel_accumulation); |
| 366 | 365 |
| 367 LayoutRect bounds = paint_layer_.PhysicalBoundingBox(offset_from_root); | 366 LayoutRect bounds = paint_layer_.PhysicalBoundingBox(offset_from_root); |
| 368 if (!painting_info.paint_dirty_rect.Contains(bounds)) | 367 if (!painting_info.paint_dirty_rect.Contains(bounds)) |
| 369 result = kMayBeClippedByPaintDirtyRect; | 368 result = kMayBeClippedByPaintDirtyRect; |
| 370 | 369 |
| 371 // These helpers output clip and compositing operations using a RAII pattern. | 370 // These helpers output clip and compositing operations using a RAII pattern. |
| 372 // Stack-allocated-varibles are destructed in the reverse order of | 371 // Stack-allocated-varibles are destructed in the reverse order of |
| 373 // construction, so they are nested properly. | 372 // construction, so they are nested properly. |
| 374 Optional<ClipPathClipper> clip_path_clipper; | 373 Optional<ClipPathClipper> clip_path_clipper; |
| 375 // Clip-path, like border radius, must not be applied to the contents of a | 374 // Clip-path, like border radius, must not be applied to the contents of a |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 painting_info.GetGlobalPaintFlags())); | 410 painting_info.GetGlobalPaintFlags())); |
| 412 compositing_recorder.emplace( | 411 compositing_recorder.emplace( |
| 413 context, paint_layer_.GetLayoutObject(), | 412 context, paint_layer_.GetLayoutObject(), |
| 414 WebCoreCompositeToSkiaComposite( | 413 WebCoreCompositeToSkiaComposite( |
| 415 kCompositeSourceOver, | 414 kCompositeSourceOver, |
| 416 paint_layer_.GetLayoutObject().Style()->BlendMode()), | 415 paint_layer_.GetLayoutObject().Style()->BlendMode()), |
| 417 paint_layer_.GetLayoutObject().Opacity(), &compositing_bounds); | 416 paint_layer_.GetLayoutObject().Opacity(), &compositing_bounds); |
| 418 } | 417 } |
| 419 | 418 |
| 420 PaintLayerPaintingInfo local_painting_info(painting_info); | 419 PaintLayerPaintingInfo local_painting_info(painting_info); |
| 421 local_painting_info.sub_pixel_accumulation = subpixel_accumulation; | |
| 422 | |
| 423 bool should_paint_content = paint_layer_.HasVisibleContent() && | 420 bool should_paint_content = paint_layer_.HasVisibleContent() && |
| 424 is_self_painting_layer && | 421 is_self_painting_layer && |
| 425 !is_painting_overlay_scrollbars; | 422 !is_painting_overlay_scrollbars; |
| 426 | 423 |
| 427 PaintLayerFragments layer_fragments; | 424 PaintLayerFragments layer_fragments; |
| 428 if (should_paint_content || should_paint_self_outline || | 425 if (should_paint_content || should_paint_self_outline || |
| 429 is_painting_overlay_scrollbars) { | 426 is_painting_overlay_scrollbars) { |
| 430 // Collect the fragments. This will compute the clip rectangles and paint | 427 // Collect the fragments. This will compute the clip rectangles and paint |
| 431 // offsets for each layer fragment. | 428 // offsets for each layer fragment. |
| 432 ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects) | 429 ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects) |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 paint_flags, kHasNotClipped); | 1231 paint_flags, kHasNotClipped); |
| 1235 } | 1232 } |
| 1236 | 1233 |
| 1237 void PaintLayerPainter::PaintOverlayScrollbars( | 1234 void PaintLayerPainter::PaintOverlayScrollbars( |
| 1238 GraphicsContext& context, | 1235 GraphicsContext& context, |
| 1239 const LayoutRect& damage_rect, | 1236 const LayoutRect& damage_rect, |
| 1240 const GlobalPaintFlags paint_flags) { | 1237 const GlobalPaintFlags paint_flags) { |
| 1241 if (!paint_layer_.ContainsDirtyOverlayScrollbars()) | 1238 if (!paint_layer_.ContainsDirtyOverlayScrollbars()) |
| 1242 return; | 1239 return; |
| 1243 | 1240 |
| 1241 DCHECK(paint_layer_.GetCompositingState() != kPaintsIntoOwnBacking || |
| 1242 paint_layer_.SubpixelAccumulation().IsZero()); |
| 1244 PaintLayerPaintingInfo painting_info( | 1243 PaintLayerPaintingInfo painting_info( |
| 1245 &paint_layer_, LayoutRect(EnclosingIntRect(damage_rect)), paint_flags, | 1244 &paint_layer_, LayoutRect(EnclosingIntRect(damage_rect)), paint_flags, |
| 1246 LayoutSize()); | 1245 LayoutSize()); |
| 1247 Paint(context, painting_info, kPaintLayerPaintingOverlayScrollbars); | 1246 Paint(context, painting_info, kPaintLayerPaintingOverlayScrollbars); |
| 1248 | 1247 |
| 1249 paint_layer_.SetContainsDirtyOverlayScrollbars(false); | 1248 paint_layer_.SetContainsDirtyOverlayScrollbars(false); |
| 1250 } | 1249 } |
| 1251 | 1250 |
| 1252 void PaintLayerPainter::FillMaskingFragment(GraphicsContext& context, | 1251 void PaintLayerPainter::FillMaskingFragment(GraphicsContext& context, |
| 1253 const ClipRect& clip_rect) { | 1252 const ClipRect& clip_rect) { |
| 1254 const LayoutObject& layout_object = paint_layer_.GetLayoutObject(); | 1253 const LayoutObject& layout_object = paint_layer_.GetLayoutObject(); |
| 1255 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( | 1254 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( |
| 1256 context, layout_object, kPaintPhaseClippingMask)) | 1255 context, layout_object, kPaintPhaseClippingMask)) |
| 1257 return; | 1256 return; |
| 1258 | 1257 |
| 1259 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); | 1258 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); |
| 1260 LayoutObjectDrawingRecorder drawing_recorder( | 1259 LayoutObjectDrawingRecorder drawing_recorder( |
| 1261 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); | 1260 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); |
| 1262 context.FillRect(snapped_clip_rect, Color::kBlack); | 1261 context.FillRect(snapped_clip_rect, Color::kBlack); |
| 1263 } | 1262 } |
| 1264 | 1263 |
| 1265 } // namespace blink | 1264 } // namespace blink |
| OLD | NEW |