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; | |
40 | |
41 namespace { | 39 namespace { |
42 | 40 |
43 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) | 41 void didVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) |
44 { | 42 { |
45 if (visible) { | 43 if (visible) { |
46 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id,
"LayerTreeHostImpl", id); | 44 TRACE_EVENT_ASYNC_BEGIN1("webkit", "LayerTreeHostImpl::setVisible", id,
"LayerTreeHostImpl", id); |
47 return; | 45 return; |
48 } | 46 } |
49 | 47 |
50 TRACE_EVENT_ASYNC_END0("webkit", "LayerTreeHostImpl::setVisible", id); | 48 TRACE_EVENT_ASYNC_END0("webkit", "LayerTreeHostImpl::setVisible", id); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 126 |
129 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { | 127 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { |
130 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); | 128 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); |
131 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch
edBounds.bottom()); | 129 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch
edBounds.bottom()); |
132 } | 130 } |
133 m_zoomedViewportOffset = pinchedBounds.OffsetFromOrigin(); | 131 m_zoomedViewportOffset = pinchedBounds.OffsetFromOrigin(); |
134 | 132 |
135 return overflow; | 133 return overflow; |
136 } | 134 } |
137 | 135 |
138 WebTransformationMatrix PinchZoomViewport::implTransform(bool pageScalePinchZoom
Enabled) const | 136 gfx::Transform PinchZoomViewport::implTransform(bool pageScalePinchZoomEnabled)
const |
139 { | 137 { |
140 WebTransformationMatrix transform; | 138 gfx::Transform transform; |
141 transform.scale(m_pageScaleDelta); | 139 transform.Scale(m_pageScaleDelta, m_pageScaleDelta); |
142 | 140 |
143 // If the pinch state is applied in the impl, then push it to the | 141 // If the pinch state is applied in the impl, then push it to the |
144 // impl transform, otherwise the scale is handled by WebCore. | 142 // impl transform, otherwise the scale is handled by WebCore. |
145 if (pageScalePinchZoomEnabled) { | 143 if (pageScalePinchZoomEnabled) { |
146 transform.scale(m_pageScaleFactor); | 144 transform.Scale(m_pageScaleFactor, m_pageScaleFactor); |
147 // The offset needs to be scaled by deviceScaleFactor as this transform | 145 // The offset needs to be scaled by deviceScaleFactor as this transform |
148 // needs to work with physical pixels. | 146 // needs to work with physical pixels. |
149 gfx::Vector2dF zoomedDeviceViewportOffset = gfx::ScaleVector2d(m_zoomedV
iewportOffset, m_deviceScaleFactor); | 147 gfx::Vector2dF zoomedDeviceViewportOffset = gfx::ScaleVector2d(m_zoomedV
iewportOffset, m_deviceScaleFactor); |
150 transform.translate(-zoomedDeviceViewportOffset.x(), -zoomedDeviceViewpo
rtOffset.y()); | 148 transform.Translate(-zoomedDeviceViewportOffset.x(), -zoomedDeviceViewpo
rtOffset.y()); |
151 } | 149 } |
152 | 150 |
153 return transform; | 151 return transform; |
154 } | 152 } |
155 | 153 |
156 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 154 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
157 public: | 155 public: |
158 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> create(LayerTreeHostIm
pl* layerTreeHostImpl, scoped_refptr<DelayBasedTimeSource> timeSource) | 156 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> create(LayerTreeHostIm
pl* layerTreeHostImpl, scoped_refptr<DelayBasedTimeSource> timeSource) |
159 { | 157 { |
160 return make_scoped_ptr(new LayerTreeHostImplTimeSourceAdapter(layerTreeH
ostImpl, timeSource)); | 158 return make_scoped_ptr(new LayerTreeHostImplTimeSourceAdapter(layerTreeH
ostImpl, timeSource)); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 targetRenderPass->shared_quad_state_list, | 439 targetRenderPass->shared_quad_state_list, |
442 rootLayer, | 440 rootLayer, |
443 occlusionTracker, | 441 occlusionTracker, |
444 rootLayer->showDebugBorders(), | 442 rootLayer->showDebugBorders(), |
445 forSurface); | 443 forSurface); |
446 | 444 |
447 // Manually create the quad state for the gutter quads, as the root layer | 445 // Manually create the quad state for the gutter quads, as the root layer |
448 // doesn't have any bounds and so can't generate this itself. | 446 // doesn't have any bounds and so can't generate this itself. |
449 // FIXME: Make the gutter quads generated by the solid color layer (make it
smarter about generating quads to fill unoccluded areas). | 447 // FIXME: Make the gutter quads generated by the solid color layer (make it
smarter about generating quads to fill unoccluded areas). |
450 | 448 |
451 DCHECK(rootLayer->screenSpaceTransform().isInvertible()); | 449 DCHECK(rootLayer->screenSpaceTransform().IsInvertible()); |
452 | 450 |
453 gfx::Rect rootTargetRect = rootLayer->renderSurface()->contentRect(); | 451 gfx::Rect rootTargetRect = rootLayer->renderSurface()->contentRect(); |
454 float opacity = 1; | 452 float opacity = 1; |
455 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS
tate::Create()); | 453 SharedQuadState* sharedQuadState = quadCuller.useSharedQuadState(SharedQuadS
tate::Create()); |
456 sharedQuadState->SetAll(rootLayer->drawTransform(), | 454 sharedQuadState->SetAll(rootLayer->drawTransform(), |
457 rootTargetRect, | 455 rootTargetRect, |
458 rootTargetRect, | 456 rootTargetRect, |
459 rootTargetRect, | 457 rootTargetRect, |
460 false, | 458 false, |
461 opacity); | 459 opacity); |
462 | 460 |
463 AppendQuadsData appendQuadsData; | 461 AppendQuadsData appendQuadsData; |
464 WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransf
orm().inverse(); | 462 gfx::Transform transformToLayerSpace = MathUtil::inverse(rootLayer->screenSp
aceTransform()); |
465 for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects
.next()) { | 463 for (Region::Iterator fillRects(fillRegion); fillRects.has_rect(); fillRects
.next()) { |
466 // The root layer transform is composed of translations and scales only, | 464 // The root layer transform is composed of translations and scales only, |
467 // no perspective, so mapping is sufficient. | 465 // no perspective, so mapping is sufficient. |
468 gfx::Rect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, fi
llRects.rect()); | 466 gfx::Rect layerRect = MathUtil::mapClippedRect(transformToLayerSpace, fi
llRects.rect()); |
469 // Skip the quad culler and just append the quads directly to avoid | 467 // Skip the quad culler and just append the quads directly to avoid |
470 // occlusion checks. | 468 // occlusion checks. |
471 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 469 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
472 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); | 470 quad->SetNew(sharedQuadState, layerRect, screenBackgroundColor); |
473 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 471 quadCuller.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
474 } | 472 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 m_numImplThreadScrolls++; | 1189 m_numImplThreadScrolls++; |
1192 return ScrollStarted; | 1190 return ScrollStarted; |
1193 } | 1191 } |
1194 return ScrollIgnored; | 1192 return ScrollIgnored; |
1195 } | 1193 } |
1196 | 1194 |
1197 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie
wportPoint, gfx::Vector2dF viewportDelta) | 1195 static gfx::Vector2dF scrollLayerWithViewportSpaceDelta(PinchZoomViewport* viewp
ort, LayerImpl& layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF vie
wportPoint, gfx::Vector2dF viewportDelta) |
1198 { | 1196 { |
1199 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 1197 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
1200 // test in the first place. | 1198 // test in the first place. |
1201 DCHECK(layerImpl.screenSpaceTransform().isInvertible()); | 1199 DCHECK(layerImpl.screenSpaceTransform().IsInvertible()); |
1202 WebTransformationMatrix inverseScreenSpaceTransform = layerImpl.screenSpaceT
ransform().inverse(); | 1200 gfx::Transform inverseScreenSpaceTransform = MathUtil::inverse(layerImpl.scr
eenSpaceTransform()); |
1203 | 1201 |
1204 gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewp
ortToScreenSpace); | 1202 gfx::PointF screenSpacePoint = gfx::ScalePoint(viewportPoint, scaleFromViewp
ortToScreenSpace); |
1205 | 1203 |
1206 gfx::Vector2dF screenSpaceDelta = viewportDelta; | 1204 gfx::Vector2dF screenSpaceDelta = viewportDelta; |
1207 screenSpaceDelta.Scale(scaleFromViewportToScreenSpace); | 1205 screenSpaceDelta.Scale(scaleFromViewportToScreenSpace); |
1208 | 1206 |
1209 // First project the scroll start and end points to local layer space to fin
d the scroll delta | 1207 // First project the scroll start and end points to local layer space to fin
d the scroll delta |
1210 // in layer coordinates. | 1208 // in layer coordinates. |
1211 bool startClipped, endClipped; | 1209 bool startClipped, endClipped; |
1212 gfx::PointF screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; | 1210 gfx::PointF screenSpaceEndPoint = screenSpacePoint + screenSpaceDelta; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 return scrollInfo.Pass(); | 1453 return scrollInfo.Pass(); |
1456 } | 1454 } |
1457 | 1455 |
1458 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); | 1456 collectScrollDeltas(scrollInfo.get(), m_rootLayerImpl.get()); |
1459 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); | 1457 scrollInfo->pageScaleDelta = m_pinchZoomViewport.pageScaleDelta(); |
1460 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); | 1458 m_pinchZoomViewport.setSentPageScaleDelta(scrollInfo->pageScaleDelta); |
1461 | 1459 |
1462 return scrollInfo.Pass(); | 1460 return scrollInfo.Pass(); |
1463 } | 1461 } |
1464 | 1462 |
1465 WebTransformationMatrix LayerTreeHostImpl::implTransform() const | 1463 gfx::Transform LayerTreeHostImpl::implTransform() const |
1466 { | 1464 { |
1467 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); | 1465 return m_pinchZoomViewport.implTransform(m_settings.pageScalePinchZoomEnable
d); |
1468 } | 1466 } |
1469 | 1467 |
1470 void LayerTreeHostImpl::setFullRootLayerDamage() | 1468 void LayerTreeHostImpl::setFullRootLayerDamage() |
1471 { | 1469 { |
1472 if (m_rootLayerImpl) { | 1470 if (m_rootLayerImpl) { |
1473 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); | 1471 RenderSurfaceImpl* renderSurface = m_rootLayerImpl->renderSurface(); |
1474 if (renderSurface) | 1472 if (renderSurface) |
1475 renderSurface->damageTracker()->forceFullDamageNextUpdate(); | 1473 renderSurface->damageTracker()->forceFullDamageNextUpdate(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1594 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
1597 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1595 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1598 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1596 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1599 m_client->setNeedsRedrawOnImplThread(); | 1597 m_client->setNeedsRedrawOnImplThread(); |
1600 | 1598 |
1601 for (size_t i = 0; i < layer->children().size(); ++i) | 1599 for (size_t i = 0; i < layer->children().size(); ++i) |
1602 animateScrollbarsRecursive(layer->children()[i], time); | 1600 animateScrollbarsRecursive(layer->children()[i], time); |
1603 } | 1601 } |
1604 | 1602 |
1605 } // namespace cc | 1603 } // namespace cc |
OLD | NEW |