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 "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "platform/graphics/paint/CachedDisplayItem.h" | 9 #include "platform/graphics/paint/CachedDisplayItem.h" |
10 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 10 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
11 #include "platform/graphics/paint/ClipPathRecorder.h" | 11 #include "platform/graphics/paint/ClipPathRecorder.h" |
12 #include "platform/graphics/paint/ClipRecorder.h" | 12 #include "platform/graphics/paint/ClipRecorder.h" |
13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
14 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
15 #include "platform/graphics/paint/SubsequenceRecorder.h" | 15 #include "platform/graphics/paint/SubsequenceRecorder.h" |
16 #include "platform/testing/FakeDisplayItemClient.h" | 16 #include "platform/testing/FakeDisplayItemClient.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include <memory> | |
19 | 18 |
20 namespace blink { | 19 namespace blink { |
21 | 20 |
22 class PaintControllerTest : public ::testing::Test { | 21 class PaintControllerTest : public ::testing::Test { |
23 public: | 22 public: |
24 PaintControllerTest() | 23 PaintControllerTest() |
25 : m_paintController(PaintController::create()) | 24 : m_paintController(PaintController::create()) |
26 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | 25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
27 | 26 |
28 IntRect visualRect(const PaintArtifact& paintArtifact, unsigned index) | 27 IntRect visualRect(const PaintArtifact& paintArtifact, unsigned index) |
29 { | 28 { |
30 return paintArtifact.getDisplayItemList().visualRect(index); | 29 return paintArtifact.getDisplayItemList().visualRect(index); |
31 } | 30 } |
32 | 31 |
33 protected: | 32 protected: |
34 PaintController& getPaintController() { return *m_paintController; } | 33 PaintController& getPaintController() { return *m_paintController; } |
35 | 34 |
36 private: | 35 private: |
37 void TearDown() override | 36 void TearDown() override |
38 { | 37 { |
39 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 38 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
40 } | 39 } |
41 | 40 |
42 std::unique_ptr<PaintController> m_paintController; | 41 OwnPtr<PaintController> m_paintController; |
43 bool m_originalSlimmingPaintV2Enabled; | 42 bool m_originalSlimmingPaintV2Enabled; |
44 }; | 43 }; |
45 | 44 |
46 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D
isplayItem::DrawingPaintPhaseFirst + 4); | 45 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D
isplayItem::DrawingPaintPhaseFirst + 4); |
47 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi
rst; | 46 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi
rst; |
48 const DisplayItem::Type clipType = DisplayItem::ClipFirst; | 47 const DisplayItem::Type clipType = DisplayItem::ClipFirst; |
49 | 48 |
50 class TestDisplayItem final : public DisplayItem { | 49 class TestDisplayItem final : public DisplayItem { |
51 public: | 50 public: |
52 TestDisplayItem(const FakeDisplayItemClient& client, Type type) : DisplayIte
m(client, type, sizeof(*this)) { } | 51 TestDisplayItem(const FakeDisplayItemClient& client, Type type) : DisplayIte
m(client, type, sizeof(*this)) { } |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); | 925 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); |
927 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); | 926 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); |
928 for (int j = 0; j < 50; ++j) | 927 for (int j = 0; j < 50; ++j) |
929 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; | 928 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; |
930 getPaintController().commitNewDisplayItems(LayoutSize()); | 929 getPaintController().commitNewDisplayItems(LayoutSize()); |
931 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); | 930 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); |
932 } | 931 } |
933 } | 932 } |
934 | 933 |
935 } // namespace blink | 934 } // namespace blink |
OLD | NEW |