| 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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
| 7 | 7 |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
| 11 #include "platform/graphics/paint/ClipRecorder.h" | 11 #include "platform/graphics/paint/ClipRecorder.h" |
| 12 #include "platform/graphics/paint/DrawingDisplayItem.h" | 12 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 13 #include "platform/graphics/paint/DrawingRecorder.h" | 13 #include "platform/graphics/paint/DrawingRecorder.h" |
| 14 #include <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class DisplayItemListTest : public ::testing::Test { | 18 class DisplayItemListTest : public ::testing::Test { |
| 19 public: | 19 public: |
| 20 DisplayItemListTest() | 20 DisplayItemListTest() |
| 21 : m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } | 21 : m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn
abled()) { } |
| 22 | 22 |
| 23 protected: | 23 protected: |
| 24 DisplayItemList& displayItemList() { return m_displayItemList; } | 24 DisplayItemList& displayItemList() { return m_displayItemList; } |
| 25 const DisplayItems& newPaintListBeforeUpdate() { return displayItemList().m_
newDisplayItems; } | 25 const DisplayItems& newPaintListBeforeUpdate() { return displayItemList().m_
newDisplayItems; } |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 virtual void SetUp() override | 28 void SetUp() override |
| 29 { | 29 { |
| 30 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 30 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
| 31 } | 31 } |
| 32 virtual void TearDown() override | 32 void TearDown() override |
| 33 { | 33 { |
| 34 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); | 34 RuntimeEnabledFeatures::setSlimmingPaintEnabled(m_originalSlimmingPaintE
nabled); |
| 35 } | 35 } |
| 36 | 36 |
| 37 DisplayItemList m_displayItemList; | 37 DisplayItemList m_displayItemList; |
| 38 bool m_originalSlimmingPaintEnabled; | 38 bool m_originalSlimmingPaintEnabled; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D
isplayItem::DrawingPaintPhaseFirst + 4); | 41 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D
isplayItem::DrawingPaintPhaseFirst + 4); |
| 42 const DisplayItem::Type backgroundDrawingType = DisplayItem::BoxDecorationBackgr
ound; | 42 const DisplayItem::Type backgroundDrawingType = DisplayItem::BoxDecorationBackgr
ound; |
| 43 const DisplayItem::Type clipType = DisplayItem::ClipFirst; | 43 const DisplayItem::Type clipType = DisplayItem::ClipFirst; |
| 44 | 44 |
| 45 class TestDisplayItemClient { | 45 class TestDisplayItemClient { |
| 46 public: | 46 public: |
| 47 TestDisplayItemClient(const String& name) | 47 TestDisplayItemClient(const String& name) |
| 48 : m_name(name) | 48 : m_name(name) |
| 49 { } | 49 { } |
| 50 | 50 |
| 51 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi
s); } | 51 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi
s); } |
| 52 String debugName() const { return m_name; } | 52 String debugName() const { return m_name; } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 String m_name; | 55 String m_name; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class TestDisplayItem : public DisplayItem { | 58 class TestDisplayItem : public DisplayItem { |
| 59 public: | 59 public: |
| 60 TestDisplayItem(const TestDisplayItemClient& client, Type type) : DisplayIte
m(client, type) { } | 60 TestDisplayItem(const TestDisplayItemClient& client, Type type) : DisplayIte
m(client, type) { } |
| 61 | 61 |
| 62 virtual void replay(GraphicsContext&) override final { ASSERT_NOT_REACHED();
} | 62 void replay(GraphicsContext&) final { ASSERT_NOT_REACHED(); } |
| 63 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override
final { ASSERT_NOT_REACHED(); } | 63 void appendToWebDisplayItemList(WebDisplayItemList*) const final { ASSERT_NO
T_REACHED(); } |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 #ifndef NDEBUG | 66 #ifndef NDEBUG |
| 67 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \ | 67 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \ |
| 68 String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).as
DebugString() + " Actual: " + (actual).asDebugString(); \ | 68 String trace = String::format("%d: ", (int)i) + "Expected: " + (expected).as
DebugString() + " Actual: " + (actual).asDebugString(); \ |
| 69 SCOPED_TRACE(trace.utf8().data()); | 69 SCOPED_TRACE(trace.utf8().data()); |
| 70 #else | 70 #else |
| 71 #define TRACE_DISPLAY_ITEMS(i, expected, actual) | 71 #define TRACE_DISPLAY_ITEMS(i, expected, actual) |
| 72 #endif | 72 #endif |
| 73 | 73 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 695 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 696 displayItemList().commitNewDisplayItems(); | 696 displayItemList().commitNewDisplayItems(); |
| 697 | 697 |
| 698 // Empty clips should have been optimized out. | 698 // Empty clips should have been optimized out. |
| 699 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, | 699 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, |
| 700 TestDisplayItem(first, backgroundDrawingType), | 700 TestDisplayItem(first, backgroundDrawingType), |
| 701 TestDisplayItem(third, backgroundDrawingType)); | 701 TestDisplayItem(third, backgroundDrawingType)); |
| 702 } | 702 } |
| 703 | 703 |
| 704 } // namespace blink | 704 } // namespace blink |
| OLD | NEW |