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

Side by Side Diff: webkit/compositor_bindings/WebLayerImpl.cpp

Issue 11192050: Rename compositor bindings filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « webkit/compositor_bindings/WebLayerImpl.h ('k') | webkit/compositor_bindings/WebLayerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "WebLayerImpl.h"
7
8 #include "SkMatrix44.h"
9 #include "WebAnimationImpl.h"
10 #ifdef LOG
11 #undef LOG
12 #endif
13 #include "base/string_util.h"
14 #include "cc/active_animation.h"
15 #include "cc/layer.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h"
20 #include "webcore_convert.h"
21
22 using cc::CCActiveAnimation;
23 using cc::LayerChromium;
24
25 namespace WebKit {
26
27 namespace {
28
29 WebTransformationMatrix transformationMatrixFromSkMatrix44(const SkMatrix44& mat rix)
30 {
31 double data[16];
32 matrix.asColMajord(data);
33 return WebTransformationMatrix(data[0], data[1], data[2], data[3],
34 data[4], data[5], data[6], data[7],
35 data[8], data[9], data[10], data[11],
36 data[12], data[13], data[14], data[15]);
37 }
38
39 SkMatrix44 skMatrix44FromTransformationMatrix(const WebTransformationMatrix& mat rix)
40 {
41 SkMatrix44 skMatrix;
42 skMatrix.set(0, 0, SkDoubleToMScalar(matrix.m11()));
43 skMatrix.set(1, 0, SkDoubleToMScalar(matrix.m12()));
44 skMatrix.set(2, 0, SkDoubleToMScalar(matrix.m13()));
45 skMatrix.set(3, 0, SkDoubleToMScalar(matrix.m14()));
46 skMatrix.set(0, 1, SkDoubleToMScalar(matrix.m21()));
47 skMatrix.set(1, 1, SkDoubleToMScalar(matrix.m22()));
48 skMatrix.set(2, 1, SkDoubleToMScalar(matrix.m23()));
49 skMatrix.set(3, 1, SkDoubleToMScalar(matrix.m24()));
50 skMatrix.set(0, 2, SkDoubleToMScalar(matrix.m31()));
51 skMatrix.set(1, 2, SkDoubleToMScalar(matrix.m32()));
52 skMatrix.set(2, 2, SkDoubleToMScalar(matrix.m33()));
53 skMatrix.set(3, 2, SkDoubleToMScalar(matrix.m34()));
54 skMatrix.set(0, 3, SkDoubleToMScalar(matrix.m41()));
55 skMatrix.set(1, 3, SkDoubleToMScalar(matrix.m42()));
56 skMatrix.set(2, 3, SkDoubleToMScalar(matrix.m43()));
57 skMatrix.set(3, 3, SkDoubleToMScalar(matrix.m44()));
58 return skMatrix;
59 }
60
61 }
62
63 WebLayer* WebLayer::create()
64 {
65 return new WebLayerImpl();
66 }
67
68 WebLayerImpl::WebLayerImpl()
69 : m_layer(LayerChromium::create())
70 {
71 }
72
73 WebLayerImpl::WebLayerImpl(scoped_refptr<LayerChromium> layer)
74 : m_layer(layer)
75 {
76 }
77
78
79 WebLayerImpl::~WebLayerImpl()
80 {
81 m_layer->clearRenderSurface();
82 m_layer->setLayerAnimationDelegate(0);
83 }
84
85 int WebLayerImpl::id() const
86 {
87 return m_layer->id();
88 }
89
90 void WebLayerImpl::invalidateRect(const WebFloatRect& rect)
91 {
92 m_layer->setNeedsDisplayRect(convert(rect));
93 }
94
95 void WebLayerImpl::invalidate()
96 {
97 m_layer->setNeedsDisplay();
98 }
99
100 void WebLayerImpl::addChild(WebLayer* child)
101 {
102 m_layer->addChild(static_cast<WebLayerImpl*>(child)->layer());
103 }
104
105 void WebLayerImpl::insertChild(WebLayer* child, size_t index)
106 {
107 m_layer->insertChild(static_cast<WebLayerImpl*>(child)->layer(), index);
108 }
109
110 void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* newLayer)
111 {
112 m_layer->replaceChild(static_cast<WebLayerImpl*>(reference)->layer(), static _cast<WebLayerImpl*>(newLayer)->layer());
113 }
114
115 void WebLayerImpl::removeFromParent()
116 {
117 m_layer->removeFromParent();
118 }
119
120 void WebLayerImpl::removeAllChildren()
121 {
122 m_layer->removeAllChildren();
123 }
124
125 void WebLayerImpl::setAnchorPoint(const WebFloatPoint& anchorPoint)
126 {
127 m_layer->setAnchorPoint(convert(anchorPoint));
128 }
129
130 WebFloatPoint WebLayerImpl::anchorPoint() const
131 {
132 return WebFloatPoint(m_layer->anchorPoint().x(), m_layer->anchorPoint().y()) ;
133 }
134
135 void WebLayerImpl::setAnchorPointZ(float anchorPointZ)
136 {
137 m_layer->setAnchorPointZ(anchorPointZ);
138 }
139
140 float WebLayerImpl::anchorPointZ() const
141 {
142 return m_layer->anchorPointZ();
143 }
144
145 void WebLayerImpl::setBounds(const WebSize& size)
146 {
147 m_layer->setBounds(convert(size));
148 }
149
150 WebSize WebLayerImpl::bounds() const
151 {
152 return convert(m_layer->bounds());
153 }
154
155 void WebLayerImpl::setMasksToBounds(bool masksToBounds)
156 {
157 m_layer->setMasksToBounds(masksToBounds);
158 }
159
160 bool WebLayerImpl::masksToBounds() const
161 {
162 return m_layer->masksToBounds();
163 }
164
165 void WebLayerImpl::setMaskLayer(WebLayer* maskLayer)
166 {
167 m_layer->setMaskLayer(maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->lay er() : 0);
168 }
169
170 void WebLayerImpl::setReplicaLayer(WebLayer* replicaLayer)
171 {
172 m_layer->setReplicaLayer(replicaLayer ? static_cast<WebLayerImpl*>(replicaLa yer)->layer() : 0);
173 }
174
175 void WebLayerImpl::setOpacity(float opacity)
176 {
177 m_layer->setOpacity(opacity);
178 }
179
180 float WebLayerImpl::opacity() const
181 {
182 return m_layer->opacity();
183 }
184
185 void WebLayerImpl::setOpaque(bool opaque)
186 {
187 m_layer->setContentsOpaque(opaque);
188 }
189
190 bool WebLayerImpl::opaque() const
191 {
192 return m_layer->contentsOpaque();
193 }
194
195 void WebLayerImpl::setPosition(const WebFloatPoint& position)
196 {
197 m_layer->setPosition(convert(position));
198 }
199
200 WebFloatPoint WebLayerImpl::position() const
201 {
202 return WebFloatPoint(m_layer->position().x(), m_layer->position().y());
203 }
204
205 void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix)
206 {
207 m_layer->setSublayerTransform(transformationMatrixFromSkMatrix44(matrix));
208 }
209
210 void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix)
211 {
212 m_layer->setSublayerTransform(matrix);
213 }
214
215 SkMatrix44 WebLayerImpl::sublayerTransform() const
216 {
217 return skMatrix44FromTransformationMatrix(m_layer->sublayerTransform());
218 }
219
220 void WebLayerImpl::setTransform(const SkMatrix44& matrix)
221 {
222 m_layer->setTransform(transformationMatrixFromSkMatrix44(matrix));
223 }
224
225 void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix)
226 {
227 m_layer->setTransform(matrix);
228 }
229
230 SkMatrix44 WebLayerImpl::transform() const
231 {
232 return skMatrix44FromTransformationMatrix(m_layer->transform());
233 }
234
235 void WebLayerImpl::setDrawsContent(bool drawsContent)
236 {
237 m_layer->setIsDrawable(drawsContent);
238 }
239
240 bool WebLayerImpl::drawsContent() const
241 {
242 return m_layer->drawsContent();
243 }
244
245 void WebLayerImpl::setPreserves3D(bool preserve3D)
246 {
247 m_layer->setPreserves3D(preserve3D);
248 }
249
250 void WebLayerImpl::setUseParentBackfaceVisibility(bool useParentBackfaceVisibili ty)
251 {
252 m_layer->setUseParentBackfaceVisibility(useParentBackfaceVisibility);
253 }
254
255 void WebLayerImpl::setBackgroundColor(WebColor color)
256 {
257 m_layer->setBackgroundColor(color);
258 }
259
260 WebColor WebLayerImpl::backgroundColor() const
261 {
262 return m_layer->backgroundColor();
263 }
264
265 void WebLayerImpl::setFilters(const WebFilterOperations& filters)
266 {
267 m_layer->setFilters(filters);
268 }
269
270 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters)
271 {
272 m_layer->setBackgroundFilters(filters);
273 }
274
275 void WebLayerImpl::setDebugBorderColor(const WebColor& color)
276 {
277 m_layer->setDebugBorderColor(color);
278 }
279
280 void WebLayerImpl::setDebugBorderWidth(float width)
281 {
282 m_layer->setDebugBorderWidth(width);
283 }
284
285 void WebLayerImpl::setDebugName(WebString name)
286 {
287 m_layer->setDebugName(UTF16ToASCII(string16(name.data(), name.length())));
288 }
289
290 void WebLayerImpl::setAnimationDelegate(WebAnimationDelegate* delegate)
291 {
292 m_layer->setLayerAnimationDelegate(delegate);
293 }
294
295 bool WebLayerImpl::addAnimation(WebAnimation* animation)
296 {
297 return m_layer->addAnimation(static_cast<WebAnimationImpl*>(animation)->clon eToCCAnimation());
298 }
299
300 void WebLayerImpl::removeAnimation(int animationId)
301 {
302 m_layer->removeAnimation(animationId);
303 }
304
305 void WebLayerImpl::removeAnimation(int animationId, WebAnimation::TargetProperty targetProperty)
306 {
307 m_layer->layerAnimationController()->removeAnimation(animationId, static_cas t<CCActiveAnimation::TargetProperty>(targetProperty));
308 }
309
310 void WebLayerImpl::pauseAnimation(int animationId, double timeOffset)
311 {
312 m_layer->pauseAnimation(animationId, timeOffset);
313 }
314
315 void WebLayerImpl::suspendAnimations(double monotonicTime)
316 {
317 m_layer->suspendAnimations(monotonicTime);
318 }
319
320 void WebLayerImpl::resumeAnimations(double monotonicTime)
321 {
322 m_layer->resumeAnimations(monotonicTime);
323 }
324
325 bool WebLayerImpl::hasActiveAnimation()
326 {
327 return m_layer->hasActiveAnimation();
328 }
329
330 void WebLayerImpl::transferAnimationsTo(WebLayer* other)
331 {
332 ASSERT(other);
333 static_cast<WebLayerImpl*>(other)->m_layer->setLayerAnimationController(m_la yer->releaseLayerAnimationController());
334 }
335
336 void WebLayerImpl::setForceRenderSurface(bool forceRenderSurface)
337 {
338 m_layer->setForceRenderSurface(forceRenderSurface);
339 }
340
341 void WebLayerImpl::setScrollPosition(WebPoint position)
342 {
343 m_layer->setScrollPosition(convert(position));
344 }
345
346 WebPoint WebLayerImpl::scrollPosition() const
347 {
348 return WebPoint(m_layer->scrollPosition().x(), m_layer->scrollPosition().y() );
349 }
350
351 void WebLayerImpl::setMaxScrollPosition(WebSize maxScrollPosition)
352 {
353 m_layer->setMaxScrollPosition(convert(maxScrollPosition));
354 }
355
356 WebSize WebLayerImpl::maxScrollPosition() const
357 {
358 return convert(m_layer->maxScrollPosition());
359 }
360
361 void WebLayerImpl::setScrollable(bool scrollable)
362 {
363 m_layer->setScrollable(scrollable);
364 }
365
366 bool WebLayerImpl::scrollable() const
367 {
368 return m_layer->scrollable();
369 }
370
371 void WebLayerImpl::setHaveWheelEventHandlers(bool haveWheelEventHandlers)
372 {
373 m_layer->setHaveWheelEventHandlers(haveWheelEventHandlers);
374 }
375
376 bool WebLayerImpl::haveWheelEventHandlers() const
377 {
378 return m_layer->haveWheelEventHandlers();
379 }
380
381 void WebLayerImpl::setShouldScrollOnMainThread(bool shouldScrollOnMainThread)
382 {
383 m_layer->setShouldScrollOnMainThread(shouldScrollOnMainThread);
384 }
385
386 bool WebLayerImpl::shouldScrollOnMainThread() const
387 {
388 return m_layer->shouldScrollOnMainThread();
389 }
390
391 void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects)
392 {
393 WebCore::Region region;
394 for (size_t i = 0; i < rects.size(); ++i) {
395 WebCore::IntRect rect = convert(rects[i]);
396 region.unite(rect);
397 }
398 m_layer->setNonFastScrollableRegion(region);
399
400 }
401
402 WebVector<WebRect> WebLayerImpl::nonFastScrollableRegion() const
403 {
404 Vector<WebCore::IntRect> regionRects = m_layer->nonFastScrollableRegion().re cts();
405 WebVector<WebRect> result(regionRects.size());
406 for (size_t i = 0; i < regionRects.size(); ++i)
407 result[i] = convert(regionRects[i]);
408 return result;
409 }
410
411 void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable)
412 {
413 m_layer->setIsContainerForFixedPositionLayers(enable);
414 }
415
416 bool WebLayerImpl::isContainerForFixedPositionLayers() const
417 {
418 return m_layer->isContainerForFixedPositionLayers();
419 }
420
421 void WebLayerImpl::setFixedToContainerLayer(bool enable)
422 {
423 m_layer->setFixedToContainerLayer(enable);
424 }
425
426 bool WebLayerImpl::fixedToContainerLayer() const
427 {
428 return m_layer->fixedToContainerLayer();
429 }
430
431 void WebLayerImpl::setScrollClient(WebLayerScrollClient* scrollClient)
432 {
433 m_layer->setLayerScrollClient(scrollClient);
434 }
435
436 LayerChromium* WebLayerImpl::layer() const
437 {
438 return m_layer.get();
439 }
440
441 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/compositor_bindings/WebLayerImpl.h ('k') | webkit/compositor_bindings/WebLayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698