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 "platform/graphics/RecordingImageBufferSurface.h" | 5 #include "platform/graphics/RecordingImageBufferSurface.h" |
6 | 6 |
7 #include "platform/WebTaskRunner.h" | 7 #include "platform/WebTaskRunner.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "platform/graphics/ImageBuffer.h" | 9 #include "platform/graphics/ImageBuffer.h" |
10 #include "platform/graphics/ImageBufferClient.h" | 10 #include "platform/graphics/ImageBufferClient.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class MockSurfaceFactory : public RecordingImageBufferFallbackSurfaceFactory { | 73 class MockSurfaceFactory : public RecordingImageBufferFallbackSurfaceFactory { |
74 public: | 74 public: |
75 MockSurfaceFactory() : m_createSurfaceCount(0) {} | 75 MockSurfaceFactory() : m_createSurfaceCount(0) {} |
76 | 76 |
77 virtual std::unique_ptr<ImageBufferSurface> createSurface( | 77 virtual std::unique_ptr<ImageBufferSurface> createSurface( |
78 const IntSize& size, | 78 const IntSize& size, |
79 OpacityMode opacityMode, | 79 OpacityMode opacityMode, |
80 sk_sp<SkColorSpace> colorSpace, | 80 sk_sp<SkColorSpace> colorSpace, |
81 SkColorType colorType) { | 81 SkColorType colorType) { |
82 m_createSurfaceCount++; | 82 m_createSurfaceCount++; |
83 return wrapUnique(new UnacceleratedImageBufferSurface( | 83 return WTF::wrapUnique(new UnacceleratedImageBufferSurface( |
84 size, opacityMode, InitializeImagePixels, std::move(colorSpace), | 84 size, opacityMode, InitializeImagePixels, std::move(colorSpace), |
85 colorType)); | 85 colorType)); |
86 } | 86 } |
87 | 87 |
88 virtual ~MockSurfaceFactory() {} | 88 virtual ~MockSurfaceFactory() {} |
89 | 89 |
90 int createSurfaceCount() { return m_createSurfaceCount; } | 90 int createSurfaceCount() { return m_createSurfaceCount; } |
91 | 91 |
92 private: | 92 private: |
93 int m_createSurfaceCount; | 93 int m_createSurfaceCount; |
94 }; | 94 }; |
95 | 95 |
96 class RecordingImageBufferSurfaceTest : public Test { | 96 class RecordingImageBufferSurfaceTest : public Test { |
97 protected: | 97 protected: |
98 RecordingImageBufferSurfaceTest() { | 98 RecordingImageBufferSurfaceTest() { |
99 std::unique_ptr<MockSurfaceFactory> surfaceFactory = | 99 std::unique_ptr<MockSurfaceFactory> surfaceFactory = |
100 makeUnique<MockSurfaceFactory>(); | 100 WTF::makeUnique<MockSurfaceFactory>(); |
101 m_surfaceFactory = surfaceFactory.get(); | 101 m_surfaceFactory = surfaceFactory.get(); |
102 std::unique_ptr<RecordingImageBufferSurface> testSurface = | 102 std::unique_ptr<RecordingImageBufferSurface> testSurface = |
103 wrapUnique(new RecordingImageBufferSurface( | 103 WTF::wrapUnique(new RecordingImageBufferSurface( |
104 IntSize(10, 10), std::move(surfaceFactory), NonOpaque, nullptr)); | 104 IntSize(10, 10), std::move(surfaceFactory), NonOpaque, nullptr)); |
105 m_testSurface = testSurface.get(); | 105 m_testSurface = testSurface.get(); |
106 // We create an ImageBuffer in order for the testSurface to be | 106 // We create an ImageBuffer in order for the testSurface to be |
107 // properly initialized with a GraphicsContext | 107 // properly initialized with a GraphicsContext |
108 m_imageBuffer = ImageBuffer::create(std::move(testSurface)); | 108 m_imageBuffer = ImageBuffer::create(std::move(testSurface)); |
109 EXPECT_FALSE(!m_imageBuffer); | 109 EXPECT_FALSE(!m_imageBuffer); |
110 m_fakeImageBufferClient = | 110 m_fakeImageBufferClient = |
111 wrapUnique(new FakeImageBufferClient(m_imageBuffer.get())); | 111 WTF::wrapUnique(new FakeImageBufferClient(m_imageBuffer.get())); |
112 m_imageBuffer->setClient(m_fakeImageBufferClient.get()); | 112 m_imageBuffer->setClient(m_fakeImageBufferClient.get()); |
113 } | 113 } |
114 | 114 |
115 public: | 115 public: |
116 void testEmptyPicture() { | 116 void testEmptyPicture() { |
117 m_testSurface->initializeCurrentFrame(); | 117 m_testSurface->initializeCurrentFrame(); |
118 sk_sp<SkPicture> picture = m_testSurface->getPicture(); | 118 sk_sp<SkPicture> picture = m_testSurface->getPicture(); |
119 EXPECT_TRUE((bool)picture.get()); | 119 EXPECT_TRUE((bool)picture.get()); |
120 EXPECT_EQ(1, m_fakeImageBufferClient->frameCount()); | 120 EXPECT_EQ(1, m_fakeImageBufferClient->frameCount()); |
121 expectDisplayListEnabled(true); | 121 expectDisplayListEnabled(true); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 CALL_TEST_TASK_WRAPPER(testAnimatedWithClear) | 270 CALL_TEST_TASK_WRAPPER(testAnimatedWithClear) |
271 expectDisplayListEnabled(true); | 271 expectDisplayListEnabled(true); |
272 } | 272 } |
273 | 273 |
274 TEST_F(RecordingImageBufferSurfaceTest, testClearRect) { | 274 TEST_F(RecordingImageBufferSurfaceTest, testClearRect) { |
275 CALL_TEST_TASK_WRAPPER(testClearRect); | 275 CALL_TEST_TASK_WRAPPER(testClearRect); |
276 expectDisplayListEnabled(true); | 276 expectDisplayListEnabled(true); |
277 } | 277 } |
278 | 278 |
279 } // namespace blink | 279 } // namespace blink |
OLD | NEW |