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 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 GraphicsContext& context, | 826 GraphicsContext& context, |
827 const PaintLayerPaintingInfo& painting_info, | 827 const PaintLayerPaintingInfo& painting_info, |
828 PaintLayerFlags paint_flags, | 828 PaintLayerFlags paint_flags, |
829 const LayoutPoint& fragment_translation) { | 829 const LayoutPoint& fragment_translation) { |
830 // This involves subtracting out the position of the layer in our current | 830 // This involves subtracting out the position of the layer in our current |
831 // coordinate space, but preserving the accumulated error for sub-pixel | 831 // coordinate space, but preserving the accumulated error for sub-pixel |
832 // layout. | 832 // layout. |
833 LayoutPoint delta; | 833 LayoutPoint delta; |
834 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, delta); | 834 paint_layer_.ConvertToLayerCoords(painting_info.root_layer, delta); |
835 delta.MoveBy(fragment_translation); | 835 delta.MoveBy(fragment_translation); |
| 836 delta += painting_info.sub_pixel_accumulation; |
| 837 IntPoint rounded_delta = RoundedIntPoint(delta); |
| 838 |
836 TransformationMatrix transform( | 839 TransformationMatrix transform( |
837 paint_layer_.RenderableTransform(painting_info.GetGlobalPaintFlags())); | 840 paint_layer_.RenderableTransform(painting_info.GetGlobalPaintFlags())); |
838 IntPoint rounded_delta = RoundedIntPoint(delta); | |
839 transform.PostTranslate(rounded_delta.X(), rounded_delta.Y()); | 841 transform.PostTranslate(rounded_delta.X(), rounded_delta.Y()); |
840 LayoutSize adjusted_sub_pixel_accumulation = | 842 |
841 painting_info.sub_pixel_accumulation + (delta - rounded_delta); | 843 LayoutSize new_sub_pixel_accumulation; |
| 844 if (transform.IsIdentityOrTranslation()) |
| 845 new_sub_pixel_accumulation += delta - rounded_delta; |
| 846 // Otherwise discard the sub-pixel remainder because paint offset can't be |
| 847 // transformed by a non-translation transform. |
842 | 848 |
843 // TODO(jbroman): Put the real transform origin here, instead of using a | 849 // TODO(jbroman): Put the real transform origin here, instead of using a |
844 // matrix with the origin baked in. | 850 // matrix with the origin baked in. |
845 FloatPoint3D transform_origin; | 851 FloatPoint3D transform_origin; |
846 Transform3DRecorder transform3d_recorder( | 852 Transform3DRecorder transform3d_recorder( |
847 context, paint_layer_.GetLayoutObject(), | 853 context, paint_layer_.GetLayoutObject(), |
848 DisplayItem::kTransform3DElementTransform, transform, transform_origin); | 854 DisplayItem::kTransform3DElementTransform, transform, transform_origin); |
849 | 855 |
850 // Now do a paint with the root layer shifted to be us. | 856 // Now do a paint with the root layer shifted to be us. |
851 PaintLayerPaintingInfo transformed_painting_info( | 857 PaintLayerPaintingInfo transformed_painting_info( |
852 &paint_layer_, | 858 &paint_layer_, |
853 LayoutRect(EnclosingIntRect( | 859 LayoutRect(EnclosingIntRect( |
854 transform.Inverse().MapRect(painting_info.paint_dirty_rect))), | 860 transform.Inverse().MapRect(painting_info.paint_dirty_rect))), |
855 painting_info.GetGlobalPaintFlags(), adjusted_sub_pixel_accumulation); | 861 painting_info.GetGlobalPaintFlags(), new_sub_pixel_accumulation); |
856 transformed_painting_info.ancestor_has_clip_path_clipping = | 862 transformed_painting_info.ancestor_has_clip_path_clipping = |
857 painting_info.ancestor_has_clip_path_clipping; | 863 painting_info.ancestor_has_clip_path_clipping; |
858 | 864 |
859 // Remove skip root background flag when we're painting with a new root. | 865 // Remove skip root background flag when we're painting with a new root. |
860 if (&paint_layer_ != painting_info.root_layer) | 866 if (&paint_layer_ != painting_info.root_layer) |
861 paint_flags &= ~kPaintLayerPaintingSkipRootBackground; | 867 paint_flags &= ~kPaintLayerPaintingSkipRootBackground; |
862 | 868 |
863 return PaintLayerContentsCompositingAllPhases( | 869 return PaintLayerContentsCompositingAllPhases( |
864 context, transformed_painting_info, paint_flags, kForceSingleFragment); | 870 context, transformed_painting_info, paint_flags, kForceSingleFragment); |
865 } | 871 } |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 context, layout_object, kPaintPhaseClippingMask)) | 1262 context, layout_object, kPaintPhaseClippingMask)) |
1257 return; | 1263 return; |
1258 | 1264 |
1259 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); | 1265 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); |
1260 LayoutObjectDrawingRecorder drawing_recorder( | 1266 LayoutObjectDrawingRecorder drawing_recorder( |
1261 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); | 1267 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); |
1262 context.FillRect(snapped_clip_rect, Color::kBlack); | 1268 context.FillRect(snapped_clip_rect, Color::kBlack); |
1263 } | 1269 } |
1264 | 1270 |
1265 } // namespace blink | 1271 } // namespace blink |
OLD | NEW |