| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 RefPtr<Image> m_image; | 57 RefPtr<Image> m_image; |
| 58 bool m_isOpaque; | 58 bool m_isOpaque; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) | 61 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) |
| 62 : m_size(size) | 62 : m_size(size) |
| 63 , m_isOpaque(opacity == OpaqueBitmap) | 63 , m_isOpaque(opacity == OpaqueBitmap) |
| 64 { | 64 { |
| 65 sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(m_size.width(), m_si
ze.height())); | 65 sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(m_size.width(), m_si
ze.height())); |
| 66 surface->getCanvas()->clear(opacity == OpaqueBitmap ? SK_ColorWHITE : SK_Col
orTRANSPARENT); | 66 surface->getCanvas()->clear(opacity == OpaqueBitmap ? SK_ColorWHITE : SK_Col
orTRANSPARENT); |
| 67 RefPtr<SkImage> image = fromSkSp(surface->makeImageSnapshot()); | 67 m_image = StaticBitmapImage::create(surface->makeImageSnapshot()); |
| 68 m_image = StaticBitmapImage::create(image); | |
| 69 } | 68 } |
| 70 | 69 |
| 71 PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(SourceImageStatus* st
atus, AccelerationHint, SnapshotReason, const FloatSize&) const | 70 PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(SourceImageStatus* st
atus, AccelerationHint, SnapshotReason, const FloatSize&) const |
| 72 { | 71 { |
| 73 if (status) | 72 if (status) |
| 74 *status = NormalSourceImageStatus; | 73 *status = NormalSourceImageStatus; |
| 75 return m_image; | 74 return m_image; |
| 76 } | 75 } |
| 77 | 76 |
| 78 //============================================================================ | 77 //============================================================================ |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); | 853 EXPECT_FALSE(canvasElement().buffer()->isAccelerated()); |
| 855 | 854 |
| 856 context->fillRect(10, 10, 100, 100); | 855 context->fillRect(10, 10, 100, 100); |
| 857 | 856 |
| 858 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); | 857 EXPECT_EQ(0, getCurrentGPUMemoryUsage()); |
| 859 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); | 858 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); |
| 860 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); | 859 EXPECT_EQ(0u, getGlobalAcceleratedImageBufferCount()); |
| 861 } | 860 } |
| 862 | 861 |
| 863 } // namespace blink | 862 } // namespace blink |
| OLD | NEW |