| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "web/PageOverlay.h" | 5 #include "web/PageOverlay.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "platform/graphics/Color.h" | 8 #include "platform/graphics/Color.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/graphics/paint/DrawingRecorder.h" | 10 #include "platform/graphics/paint/DrawingRecorder.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 public: | 101 public: |
| 102 RuntimeFeatureChange(bool newValue) : m_oldValue(getter()) { | 102 RuntimeFeatureChange(bool newValue) : m_oldValue(getter()) { |
| 103 setter(newValue); | 103 setter(newValue); |
| 104 } | 104 } |
| 105 ~RuntimeFeatureChange() { setter(m_oldValue); } | 105 ~RuntimeFeatureChange() { setter(m_oldValue); } |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 bool m_oldValue; | 108 bool m_oldValue; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 class MockCanvas : public SkCanvas { | 111 class MockCanvas : public CdlCanvas { |
| 112 public: | 112 public: |
| 113 MockCanvas(int width, int height) : SkCanvas(width, height) {} | 113 MockCanvas(int width, int height) : CdlCanvas(width, height) {} |
| 114 MOCK_METHOD2(onDrawRect, void(const SkRect&, const SkPaint&)); | 114 MOCK_METHOD2(onDrawRect, void(const SkRect&, const CdlPaint&)); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) { | 117 TEST_F(PageOverlayTest, PageOverlay_AcceleratedCompositing) { |
| 118 initialize(AcceleratedCompositing); | 118 initialize(AcceleratedCompositing); |
| 119 webViewImpl()->layerTreeView()->setViewportSize( | 119 webViewImpl()->layerTreeView()->setViewportSize( |
| 120 WebSize(viewportWidth, viewportHeight)); | 120 WebSize(viewportWidth, viewportHeight)); |
| 121 | 121 |
| 122 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); | 122 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); |
| 123 pageOverlay->update(); | 123 pageOverlay->update(); |
| 124 webViewImpl()->updateAllLifecyclePhases(); | 124 webViewImpl()->updateAllLifecyclePhases(); |
| 125 | 125 |
| 126 // Ideally, we would get results from the compositor that showed that this | 126 // Ideally, we would get results from the compositor that showed that this |
| 127 // page overlay actually winds up getting drawn on top of the rest. | 127 // page overlay actually winds up getting drawn on top of the rest. |
| 128 // For now, we just check that the GraphicsLayer will draw the right thing. | 128 // For now, we just check that the GraphicsLayer will draw the right thing. |
| 129 | 129 |
| 130 MockCanvas canvas(viewportWidth, viewportHeight); | 130 MockCanvas canvas(viewportWidth, viewportHeight); |
| 131 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0)); | 131 EXPECT_CALL(canvas, onDrawRect(_, _)).Times(AtLeast(0)); |
| 132 EXPECT_CALL(canvas, onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight), | 132 EXPECT_CALL(canvas, |
| 133 Property(&SkPaint::getColor, SK_ColorYELLOW))); | 133 onDrawRect(SkRect::MakeWH(viewportWidth, viewportHeight), |
| 134 Property(&CdlPaint::getColor, SK_ColorYELLOW))); |
| 134 | 135 |
| 135 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer(); | 136 GraphicsLayer* graphicsLayer = pageOverlay->graphicsLayer(); |
| 136 WebRect rect(0, 0, viewportWidth, viewportHeight); | 137 WebRect rect(0, 0, viewportWidth, viewportHeight); |
| 137 | 138 |
| 138 // Paint the layer with a null canvas to get a display list, and then | 139 // Paint the layer with a null canvas to get a display list, and then |
| 139 // replay that onto the mock canvas for examination. | 140 // replay that onto the mock canvas for examination. |
| 140 IntRect intRect = rect; | 141 IntRect intRect = rect; |
| 141 graphicsLayer->paint(&intRect); | 142 graphicsLayer->paint(&intRect); |
| 142 | 143 |
| 143 PaintController& paintController = graphicsLayer->getPaintController(); | 144 PaintController& paintController = graphicsLayer->getPaintController(); |
| 144 GraphicsContext graphicsContext(paintController); | 145 GraphicsContext graphicsContext(paintController); |
| 145 graphicsContext.beginRecording(intRect); | 146 graphicsContext.beginRecording(intRect); |
| 146 paintController.paintArtifact().replay(graphicsContext); | 147 paintController.paintArtifact().replay(graphicsContext); |
| 147 graphicsContext.endRecording()->playback(&canvas); | 148 graphicsContext.endRecording()->playback(&canvas); |
| 148 } | 149 } |
| 149 | 150 |
| 150 TEST_F(PageOverlayTest, PageOverlay_VisualRect) { | 151 TEST_F(PageOverlayTest, PageOverlay_VisualRect) { |
| 151 initialize(AcceleratedCompositing); | 152 initialize(AcceleratedCompositing); |
| 152 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); | 153 std::unique_ptr<PageOverlay> pageOverlay = createSolidYellowOverlay(); |
| 153 pageOverlay->update(); | 154 pageOverlay->update(); |
| 154 webViewImpl()->updateAllLifecyclePhases(); | 155 webViewImpl()->updateAllLifecyclePhases(); |
| 155 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), | 156 EXPECT_EQ(LayoutRect(0, 0, viewportWidth, viewportHeight), |
| 156 pageOverlay->visualRect()); | 157 pageOverlay->visualRect()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 } // namespace | 160 } // namespace |
| 160 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |