Chromium Code Reviews| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 if (paint_layer_.GetLayoutObject().View()->GetFrame() && | 319 if (paint_layer_.GetLayoutObject().View()->GetFrame() && |
| 318 paint_layer_.GetLayoutObject() | 320 paint_layer_.GetLayoutObject() |
| 319 .View() | 321 .View() |
| 320 ->GetFrame() | 322 ->GetFrame() |
| 321 ->ShouldThrottleRendering()) | 323 ->ShouldThrottleRendering()) |
| 322 return result; | 324 return result; |
| 323 | 325 |
| 324 // Ensure our lists are up to date. | 326 // Ensure our lists are up to date. |
| 325 paint_layer_.StackingNode()->UpdateLayerListsIfNeeded(); | 327 paint_layer_.StackingNode()->UpdateLayerListsIfNeeded(); |
| 326 | 328 |
| 327 LayoutSize subpixel_accumulation = | |
| 328 paint_layer_.GetCompositingState() == kPaintsIntoOwnBacking | |
| 329 ? paint_layer_.SubpixelAccumulation() | |
| 330 : painting_info_arg.sub_pixel_accumulation; | |
| 331 ShouldRespectOverflowClipType respect_overflow_clip = | 329 ShouldRespectOverflowClipType respect_overflow_clip = |
| 332 ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject()); | 330 ShouldRespectOverflowClip(paint_flags, paint_layer_.GetLayoutObject()); |
| 333 | 331 |
| 334 Optional<SubsequenceRecorder> subsequence_recorder; | 332 Optional<SubsequenceRecorder> subsequence_recorder; |
| 335 bool should_clear_empty_paint_phase_flags = false; | 333 bool should_clear_empty_paint_phase_flags = false; |
| 336 if (ShouldCreateSubsequence(paint_layer_, context, painting_info_arg, | 334 if (ShouldCreateSubsequence(paint_layer_, context, painting_info_arg, |
| 337 paint_flags)) { | 335 paint_flags)) { |
| 338 if (!ShouldRepaintSubsequence(paint_layer_, painting_info_arg, | 336 if (!ShouldRepaintSubsequence(paint_layer_, painting_info_arg, |
| 339 respect_overflow_clip, subpixel_accumulation, | 337 respect_overflow_clip, |
| 338 painting_info_arg.sub_pixel_accumulation, | |
| 340 should_clear_empty_paint_phase_flags) && | 339 should_clear_empty_paint_phase_flags) && |
| 341 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, | 340 SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, |
| 342 paint_layer_)) | 341 paint_layer_)) |
| 343 return result; | 342 return result; |
| 344 DCHECK(paint_layer_.SupportsSubsequenceCaching()); | 343 DCHECK(paint_layer_.SupportsSubsequenceCaching()); |
| 345 subsequence_recorder.emplace(context, paint_layer_); | 344 subsequence_recorder.emplace(context, paint_layer_); |
| 346 } else { | 345 } else { |
| 347 should_clear_empty_paint_phase_flags = true; | 346 should_clear_empty_paint_phase_flags = true; |
| 348 } | 347 } |
| 349 | 348 |
| 350 if (should_clear_empty_paint_phase_flags) { | 349 if (should_clear_empty_paint_phase_flags) { |
| 351 paint_layer_.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); | 350 paint_layer_.SetPreviousPaintPhaseDescendantOutlinesEmpty(false); |
| 352 paint_layer_.SetPreviousPaintPhaseFloatEmpty(false); | 351 paint_layer_.SetPreviousPaintPhaseFloatEmpty(false); |
| 353 paint_layer_.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); | 352 paint_layer_.SetPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); |
| 354 } | 353 } |
| 355 | 354 |
| 356 PaintLayerPaintingInfo painting_info = painting_info_arg; | 355 PaintLayerPaintingInfo painting_info = painting_info_arg; |
| 357 | 356 |
| 358 LayoutPoint offset_from_root; | 357 LayoutPoint offset_from_root; |
| 359 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, offset_from_root); | 358 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, offset_from_root); |
| 360 offset_from_root.Move(subpixel_accumulation); | 359 offset_from_root.Move(painting_info_arg.sub_pixel_accumulation); |
| 361 | 360 |
| 362 LayoutRect bounds = paint_layer_.PhysicalBoundingBox(offset_from_root); | 361 LayoutRect bounds = paint_layer_.PhysicalBoundingBox(offset_from_root); |
| 363 if (!painting_info.paint_dirty_rect.Contains(bounds)) | 362 if (!painting_info.paint_dirty_rect.Contains(bounds)) |
| 364 result = kMayBeClippedByPaintDirtyRect; | 363 result = kMayBeClippedByPaintDirtyRect; |
| 365 | 364 |
| 366 // These helpers output clip and compositing operations using a RAII pattern. | 365 // These helpers output clip and compositing operations using a RAII pattern. |
| 367 // Stack-allocated-varibles are destructed in the reverse order of | 366 // Stack-allocated-varibles are destructed in the reverse order of |
| 368 // construction, so they are nested properly. | 367 // construction, so they are nested properly. |
| 369 Optional<ClipPathClipper> clip_path_clipper; | 368 Optional<ClipPathClipper> clip_path_clipper; |
| 370 // Clip-path, like border radius, must not be applied to the contents of a | 369 // 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... | |
| 406 painting_info.GetGlobalPaintFlags())); | 405 painting_info.GetGlobalPaintFlags())); |
| 407 compositing_recorder.emplace( | 406 compositing_recorder.emplace( |
| 408 context, paint_layer_.GetLayoutObject(), | 407 context, paint_layer_.GetLayoutObject(), |
| 409 WebCoreCompositeToSkiaComposite( | 408 WebCoreCompositeToSkiaComposite( |
| 410 kCompositeSourceOver, | 409 kCompositeSourceOver, |
| 411 paint_layer_.GetLayoutObject().Style()->BlendMode()), | 410 paint_layer_.GetLayoutObject().Style()->BlendMode()), |
| 412 paint_layer_.GetLayoutObject().Opacity(), &compositing_bounds); | 411 paint_layer_.GetLayoutObject().Opacity(), &compositing_bounds); |
| 413 } | 412 } |
| 414 | 413 |
| 415 PaintLayerPaintingInfo local_painting_info(painting_info); | 414 PaintLayerPaintingInfo local_painting_info(painting_info); |
| 416 local_painting_info.sub_pixel_accumulation = subpixel_accumulation; | |
| 417 | |
| 418 bool should_paint_content = paint_layer_.HasVisibleContent() && | 415 bool should_paint_content = paint_layer_.HasVisibleContent() && |
| 419 is_self_painting_layer && | 416 is_self_painting_layer && |
| 420 !is_painting_overlay_scrollbars; | 417 !is_painting_overlay_scrollbars; |
| 421 | 418 |
| 422 PaintLayerFragments layer_fragments; | 419 PaintLayerFragments layer_fragments; |
| 423 if (should_paint_content || should_paint_self_outline || | 420 if (should_paint_content || should_paint_self_outline || |
| 424 is_painting_overlay_scrollbars) { | 421 is_painting_overlay_scrollbars) { |
| 425 // Collect the fragments. This will compute the clip rectangles and paint | 422 // Collect the fragments. This will compute the clip rectangles and paint |
| 426 // offsets for each layer fragment. | 423 // offsets for each layer fragment. |
| 427 ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects) | 424 ClipRectsCacheSlot cache_slot = (paint_flags & kPaintLayerUncachedClipRects) |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 // coordinate space, but preserving the accumulated error for sub-pixel | 813 // coordinate space, but preserving the accumulated error for sub-pixel |
| 817 // layout. | 814 // layout. |
| 818 LayoutPoint delta; | 815 LayoutPoint delta; |
| 819 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, delta); | 816 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, delta); |
| 820 delta.MoveBy(fragment_translation); | 817 delta.MoveBy(fragment_translation); |
| 821 TransformationMatrix transform( | 818 TransformationMatrix transform( |
| 822 paint_layer_.RenderableTransform(painting_info.GetGlobalPaintFlags())); | 819 paint_layer_.RenderableTransform(painting_info.GetGlobalPaintFlags())); |
| 823 IntPoint rounded_delta = RoundedIntPoint(delta); | 820 IntPoint rounded_delta = RoundedIntPoint(delta); |
| 824 transform.PostTranslate(rounded_delta.X(), rounded_delta.Y()); | 821 transform.PostTranslate(rounded_delta.X(), rounded_delta.Y()); |
| 825 LayoutSize adjusted_sub_pixel_accumulation = | 822 LayoutSize adjusted_sub_pixel_accumulation = |
| 826 painting_info.sub_pixel_accumulation + (delta - rounded_delta); | 823 paint_layer_.GetCompositingState() == kPaintsIntoOwnBacking |
|
chrishtr
2017/04/21 15:50:51
Why is this change needed?
flackr
2017/05/04 17:38:41
This was to make the code behave the same as befor
| |
| 824 ? paint_layer_.SubpixelAccumulation() | |
| 825 : painting_info.sub_pixel_accumulation + (delta - rounded_delta); | |
| 827 | 826 |
| 828 // TODO(jbroman): Put the real transform origin here, instead of using a | 827 // TODO(jbroman): Put the real transform origin here, instead of using a |
| 829 // matrix with the origin baked in. | 828 // matrix with the origin baked in. |
| 830 FloatPoint3D transform_origin; | 829 FloatPoint3D transform_origin; |
| 831 Transform3DRecorder transform3d_recorder( | 830 Transform3DRecorder transform3d_recorder( |
| 832 context, paint_layer_.GetLayoutObject(), | 831 context, paint_layer_.GetLayoutObject(), |
| 833 DisplayItem::kTransform3DElementTransform, transform, transform_origin); | 832 DisplayItem::kTransform3DElementTransform, transform, transform_origin); |
| 834 | 833 |
| 835 // Now do a paint with the root layer shifted to be us. | 834 // Now do a paint with the root layer shifted to be us. |
| 836 PaintLayerPaintingInfo transformed_painting_info( | 835 PaintLayerPaintingInfo transformed_painting_info( |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 paint_flags, kHasNotClipped); | 1218 paint_flags, kHasNotClipped); |
| 1220 } | 1219 } |
| 1221 | 1220 |
| 1222 void PaintLayerPainter::PaintOverlayScrollbars( | 1221 void PaintLayerPainter::PaintOverlayScrollbars( |
| 1223 GraphicsContext& context, | 1222 GraphicsContext& context, |
| 1224 const LayoutRect& damage_rect, | 1223 const LayoutRect& damage_rect, |
| 1225 const GlobalPaintFlags paint_flags) { | 1224 const GlobalPaintFlags paint_flags) { |
| 1226 if (!paint_layer_.ContainsDirtyOverlayScrollbars()) | 1225 if (!paint_layer_.ContainsDirtyOverlayScrollbars()) |
| 1227 return; | 1226 return; |
| 1228 | 1227 |
| 1228 DCHECK(paint_layer_.GetCompositingState() != kPaintsIntoOwnBacking || | |
| 1229 paint_layer_.SubpixelAccumulation().IsZero()); | |
| 1229 PaintLayerPaintingInfo painting_info( | 1230 PaintLayerPaintingInfo painting_info( |
| 1230 &paint_layer_, LayoutRect(EnclosingIntRect(damage_rect)), paint_flags, | 1231 &paint_layer_, LayoutRect(EnclosingIntRect(damage_rect)), paint_flags, |
| 1231 LayoutSize()); | 1232 LayoutSize()); |
| 1232 Paint(context, painting_info, kPaintLayerPaintingOverlayScrollbars); | 1233 Paint(context, painting_info, kPaintLayerPaintingOverlayScrollbars); |
| 1233 | 1234 |
| 1234 paint_layer_.SetContainsDirtyOverlayScrollbars(false); | 1235 paint_layer_.SetContainsDirtyOverlayScrollbars(false); |
| 1235 } | 1236 } |
| 1236 | 1237 |
| 1237 void PaintLayerPainter::FillMaskingFragment(GraphicsContext& context, | 1238 void PaintLayerPainter::FillMaskingFragment(GraphicsContext& context, |
| 1238 const ClipRect& clip_rect) { | 1239 const ClipRect& clip_rect) { |
| 1239 const LayoutObject& layout_object = paint_layer_.GetLayoutObject(); | 1240 const LayoutObject& layout_object = paint_layer_.GetLayoutObject(); |
| 1240 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( | 1241 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( |
| 1241 context, layout_object, kPaintPhaseClippingMask)) | 1242 context, layout_object, kPaintPhaseClippingMask)) |
| 1242 return; | 1243 return; |
| 1243 | 1244 |
| 1244 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); | 1245 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); |
| 1245 LayoutObjectDrawingRecorder drawing_recorder( | 1246 LayoutObjectDrawingRecorder drawing_recorder( |
| 1246 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); | 1247 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); |
| 1247 context.FillRect(snapped_clip_rect, Color::kBlack); | 1248 context.FillRect(snapped_clip_rect, Color::kBlack); |
| 1248 } | 1249 } |
| 1249 | 1250 |
| 1250 } // namespace blink | 1251 } // namespace blink |
| OLD | NEW |