Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/UnacceleratedImageBufferSurface.cpp

Issue 2690583002: Make cc/paint have concrete types (Closed)
Patch Set: PaintRecord as typedef, fixup playback calls Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
34 #include "wtf/PassRefPtr.h" 35 #include "wtf/PassRefPtr.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface( 39 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface(
39 const IntSize& size, 40 const IntSize& size,
40 OpacityMode opacityMode, 41 OpacityMode opacityMode,
41 ImageInitializationMode initializationMode, 42 ImageInitializationMode initializationMode,
42 sk_sp<SkColorSpace> colorSpace, 43 sk_sp<SkColorSpace> colorSpace,
43 SkColorType colorType) 44 SkColorType colorType)
44 : ImageBufferSurface(size, opacityMode, colorSpace, colorType) { 45 : ImageBufferSurface(size, opacityMode, colorSpace, colorType) {
45 SkAlphaType alphaType = 46 SkAlphaType alphaType =
46 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 47 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
47 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, 48 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType,
48 alphaType, colorSpace); 49 alphaType, colorSpace);
49 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); 50 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry);
50 m_surface = PaintSurface::MakeRaster( 51 m_surface =
51 info, Opaque == opacityMode ? 0 : &disableLCDProps); 52 SkSurface::MakeRaster(info, Opaque == opacityMode ? 0 : &disableLCDProps);
53
54 if (!m_surface)
55 return;
52 56
53 // Always save an initial frame, to support resetting the top level matrix 57 // Always save an initial frame, to support resetting the top level matrix
54 // and clip. 58 // and clip.
55 if (m_surface) 59 m_canvas = WTF::wrapUnique(new PaintCanvas(m_surface->getCanvas()));
56 m_surface->getCanvas()->save(); 60 m_canvas->save();
57 61
58 if (initializationMode == InitializeImagePixels) { 62 if (initializationMode == InitializeImagePixels)
59 if (m_surface) 63 clear();
60 clear();
61 }
62 } 64 }
63 65
64 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {} 66 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {}
65 67
66 PaintCanvas* UnacceleratedImageBufferSurface::canvas() { 68 PaintCanvas* UnacceleratedImageBufferSurface::canvas() {
67 return m_surface->getCanvas(); 69 return m_canvas.get();
68 } 70 }
69 71
70 bool UnacceleratedImageBufferSurface::isValid() const { 72 bool UnacceleratedImageBufferSurface::isValid() const {
71 return m_surface; 73 return m_surface;
72 } 74 }
73 75
74 sk_sp<SkImage> UnacceleratedImageBufferSurface::newImageSnapshot( 76 sk_sp<SkImage> UnacceleratedImageBufferSurface::newImageSnapshot(
75 AccelerationHint, 77 AccelerationHint,
76 SnapshotReason) { 78 SnapshotReason) {
77 return m_surface->makeImageSnapshot(); 79 return m_surface->makeImageSnapshot();
78 } 80 }
79 81
80 } // namespace blink 82 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698