| 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 "modules/canvas2d/CanvasRenderingContext2D.h" | 5 #include "modules/canvas2d/CanvasRenderingContext2D.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/fetch/MemoryCache.h" | 8 #include "core/fetch/MemoryCache.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/ImageBitmap.h" | 10 #include "core/frame/ImageBitmap.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void CanvasRenderingContext2DTest::TearDown() { | 203 void CanvasRenderingContext2DTest::TearDown() { |
| 204 ThreadState::current()->collectGarbage( | 204 ThreadState::current()->collectGarbage( |
| 205 BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC); | 205 BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC); |
| 206 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); | 206 replaceMemoryCacheForTesting(m_globalMemoryCache.release()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 PassRefPtr<Canvas2DLayerBridge> CanvasRenderingContext2DTest::makeBridge( | 209 PassRefPtr<Canvas2DLayerBridge> CanvasRenderingContext2DTest::makeBridge( |
| 210 std::unique_ptr<FakeWebGraphicsContext3DProvider> provider, | 210 std::unique_ptr<FakeWebGraphicsContext3DProvider> provider, |
| 211 const IntSize& size, | 211 const IntSize& size, |
| 212 Canvas2DLayerBridge::AccelerationMode accelerationMode) { | 212 Canvas2DLayerBridge::AccelerationMode accelerationMode) { |
| 213 return adoptRef(new Canvas2DLayerBridge( | 213 return adoptRef(new Canvas2DLayerBridge(std::move(provider), size, 0, |
| 214 std::move(provider), size, 0, NonOpaque, accelerationMode, nullptr)); | 214 NonOpaque, accelerationMode, nullptr, |
| 215 kN32_SkColorType)); |
| 215 } | 216 } |
| 216 | 217 |
| 217 //============================================================================ | 218 //============================================================================ |
| 218 | 219 |
| 219 class FakeAcceleratedImageBufferSurfaceForTesting | 220 class FakeAcceleratedImageBufferSurfaceForTesting |
| 220 : public UnacceleratedImageBufferSurface { | 221 : public UnacceleratedImageBufferSurface { |
| 221 public: | 222 public: |
| 222 FakeAcceleratedImageBufferSurfaceForTesting(const IntSize& size, | 223 FakeAcceleratedImageBufferSurfaceForTesting(const IntSize& size, |
| 223 OpacityMode mode) | 224 OpacityMode mode) |
| 224 : UnacceleratedImageBufferSurface(size, mode), m_isAccelerated(true) {} | 225 : UnacceleratedImageBufferSurface(size, mode), m_isAccelerated(true) {} |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 public: | 306 public: |
| 306 enum FallbackExpectation { ExpectFallback, ExpectNoFallback }; | 307 enum FallbackExpectation { ExpectFallback, ExpectNoFallback }; |
| 307 static std::unique_ptr<MockSurfaceFactory> create( | 308 static std::unique_ptr<MockSurfaceFactory> create( |
| 308 FallbackExpectation expectation) { | 309 FallbackExpectation expectation) { |
| 309 return wrapUnique(new MockSurfaceFactory(expectation)); | 310 return wrapUnique(new MockSurfaceFactory(expectation)); |
| 310 } | 311 } |
| 311 | 312 |
| 312 std::unique_ptr<ImageBufferSurface> createSurface( | 313 std::unique_ptr<ImageBufferSurface> createSurface( |
| 313 const IntSize& size, | 314 const IntSize& size, |
| 314 OpacityMode mode, | 315 OpacityMode mode, |
| 315 sk_sp<SkColorSpace> colorSpace) override { | 316 sk_sp<SkColorSpace> colorSpace, |
| 317 SkColorType colorType) override { |
| 316 EXPECT_EQ(ExpectFallback, m_expectation); | 318 EXPECT_EQ(ExpectFallback, m_expectation); |
| 317 m_didFallback = true; | 319 m_didFallback = true; |
| 318 return wrapUnique(new UnacceleratedImageBufferSurface( | 320 return wrapUnique(new UnacceleratedImageBufferSurface( |
| 319 size, mode, InitializeImagePixels, colorSpace)); | 321 size, mode, InitializeImagePixels, colorSpace, colorType)); |
| 320 } | 322 } |
| 321 | 323 |
| 322 ~MockSurfaceFactory() override { | 324 ~MockSurfaceFactory() override { |
| 323 if (m_expectation == ExpectFallback) { | 325 if (m_expectation == ExpectFallback) { |
| 324 EXPECT_TRUE(m_didFallback); | 326 EXPECT_TRUE(m_didFallback); |
| 325 } | 327 } |
| 326 } | 328 } |
| 327 | 329 |
| 328 private: | 330 private: |
| 329 MockSurfaceFactory(FallbackExpectation expectation) | 331 MockSurfaceFactory(FallbackExpectation expectation) |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); | 1165 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); |
| 1164 | 1166 |
| 1165 context->fillRect(10, 10, 100, 100); | 1167 context->fillRect(10, 10, 100, 100); |
| 1166 | 1168 |
| 1167 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); | 1169 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); |
| 1168 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); | 1170 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); |
| 1169 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); | 1171 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); |
| 1170 } | 1172 } |
| 1171 | 1173 |
| 1172 } // namespace blink | 1174 } // namespace blink |
| OLD | NEW |