Index: Source/platform/graphics/paint/DisplayItemListTest.cpp |
diff --git a/Source/platform/graphics/paint/DisplayItemListTest.cpp b/Source/platform/graphics/paint/DisplayItemListTest.cpp |
index 59e7642e15a0df630c18a0e3f31dec68c67c752b..544fbaa0c446623d82c54172e909fb617931e0f2 100644 |
--- a/Source/platform/graphics/paint/DisplayItemListTest.cpp |
+++ b/Source/platform/graphics/paint/DisplayItemListTest.cpp |
@@ -12,11 +12,30 @@ |
#include "platform/graphics/paint/ClipRecorder.h" |
#include "platform/graphics/paint/DrawingDisplayItem.h" |
#include "platform/graphics/paint/DrawingRecorder.h" |
-#include "platform/graphics/paint/SubtreeRecorder.h" |
#include <gtest/gtest.h> |
namespace blink { |
+class SimpleSubtreeRecorder { |
+public: |
+ SimpleSubtreeRecorder(DisplayItemList& displayItemList, const DisplayItemClientWrapper& client, int paintPhase) |
+ : m_displayItemList(displayItemList) |
+ , m_client(client) |
+ , m_paintPhase(paintPhase) |
+ { |
+ displayItemList.createAndAppend<BeginSubtreeDisplayItem>(client, DisplayItem::paintPhaseToBeginSubtreeType(paintPhase)); |
+ } |
+ ~SimpleSubtreeRecorder() |
+ { |
+ m_displayItemList.createAndAppend<EndSubtreeDisplayItem>(m_client, DisplayItem::paintPhaseToEndSubtreeType(m_paintPhase)); |
+ } |
+ |
+private: |
pdr.
2015/08/24 20:30:10
Should these be const?
Xianzhu
2015/08/24 23:03:21
Done.
|
+ DisplayItemList& m_displayItemList; |
+ DisplayItemClientWrapper m_client; |
+ int m_paintPhase; |
+}; |
+ |
class DisplayItemListTest : public ::testing::Test { |
public: |
DisplayItemListTest() |
@@ -462,26 +481,22 @@ TEST_F(DisplayItemListTest, CachedSubtreeSwapOrder) |
const int foregroundPaintPhase = foregroundDrawingType - DisplayItem::DrawingPaintPhaseFirst; |
{ |
- SubtreeRecorder r(context, container1, backgroundPaintPhase); |
- EXPECT_FALSE(r.canUseCache()); |
+ SimpleSubtreeRecorder r(context, container1, backgroundPaintPhase); |
drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); |
drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 200)); |
} |
{ |
- SubtreeRecorder r(context, container1, foregroundPaintPhase); |
- EXPECT_FALSE(r.canUseCache()); |
+ SimpleSubtreeRecorder r(context, container1, foregroundPaintPhase); |
drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 200)); |
drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); |
} |
{ |
- SubtreeRecorder r(context, container2, backgroundPaintPhase); |
- EXPECT_FALSE(r.canUseCache()); |
+ SimpleSubtreeRecorder r(context, container2, backgroundPaintPhase); |
drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); |
drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 200)); |
} |
{ |
- SubtreeRecorder r(context, container2, foregroundPaintPhase); |
- EXPECT_FALSE(r.canUseCache()); |
+ SimpleSubtreeRecorder r(context, container2, foregroundPaintPhase); |
drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 200)); |
drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100)); |
} |
@@ -509,17 +524,17 @@ TEST_F(DisplayItemListTest, CachedSubtreeSwapOrder) |
TestDisplayItem(container2, DisplayItem::paintPhaseToEndSubtreeType(foregroundPaintPhase))); |
// Simulate the situation when container1 e.g. gets a z-index that is now greater than container2. |
- displayItemList().createAndAppend<CachedDisplayItem>(container2, DisplayItem::paintPhaseToCachedSubtreeType(backgroundPaintPhase)); |
+ EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container2, backgroundPaintPhase)); |
EXPECT_EQ((size_t)1, newPaintListBeforeUpdate().size()); |
EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
- displayItemList().createAndAppend<CachedDisplayItem>(container2, DisplayItem::paintPhaseToCachedSubtreeType(foregroundPaintPhase)); |
+ EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container2, foregroundPaintPhase)); |
EXPECT_EQ((size_t)2, newPaintListBeforeUpdate().size()); |
EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
- displayItemList().createAndAppend<CachedDisplayItem>(container1, DisplayItem::paintPhaseToCachedSubtreeType(backgroundPaintPhase)); |
+ EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container1, backgroundPaintPhase)); |
EXPECT_EQ((size_t)3, newPaintListBeforeUpdate().size()); |
EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
- displayItemList().createAndAppend<CachedDisplayItem>(container1, DisplayItem::paintPhaseToCachedSubtreeType(foregroundPaintPhase)); |
+ EXPECT_TRUE(SubtreeRecorder::useCachedSubtreeIfPossible(context, container1, foregroundPaintPhase)); |
EXPECT_EQ((size_t)4, newPaintListBeforeUpdate().size()); |
EXPECT_TRUE(newPaintListBeforeUpdate().last().isCachedSubtree()); |
displayItemList().commitNewDisplayItems(); |