| 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/fetch/MemoryCache.h" | 7 #include "core/fetch/MemoryCache.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/ImageBitmap.h" | 9 #include "core/frame/ImageBitmap.h" |
| 10 #include "core/html/HTMLCanvasElement.h" | 10 #include "core/html/HTMLCanvasElement.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 private: | 48 private: |
| 49 IntSize m_size; | 49 IntSize m_size; |
| 50 RefPtr<Image> m_image; | 50 RefPtr<Image> m_image; |
| 51 bool m_isOpaque; | 51 bool m_isOpaque; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) | 54 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) |
| 55 : m_size(size) | 55 : m_size(size) |
| 56 , m_isOpaque(opacity == OpaqueBitmap) | 56 , m_isOpaque(opacity == OpaqueBitmap) |
| 57 { | 57 { |
| 58 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(m_size.width()
, m_size.height())); | 58 sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(m_size.width(), m_si
ze.height())); |
| 59 surface->getCanvas()->clear(opacity == OpaqueBitmap ? SK_ColorWHITE : SK_Col
orTRANSPARENT); | 59 surface->getCanvas()->clear(opacity == OpaqueBitmap ? SK_ColorWHITE : SK_Col
orTRANSPARENT); |
| 60 RefPtr<SkImage> image = adoptRef(surface->newImageSnapshot()); | 60 RefPtr<SkImage> image = adoptRef(surface->newImageSnapshot()); |
| 61 m_image = StaticBitmapImage::create(image); | 61 m_image = StaticBitmapImage::create(image); |
| 62 } | 62 } |
| 63 | 63 |
| 64 PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(SourceImageStatus* st
atus, AccelerationHint, SnapshotReason, const FloatSize&) const | 64 PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(SourceImageStatus* st
atus, AccelerationHint, SnapshotReason, const FloatSize&) const |
| 65 { | 65 { |
| 66 if (status) | 66 if (status) |
| 67 *status = NormalSourceImageStatus; | 67 *status = NormalSourceImageStatus; |
| 68 return m_image; | 68 return m_image; |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 canvasElement().setSize(IntSize(20, 20)); | 713 canvasElement().setSize(IntSize(20, 20)); |
| 714 Mock::VerifyAndClearExpectations(fakeAccelerateSurfacePtr); | 714 Mock::VerifyAndClearExpectations(fakeAccelerateSurfacePtr); |
| 715 EXPECT_EQ(400, getGlobalGPUMemoryUsage()); | 715 EXPECT_EQ(400, getGlobalGPUMemoryUsage()); |
| 716 | 716 |
| 717 // Tear down the second image buffer | 717 // Tear down the second image buffer |
| 718 imageBuffer2.clear(); | 718 imageBuffer2.clear(); |
| 719 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); | 719 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); |
| 720 } | 720 } |
| 721 | 721 |
| 722 } // namespace blink | 722 } // namespace blink |
| OLD | NEW |