| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 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 "webkit/compositor_bindings/web_layer_impl.h" | 5 #include "webkit/compositor_bindings/web_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "cc/animation.h" | 8 #include "cc/animation.h" |
| 9 #include "cc/layer.h" | 9 #include "cc/layer.h" |
| 10 #include "cc/region.h" | 10 #include "cc/region.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 14 #include "third_party/skia/include/utils/SkMatrix44.h" | 14 #include "third_party/skia/include/utils/SkMatrix44.h" |
| 15 #include "webkit/compositor_bindings/web_animation_impl.h" | 15 #include "webkit/compositor_bindings/web_animation_impl.h" |
| 16 | 16 |
| 17 using cc::Animation; | 17 using cc::Animation; |
| 18 using cc::Layer; | 18 using cc::Layer; |
| 19 using WebKit::WebLayer; |
| 20 using WebKit::WebFloatPoint; |
| 21 using WebKit::WebVector; |
| 22 using WebKit::WebRect; |
| 23 using WebKit::WebSize; |
| 24 using WebKit::WebColor; |
| 25 using WebKit::WebFilterOperations; |
| 19 | 26 |
| 20 namespace WebKit { | 27 namespace webkit { |
| 21 | 28 |
| 22 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) {} | 29 WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) {} |
| 23 | 30 |
| 24 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) {} | 31 WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) {} |
| 25 | 32 |
| 26 WebLayerImpl::~WebLayerImpl() { | 33 WebLayerImpl::~WebLayerImpl() { |
| 27 layer_->ClearRenderSurface(); | 34 layer_->ClearRenderSurface(); |
| 28 layer_->set_layer_animation_delegate(NULL); | 35 layer_->set_layer_animation_delegate(NULL); |
| 29 } | 36 } |
| 30 | 37 |
| 31 int WebLayerImpl::id() const { return layer_->id(); } | 38 int WebLayerImpl::id() const { return layer_->id(); } |
| 32 | 39 |
| 33 void WebLayerImpl::invalidateRect(const WebFloatRect& rect) { | 40 void WebLayerImpl::invalidateRect(const WebKit::WebFloatRect& rect) { |
| 34 layer_->SetNeedsDisplayRect(rect); | 41 layer_->SetNeedsDisplayRect(rect); |
| 35 } | 42 } |
| 36 | 43 |
| 37 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } | 44 void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); } |
| 38 | 45 |
| 39 void WebLayerImpl::addChild(WebLayer* child) { | 46 void WebLayerImpl::addChild(WebLayer* child) { |
| 40 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); | 47 layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer()); |
| 41 } | 48 } |
| 42 | 49 |
| 43 void WebLayerImpl::insertChild(WebLayer* child, size_t index) { | 50 void WebLayerImpl::insertChild(WebLayer* child, size_t index) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 157 |
| 151 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { | 158 void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) { |
| 152 layer_->SetBackgroundFilters(filters); | 159 layer_->SetBackgroundFilters(filters); |
| 153 } | 160 } |
| 154 | 161 |
| 155 void WebLayerImpl::setFilter(SkImageFilter* filter) { | 162 void WebLayerImpl::setFilter(SkImageFilter* filter) { |
| 156 SkSafeRef(filter); // Claim a reference for the compositor. | 163 SkSafeRef(filter); // Claim a reference for the compositor. |
| 157 layer_->SetFilter(skia::AdoptRef(filter)); | 164 layer_->SetFilter(skia::AdoptRef(filter)); |
| 158 } | 165 } |
| 159 | 166 |
| 160 void WebLayerImpl::setDebugName(WebString name) { | 167 void WebLayerImpl::setDebugName(WebKit::WebString name) { |
| 161 layer_->SetDebugName(UTF16ToASCII(string16(name.data(), name.length()))); | 168 layer_->SetDebugName(UTF16ToASCII(string16(name.data(), name.length()))); |
| 162 } | 169 } |
| 163 | 170 |
| 164 void WebLayerImpl::setAnimationDelegate(WebAnimationDelegate* delegate) { | 171 void WebLayerImpl::setAnimationDelegate( |
| 172 WebKit::WebAnimationDelegate* delegate) { |
| 165 layer_->set_layer_animation_delegate(delegate); | 173 layer_->set_layer_animation_delegate(delegate); |
| 166 } | 174 } |
| 167 | 175 |
| 168 bool WebLayerImpl::addAnimation(WebAnimation* animation) { | 176 bool WebLayerImpl::addAnimation(WebKit::WebAnimation* animation) { |
| 169 return layer_->AddAnimation( | 177 return layer_->AddAnimation( |
| 170 static_cast<WebAnimationImpl*>(animation)->cloneToAnimation()); | 178 static_cast<WebAnimationImpl*>(animation)->cloneToAnimation()); |
| 171 } | 179 } |
| 172 | 180 |
| 173 void WebLayerImpl::removeAnimation(int animation_id) { | 181 void WebLayerImpl::removeAnimation(int animation_id) { |
| 174 layer_->RemoveAnimation(animation_id); | 182 layer_->RemoveAnimation(animation_id); |
| 175 } | 183 } |
| 176 | 184 |
| 177 void WebLayerImpl::removeAnimation( | 185 void WebLayerImpl::removeAnimation( |
| 178 int animation_id, | 186 int animation_id, |
| 179 WebAnimation::TargetProperty target_property) { | 187 WebKit::WebAnimation::TargetProperty target_property) { |
| 180 layer_->layer_animation_controller()->RemoveAnimation( | 188 layer_->layer_animation_controller()->RemoveAnimation( |
| 181 animation_id, | 189 animation_id, |
| 182 static_cast<Animation::TargetProperty>(target_property)); | 190 static_cast<Animation::TargetProperty>(target_property)); |
| 183 } | 191 } |
| 184 | 192 |
| 185 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { | 193 void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) { |
| 186 layer_->PauseAnimation(animation_id, time_offset); | 194 layer_->PauseAnimation(animation_id, time_offset); |
| 187 } | 195 } |
| 188 | 196 |
| 189 void WebLayerImpl::suspendAnimations(double monotonic_time) { | 197 void WebLayerImpl::suspendAnimations(double monotonic_time) { |
| 190 layer_->SuspendAnimations(monotonic_time); | 198 layer_->SuspendAnimations(monotonic_time); |
| 191 } | 199 } |
| 192 | 200 |
| 193 void WebLayerImpl::resumeAnimations(double monotonic_time) { | 201 void WebLayerImpl::resumeAnimations(double monotonic_time) { |
| 194 layer_->ResumeAnimations(monotonic_time); | 202 layer_->ResumeAnimations(monotonic_time); |
| 195 } | 203 } |
| 196 | 204 |
| 197 bool WebLayerImpl::hasActiveAnimation() { return layer_->HasActiveAnimation(); } | 205 bool WebLayerImpl::hasActiveAnimation() { return layer_->HasActiveAnimation(); } |
| 198 | 206 |
| 199 void WebLayerImpl::transferAnimationsTo(WebLayer* other) { | 207 void WebLayerImpl::transferAnimationsTo(WebLayer* other) { |
| 200 DCHECK(other); | 208 DCHECK(other); |
| 201 static_cast<WebLayerImpl*>(other)->layer_->SetLayerAnimationController( | 209 static_cast<WebLayerImpl*>(other)->layer_->SetLayerAnimationController( |
| 202 layer_->ReleaseLayerAnimationController()); | 210 layer_->ReleaseLayerAnimationController()); |
| 203 } | 211 } |
| 204 | 212 |
| 205 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { | 213 void WebLayerImpl::setForceRenderSurface(bool force_render_surface) { |
| 206 layer_->SetForceRenderSurface(force_render_surface); | 214 layer_->SetForceRenderSurface(force_render_surface); |
| 207 } | 215 } |
| 208 | 216 |
| 209 void WebLayerImpl::setScrollPosition(WebPoint position) { | 217 void WebLayerImpl::setScrollPosition(WebKit::WebPoint position) { |
| 210 layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); | 218 layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin()); |
| 211 } | 219 } |
| 212 | 220 |
| 213 WebPoint WebLayerImpl::scrollPosition() const { | 221 WebKit::WebPoint WebLayerImpl::scrollPosition() const { |
| 214 return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); | 222 return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset()); |
| 215 } | 223 } |
| 216 | 224 |
| 217 void WebLayerImpl::setMaxScrollPosition(WebSize max_scroll_position) { | 225 void WebLayerImpl::setMaxScrollPosition(WebSize max_scroll_position) { |
| 218 layer_->SetMaxScrollOffset(max_scroll_position); | 226 layer_->SetMaxScrollOffset(max_scroll_position); |
| 219 } | 227 } |
| 220 | 228 |
| 221 WebSize WebLayerImpl::maxScrollPosition() const { | 229 WebSize WebLayerImpl::maxScrollPosition() const { |
| 222 return layer_->max_scroll_offset(); | 230 return layer_->max_scroll_offset(); |
| 223 } | 231 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 312 } |
| 305 | 313 |
| 306 void WebLayerImpl::setFixedToContainerLayer(bool enable) { | 314 void WebLayerImpl::setFixedToContainerLayer(bool enable) { |
| 307 layer_->SetFixedToContainerLayer(enable); | 315 layer_->SetFixedToContainerLayer(enable); |
| 308 } | 316 } |
| 309 | 317 |
| 310 bool WebLayerImpl::fixedToContainerLayer() const { | 318 bool WebLayerImpl::fixedToContainerLayer() const { |
| 311 return layer_->fixed_to_container_layer(); | 319 return layer_->fixed_to_container_layer(); |
| 312 } | 320 } |
| 313 | 321 |
| 314 void WebLayerImpl::setScrollClient(WebLayerScrollClient* scroll_client) { | 322 void WebLayerImpl::setScrollClient( |
| 323 WebKit::WebLayerScrollClient* scroll_client) { |
| 315 layer_->set_layer_scroll_client(scroll_client); | 324 layer_->set_layer_scroll_client(scroll_client); |
| 316 } | 325 } |
| 317 | 326 |
| 318 Layer* WebLayerImpl::layer() const { return layer_.get(); } | 327 Layer* WebLayerImpl::layer() const { return layer_.get(); } |
| 319 | 328 |
| 320 } // namespace WebKit | 329 } // namespace WebKit |
| OLD | NEW |