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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 bool m_isOpaque; | 50 bool m_isOpaque; |
51 }; | 51 }; |
52 | 52 |
53 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) | 53 FakeImageSource::FakeImageSource(IntSize size, BitmapOpacity opacity) |
54 : m_size(size) | 54 : m_size(size) |
55 , m_isOpaque(opacity == OpaqueBitmap) | 55 , m_isOpaque(opacity == OpaqueBitmap) |
56 { | 56 { |
57 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(m_size.width()
, m_size.height())); | 57 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(m_size.width()
, m_size.height())); |
58 surface->getCanvas()->clear(opacity == OpaqueBitmap ? SK_ColorWHITE : SK_Col
orTRANSPARENT); | 58 surface->getCanvas()->clear(opacity == OpaqueBitmap ? SK_ColorWHITE : SK_Col
orTRANSPARENT); |
59 RefPtr<SkImage> image = adoptRef(surface->newImageSnapshot()); | 59 RefPtr<SkImage> image = adoptRef(surface->newImageSnapshot()); |
60 m_image = StaticBitmapImage::create(image); | 60 m_image = StaticBitmapImage::create(image, true); |
61 } | 61 } |
62 | 62 |
63 PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(SourceImageStatus* st
atus, AccelerationHint) const | 63 PassRefPtr<Image> FakeImageSource::getSourceImageForCanvas(SourceImageStatus* st
atus, AccelerationHint) const |
64 { | 64 { |
65 if (status) | 65 if (status) |
66 *status = NormalSourceImageStatus; | 66 *status = NormalSourceImageStatus; |
67 return m_image; | 67 return m_image; |
68 } | 68 } |
69 | 69 |
70 //============================================================================ | 70 //============================================================================ |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 canvasElement().setSize(IntSize(20, 20)); | 683 canvasElement().setSize(IntSize(20, 20)); |
684 Mock::VerifyAndClearExpectations(fakeAccelerateSurfacePtr); | 684 Mock::VerifyAndClearExpectations(fakeAccelerateSurfacePtr); |
685 EXPECT_EQ(400, getGlobalGPUMemoryUsage()); | 685 EXPECT_EQ(400, getGlobalGPUMemoryUsage()); |
686 | 686 |
687 // Tear down the second image buffer | 687 // Tear down the second image buffer |
688 imageBuffer2.clear(); | 688 imageBuffer2.clear(); |
689 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); | 689 EXPECT_EQ(0, getGlobalGPUMemoryUsage()); |
690 } | 690 } |
691 | 691 |
692 } // namespace blink | 692 } // namespace blink |
OLD | NEW |