| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 DCHECK(m_betweenWillDrawAndDidDraw); | 147 DCHECK(m_betweenWillDrawAndDidDraw); |
| 146 m_betweenWillDrawAndDidDraw = false; | 148 m_betweenWillDrawAndDidDraw = false; |
| 147 #endif | 149 #endif |
| 148 } | 150 } |
| 149 | 151 |
| 150 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState*
sharedQuadState, AppendQuadsData& appendQuadsData) const | 152 void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState*
sharedQuadState, AppendQuadsData& appendQuadsData) const |
| 151 { | 153 { |
| 152 if (!hasDebugBorders()) | 154 if (!hasDebugBorders()) |
| 153 return; | 155 return; |
| 154 | 156 |
| 155 IntRect contentRect(IntPoint(), contentBounds()); | 157 gfx::Rect contentRect(gfx::Point(), contentBounds()); |
| 156 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, de
bugBorderColor(), debugBorderWidth()).PassAs<DrawQuad>(), appendQuadsData); | 158 quadList.append(DebugBorderDrawQuad::create(sharedQuadState, contentRect, de
bugBorderColor(), debugBorderWidth()).PassAs<DrawQuad>(), appendQuadsData); |
| 157 } | 159 } |
| 158 | 160 |
| 159 bool LayerImpl::hasContributingDelegatedRenderPasses() const | 161 bool LayerImpl::hasContributingDelegatedRenderPasses() const |
| 160 { | 162 { |
| 161 return false; | 163 return false; |
| 162 } | 164 } |
| 163 | 165 |
| 164 RenderPass::Id LayerImpl::firstContributingRenderPassId() const | 166 RenderPass::Id LayerImpl::firstContributingRenderPassId() const |
| 165 { | 167 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 return InputHandlerClient::ScrollOnMainThread; | 205 return InputHandlerClient::ScrollOnMainThread; |
| 204 } | 206 } |
| 205 | 207 |
| 206 if (!screenSpaceTransform().isInvertible()) { | 208 if (!screenSpaceTransform().isInvertible()) { |
| 207 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform
"); | 209 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform
"); |
| 208 return InputHandlerClient::ScrollIgnored; | 210 return InputHandlerClient::ScrollIgnored; |
| 209 } | 211 } |
| 210 | 212 |
| 211 if (!nonFastScrollableRegion().isEmpty()) { | 213 if (!nonFastScrollableRegion().isEmpty()) { |
| 212 bool clipped = false; | 214 bool clipped = false; |
| 213 FloatPoint hitTestPointInLocalSpace = MathUtil::projectPoint(screenSpace
Transform().inverse(), FloatPoint(screenSpacePoint), clipped); | 215 gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(screenSpac
eTransform().inverse(), FloatPoint(screenSpacePoint), clipped); |
| 214 if (!clipped && nonFastScrollableRegion().contains(flooredIntPoint(hitTe
stPointInLocalSpace))) { | 216 if (!clipped && nonFastScrollableRegion().contains(cc::IntPoint(gfx::ToF
looredPoint(hitTestPointInLocalSpace)))) { |
| 215 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRe
gion"); | 217 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRe
gion"); |
| 216 return InputHandlerClient::ScrollOnMainThread; | 218 return InputHandlerClient::ScrollOnMainThread; |
| 217 } | 219 } |
| 218 } | 220 } |
| 219 | 221 |
| 220 if (type == InputHandlerClient::Wheel && haveWheelEventHandlers()) { | 222 if (type == InputHandlerClient::Wheel && haveWheelEventHandlers()) { |
| 221 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers"); | 223 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers"); |
| 222 return InputHandlerClient::ScrollOnMainThread; | 224 return InputHandlerClient::ScrollOnMainThread; |
| 223 } | 225 } |
| 224 | 226 |
| 225 if (!scrollable()) { | 227 if (!scrollable()) { |
| 226 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); | 228 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); |
| 227 return InputHandlerClient::ScrollIgnored; | 229 return InputHandlerClient::ScrollIgnored; |
| 228 } | 230 } |
| 229 | 231 |
| 230 return InputHandlerClient::ScrollStarted; | 232 return InputHandlerClient::ScrollStarted; |
| 231 } | 233 } |
| 232 | 234 |
| 233 bool LayerImpl::drawCheckerboardForMissingTiles() const | 235 bool LayerImpl::drawCheckerboardForMissingTiles() const |
| 234 { | 236 { |
| 235 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea
dOfCheckerboard(); | 237 return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInstea
dOfCheckerboard(); |
| 236 } | 238 } |
| 237 | 239 |
| 238 IntRect LayerImpl::layerRectToContentRect(const FloatRect& layerRect) const | 240 gfx::Rect LayerImpl::layerRectToContentRect(const gfx::RectF& layerRect) const |
| 239 { | 241 { |
| 240 FloatRect contentRect(layerRect); | 242 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); |
| 241 contentRect.scale(contentsScaleX(), contentsScaleY()); | |
| 242 IntRect intContentRect = enclosingIntRect(contentRect); | |
| 243 // Intersect with content rect to avoid the extra pixel because for some | 243 // Intersect with content rect to avoid the extra pixel because for some |
| 244 // values x and y, ceil((x / y) * y) may be x + 1. | 244 // values x and y, ceil((x / y) * y) may be x + 1. |
| 245 intContentRect.intersect(IntRect(IntPoint(), contentBounds())); | 245 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); |
| 246 return intContentRect; | 246 return gfx::ToEnclosingRect(contentRect); |
| 247 } | 247 } |
| 248 | 248 |
| 249 std::string LayerImpl::indentString(int indent) | 249 std::string LayerImpl::indentString(int indent) |
| 250 { | 250 { |
| 251 std::string str; | 251 std::string str; |
| 252 for (int i = 0; i != indent; ++i) | 252 for (int i = 0; i != indent; ++i) |
| 253 str.append(" "); | 253 str.append(" "); |
| 254 return str; | 254 return str; |
| 255 } | 255 } |
| 256 | 256 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 const char* LayerImpl::layerTypeAsString() const | 353 const char* LayerImpl::layerTypeAsString() const |
| 354 { | 354 { |
| 355 return "Layer"; | 355 return "Layer"; |
| 356 } | 356 } |
| 357 | 357 |
| 358 void LayerImpl::resetAllChangeTrackingForSubtree() | 358 void LayerImpl::resetAllChangeTrackingForSubtree() |
| 359 { | 359 { |
| 360 m_layerPropertyChanged = false; | 360 m_layerPropertyChanged = false; |
| 361 m_layerSurfacePropertyChanged = false; | 361 m_layerSurfacePropertyChanged = false; |
| 362 | 362 |
| 363 m_updateRect = FloatRect(); | 363 m_updateRect = gfx::RectF(); |
| 364 | 364 |
| 365 if (m_renderSurface) | 365 if (m_renderSurface) |
| 366 m_renderSurface->resetPropertyChangedFlag(); | 366 m_renderSurface->resetPropertyChangedFlag(); |
| 367 | 367 |
| 368 if (m_maskLayer) | 368 if (m_maskLayer) |
| 369 m_maskLayer->resetAllChangeTrackingForSubtree(); | 369 m_maskLayer->resetAllChangeTrackingForSubtree(); |
| 370 | 370 |
| 371 if (m_replicaLayer) | 371 if (m_replicaLayer) |
| 372 m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the r
eplica mask, if it exists. | 372 m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the r
eplica mask, if it exists. |
| 373 | 373 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 398 const WebKit::WebTransformationMatrix& LayerImpl::transform() const | 398 const WebKit::WebTransformationMatrix& LayerImpl::transform() const |
| 399 { | 399 { |
| 400 return m_transform; | 400 return m_transform; |
| 401 } | 401 } |
| 402 | 402 |
| 403 void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transfo
rm) | 403 void LayerImpl::setTransformFromAnimation(const WebTransformationMatrix& transfo
rm) |
| 404 { | 404 { |
| 405 setTransform(transform); | 405 setTransform(transform); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void LayerImpl::setBounds(const IntSize& bounds) | 408 void LayerImpl::setBounds(const gfx::Size& bounds) |
| 409 { | 409 { |
| 410 if (m_bounds == bounds) | 410 if (m_bounds == bounds) |
| 411 return; | 411 return; |
| 412 | 412 |
| 413 m_bounds = bounds; | 413 m_bounds = bounds; |
| 414 | 414 |
| 415 if (masksToBounds()) | 415 if (masksToBounds()) |
| 416 noteLayerPropertyChangedForSubtree(); | 416 noteLayerPropertyChangedForSubtree(); |
| 417 else | 417 else |
| 418 m_layerPropertyChanged = true; | 418 m_layerPropertyChanged = true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 444 | 444 |
| 445 void LayerImpl::setDrawsContent(bool drawsContent) | 445 void LayerImpl::setDrawsContent(bool drawsContent) |
| 446 { | 446 { |
| 447 if (m_drawsContent == drawsContent) | 447 if (m_drawsContent == drawsContent) |
| 448 return; | 448 return; |
| 449 | 449 |
| 450 m_drawsContent = drawsContent; | 450 m_drawsContent = drawsContent; |
| 451 m_layerPropertyChanged = true; | 451 m_layerPropertyChanged = true; |
| 452 } | 452 } |
| 453 | 453 |
| 454 void LayerImpl::setAnchorPoint(const FloatPoint& anchorPoint) | 454 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) |
| 455 { | 455 { |
| 456 if (m_anchorPoint == anchorPoint) | 456 if (m_anchorPoint == anchorPoint) |
| 457 return; | 457 return; |
| 458 | 458 |
| 459 m_anchorPoint = anchorPoint; | 459 m_anchorPoint = anchorPoint; |
| 460 noteLayerPropertyChangedForSubtree(); | 460 noteLayerPropertyChangedForSubtree(); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void LayerImpl::setAnchorPointZ(float anchorPointZ) | 463 void LayerImpl::setAnchorPointZ(float anchorPointZ) |
| 464 { | 464 { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 m_opacity = opacity; | 533 m_opacity = opacity; |
| 534 m_layerSurfacePropertyChanged = true; | 534 m_layerSurfacePropertyChanged = true; |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool LayerImpl::opacityIsAnimating() const | 537 bool LayerImpl::opacityIsAnimating() const |
| 538 { | 538 { |
| 539 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 539 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void LayerImpl::setPosition(const FloatPoint& position) | 542 void LayerImpl::setPosition(const gfx::PointF& position) |
| 543 { | 543 { |
| 544 if (m_position == position) | 544 if (m_position == position) |
| 545 return; | 545 return; |
| 546 | 546 |
| 547 m_position = position; | 547 m_position = position; |
| 548 noteLayerPropertyChangedForSubtree(); | 548 noteLayerPropertyChangedForSubtree(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void LayerImpl::setPreserves3D(bool preserves3D) | 551 void LayerImpl::setPreserves3D(bool preserves3D) |
| 552 { | 552 { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 597 |
| 598 m_debugBorderWidth = debugBorderWidth; | 598 m_debugBorderWidth = debugBorderWidth; |
| 599 m_layerPropertyChanged = true; | 599 m_layerPropertyChanged = true; |
| 600 } | 600 } |
| 601 | 601 |
| 602 bool LayerImpl::hasDebugBorders() const | 602 bool LayerImpl::hasDebugBorders() const |
| 603 { | 603 { |
| 604 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; | 604 return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; |
| 605 } | 605 } |
| 606 | 606 |
| 607 void LayerImpl::setContentBounds(const IntSize& contentBounds) | 607 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
| 608 { | 608 { |
| 609 if (m_contentBounds == contentBounds) | 609 if (m_contentBounds == contentBounds) |
| 610 return; | 610 return; |
| 611 | 611 |
| 612 m_contentBounds = contentBounds; | 612 m_contentBounds = contentBounds; |
| 613 m_layerPropertyChanged = true; | 613 m_layerPropertyChanged = true; |
| 614 } | 614 } |
| 615 | 615 |
| 616 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) | 616 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) |
| 617 { | 617 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 if (m_doubleSided == doubleSided) | 655 if (m_doubleSided == doubleSided) |
| 656 return; | 656 return; |
| 657 | 657 |
| 658 m_doubleSided = doubleSided; | 658 m_doubleSided = doubleSided; |
| 659 noteLayerPropertyChangedForSubtree(); | 659 noteLayerPropertyChangedForSubtree(); |
| 660 } | 660 } |
| 661 | 661 |
| 662 Region LayerImpl::visibleContentOpaqueRegion() const | 662 Region LayerImpl::visibleContentOpaqueRegion() const |
| 663 { | 663 { |
| 664 if (contentsOpaque()) | 664 if (contentsOpaque()) |
| 665 return visibleContentRect(); | 665 return cc::IntRect(visibleContentRect()); |
| 666 return Region(); | 666 return Region(); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void LayerImpl::didLoseContext() | 669 void LayerImpl::didLoseContext() |
| 670 { | 670 { |
| 671 } | 671 } |
| 672 | 672 |
| 673 void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) | 673 void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) |
| 674 { | 674 { |
| 675 m_maxScrollPosition = maxScrollPosition; | 675 m_maxScrollPosition = maxScrollPosition; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 699 | 699 |
| 700 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 700 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
| 701 { | 701 { |
| 702 if (!m_scrollbarAnimationController) | 702 if (!m_scrollbarAnimationController) |
| 703 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 703 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
| 704 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 704 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 705 m_scrollbarAnimationController->updateScrollOffset(this); | 705 m_scrollbarAnimationController->updateScrollOffset(this); |
| 706 } | 706 } |
| 707 | 707 |
| 708 } | 708 } |
| OLD | NEW |