OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 31 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
32 | 32 |
33 #include "platform/graphics/skia/SkiaUtils.h" | 33 #include "platform/graphics/skia/SkiaUtils.h" |
34 #include "third_party/skia/include/core/SkSurface.h" | |
35 #include "wtf/PassRefPtr.h" | 34 #include "wtf/PassRefPtr.h" |
36 | 35 |
37 class SkCanvas; | |
38 | |
39 namespace blink { | 36 namespace blink { |
40 | 37 |
41 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface( | 38 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface( |
42 const IntSize& size, | 39 const IntSize& size, |
43 OpacityMode opacityMode, | 40 OpacityMode opacityMode, |
44 ImageInitializationMode initializationMode, | 41 ImageInitializationMode initializationMode, |
45 sk_sp<SkColorSpace> colorSpace, | 42 sk_sp<SkColorSpace> colorSpace, |
46 SkColorType colorType) | 43 SkColorType colorType) |
47 : ImageBufferSurface(size, opacityMode, colorSpace, colorType) { | 44 : ImageBufferSurface(size, opacityMode, colorSpace, colorType) { |
48 SkAlphaType alphaType = | 45 SkAlphaType alphaType = |
49 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 46 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
50 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, | 47 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, |
51 alphaType, colorSpace); | 48 alphaType, colorSpace); |
52 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); | 49 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); |
53 m_surface = | 50 m_surface = PaintSurface::MakeRaster( |
54 SkSurface::MakeRaster(info, Opaque == opacityMode ? 0 : &disableLCDProps); | 51 info, Opaque == opacityMode ? 0 : &disableLCDProps); |
55 | 52 |
56 // Always save an initial frame, to support resetting the top level matrix | 53 // Always save an initial frame, to support resetting the top level matrix |
57 // and clip. | 54 // and clip. |
58 if (m_surface) | 55 if (m_surface) |
59 m_surface->getCanvas()->save(); | 56 m_surface->getCanvas()->save(); |
60 | 57 |
61 if (initializationMode == InitializeImagePixels) { | 58 if (initializationMode == InitializeImagePixels) { |
62 if (m_surface) | 59 if (m_surface) |
63 clear(); | 60 clear(); |
64 } | 61 } |
65 } | 62 } |
66 | 63 |
67 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {} | 64 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {} |
68 | 65 |
69 SkCanvas* UnacceleratedImageBufferSurface::canvas() { | 66 PaintCanvas* UnacceleratedImageBufferSurface::canvas() { |
70 return m_surface->getCanvas(); | 67 return m_surface->getCanvas(); |
71 } | 68 } |
72 | 69 |
73 bool UnacceleratedImageBufferSurface::isValid() const { | 70 bool UnacceleratedImageBufferSurface::isValid() const { |
74 return m_surface; | 71 return m_surface; |
75 } | 72 } |
76 | 73 |
77 sk_sp<SkImage> UnacceleratedImageBufferSurface::newImageSnapshot( | 74 sk_sp<SkImage> UnacceleratedImageBufferSurface::newImageSnapshot( |
78 AccelerationHint, | 75 AccelerationHint, |
79 SnapshotReason) { | 76 SnapshotReason) { |
80 return m_surface->makeImageSnapshot(); | 77 return m_surface->makeImageSnapshot(); |
81 } | 78 } |
82 | 79 |
83 } // namespace blink | 80 } // namespace blink |
OLD | NEW |