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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 3 years, 12 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 "skia/ext/cdl_canvas.h"
34 #include "third_party/skia/include/core/SkSurface.h" 35 #include "third_party/skia/include/core/SkSurface.h"
35 #include "wtf/PassRefPtr.h" 36 #include "wtf/PassRefPtr.h"
36 37
37 class SkCanvas; 38 class SkCanvas;
38 39
39 namespace blink { 40 namespace blink {
40 41
41 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface( 42 UnacceleratedImageBufferSurface::UnacceleratedImageBufferSurface(
42 const IntSize& size, 43 const IntSize& size,
43 OpacityMode opacityMode, 44 OpacityMode opacityMode,
44 ImageInitializationMode initializationMode, 45 ImageInitializationMode initializationMode,
45 sk_sp<SkColorSpace> colorSpace, 46 sk_sp<SkColorSpace> colorSpace,
46 SkColorType colorType) 47 SkColorType colorType)
47 : ImageBufferSurface(size, opacityMode, colorSpace, colorType) { 48 : ImageBufferSurface(size, opacityMode, colorSpace, colorType) {
48 SkAlphaType alphaType = 49 SkAlphaType alphaType =
49 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 50 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
50 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, 51 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType,
51 alphaType, colorSpace); 52 alphaType, colorSpace);
52 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); 53 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry);
53 m_surface = 54 m_surface =
54 SkSurface::MakeRaster(info, Opaque == opacityMode ? 0 : &disableLCDProps); 55 SkSurface::MakeRaster(info, Opaque == opacityMode ? 0 : &disableLCDProps);
55 56
57 if (!m_surface)
58 return;
59
60 m_canvas.reset(new CdlPassThroughCanvas(m_surface->getCanvas()));
61
56 // Always save an initial frame, to support resetting the top level matrix 62 // Always save an initial frame, to support resetting the top level matrix
57 // and clip. 63 // and clip.
58 if (m_surface) 64 canvas()->save();
59 m_surface->getCanvas()->save();
60 65
61 if (initializationMode == InitializeImagePixels) { 66 if (initializationMode == InitializeImagePixels) {
62 if (m_surface) 67 clear();
63 clear();
64 } 68 }
65 } 69 }
66 70
67 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {} 71 UnacceleratedImageBufferSurface::~UnacceleratedImageBufferSurface() {}
68 72
69 SkCanvas* UnacceleratedImageBufferSurface::canvas() { 73 CdlCanvas* UnacceleratedImageBufferSurface::canvas() {
70 return m_surface->getCanvas(); 74 return m_canvas.get();
71 } 75 }
72 76
73 bool UnacceleratedImageBufferSurface::isValid() const { 77 bool UnacceleratedImageBufferSurface::isValid() const {
74 return m_surface; 78 return m_canvas.get();
75 } 79 }
76 80
77 sk_sp<SkImage> UnacceleratedImageBufferSurface::newImageSnapshot( 81 sk_sp<SkImage> UnacceleratedImageBufferSurface::newImageSnapshot(
78 AccelerationHint, 82 AccelerationHint,
79 SnapshotReason) { 83 SnapshotReason) {
80 return m_surface->makeImageSnapshot(); 84 return m_surface->makeImageSnapshot();
81 } 85 }
82 86
83 } // namespace blink 87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698