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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "platform/graphics/RecordingImageBufferSurface.h" | 7 #include "platform/graphics/RecordingImageBufferSurface.h" |
8 | 8 |
9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
10 #include "platform/graphics/ImageBuffer.h" | 10 #include "platform/graphics/ImageBuffer.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 { } | 29 { } |
30 | 30 |
31 void RecordingImageBufferSurface::initializeCurrentFrame() | 31 void RecordingImageBufferSurface::initializeCurrentFrame() |
32 { | 32 { |
33 static SkRTreeFactory rTreeFactory; | 33 static SkRTreeFactory rTreeFactory; |
34 m_currentFrame = adoptPtr(new SkPictureRecorder); | 34 m_currentFrame = adoptPtr(new SkPictureRecorder); |
35 m_currentFrame->beginRecording(size().width(), size().height(), &rTreeFactor
y); | 35 m_currentFrame->beginRecording(size().width(), size().height(), &rTreeFactor
y); |
36 m_initialSaveCount = m_currentFrame->getRecordingCanvas()->getSaveCount(); | 36 m_initialSaveCount = m_currentFrame->getRecordingCanvas()->getSaveCount(); |
37 if (m_graphicsContext) { | 37 if (m_graphicsContext) { |
38 m_graphicsContext->resetCanvas(m_currentFrame->getRecordingCanvas()); | 38 m_graphicsContext->resetCanvas(m_currentFrame->getRecordingCanvas()); |
39 m_graphicsContext->setTrackOpaqueRegion(true); | 39 m_graphicsContext->setRegionTrackingMode(GraphicsContext::RegionTracking
Overwrite); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 void RecordingImageBufferSurface::setImageBuffer(ImageBuffer* imageBuffer) | 43 void RecordingImageBufferSurface::setImageBuffer(ImageBuffer* imageBuffer) |
44 { | 44 { |
45 m_graphicsContext = imageBuffer ? imageBuffer->context() : 0; | 45 m_graphicsContext = imageBuffer ? imageBuffer->context() : 0; |
46 if (m_currentFrame && m_graphicsContext) { | 46 if (m_currentFrame && m_graphicsContext) { |
47 m_graphicsContext->setTrackOpaqueRegion(true); | 47 m_graphicsContext->setRegionTrackingMode(GraphicsContext::RegionTracking
Overwrite); |
48 m_graphicsContext->resetCanvas(m_currentFrame->getRecordingCanvas()); | 48 m_graphicsContext->resetCanvas(m_currentFrame->getRecordingCanvas()); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 void RecordingImageBufferSurface::willReadback() | 52 void RecordingImageBufferSurface::willReadback() |
53 { | 53 { |
54 fallBackToRasterCanvas(); | 54 fallBackToRasterCanvas(); |
55 } | 55 } |
56 | 56 |
57 void RecordingImageBufferSurface::fallBackToRasterCanvas() | 57 void RecordingImageBufferSurface::fallBackToRasterCanvas() |
58 { | 58 { |
59 if (m_rasterCanvas) { | 59 if (m_rasterCanvas) { |
60 ASSERT(!m_currentFrame); | 60 ASSERT(!m_currentFrame); |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 m_rasterCanvas = adoptPtr(SkCanvas::NewRasterN32(size().width(), size().heig
ht())); | 64 m_rasterCanvas = adoptPtr(SkCanvas::NewRasterN32(size().width(), size().heig
ht())); |
65 | 65 |
66 if (m_previousFrame) { | 66 if (m_previousFrame) { |
67 m_previousFrame->draw(m_rasterCanvas.get()); | 67 m_previousFrame->draw(m_rasterCanvas.get()); |
68 m_previousFrame.clear(); | 68 m_previousFrame.clear(); |
69 } | 69 } |
70 if (m_currentFrame) { | 70 if (m_currentFrame) { |
71 RefPtr<SkPicture> currentPicture = adoptRef(m_currentFrame->endRecording
()); | 71 RefPtr<SkPicture> currentPicture = adoptRef(m_currentFrame->endRecording
()); |
72 currentPicture->draw(m_rasterCanvas.get()); | 72 currentPicture->draw(m_rasterCanvas.get()); |
73 m_currentFrame.clear(); | 73 m_currentFrame.clear(); |
74 } | 74 } |
75 | 75 |
76 if (m_graphicsContext) { | 76 if (m_graphicsContext) { |
77 m_graphicsContext->setTrackOpaqueRegion(false); | 77 m_graphicsContext->setRegionTrackingMode(GraphicsContext::RegionTracking
Disabled); |
78 m_graphicsContext->resetCanvas(m_rasterCanvas.get()); | 78 m_graphicsContext->resetCanvas(m_rasterCanvas.get()); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 SkCanvas* RecordingImageBufferSurface::canvas() const | 82 SkCanvas* RecordingImageBufferSurface::canvas() const |
83 { | 83 { |
84 if (m_rasterCanvas) | 84 if (m_rasterCanvas) |
85 return m_rasterCanvas.get(); | 85 return m_rasterCanvas.get(); |
86 | 86 |
87 ASSERT(m_currentFrame->getRecordingCanvas()); | 87 ASSERT(m_currentFrame->getRecordingCanvas()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 SkCanvas* newCanvas = m_currentFrame->getRecordingCanvas(); | 139 SkCanvas* newCanvas = m_currentFrame->getRecordingCanvas(); |
140 newCanvas->concat(ctm); | 140 newCanvas->concat(ctm); |
141 newCanvas->clipRect(clip); | 141 newCanvas->clipRect(clip); |
142 | 142 |
143 m_frameWasCleared = false; | 143 m_frameWasCleared = false; |
144 return true; | 144 return true; |
145 } | 145 } |
146 | 146 |
147 } // namespace WebCore | 147 } // namespace WebCore |
OLD | NEW |