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