| 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 "WebLayerImpl.h" | |
| 7 | |
| 8 #include "CCActiveAnimation.h" | |
| 9 #include "LayerChromium.h" | |
| 10 #include "SkMatrix44.h" | |
| 11 #include "WebAnimationImpl.h" | |
| 12 #include <public/WebFloatPoint.h> | |
| 13 #include <public/WebFloatRect.h> | |
| 14 #include <public/WebSize.h> | |
| 15 #include <public/WebTransformationMatrix.h> | |
| 16 | |
| 17 using WebCore::CCActiveAnimation; | |
| 18 using WebCore::LayerChromium; | |
| 19 | |
| 20 namespace WebKit { | |
| 21 | |
| 22 namespace { | |
| 23 | |
| 24 WebTransformationMatrix transformationMatrixFromSkMatrix44(const SkMatrix44& mat
rix) | |
| 25 { | |
| 26 double data[16]; | |
| 27 matrix.asColMajord(data); | |
| 28 return WebTransformationMatrix(data[0], data[1], data[2], data[3], | |
| 29 data[4], data[5], data[6], data[7], | |
| 30 data[8], data[9], data[10], data[11], | |
| 31 data[12], data[13], data[14], data[15]); | |
| 32 } | |
| 33 | |
| 34 SkMatrix44 skMatrix44FromTransformationMatrix(const WebTransformationMatrix& mat
rix) | |
| 35 { | |
| 36 SkMatrix44 skMatrix; | |
| 37 skMatrix.set(0, 0, SkDoubleToMScalar(matrix.m11())); | |
| 38 skMatrix.set(1, 0, SkDoubleToMScalar(matrix.m12())); | |
| 39 skMatrix.set(2, 0, SkDoubleToMScalar(matrix.m13())); | |
| 40 skMatrix.set(3, 0, SkDoubleToMScalar(matrix.m14())); | |
| 41 skMatrix.set(0, 1, SkDoubleToMScalar(matrix.m21())); | |
| 42 skMatrix.set(1, 1, SkDoubleToMScalar(matrix.m22())); | |
| 43 skMatrix.set(2, 1, SkDoubleToMScalar(matrix.m23())); | |
| 44 skMatrix.set(3, 1, SkDoubleToMScalar(matrix.m24())); | |
| 45 skMatrix.set(0, 2, SkDoubleToMScalar(matrix.m31())); | |
| 46 skMatrix.set(1, 2, SkDoubleToMScalar(matrix.m32())); | |
| 47 skMatrix.set(2, 2, SkDoubleToMScalar(matrix.m33())); | |
| 48 skMatrix.set(3, 2, SkDoubleToMScalar(matrix.m34())); | |
| 49 skMatrix.set(0, 3, SkDoubleToMScalar(matrix.m41())); | |
| 50 skMatrix.set(1, 3, SkDoubleToMScalar(matrix.m42())); | |
| 51 skMatrix.set(2, 3, SkDoubleToMScalar(matrix.m43())); | |
| 52 skMatrix.set(3, 3, SkDoubleToMScalar(matrix.m44())); | |
| 53 return skMatrix; | |
| 54 } | |
| 55 | |
| 56 } // anonymous namespace | |
| 57 | |
| 58 | |
| 59 WebLayer* WebLayer::create() | |
| 60 { | |
| 61 return new WebLayerImpl(); | |
| 62 } | |
| 63 | |
| 64 WebLayerImpl::WebLayerImpl() | |
| 65 : m_layer(LayerChromium::create()) | |
| 66 { | |
| 67 } | |
| 68 | |
| 69 WebLayerImpl::WebLayerImpl(PassRefPtr<LayerChromium> layer) | |
| 70 : m_layer(layer) | |
| 71 { | |
| 72 } | |
| 73 | |
| 74 | |
| 75 WebLayerImpl::~WebLayerImpl() | |
| 76 { | |
| 77 m_layer->clearRenderSurface(); | |
| 78 m_layer->setLayerAnimationDelegate(0); | |
| 79 } | |
| 80 | |
| 81 int WebLayerImpl::id() const | |
| 82 { | |
| 83 return m_layer->id(); | |
| 84 } | |
| 85 | |
| 86 void WebLayerImpl::invalidateRect(const WebFloatRect& rect) | |
| 87 { | |
| 88 m_layer->setNeedsDisplayRect(rect); | |
| 89 } | |
| 90 | |
| 91 void WebLayerImpl::invalidate() | |
| 92 { | |
| 93 m_layer->setNeedsDisplay(); | |
| 94 } | |
| 95 | |
| 96 void WebLayerImpl::addChild(WebLayer* child) | |
| 97 { | |
| 98 m_layer->addChild(static_cast<WebLayerImpl*>(child)->layer()); | |
| 99 } | |
| 100 | |
| 101 void WebLayerImpl::insertChild(WebLayer* child, size_t index) | |
| 102 { | |
| 103 m_layer->insertChild(static_cast<WebLayerImpl*>(child)->layer(), index); | |
| 104 } | |
| 105 | |
| 106 void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* newLayer) | |
| 107 { | |
| 108 m_layer->replaceChild(static_cast<WebLayerImpl*>(reference)->layer(), static
_cast<WebLayerImpl*>(newLayer)->layer()); | |
| 109 } | |
| 110 | |
| 111 void WebLayerImpl::removeFromParent() | |
| 112 { | |
| 113 m_layer->removeFromParent(); | |
| 114 } | |
| 115 | |
| 116 void WebLayerImpl::removeAllChildren() | |
| 117 { | |
| 118 m_layer->removeAllChildren(); | |
| 119 } | |
| 120 | |
| 121 void WebLayerImpl::setAnchorPoint(const WebFloatPoint& anchorPoint) | |
| 122 { | |
| 123 m_layer->setAnchorPoint(anchorPoint); | |
| 124 } | |
| 125 | |
| 126 WebFloatPoint WebLayerImpl::anchorPoint() const | |
| 127 { | |
| 128 return WebFloatPoint(m_layer->anchorPoint()); | |
| 129 } | |
| 130 | |
| 131 void WebLayerImpl::setAnchorPointZ(float anchorPointZ) | |
| 132 { | |
| 133 m_layer->setAnchorPointZ(anchorPointZ); | |
| 134 } | |
| 135 | |
| 136 float WebLayerImpl::anchorPointZ() const | |
| 137 { | |
| 138 return m_layer->anchorPointZ(); | |
| 139 } | |
| 140 | |
| 141 void WebLayerImpl::setBounds(const WebSize& size) | |
| 142 { | |
| 143 m_layer->setBounds(size); | |
| 144 } | |
| 145 | |
| 146 WebSize WebLayerImpl::bounds() const | |
| 147 { | |
| 148 return WebSize(m_layer->bounds()); | |
| 149 } | |
| 150 | |
| 151 void WebLayerImpl::setMasksToBounds(bool masksToBounds) | |
| 152 { | |
| 153 m_layer->setMasksToBounds(masksToBounds); | |
| 154 } | |
| 155 | |
| 156 bool WebLayerImpl::masksToBounds() const | |
| 157 { | |
| 158 return m_layer->masksToBounds(); | |
| 159 } | |
| 160 | |
| 161 void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) | |
| 162 { | |
| 163 m_layer->setMaskLayer(maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->lay
er() : 0); | |
| 164 } | |
| 165 | |
| 166 void WebLayerImpl::setReplicaLayer(WebLayer* replicaLayer) | |
| 167 { | |
| 168 m_layer->setReplicaLayer(replicaLayer ? static_cast<WebLayerImpl*>(replicaLa
yer)->layer() : 0); | |
| 169 } | |
| 170 | |
| 171 void WebLayerImpl::setOpacity(float opacity) | |
| 172 { | |
| 173 m_layer->setOpacity(opacity); | |
| 174 } | |
| 175 | |
| 176 float WebLayerImpl::opacity() const | |
| 177 { | |
| 178 return m_layer->opacity(); | |
| 179 } | |
| 180 | |
| 181 void WebLayerImpl::setOpaque(bool opaque) | |
| 182 { | |
| 183 m_layer->setOpaque(opaque); | |
| 184 } | |
| 185 | |
| 186 bool WebLayerImpl::opaque() const | |
| 187 { | |
| 188 return m_layer->opaque(); | |
| 189 } | |
| 190 | |
| 191 void WebLayerImpl::setPosition(const WebFloatPoint& position) | |
| 192 { | |
| 193 m_layer->setPosition(position); | |
| 194 } | |
| 195 | |
| 196 WebFloatPoint WebLayerImpl::position() const | |
| 197 { | |
| 198 return WebFloatPoint(m_layer->position()); | |
| 199 } | |
| 200 | |
| 201 void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix) | |
| 202 { | |
| 203 m_layer->setSublayerTransform(transformationMatrixFromSkMatrix44(matrix)); | |
| 204 } | |
| 205 | |
| 206 void WebLayerImpl::setSublayerTransform(const WebTransformationMatrix& matrix) | |
| 207 { | |
| 208 m_layer->setSublayerTransform(matrix); | |
| 209 } | |
| 210 | |
| 211 SkMatrix44 WebLayerImpl::sublayerTransform() const | |
| 212 { | |
| 213 return skMatrix44FromTransformationMatrix(m_layer->sublayerTransform()); | |
| 214 } | |
| 215 | |
| 216 void WebLayerImpl::setTransform(const SkMatrix44& matrix) | |
| 217 { | |
| 218 m_layer->setTransform(transformationMatrixFromSkMatrix44(matrix)); | |
| 219 } | |
| 220 | |
| 221 void WebLayerImpl::setTransform(const WebTransformationMatrix& matrix) | |
| 222 { | |
| 223 m_layer->setTransform(matrix); | |
| 224 } | |
| 225 | |
| 226 SkMatrix44 WebLayerImpl::transform() const | |
| 227 { | |
| 228 return skMatrix44FromTransformationMatrix(m_layer->transform()); | |
| 229 } | |
| 230 | |
| 231 void WebLayerImpl::setDrawsContent(bool drawsContent) | |
| 232 { | |
| 233 m_layer->setIsDrawable(drawsContent); | |
| 234 } | |
| 235 | |
| 236 bool WebLayerImpl::drawsContent() const | |
| 237 { | |
| 238 return m_layer->drawsContent(); | |
| 239 } | |
| 240 | |
| 241 void WebLayerImpl::setPreserves3D(bool preserve3D) | |
| 242 { | |
| 243 m_layer->setPreserves3D(preserve3D); | |
| 244 } | |
| 245 | |
| 246 void WebLayerImpl::setUseParentBackfaceVisibility(bool useParentBackfaceVisibili
ty) | |
| 247 { | |
| 248 m_layer->setUseParentBackfaceVisibility(useParentBackfaceVisibility); | |
| 249 } | |
| 250 | |
| 251 void WebLayerImpl::setBackgroundColor(WebColor color) | |
| 252 { | |
| 253 m_layer->setBackgroundColor(color); | |
| 254 } | |
| 255 | |
| 256 void WebLayerImpl::setFilters(const WebFilterOperations& filters) | |
| 257 { | |
| 258 m_layer->setFilters(filters); | |
| 259 } | |
| 260 | |
| 261 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) | |
| 262 { | |
| 263 m_layer->setBackgroundFilters(filters); | |
| 264 } | |
| 265 | |
| 266 void WebLayerImpl::setDebugBorderColor(const WebColor& color) | |
| 267 { | |
| 268 m_layer->setDebugBorderColor(color); | |
| 269 } | |
| 270 | |
| 271 void WebLayerImpl::setDebugBorderWidth(float width) | |
| 272 { | |
| 273 m_layer->setDebugBorderWidth(width); | |
| 274 } | |
| 275 | |
| 276 void WebLayerImpl::setDebugName(WebString name) | |
| 277 { | |
| 278 m_layer->setDebugName(name); | |
| 279 } | |
| 280 | |
| 281 void WebLayerImpl::setAnimationDelegate(WebAnimationDelegate* delegate) | |
| 282 { | |
| 283 m_layer->setLayerAnimationDelegate(delegate); | |
| 284 } | |
| 285 | |
| 286 bool WebLayerImpl::addAnimation(WebAnimation* animation) | |
| 287 { | |
| 288 return m_layer->addAnimation(static_cast<WebAnimationImpl*>(animation)->clon
eToCCAnimation()); | |
| 289 } | |
| 290 | |
| 291 void WebLayerImpl::removeAnimation(int animationId) | |
| 292 { | |
| 293 m_layer->removeAnimation(animationId); | |
| 294 } | |
| 295 | |
| 296 void WebLayerImpl::removeAnimation(int animationId, WebAnimation::TargetProperty
targetProperty) | |
| 297 { | |
| 298 m_layer->layerAnimationController()->removeAnimation(animationId, static_cas
t<CCActiveAnimation::TargetProperty>(targetProperty)); | |
| 299 } | |
| 300 | |
| 301 void WebLayerImpl::pauseAnimation(int animationId, double timeOffset) | |
| 302 { | |
| 303 m_layer->pauseAnimation(animationId, timeOffset); | |
| 304 } | |
| 305 | |
| 306 void WebLayerImpl::suspendAnimations(double monotonicTime) | |
| 307 { | |
| 308 m_layer->suspendAnimations(monotonicTime); | |
| 309 } | |
| 310 | |
| 311 void WebLayerImpl::resumeAnimations(double monotonicTime) | |
| 312 { | |
| 313 m_layer->resumeAnimations(monotonicTime); | |
| 314 } | |
| 315 | |
| 316 bool WebLayerImpl::hasActiveAnimation() | |
| 317 { | |
| 318 return m_layer->hasActiveAnimation(); | |
| 319 } | |
| 320 | |
| 321 void WebLayerImpl::transferAnimationsTo(WebLayer* other) | |
| 322 { | |
| 323 ASSERT(other); | |
| 324 static_cast<WebLayerImpl*>(other)->m_layer->setLayerAnimationController(m_la
yer->releaseLayerAnimationController()); | |
| 325 } | |
| 326 | |
| 327 void WebLayerImpl::setForceRenderSurface(bool forceRenderSurface) | |
| 328 { | |
| 329 m_layer->setForceRenderSurface(forceRenderSurface); | |
| 330 } | |
| 331 | |
| 332 void WebLayerImpl::setScrollPosition(WebPoint position) | |
| 333 { | |
| 334 m_layer->setScrollPosition(position); | |
| 335 } | |
| 336 | |
| 337 void WebLayerImpl::setScrollable(bool scrollable) | |
| 338 { | |
| 339 m_layer->setScrollable(scrollable); | |
| 340 } | |
| 341 | |
| 342 void WebLayerImpl::setHaveWheelEventHandlers(bool haveWheelEventHandlers) | |
| 343 { | |
| 344 m_layer->setHaveWheelEventHandlers(haveWheelEventHandlers); | |
| 345 } | |
| 346 | |
| 347 void WebLayerImpl::setShouldScrollOnMainThread(bool shouldScrollOnMainThread) | |
| 348 { | |
| 349 m_layer->setShouldScrollOnMainThread(shouldScrollOnMainThread); | |
| 350 } | |
| 351 | |
| 352 void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects) | |
| 353 { | |
| 354 WebCore::Region region; | |
| 355 for (size_t i = 0; i < rects.size(); ++i) { | |
| 356 WebCore::IntRect rect = rects[i]; | |
| 357 region.unite(rect); | |
| 358 } | |
| 359 m_layer->setNonFastScrollableRegion(region); | |
| 360 | |
| 361 } | |
| 362 | |
| 363 void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable) | |
| 364 { | |
| 365 m_layer->setIsContainerForFixedPositionLayers(enable); | |
| 366 } | |
| 367 | |
| 368 void WebLayerImpl::setFixedToContainerLayer(bool enable) | |
| 369 { | |
| 370 m_layer->setFixedToContainerLayer(enable); | |
| 371 } | |
| 372 | |
| 373 LayerChromium* WebLayerImpl::layer() const | |
| 374 { | |
| 375 return m_layer.get(); | |
| 376 } | |
| 377 | |
| 378 } // namespace WebKit | |
| OLD | NEW |