| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "cc/debug_border_draw_quad.h" | 11 #include "cc/debug_border_draw_quad.h" |
| 12 #include "cc/layer_sorter.h" | 12 #include "cc/layer_sorter.h" |
| 13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
| 14 #include "cc/proxy.h" | 14 #include "cc/proxy.h" |
| 15 #include "cc/quad_sink.h" | 15 #include "cc/quad_sink.h" |
| 16 #include "cc/scrollbar_animation_controller.h" | 16 #include "cc/scrollbar_animation_controller.h" |
| 17 #include "cc/settings.h" | 17 #include "cc/settings.h" |
| 18 #include "third_party/skia/include/core/SkImageFilter.h" | 18 #include "third_party/skia/include/core/SkImageFilter.h" |
| 19 #include "ui/gfx/point_conversions.h" |
| 20 #include "ui/gfx/rect_conversions.h" |
| 19 | 21 |
| 20 using WebKit::WebTransformationMatrix; | 22 using WebKit::WebTransformationMatrix; |
| 21 | 23 |
| 22 namespace cc { | 24 namespace cc { |
| 23 | 25 |
| 24 LayerImpl::LayerImpl(int id) | 26 LayerImpl::LayerImpl(int id) |
| 25 : m_parent(0) | 27 : m_parent(0) |
| 26 , m_maskLayerId(-1) | 28 , m_maskLayerId(-1) |
| 27 , m_replicaLayerId(-1) | 29 , m_replicaLayerId(-1) |
| 28 , m_layerId(id) | 30 , m_layerId(id) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 DCHECK(m_betweenWillDrawAndDidDraw); | 145 DCHECK(m_betweenWillDrawAndDidDraw); |
| 144 m_betweenWillDrawAndDidDraw = false; | 146 m_betweenWillDrawAndDidDraw = false; |
| 145 #endif | 147 #endif |
| 146 } | 148 } |
| 147 | 149 |
| 148 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState*
sharedQuadState, AppendQuadsData& appendQuadsData) const | 150 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState*
sharedQuadState, AppendQuadsData& appendQuadsData) const |
| 149 { | 151 { |
| 150 if (!hasDebugBorders()) | 152 if (!hasDebugBorders()) |
| 151 return; | 153 return; |
| 152 | 154 |
| 153 IntRect contentRect(IntPoint(), contentBounds()); | 155 gfx::Rect contentRect(gfx::Point(), contentBounds()); |
| 154 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, de
bugBorderColor(), debugBorderWidth()).PassAs<DrawQuad>(), appendQuadsData); | 156 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, de
bugBorderColor(), debugBorderWidth()).PassAs<DrawQuad>(), appendQuadsData); |
| 155 } | 157 } |
| 156 | 158 |
| 157 bool LayerImpl::hasContributingDelegatedRenderPasses() const | 159 bool LayerImpl::hasContributingDelegatedRenderPasses() const |
| 158 { | 160 { |
| 159 return false; | 161 return false; |
| 160 } | 162 } |
| 161 | 163 |
| 162 RenderPass::Id LayerImpl::firstContributingRenderPassId() const | 164 RenderPass::Id LayerImpl::firstContributingRenderPassId() const |
| 163 { | 165 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return InputHandlerClient::ScrollOnMainThread; | 203 return InputHandlerClient::ScrollOnMainThread; |
| 202 } | 204 } |
| 203 | 205 |
| 204 if (!screenSpaceTransform().isInvertible()) { | 206 if (!screenSpaceTransform().isInvertible()) { |
| 205 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform
"); | 207 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform
"); |
| 206 return InputHandlerClient::ScrollIgnored; | 208 return InputHandlerClient::ScrollIgnored; |
| 207 } | 209 } |
| 208 | 210 |
| 209 if (!nonFastScrollableRegion().isEmpty()) { | 211 if (!nonFastScrollableRegion().isEmpty()) { |
| 210 bool clipped = false; | 212 bool clipped = false; |
| 211 FloatPoint hitTestPointInLocalSpace = MathUtil::projectPoint(screenSpace
Transform().inverse(), FloatPoint(screenSpacePoint), clipped); | 213 gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(screenSpac
eTransform().inverse(), FloatPoint(screenSpacePoint), clipped); |
| 212 if (!clipped && nonFastScrollableRegion().contains(flooredIntPoint(hitTe
stPointInLocalSpace))) { | 214 if (!clipped && nonFastScrollableRegion().contains(cc::IntPoint(gfx::ToF
looredPoint(hitTestPointInLocalSpace)))) { |
| 213 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRe
gion"); | 215 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRe
gion"); |
| 214 return InputHandlerClient::ScrollOnMainThread; | 216 return InputHandlerClient::ScrollOnMainThread; |
| 215 } | 217 } |
| 216 } | 218 } |
| 217 | 219 |
| 218 if (type == InputHandlerClient::Wheel && haveWheelEventHandlers()) { | 220 if (type == InputHandlerClient::Wheel && haveWheelEventHandlers()) { |
| 219 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers"); | 221 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers"); |
| 220 return InputHandlerClient::ScrollOnMainThread; | 222 return InputHandlerClient::ScrollOnMainThread; |
| 221 } | 223 } |
| 222 | 224 |
| 223 if (!scrollable()) { | 225 if (!scrollable()) { |
| 224 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); | 226 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); |
| 225 return InputHandlerClient::ScrollIgnored; | 227 return InputHandlerClient::ScrollIgnored; |
| 226 } | 228 } |
| 227 | 229 |
| 228 return InputHandlerClient::ScrollStarted; | 230 return InputHandlerClient::ScrollStarted; |
| 229 } | 231 } |
| 230 | 232 |
| 231 bool LayerImpl::drawCheckerboardForMissingTiles() const | 233 bool LayerImpl::drawCheckerboardForMissingTiles() const |
| 232 { | 234 { |
| 233 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea
dOfCheckerboard(); | 235 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea
dOfCheckerboard(); |
| 234 } | 236 } |
| 235 | 237 |
| 236 IntRect LayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect) | 238 gfx::Rect LayerImpl::layerRectToContentRect(const gfx::Rect& layerRect) |
| 237 { | 239 { |
| 238 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); | 240 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); |
| 239 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); | 241 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); |
| 240 FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.h
eight); | 242 gfx::RectF contentRect = gfx::ScaleRect(layerRect, widthScale, heightScale); |
| 241 contentRect.scale(widthScale, heightScale); | 243 return gfx::ToEnclosingRect(contentRect); |
| 242 return enclosingIntRect(contentRect); | |
| 243 } | 244 } |
| 244 | 245 |
| 245 std::string LayerImpl::indentString(int indent) | 246 std::string LayerImpl::indentString(int indent) |
| 246 { | 247 { |
| 247 std::string str; | 248 std::string str; |
| 248 for (int i = 0; i != indent; ++i) | 249 for (int i = 0; i != indent; ++i) |
| 249 str.append(" "); | 250 str.append(" "); |
| 250 return str; | 251 return str; |
| 251 } | 252 } |
| 252 | 253 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 const char* LayerImpl::layerTypeAsString() const | 350 const char* LayerImpl::layerTypeAsString() const |
| 350 { | 351 { |
| 351 return "Layer"; | 352 return "Layer"; |
| 352 } | 353 } |
| 353 | 354 |
| 354 void LayerImpl::resetAllChangeTrackingForSubtree() | 355 void LayerImpl::resetAllChangeTrackingForSubtree() |
| 355 { | 356 { |
| 356 m_layerPropertyChanged = false; | 357 m_layerPropertyChanged = false; |
| 357 m_layerSurfacePropertyChanged = false; | 358 m_layerSurfacePropertyChanged = false; |
| 358 | 359 |
| 359 m_updateRect = FloatRect(); | 360 m_updateRect = gfx::RectF(); |
| 360 | 361 |
| 361 if (m_renderSurface) | 362 if (m_renderSurface) |
| 362 m_renderSurface->resetPropertyChangedFlag(); | 363 m_renderSurface->resetPropertyChangedFlag(); |
| 363 | 364 |
| 364 if (m_maskLayer) | 365 if (m_maskLayer) |
| 365 m_maskLayer->resetAllChangeTrackingForSubtree(); | 366 m_maskLayer->resetAllChangeTrackingForSubtree(); |
| 366 | 367 |
| 367 if (m_replicaLayer) | 368 if (m_replicaLayer) |
| 368 m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the r
eplica mask, if it exists. | 369 m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the r
eplica mask, if it exists. |
| 369 | 370 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 394 const WebKit::WebTransformationMatrix& LayerImpl::transform() const | 395 const WebKit::WebTransformationMatrix& LayerImpl::transform() const |
| 395 { | 396 { |
| 396 return m_transform; | 397 return m_transform; |
| 397 } | 398 } |
| 398 | 399 |
| 399 void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transfo
rm) | 400 void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transfo
rm) |
| 400 { | 401 { |
| 401 setTransform(transform); | 402 setTransform(transform); |
| 402 } | 403 } |
| 403 | 404 |
| 404 void LayerImpl::setBounds(const IntSize& bounds) | 405 void LayerImpl::setBounds(const gfx::Size& bounds) |
| 405 { | 406 { |
| 406 if (m_bounds == bounds) | 407 if (m_bounds == bounds) |
| 407 return; | 408 return; |
| 408 | 409 |
| 409 m_bounds = bounds; | 410 m_bounds = bounds; |
| 410 | 411 |
| 411 if (masksToBounds()) | 412 if (masksToBounds()) |
| 412 noteLayerPropertyChangedForSubtree(); | 413 noteLayerPropertyChangedForSubtree(); |
| 413 else | 414 else |
| 414 m_layerPropertyChanged = true; | 415 m_layerPropertyChanged = true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 440 | 441 |
| 441 void LayerImpl::setDrawsContent(bool drawsContent) | 442 void LayerImpl::setDrawsContent(bool drawsContent) |
| 442 { | 443 { |
| 443 if (m_drawsContent == drawsContent) | 444 if (m_drawsContent == drawsContent) |
| 444 return; | 445 return; |
| 445 | 446 |
| 446 m_drawsContent = drawsContent; | 447 m_drawsContent = drawsContent; |
| 447 m_layerPropertyChanged = true; | 448 m_layerPropertyChanged = true; |
| 448 } | 449 } |
| 449 | 450 |
| 450 void LayerImpl::setAnchorPoint(const FloatPoint& anchorPoint) | 451 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) |
| 451 { | 452 { |
| 452 if (m_anchorPoint == anchorPoint) | 453 if (m_anchorPoint == anchorPoint) |
| 453 return; | 454 return; |
| 454 | 455 |
| 455 m_anchorPoint = anchorPoint; | 456 m_anchorPoint = anchorPoint; |
| 456 noteLayerPropertyChangedForSubtree(); | 457 noteLayerPropertyChangedForSubtree(); |
| 457 } | 458 } |
| 458 | 459 |
| 459 void LayerImpl::setAnchorPointZ(float anchorPointZ) | 460 void LayerImpl::setAnchorPointZ(float anchorPointZ) |
| 460 { | 461 { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 529 |
| 529 m_opacity = opacity; | 530 m_opacity = opacity; |
| 530 m_layerSurfacePropertyChanged = true; | 531 m_layerSurfacePropertyChanged = true; |
| 531 } | 532 } |
| 532 | 533 |
| 533 bool LayerImpl::opacityIsAnimating() const | 534 bool LayerImpl::opacityIsAnimating() const |
| 534 { | 535 { |
| 535 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 536 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
| 536 } | 537 } |
| 537 | 538 |
| 538 void LayerImpl::setPosition(const FloatPoint& position) | 539 void LayerImpl::setPosition(const gfx::PointF& position) |
| 539 { | 540 { |
| 540 if (m_position == position) | 541 if (m_position == position) |
| 541 return; | 542 return; |
| 542 | 543 |
| 543 m_position = position; | 544 m_position = position; |
| 544 noteLayerPropertyChangedForSubtree(); | 545 noteLayerPropertyChangedForSubtree(); |
| 545 } | 546 } |
| 546 | 547 |
| 547 void LayerImpl::setPreserves3D(bool preserves3D) | 548 void LayerImpl::setPreserves3D(bool preserves3D) |
| 548 { | 549 { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 594 |
| 594 m_debugBorderWidth = debugBorderWidth; | 595 m_debugBorderWidth = debugBorderWidth; |
| 595 m_layerPropertyChanged = true; | 596 m_layerPropertyChanged = true; |
| 596 } | 597 } |
| 597 | 598 |
| 598 bool LayerImpl::hasDebugBorders() const | 599 bool LayerImpl::hasDebugBorders() const |
| 599 { | 600 { |
| 600 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; | 601 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; |
| 601 } | 602 } |
| 602 | 603 |
| 603 void LayerImpl::setContentBounds(const IntSize& contentBounds) | 604 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
| 604 { | 605 { |
| 605 if (m_contentBounds == contentBounds) | 606 if (m_contentBounds == contentBounds) |
| 606 return; | 607 return; |
| 607 | 608 |
| 608 m_contentBounds = contentBounds; | 609 m_contentBounds = contentBounds; |
| 609 m_layerPropertyChanged = true; | 610 m_layerPropertyChanged = true; |
| 610 } | 611 } |
| 611 | 612 |
| 612 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) | 613 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) |
| 613 { | 614 { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 641 if (m_doubleSided == doubleSided) | 642 if (m_doubleSided == doubleSided) |
| 642 return; | 643 return; |
| 643 | 644 |
| 644 m_doubleSided = doubleSided; | 645 m_doubleSided = doubleSided; |
| 645 noteLayerPropertyChangedForSubtree(); | 646 noteLayerPropertyChangedForSubtree(); |
| 646 } | 647 } |
| 647 | 648 |
| 648 Region LayerImpl::visibleContentOpaqueRegion() const | 649 Region LayerImpl::visibleContentOpaqueRegion() const |
| 649 { | 650 { |
| 650 if (contentsOpaque()) | 651 if (contentsOpaque()) |
| 651 return visibleContentRect(); | 652 return cc::IntRect(visibleContentRect()); |
| 652 return Region(); | 653 return Region(); |
| 653 } | 654 } |
| 654 | 655 |
| 655 void LayerImpl::didLoseContext() | 656 void LayerImpl::didLoseContext() |
| 656 { | 657 { |
| 657 } | 658 } |
| 658 | 659 |
| 659 void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) | 660 void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) |
| 660 { | 661 { |
| 661 m_maxScrollPosition = maxScrollPosition; | 662 m_maxScrollPosition = maxScrollPosition; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 685 | 686 |
| 686 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 687 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
| 687 { | 688 { |
| 688 if (!m_scrollbarAnimationController) | 689 if (!m_scrollbarAnimationController) |
| 689 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 690 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
| 690 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 691 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 691 m_scrollbarAnimationController->updateScrollOffset(this); | 692 m_scrollbarAnimationController->updateScrollOffset(this); |
| 692 } | 693 } |
| 693 | 694 |
| 694 } | 695 } |
| OLD | NEW |