OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 PaintControllerPaintTest_h | 5 #ifndef PaintControllerPaintTest_h |
6 #define PaintControllerPaintTest_h | 6 #define PaintControllerPaintTest_h |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
11 #include "core/paint/PaintLayer.h" | 11 #include "core/paint/PaintLayer.h" |
12 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
13 #include "platform/graphics/GraphicsLayer.h" | 13 #include "platform/graphics/GraphicsLayer.h" |
| 14 #include "platform/graphics/paint/CullRect.h" |
14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
15 #include <gtest/gtest.h> | 16 #include <gtest/gtest.h> |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 class PaintControllerPaintTestBase | 20 class PaintControllerPaintTestBase |
20 : private ScopedSlimmingPaintV2ForTest | 21 : private ScopedSlimmingPaintV2ForTest |
21 , public RenderingTest { | 22 , public RenderingTest { |
22 public: | 23 public: |
23 PaintControllerPaintTestBase(bool enableSlimmingPaintV2) : ScopedSlimmingPai
ntV2ForTest(enableSlimmingPaintV2) { } | 24 PaintControllerPaintTestBase(bool enableSlimmingPaintV2) : ScopedSlimmingPai
ntV2ForTest(enableSlimmingPaintV2) { } |
24 | 25 |
25 protected: | 26 protected: |
26 LayoutView& layoutView() { return *document().layoutView(); } | 27 LayoutView& layoutView() { return *document().layoutView(); } |
27 PaintController& rootPaintController() { return layoutView().layer()->graphi
csLayerBacking()->getPaintController(); } | 28 PaintController& rootPaintController() |
| 29 { |
| 30 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 31 return *document().view()->paintController(); |
| 32 return layoutView().layer()->graphicsLayerBacking()->getPaintController(
); |
| 33 } |
28 | 34 |
29 void SetUp() override | 35 void SetUp() override |
30 { | 36 { |
31 RenderingTest::SetUp(); | 37 RenderingTest::SetUp(); |
32 enableCompositing(); | 38 enableCompositing(); |
33 } | 39 } |
34 | 40 |
35 bool paintWithoutCommit(const IntRect* interestRect = nullptr) | 41 bool paintWithoutCommit(const IntRect* interestRect = nullptr) |
36 { | 42 { |
| 43 document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint); |
| 44 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 45 if (layoutView().layer()->needsRepaint()) { |
| 46 GraphicsContext graphicsContext(rootPaintController()); |
| 47 document().view()->paint(graphicsContext, CullRect(LayoutRect::i
nfiniteIntRect())); |
| 48 return true; |
| 49 } |
| 50 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle
an); |
| 51 return false; |
| 52 } |
37 // Only root graphics layer is supported. | 53 // Only root graphics layer is supported. |
38 document().view()->lifecycle().advanceTo(DocumentLifecycle::InPaint); | |
39 if (!layoutView().layer()->graphicsLayerBacking()->paintWithoutCommit(in
terestRect)) { | 54 if (!layoutView().layer()->graphicsLayerBacking()->paintWithoutCommit(in
terestRect)) { |
40 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle
an); | 55 document().view()->lifecycle().advanceTo(DocumentLifecycle::PaintCle
an); |
41 return false; | 56 return false; |
42 } | 57 } |
43 return true; | 58 return true; |
44 } | 59 } |
45 | 60 |
46 void commit() | 61 void commit() |
47 { | 62 { |
48 // Only root graphics layer is supported. | 63 // Only root graphics layer is supported. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } while (false); | 131 } while (false); |
117 | 132 |
118 // Shorter names for frequently used display item types in tests. | 133 // Shorter names for frequently used display item types in tests. |
119 const DisplayItem::Type backgroundType = DisplayItem::kBoxDecorationBackground; | 134 const DisplayItem::Type backgroundType = DisplayItem::kBoxDecorationBackground; |
120 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground); | 135 const DisplayItem::Type foregroundType = DisplayItem::paintPhaseToDrawingType(Pa
intPhaseForeground); |
121 const DisplayItem::Type documentBackgroundType = DisplayItem::kDocumentBackgroun
d; | 136 const DisplayItem::Type documentBackgroundType = DisplayItem::kDocumentBackgroun
d; |
122 | 137 |
123 } // namespace blink | 138 } // namespace blink |
124 | 139 |
125 #endif // PaintControllerPaintTest_h | 140 #endif // PaintControllerPaintTest_h |
OLD | NEW |