OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef BoxPainter_h | 5 #ifndef NGBoxFragmentPainter_h |
6 #define BoxPainter_h | 6 #define NGBoxFragmentPainter_h |
7 | 7 |
8 #include "core/layout/BackgroundBleedAvoidance.h" | 8 #include "core/layout/BackgroundBleedAvoidance.h" |
9 #include "core/paint/BoxPainterBase.h" | 9 #include "core/paint/BoxPainterBase.h" |
10 #include "platform/geometry/LayoutSize.h" | 10 #include "platform/geometry/LayoutSize.h" |
11 #include "platform/graphics/GraphicsTypes.h" | 11 #include "platform/graphics/GraphicsTypes.h" |
12 #include "platform/wtf/Allocator.h" | 12 #include "platform/wtf/Allocator.h" |
13 #include "third_party/skia/include/core/SkBlendMode.h" | 13 #include "third_party/skia/include/core/SkBlendMode.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class ComputedStyle; | 17 class ComputedStyle; |
18 class FillLayer; | 18 class FillLayer; |
19 class GraphicsContext; | |
20 class Image; | |
21 class InlineFlowBox; | |
22 class LayoutPoint; | 19 class LayoutPoint; |
23 class LayoutRect; | 20 class LayoutRect; |
24 class NinePieceImage; | 21 class NGPhysicalBoxFragment; |
| 22 class NGPhysicalLineBoxFragment; |
| 23 class NGPhysicalFragment; |
25 struct PaintInfo; | 24 struct PaintInfo; |
26 class LayoutBox; | 25 class Document; |
27 class LayoutObject; | |
28 class LayoutBoxModelObject; | |
29 | 26 |
30 class BoxPainter : public BoxPainterBase { | 27 class NGBoxFragmentPainter : public BoxPainterBase { |
31 STACK_ALLOCATED(); | 28 STACK_ALLOCATED(); |
32 | 29 |
33 public: | 30 public: |
34 BoxPainter(const LayoutBox& layout_box) : layout_box_(layout_box) {} | 31 NGBoxFragmentPainter(const NGPhysicalBoxFragment* box_fragment) |
| 32 : box_fragment_(box_fragment) {} |
| 33 ~NGBoxFragmentPainter() {} |
35 void Paint(const PaintInfo&, const LayoutPoint&); | 34 void Paint(const PaintInfo&, const LayoutPoint&); |
36 | 35 |
37 void PaintChildren(const PaintInfo&, const LayoutPoint&); | 36 void PaintChildren(const PaintInfo&, const LayoutPoint&); |
| 37 void PaintLineBox(const NGPhysicalLineBoxFragment*, |
| 38 const PaintInfo&, |
| 39 const LayoutPoint& paint_offset); |
| 40 |
38 void PaintBoxDecorationBackground(const PaintInfo&, const LayoutPoint&); | 41 void PaintBoxDecorationBackground(const PaintInfo&, const LayoutPoint&); |
39 void PaintMask(const PaintInfo&, const LayoutPoint&); | |
40 void PaintClippingMask(const PaintInfo&, const LayoutPoint&); | |
41 | |
42 typedef Vector<const FillLayer*, 8> FillLayerOcclusionOutputList; | |
43 // Returns true if the result fill layers have non-associative blending or | |
44 // compositing mode. (i.e. The rendering will be different without creating | |
45 // isolation group by context.saveLayer().) Note that the output list will be | |
46 // in top-bottom order. | |
47 bool CalculateFillLayerOcclusionCulling( | |
48 FillLayerOcclusionOutputList& reversed_paint_list, | |
49 const FillLayer&); | |
50 | |
51 // Returns true if the fill layer will certainly occlude anything painted | |
52 // behind it. | |
53 static bool IsFillLayerOpaque(const FillLayer&, const LayoutObject&); | |
54 | 42 |
55 void PaintFillLayers(const PaintInfo&, | 43 void PaintFillLayers(const PaintInfo&, |
56 const Color&, | 44 const Color&, |
57 const FillLayer&, | 45 const FillLayer&, |
58 const LayoutRect&, | 46 const LayoutRect&, |
59 BackgroundBleedAvoidance = kBackgroundBleedNone, | 47 BackgroundBleedAvoidance = kBackgroundBleedNone, |
60 SkBlendMode = SkBlendMode::kSrcOver, | 48 SkBlendMode = SkBlendMode::kSrcOver, |
61 const LayoutObject* background_object = nullptr); | 49 const NGPhysicalFragment* bg_fragment = nullptr); |
62 void PaintMaskImages(const PaintInfo&, const LayoutRect&); | 50 |
63 void PaintBoxDecorationBackgroundWithRect(const PaintInfo&, | 51 void PaintBoxDecorationBackgroundWithRect(const PaintInfo&, |
64 const LayoutPoint&, | 52 const LayoutPoint&, |
65 const LayoutRect&); | 53 const LayoutRect&); |
66 static void PaintFillLayer(const LayoutBoxModelObject&, | 54 static void PaintFillLayer(const NGPhysicalBoxFragment*, |
67 const PaintInfo&, | 55 const PaintInfo&, |
68 const Color&, | 56 const Color&, |
69 const FillLayer&, | 57 const FillLayer&, |
70 const LayoutRect&, | 58 const LayoutRect&, |
71 BackgroundBleedAvoidance, | 59 BackgroundBleedAvoidance, |
72 const InlineFlowBox* = nullptr, | 60 const NGPhysicalFragment* = nullptr, |
73 const LayoutSize& = LayoutSize(), | 61 const LayoutSize& = LayoutSize(), |
74 SkBlendMode = SkBlendMode::kSrcOver, | 62 SkBlendMode = SkBlendMode::kSrcOver, |
75 const LayoutObject* background_object = nullptr); | 63 const NGPhysicalFragment* bg_object = nullptr); |
76 static InterpolationQuality ChooseInterpolationQuality(const LayoutObject&, | 64 |
77 Image*, | 65 static void PaintBorder(const NGPhysicalBoxFragment*, |
78 const void*, | |
79 const LayoutSize&); | |
80 static bool PaintNinePieceImage(const LayoutBoxModelObject&, | |
81 GraphicsContext&, | |
82 const LayoutRect&, | |
83 const ComputedStyle&, | |
84 const NinePieceImage&, | |
85 SkBlendMode = SkBlendMode::kSrcOver); | |
86 static void PaintBorder(const LayoutBoxModelObject&, | |
87 const PaintInfo&, | 66 const PaintInfo&, |
88 const LayoutRect&, | 67 const LayoutRect&, |
89 const ComputedStyle&, | 68 const ComputedStyle&, |
90 BackgroundBleedAvoidance = kBackgroundBleedNone, | 69 BackgroundBleedAvoidance = kBackgroundBleedNone, |
91 bool include_logical_left_edge = true, | 70 bool include_logical_left_edge = true, |
92 bool include_logical_right_edge = true); | 71 bool include_logical_right_edge = true); |
93 | 72 |
94 LayoutRect BoundsForDrawingRecorder(const PaintInfo&, | 73 LayoutRect BoundsForDrawingRecorder(const PaintInfo&, |
95 const LayoutPoint& adjusted_paint_offset); | 74 const LayoutPoint& adjusted_paint_offset); |
96 | 75 |
97 static bool IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( | |
98 const LayoutBoxModelObject*, | |
99 const PaintInfo&); | |
100 | |
101 private: | 76 private: |
| 77 const Document& GetDocument() const; |
102 void PaintBackground(const PaintInfo&, | 78 void PaintBackground(const PaintInfo&, |
103 const LayoutRect&, | 79 const LayoutRect&, |
104 const Color& background_color, | 80 const Color& background_color, |
105 BackgroundBleedAvoidance = kBackgroundBleedNone); | 81 BackgroundBleedAvoidance = kBackgroundBleedNone); |
106 | 82 |
107 const LayoutBox& layout_box_; | 83 const NGPhysicalBoxFragment* box_fragment_; |
108 }; | 84 }; |
109 | 85 |
110 } // namespace blink | 86 } // namespace blink |
111 | 87 |
112 #endif | 88 #endif // NGBoxFragmentPainter_h |
OLD | NEW |