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 "cc/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "cc/scrollbar_animation_controller.h" | 29 #include "cc/scrollbar_animation_controller.h" |
30 #include "cc/scrollbar_layer_impl.h" | 30 #include "cc/scrollbar_layer_impl.h" |
31 #include "cc/shared_quad_state.h" | 31 #include "cc/shared_quad_state.h" |
32 #include "cc/single_thread_proxy.h" | 32 #include "cc/single_thread_proxy.h" |
33 #include "cc/software_renderer.h" | 33 #include "cc/software_renderer.h" |
34 #include "cc/solid_color_draw_quad.h" | 34 #include "cc/solid_color_draw_quad.h" |
35 #include "cc/texture_uploader.h" | 35 #include "cc/texture_uploader.h" |
36 #include "ui/gfx/size_conversions.h" | 36 #include "ui/gfx/size_conversions.h" |
37 #include "ui/gfx/vector2d_conversions.h" | 37 #include "ui/gfx/vector2d_conversions.h" |
38 | 38 |
39 using WebKit::WebTransformationMatrix; | 39 using gfx::Transform; |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) | 43 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) |
44 { | 44 { |
45 if (visible) { | 45 if (visible) { |
46 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id,
"LayerTreeHostImpl", id); | 46 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id,
"LayerTreeHostImpl", id); |
47 return; | 47 return; |
48 } | 48 } |
49 | 49 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { | 128 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { |
129 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); | 129 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); |
130 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch
edBounds.bottom()); | 130 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch
edBounds.bottom()); |
131 } | 131 } |
132 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); | 132 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); |
133 | 133 |
134 return overflow; | 134 return overflow; |
135 } | 135 } |
136 | 136 |
137 WebTransformationMatrix PinchZoomViewport::implTransform(bool pageScalePinchZoom
Enabled) const | 137 Transform PinchZoomViewport::implTransform(bool pageScalePinchZoomEnabled) const |
138 { | 138 { |
139 WebTransformationMatrix transform; | 139 Transform transform; |
140 transform.scale(m_pageScaleDelta); | 140 transform.PreconcatScale(m_pageScaleDelta, m_pageScaleDelta); |
141 | 141 |
142 // If the pinch state is applied in the impl, then push it to the | 142 // If the pinch state is applied in the impl, then push it to the |
143 // impl transform, otherwise the scale is handled by WebCore. | 143 // impl transform, otherwise the scale is handled by WebCore. |
144 if (pageScalePinchZoomEnabled) { | 144 if (pageScalePinchZoomEnabled) { |
145 transform.scale(m_pageScaleFactor); | 145 transform.PreconcatScale(m_pageScaleFactor, m_pageScaleFactor); |
146 transform.translate(-m_pinchViewportScrollDelta.x(), | 146 transform.PreconcatTranslate(-m_pinchViewportScrollDelta.x(), |
147 -m_pinchViewportScrollDelta.y()); | 147 -m_pinchViewportScrollDelta.y()); |
148 } | 148 } |
149 | 149 |
150 return transform; | 150 return transform; |
151 } | 151 } |
152 | 152 |
153 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 153 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
154 public: | 154 public: |
155 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> create(LayerTreeHostIm
pl* layerTreeHostImpl, scoped_refptr<DelayBasedTimeSource> timeSource) | 155 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> create(LayerTreeHostIm
pl* layerTreeHostImpl, scoped_refptr<DelayBasedTimeSource> timeSource) |
156 { | 156 { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 targetRenderPass->shared_quad_state_list, | 438 targetRenderPass->shared_quad_state_list, |
439 rootLayer, | 439 rootLayer, |
440 occlusionTracker, | 440 occlusionTracker, |
441 rootLayer->showDebugBorders(), | 441 rootLayer->showDebugBorders(), |
442 forSurface); | 442 forSurface); |
443 | 443 |
444 // Manually create the quad state for the gutter quads, as the root layer | 444 // Manually create the quad state for the gutter quads, as the root layer |
445 // doesn't have any bounds and so can't generate this itself. | 445 // doesn't have any bounds and so can't generate this itself. |
446 // FIXME: Make the gutter quads generated by the solid color layer (make it
smarter about generating quads to fill unoccluded areas). | 446 // FIXME: Make the gutter quads generated by the solid color layer (make it
smarter about generating quads to fill unoccluded areas). |
447 | 447 |
448 DCHECK(rootLayer->screenSpaceTransform().isInvertible()); | 448 DCHECK(rootLayer->screenSpaceTransform().IsInvertible()); |
449 | 449 |
450 gfx::Rect rootTargetRect = rootLayer->renderSurface()->contentRect(); | 450 gfx::Rect rootTargetRect = rootLayer->renderSurface()->contentRect(); |
451 float opacity = 1; | 451 float opacity = 1; |
452 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS
tate::Create()); | 452 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS
tate::Create()); |
453 sharedQuadState->SetAll(rootLayer->drawTransform(), | 453 sharedQuadState->SetAll(rootLayer->drawTransform(), |
454 rootTargetRect, | 454 rootTargetRect, |
455 rootTargetRect, | 455 rootTargetRect, |
456 opacity); | 456 opacity); |
457 | 457 |
458 AppendQuadsData appendQuadsData; | 458 AppendQuadsData appendQuadsData; |
459 WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransf
orm().inverse(); | 459 Transform transformToLayerSpace = MathUtil::inverse(rootLayer->screenSpaceTr
ansform()); |
460 for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects
.next()) { | 460 for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects
.next()) { |
461 // The root layer transform is composed of translations and scales only, | 461 // The root layer transform is composed of translations and scales only, |
462 // no perspective, so mapping is sufficient. | 462 // no perspective, so mapping is sufficient. |
463 gfx::Rect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, fi
llRects.rect()); | 463 gfx::Rect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, fi
llRects.rect()); |
464 // Skip the quad culler and just append the quads directly to avoid | 464 // Skip the quad culler and just append the quads directly to avoid |
465 // occlusion checks. | 465 // occlusion checks. |
466 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 466 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
467 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); | 467 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); |
468 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 468 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
469 } | 469 } |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 m_numImplThreadScrolls++; | 1185 m_numImplThreadScrolls++; |
1186 return ScrollStarted; | 1186 return ScrollStarted; |
1187 } | 1187 } |
1188 return ScrollIgnored; | 1188 return ScrollIgnored; |
1189 } | 1189 } |
1190 | 1190 |
1191 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie
wportPoint, gfx::Vector2dF viewportDelta) | 1191 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie
wportPoint, gfx::Vector2dF viewportDelta) |
1192 { | 1192 { |
1193 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 1193 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
1194 // test in the first place. | 1194 // test in the first place. |
1195 DCHECK(layerImpl.screenSpaceTransform().isInvertible()); | 1195 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); |
1196 WebTransformationMatrix inverseScreenSpaceTransform = layerImpl.screenSpaceT
ransform().inverse(); | 1196 Transform inverseScreenSpaceTransform = MathUtil::inverse(layerImpl.screenSp
aceTransform()); |
1197 | 1197 |
1198 gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewp
ortToScreenSpace); | 1198 gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewp
ortToScreenSpace); |
1199 | 1199 |
1200 gfx::Vector2dF screenSpaceDelta = viewportDelta; | 1200 gfx::Vector2dF screenSpaceDelta = viewportDelta; |
1201 screenSpaceDelta.Scale(scaleFromViewportToScreenSpace); | 1201 screenSpaceDelta.Scale(scaleFromViewportToScreenSpace); |
1202 | 1202 |
1203 // First project the scroll start and end points to local layer space to fin
d the scroll delta | 1203 // First project the scroll start and end points to local layer space to fin
d the scroll delta |
1204 // in layer coordinates. | 1204 // in layer coordinates. |
1205 bool startClipped, endClipped; | 1205 bool startClipped, endClipped; |
1206 gfx::PointF screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; | 1206 gfx::PointF screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 return scrollInfo.Pass(); | 1448 return scrollInfo.Pass(); |
1449 } | 1449 } |
1450 | 1450 |
1451 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); | 1451 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); |
1452 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1452 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
1453 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); | 1453 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
1454 | 1454 |
1455 return scrollInfo.Pass(); | 1455 return scrollInfo.Pass(); |
1456 } | 1456 } |
1457 | 1457 |
1458 WebTransformationMatrix LayerTreeHostImpl::implTransform() const | 1458 Transform LayerTreeHostImpl::implTransform() const |
1459 { | 1459 { |
1460 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); | 1460 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); |
1461 } | 1461 } |
1462 | 1462 |
1463 void LayerTreeHostImpl::setFullRootLayerDamage() | 1463 void LayerTreeHostImpl::setFullRootLayerDamage() |
1464 { | 1464 { |
1465 if (m_rootLayerImpl) { | 1465 if (m_rootLayerImpl) { |
1466 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); | 1466 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); |
1467 if (renderSurface) | 1467 if (renderSurface) |
1468 renderSurface->damageTracker()->forceFullDamageNextUpdate(); | 1468 renderSurface->damageTracker()->forceFullDamageNextUpdate(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1589 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
1590 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1590 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1591 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1591 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1592 m_client->setNeedsRedrawOnImplThread(); | 1592 m_client->setNeedsRedrawOnImplThread(); |
1593 | 1593 |
1594 for (size_t i = 0; i < layer->children().size(); ++i) | 1594 for (size_t i = 0; i < layer->children().size(); ++i) |
1595 animateScrollbarsRecursive(layer->children()[i], time); | 1595 animateScrollbarsRecursive(layer->children()[i], time); |
1596 } | 1596 } |
1597 | 1597 |
1598 } // namespace cc | 1598 } // namespace cc |
OLD | NEW |