OLD | NEW |
| (Empty) |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "WebLayerTreeViewImpl.h" | |
7 | |
8 #include "CCFontAtlas.h" | |
9 #include "CCLayerTreeHost.h" | |
10 #include "LayerChromium.h" | |
11 #include "WebLayerImpl.h" | |
12 #include <public/WebGraphicsContext3D.h> | |
13 #include <public/WebLayer.h> | |
14 #include <public/WebLayerTreeView.h> | |
15 #include <public/WebLayerTreeViewClient.h> | |
16 #include <public/WebRenderingStats.h> | |
17 #include <public/WebSize.h> | |
18 | |
19 using namespace WebCore; | |
20 | |
21 namespace WebKit { | |
22 | |
23 WebLayerTreeView* WebLayerTreeView::create(WebLayerTreeViewClient* client, const
WebLayer& root, const WebLayerTreeView::Settings& settings) | |
24 { | |
25 OwnPtr<WebLayerTreeViewImpl> layerTreeViewImpl = adoptPtr(new WebLayerTreeVi
ewImpl(client)); | |
26 if (!layerTreeViewImpl->initialize(settings)) | |
27 return 0; | |
28 layerTreeViewImpl->setRootLayer(root); | |
29 return layerTreeViewImpl.leakPtr(); | |
30 } | |
31 | |
32 WebLayerTreeViewImpl::WebLayerTreeViewImpl(WebLayerTreeViewClient* client) | |
33 : m_client(client) | |
34 { | |
35 } | |
36 | |
37 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() | |
38 { | |
39 } | |
40 | |
41 bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSetti
ngs) | |
42 { | |
43 CCLayerTreeSettings settings; | |
44 settings.acceleratePainting = webSettings.acceleratePainting; | |
45 settings.showFPSCounter = webSettings.showFPSCounter; | |
46 settings.showPlatformLayerTree = webSettings.showPlatformLayerTree; | |
47 settings.showPaintRects = webSettings.showPaintRects; | |
48 settings.renderVSyncEnabled = webSettings.renderVSyncEnabled; | |
49 settings.refreshRate = webSettings.refreshRate; | |
50 settings.defaultTileSize = webSettings.defaultTileSize; | |
51 settings.maxUntiledLayerSize = webSettings.maxUntiledLayerSize; | |
52 m_layerTreeHost = CCLayerTreeHost::create(this, settings); | |
53 if (!m_layerTreeHost) | |
54 return false; | |
55 return true; | |
56 } | |
57 | |
58 void WebLayerTreeViewImpl::setSurfaceReady() | |
59 { | |
60 m_layerTreeHost->setSurfaceReady(); | |
61 } | |
62 | |
63 void WebLayerTreeViewImpl::setRootLayer(const WebLayer& root) | |
64 { | |
65 m_layerTreeHost->setRootLayer(static_cast<const WebLayerImpl*>(&root)->layer
()); | |
66 } | |
67 | |
68 void WebLayerTreeViewImpl::clearRootLayer() | |
69 { | |
70 m_layerTreeHost->setRootLayer(PassRefPtr<LayerChromium>()); | |
71 } | |
72 | |
73 int WebLayerTreeViewImpl::compositorIdentifier() | |
74 { | |
75 return m_layerTreeHost->compositorIdentifier(); | |
76 } | |
77 | |
78 void WebLayerTreeViewImpl::setViewportSize(const WebSize& layoutViewportSize, co
nst WebSize& deviceViewportSize) | |
79 { | |
80 if (!deviceViewportSize.isEmpty()) | |
81 m_layerTreeHost->setViewportSize(layoutViewportSize, deviceViewportSize)
; | |
82 else | |
83 m_layerTreeHost->setViewportSize(layoutViewportSize, layoutViewportSize)
; | |
84 } | |
85 | |
86 WebSize WebLayerTreeViewImpl::layoutViewportSize() const | |
87 { | |
88 return WebSize(m_layerTreeHost->layoutViewportSize()); | |
89 } | |
90 | |
91 WebSize WebLayerTreeViewImpl::deviceViewportSize() const | |
92 { | |
93 return WebSize(m_layerTreeHost->deviceViewportSize()); | |
94 } | |
95 | |
96 void WebLayerTreeViewImpl::setDeviceScaleFactor(const float deviceScaleFactor) | |
97 { | |
98 m_layerTreeHost->setDeviceScaleFactor(deviceScaleFactor); | |
99 } | |
100 | |
101 float WebLayerTreeViewImpl::deviceScaleFactor() const | |
102 { | |
103 return m_layerTreeHost->deviceScaleFactor(); | |
104 } | |
105 | |
106 void WebLayerTreeViewImpl::setBackgroundColor(WebColor color) | |
107 { | |
108 m_layerTreeHost->setBackgroundColor(color); | |
109 } | |
110 | |
111 void WebLayerTreeViewImpl::setHasTransparentBackground(bool transparent) | |
112 { | |
113 m_layerTreeHost->setHasTransparentBackground(transparent); | |
114 } | |
115 | |
116 void WebLayerTreeViewImpl::setVisible(bool visible) | |
117 { | |
118 m_layerTreeHost->setVisible(visible); | |
119 } | |
120 | |
121 void WebLayerTreeViewImpl::setPageScaleFactorAndLimits(float pageScaleFactor, fl
oat minimum, float maximum) | |
122 { | |
123 m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor, minimum, maxim
um); | |
124 } | |
125 | |
126 void WebLayerTreeViewImpl::startPageScaleAnimation(const WebPoint& scroll, bool
useAnchor, float newPageScale, double durationSec) | |
127 { | |
128 m_layerTreeHost->startPageScaleAnimation(IntSize(scroll.x, scroll.y), useAnc
hor, newPageScale, durationSec); | |
129 } | |
130 | |
131 void WebLayerTreeViewImpl::setNeedsAnimate() | |
132 { | |
133 m_layerTreeHost->setNeedsAnimate(); | |
134 } | |
135 | |
136 void WebLayerTreeViewImpl::setNeedsRedraw() | |
137 { | |
138 m_layerTreeHost->setNeedsRedraw(); | |
139 } | |
140 | |
141 bool WebLayerTreeViewImpl::commitRequested() const | |
142 { | |
143 return m_layerTreeHost->commitRequested(); | |
144 } | |
145 | |
146 void WebLayerTreeViewImpl::composite() | |
147 { | |
148 if (CCProxy::hasImplThread()) | |
149 m_layerTreeHost->setNeedsCommit(); | |
150 else | |
151 m_layerTreeHost->composite(); | |
152 } | |
153 | |
154 void WebLayerTreeViewImpl::updateAnimations(double frameBeginTime) | |
155 { | |
156 m_layerTreeHost->updateAnimations(frameBeginTime); | |
157 } | |
158 | |
159 bool WebLayerTreeViewImpl::compositeAndReadback(void *pixels, const WebRect& rec
t) | |
160 { | |
161 return m_layerTreeHost->compositeAndReadback(pixels, rect); | |
162 } | |
163 | |
164 void WebLayerTreeViewImpl::finishAllRendering() | |
165 { | |
166 m_layerTreeHost->finishAllRendering(); | |
167 } | |
168 | |
169 void WebLayerTreeViewImpl::renderingStats(WebRenderingStats& stats) const | |
170 { | |
171 CCRenderingStats ccStats; | |
172 m_layerTreeHost->renderingStats(ccStats); | |
173 | |
174 stats.numAnimationFrames = ccStats.numAnimationFrames; | |
175 stats.numFramesSentToScreen = ccStats.numFramesSentToScreen; | |
176 stats.droppedFrameCount = ccStats.droppedFrameCount; | |
177 stats.totalPaintTimeInSeconds = ccStats.totalPaintTimeInSeconds; | |
178 stats.totalRasterizeTimeInSeconds = ccStats.totalRasterizeTimeInSeconds; | |
179 } | |
180 | |
181 void WebLayerTreeViewImpl::setFontAtlas(SkBitmap bitmap, WebRect asciiToWebRectT
able[128], int fontHeight) | |
182 { | |
183 IntRect asciiToRectTable[128]; | |
184 for (int i = 0; i < 128; ++i) | |
185 asciiToRectTable[i] = asciiToWebRectTable[i]; | |
186 OwnPtr<CCFontAtlas> fontAtlas = CCFontAtlas::create(bitmap, asciiToRectTable
, fontHeight); | |
187 m_layerTreeHost->setFontAtlas(fontAtlas.release()); | |
188 } | |
189 | |
190 void WebLayerTreeViewImpl::loseCompositorContext(int numTimes) | |
191 { | |
192 m_layerTreeHost->loseContext(numTimes); | |
193 } | |
194 | |
195 void WebLayerTreeViewImpl::willBeginFrame() | |
196 { | |
197 m_client->willBeginFrame(); | |
198 } | |
199 | |
200 void WebLayerTreeViewImpl::didBeginFrame() | |
201 { | |
202 m_client->didBeginFrame(); | |
203 } | |
204 | |
205 void WebLayerTreeViewImpl::animate(double monotonicFrameBeginTime) | |
206 { | |
207 m_client->updateAnimations(monotonicFrameBeginTime); | |
208 } | |
209 | |
210 void WebLayerTreeViewImpl::layout() | |
211 { | |
212 m_client->layout(); | |
213 } | |
214 | |
215 void WebLayerTreeViewImpl::applyScrollAndScale(const WebCore::IntSize& scrollDel
ta, float pageScale) | |
216 { | |
217 m_client->applyScrollAndScale(scrollDelta, pageScale); | |
218 } | |
219 | |
220 PassOwnPtr<WebCompositorOutputSurface> WebLayerTreeViewImpl::createOutputSurface
() | |
221 { | |
222 return adoptPtr(m_client->createOutputSurface()); | |
223 } | |
224 | |
225 void WebLayerTreeViewImpl::didRecreateOutputSurface(bool success) | |
226 { | |
227 m_client->didRecreateOutputSurface(success); | |
228 } | |
229 | |
230 void WebLayerTreeViewImpl::willCommit() | |
231 { | |
232 m_client->willCommit(); | |
233 } | |
234 | |
235 void WebLayerTreeViewImpl::didCommit() | |
236 { | |
237 m_client->didCommit(); | |
238 } | |
239 | |
240 void WebLayerTreeViewImpl::didCommitAndDrawFrame() | |
241 { | |
242 m_client->didCommitAndDrawFrame(); | |
243 } | |
244 | |
245 void WebLayerTreeViewImpl::didCompleteSwapBuffers() | |
246 { | |
247 m_client->didCompleteSwapBuffers(); | |
248 } | |
249 | |
250 void WebLayerTreeViewImpl::scheduleComposite() | |
251 { | |
252 m_client->scheduleComposite(); | |
253 } | |
254 | |
255 } // namespace WebKit | |
OLD | NEW |