| 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 "core/paint/ClipRecorder.h" | 6 #include "core/paint/ClipRecorder.h" |
| 7 | 7 |
| 8 #include "core/rendering/RenderView.h" | 8 #include "core/rendering/RenderView.h" |
| 9 #include "core/rendering/RenderingTestHelper.h" | 9 #include "core/rendering/RenderingTestHelper.h" |
| 10 #include "core/rendering/compositing/RenderLayerCompositor.h" | 10 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 11 #include "platform/graphics/GraphicsContext.h" | 11 #include "platform/graphics/GraphicsContext.h" |
| 12 #include "platform/graphics/GraphicsLayer.h" | |
| 13 #include "platform/graphics/paint/DisplayItemList.h" | |
| 14 #include <gtest/gtest.h> | 12 #include <gtest/gtest.h> |
| 15 | 13 |
| 16 namespace blink { | 14 namespace blink { |
| 17 namespace { | 15 namespace { |
| 18 | 16 |
| 19 class ClipRecorderTest : public RenderingTest { | 17 class ClipRecorderTest : public RenderingTest { |
| 20 public: | 18 public: |
| 21 ClipRecorderTest() : m_renderView(nullptr) { } | 19 ClipRecorderTest() : m_renderView(nullptr) { } |
| 22 | 20 |
| 23 protected: | 21 protected: |
| 24 RenderView* renderView() { return m_renderView; } | 22 RenderView* renderView() { return m_renderView; } |
| 25 DisplayItemList& rootDisplayItemList() { return renderView()->layer()->graph
icsLayerBacking()->displayItemList(); } | |
| 26 | 23 |
| 27 private: | 24 private: |
| 28 virtual void SetUp() override | 25 virtual void SetUp() override |
| 29 { | 26 { |
| 30 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); | 27 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); |
| 31 | 28 |
| 32 RenderingTest::SetUp(); | 29 RenderingTest::SetUp(); |
| 33 enableCompositing(); | |
| 34 | 30 |
| 35 m_renderView = document().view()->renderView(); | 31 m_renderView = document().view()->renderView(); |
| 36 ASSERT_TRUE(m_renderView); | 32 ASSERT_TRUE(m_renderView); |
| 37 } | 33 } |
| 38 | 34 |
| 39 RenderView* m_renderView; | 35 RenderView* m_renderView; |
| 40 }; | 36 }; |
| 41 | 37 |
| 42 void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
const FloatRect& bound) | 38 void drawClip(GraphicsContext* context, RenderView* renderer, PaintPhase phase,
const FloatRect& bound) |
| 43 { | 39 { |
| 44 IntRect rect(1, 1, 9, 9); | 40 IntRect rect(1, 1, 9, 9); |
| 45 ClipRect clipRect(rect); | 41 ClipRect clipRect(rect); |
| 46 ClipRecorder clipRecorder(renderer->compositor()->rootRenderLayer(), context
, DisplayItem::ClipLayerForeground, clipRect); | 42 ClipRecorder clipRecorder(renderer->compositor()->rootRenderLayer(), context
, DisplayItem::ClipLayerForeground, clipRect); |
| 47 } | 43 } |
| 48 | 44 |
| 49 TEST_F(ClipRecorderTest, ClipRecorderTest_Single) | 45 TEST_F(ClipRecorderTest, ClipRecorderTest_Single) |
| 50 { | 46 { |
| 51 GraphicsContext* context = new GraphicsContext(nullptr); | 47 GraphicsContext* context = new GraphicsContext(nullptr); |
| 52 FloatRect bound = renderView()->viewRect(); | 48 FloatRect bound = renderView()->viewRect(); |
| 53 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); | 49 EXPECT_EQ((size_t)0, renderView()->viewDisplayList().paintList().size()); |
| 54 | 50 |
| 55 drawClip(context, renderView(), PaintPhaseForeground, bound); | 51 drawClip(context, renderView(), PaintPhaseForeground, bound); |
| 56 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); | 52 EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size()); |
| 57 } | 53 } |
| 58 | 54 |
| 59 } | 55 } |
| 60 } | 56 } |
| OLD | NEW |