[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | d50c686 | 2012-10-23 02:08:31 | [diff] [blame] | 5 | #include "cc/layer_impl.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 6 | |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 7 | #include "base/debug/trace_event.h" |
| 8 | #include "base/stringprintf.h" |
[email protected] | 4a23c374c | 2012-12-08 08:38:55 | [diff] [blame] | 9 | #include "base/values.h" |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 10 | #include "cc/animation_registrar.h" |
[email protected] | aa0a9d3 | 2012-10-24 01:58:10 | [diff] [blame] | 11 | #include "cc/debug_border_draw_quad.h" |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 12 | #include "cc/debug_colors.h" |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 13 | #include "cc/layer_tree_debug_state.h" |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 14 | #include "cc/layer_tree_impl.h" |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 15 | #include "cc/layer_tree_settings.h" |
[email protected] | 55a124d0 | 2012-10-22 03:07:13 | [diff] [blame] | 16 | #include "cc/math_util.h" |
| 17 | #include "cc/proxy.h" |
| 18 | #include "cc/quad_sink.h" |
[email protected] | c4040a52 | 2012-10-21 15:01:40 | [diff] [blame] | 19 | #include "cc/scrollbar_animation_controller.h" |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 20 | #include "ui/gfx/point_conversions.h" |
| 21 | #include "ui/gfx/rect_conversions.h" |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 22 | |
[email protected] | 9c88e56 | 2012-09-14 22:21:30 | [diff] [blame] | 23 | namespace cc { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 24 | |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 25 | LayerImpl::LayerImpl(LayerTreeImpl* treeImpl, int id) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 26 | : m_parent(0) |
| 27 | , m_maskLayerId(-1) |
| 28 | , m_replicaLayerId(-1) |
| 29 | , m_layerId(id) |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 30 | , m_layerTreeImpl(treeImpl) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 31 | , m_anchorPoint(0.5, 0.5) |
| 32 | , m_anchorPointZ(0) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 33 | , m_scrollable(false) |
| 34 | , m_shouldScrollOnMainThread(false) |
| 35 | , m_haveWheelEventHandlers(false) |
| 36 | , m_backgroundColor(0) |
| 37 | , m_doubleSided(true) |
| 38 | , m_layerPropertyChanged(false) |
| 39 | , m_layerSurfacePropertyChanged(false) |
| 40 | , m_masksToBounds(false) |
[email protected] | 048634c | 2012-10-02 22:33:14 | [diff] [blame] | 41 | , m_contentsOpaque(false) |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 42 | , m_opacity(1.0) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 43 | , m_preserves3D(false) |
| 44 | , m_useParentBackfaceVisibility(false) |
| 45 | , m_drawCheckerboardForMissingTiles(false) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 46 | , m_drawsContent(false) |
| 47 | , m_forceRenderSurface(false) |
| 48 | , m_isContainerForFixedPositionLayers(false) |
| 49 | , m_fixedToContainerLayer(false) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 50 | , m_drawDepth(0) |
[email protected] | e7f87cfb | 2012-10-17 01:25:18 | [diff] [blame] | 51 | #ifndef NDEBUG |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 52 | , m_betweenWillDrawAndDidDraw(false) |
| 53 | #endif |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 54 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 55 | DCHECK(m_layerId > 0); |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 56 | DCHECK(m_layerTreeImpl); |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 57 | m_layerTreeImpl->RegisterLayer(this); |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 58 | AnimationRegistrar* registrar = m_layerTreeImpl->animationRegistrar(); |
| 59 | m_layerAnimationController = registrar->GetAnimationControllerForId(m_layerId); |
| 60 | m_layerAnimationController->addObserver(this); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 61 | } |
| 62 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 63 | LayerImpl::~LayerImpl() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 64 | { |
[email protected] | e7f87cfb | 2012-10-17 01:25:18 | [diff] [blame] | 65 | #ifndef NDEBUG |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 66 | DCHECK(!m_betweenWillDrawAndDidDraw); |
[email protected] | e7f87cfb | 2012-10-17 01:25:18 | [diff] [blame] | 67 | #endif |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 68 | m_layerTreeImpl->UnregisterLayer(this); |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 69 | m_layerAnimationController->removeObserver(this); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 70 | } |
| 71 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 72 | void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 73 | { |
| 74 | child->setParent(this); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 75 | DCHECK_EQ(layerTreeImpl(), child->layerTreeImpl()); |
[email protected] | e0bd43a | 2012-10-12 16:54:21 | [diff] [blame] | 76 | m_children.append(child.Pass()); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 77 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 78 | } |
| 79 | |
[email protected] | 30461f1 | 2012-12-10 01:30:20 | [diff] [blame] | 80 | scoped_ptr<LayerImpl> LayerImpl::removeChild(LayerImpl* child) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 81 | { |
[email protected] | 30461f1 | 2012-12-10 01:30:20 | [diff] [blame] | 82 | for (size_t i = 0; i < m_children.size(); ++i) { |
| 83 | if (m_children[i] == child) { |
| 84 | scoped_ptr<LayerImpl> ret = m_children.take(i); |
| 85 | m_children.remove(i); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 86 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 30461f1 | 2012-12-10 01:30:20 | [diff] [blame] | 87 | return ret.Pass(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 88 | } |
| 89 | } |
[email protected] | 30461f1 | 2012-12-10 01:30:20 | [diff] [blame] | 90 | return scoped_ptr<LayerImpl>(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 91 | } |
| 92 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 93 | void LayerImpl::removeAllChildren() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 94 | { |
[email protected] | 30461f1 | 2012-12-10 01:30:20 | [diff] [blame] | 95 | m_children.clear(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 96 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 97 | } |
| 98 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 99 | void LayerImpl::clearChildList() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 100 | { |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 101 | if (m_children.isEmpty()) |
| 102 | return; |
| 103 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 104 | m_children.clear(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 105 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 106 | } |
| 107 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 108 | void LayerImpl::createRenderSurface() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 109 | { |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 110 | DCHECK(!m_drawProperties.render_surface); |
| 111 | m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this)); |
| 112 | m_drawProperties.render_target = this; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 113 | } |
| 114 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 115 | scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 116 | { |
[email protected] | cb7af74 | 2012-11-21 04:02:24 | [diff] [blame] | 117 | scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 118 | state->SetAll(m_drawProperties.target_space_transform, |
| 119 | m_drawProperties.visible_content_rect, |
| 120 | m_drawProperties.drawable_content_rect, |
| 121 | m_drawProperties.clip_rect, |
| 122 | m_drawProperties.is_clipped, |
| 123 | m_drawProperties.opacity); |
[email protected] | cb7af74 | 2012-11-21 04:02:24 | [diff] [blame] | 124 | return state.Pass(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 125 | } |
| 126 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 127 | void LayerImpl::willDraw(ResourceProvider*) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 128 | { |
[email protected] | e7f87cfb | 2012-10-17 01:25:18 | [diff] [blame] | 129 | #ifndef NDEBUG |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 130 | // willDraw/didDraw must be matched. |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 131 | DCHECK(!m_betweenWillDrawAndDidDraw); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 132 | m_betweenWillDrawAndDidDraw = true; |
| 133 | #endif |
| 134 | } |
| 135 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 136 | void LayerImpl::didDraw(ResourceProvider*) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 137 | { |
[email protected] | e7f87cfb | 2012-10-17 01:25:18 | [diff] [blame] | 138 | #ifndef NDEBUG |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 139 | DCHECK(m_betweenWillDrawAndDidDraw); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 140 | m_betweenWillDrawAndDidDraw = false; |
| 141 | #endif |
| 142 | } |
| 143 | |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 144 | bool LayerImpl::showDebugBorders() const |
| 145 | { |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 146 | return layerTreeImpl()->debug_state().showDebugBorders; |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | void LayerImpl::getDebugBorderProperties(SkColor* color, float* width) const |
| 150 | { |
| 151 | if (m_drawsContent) { |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 152 | *color = DebugColors::ContentLayerBorderColor(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 153 | *width = DebugColors::ContentLayerBorderWidth(layerTreeImpl()); |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 154 | return; |
| 155 | } |
| 156 | |
| 157 | if (m_masksToBounds) { |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 158 | *color = DebugColors::MaskingLayerBorderColor(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 159 | *width = DebugColors::MaskingLayerBorderWidth(layerTreeImpl()); |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 160 | return; |
| 161 | } |
| 162 | |
[email protected] | 08d06fa | 2012-11-16 00:06:38 | [diff] [blame] | 163 | *color = DebugColors::ContainerLayerBorderColor(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 164 | *width = DebugColors::ContainerLayerBorderWidth(layerTreeImpl()); |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 165 | } |
| 166 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 167 | void LayerImpl::appendDebugBorderQuad(QuadSink& quadList, const SharedQuadState* sharedQuadState, AppendQuadsData& appendQuadsData) const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 168 | { |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 169 | if (!showDebugBorders()) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 170 | return; |
| 171 | |
[email protected] | 3dce3723 | 2012-11-15 01:47:44 | [diff] [blame] | 172 | SkColor color; |
| 173 | float width; |
| 174 | getDebugBorderProperties(&color, &width); |
| 175 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 176 | gfx::Rect contentRect(gfx::Point(), contentBounds()); |
[email protected] | c22418b | 2012-11-20 23:06:26 | [diff] [blame] | 177 | scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = DebugBorderDrawQuad::Create(); |
| 178 | debugBorderQuad->SetNew(sharedQuadState, contentRect, color, width); |
| 179 | quadList.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 180 | } |
| 181 | |
[email protected] | b5b1fce | 2012-12-12 22:49:36 | [diff] [blame] | 182 | bool LayerImpl::hasDelegatedContent() const |
| 183 | { |
| 184 | return false; |
| 185 | } |
| 186 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 187 | bool LayerImpl::hasContributingDelegatedRenderPasses() const |
[email protected] | 7648159 | 2012-09-21 16:47:06 | [diff] [blame] | 188 | { |
| 189 | return false; |
| 190 | } |
| 191 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 192 | RenderPass::Id LayerImpl::firstContributingRenderPassId() const |
[email protected] | 7648159 | 2012-09-21 16:47:06 | [diff] [blame] | 193 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 194 | return RenderPass::Id(0, 0); |
[email protected] | 7648159 | 2012-09-21 16:47:06 | [diff] [blame] | 195 | } |
| 196 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 197 | RenderPass::Id LayerImpl::nextContributingRenderPassId(RenderPass::Id) const |
[email protected] | 7648159 | 2012-09-21 16:47:06 | [diff] [blame] | 198 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 199 | return RenderPass::Id(0, 0); |
[email protected] | 7648159 | 2012-09-21 16:47:06 | [diff] [blame] | 200 | } |
| 201 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 202 | ResourceProvider::ResourceId LayerImpl::contentsResourceId() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 203 | { |
[email protected] | 1d99317 | 2012-10-18 18:15:04 | [diff] [blame] | 204 | NOTREACHED(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 205 | return 0; |
| 206 | } |
| 207 | |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame^] | 208 | void LayerImpl::setSentScrollDelta(const gfx::Vector2d& sentScrollDelta) |
| 209 | { |
| 210 | m_sentScrollDelta = sentScrollDelta; |
| 211 | if (layerTreeImpl()->IsActiveTree()) |
| 212 | { |
| 213 | LayerImpl* pending_twin = layerTreeImpl()->FindPendingTreeLayerById(id()); |
| 214 | if (pending_twin) |
| 215 | pending_twin->setSentScrollDelta(sentScrollDelta); |
| 216 | } |
| 217 | } |
| 218 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 219 | gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 220 | { |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 221 | gfx::Vector2dF minDelta = -m_scrollOffset; |
| 222 | gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 223 | // Clamp newDelta so that position + delta stays within scroll bounds. |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 224 | gfx::Vector2dF newDelta = (m_scrollDelta + scroll); |
[email protected] | fe07b64 | 2012-11-10 00:07:59 | [diff] [blame] | 225 | newDelta.ClampToMin(minDelta); |
| 226 | newDelta.ClampToMax(maxDelta); |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 227 | gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 228 | |
| 229 | if (m_scrollDelta == newDelta) |
[email protected] | 1c0c9bc | 2012-10-08 22:41:48 | [diff] [blame] | 230 | return unscrolled; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 231 | |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame^] | 232 | if (layerTreeImpl()->IsActiveTree()) |
| 233 | { |
| 234 | LayerImpl* pending_twin = layerTreeImpl()->FindPendingTreeLayerById(id()); |
| 235 | if (pending_twin) { |
| 236 | // Don't send the full scroll to the new layer, as if it is larger |
| 237 | // then it may cause a jump during tree activation. Instead, |
| 238 | // scroll it by the clamped amount that this layer scrolled. |
| 239 | pending_twin->scrollBy(newDelta - m_scrollDelta); |
| 240 | } |
| 241 | } |
| 242 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 243 | m_scrollDelta = newDelta; |
| 244 | if (m_scrollbarAnimationController) |
| 245 | m_scrollbarAnimationController->updateScrollOffset(this); |
| 246 | noteLayerPropertyChangedForSubtree(); |
[email protected] | 1c0c9bc | 2012-10-08 22:41:48 | [diff] [blame] | 247 | |
| 248 | return unscrolled; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 249 | } |
| 250 | |
[email protected] | d455d55 | 2012-11-02 00:19:06 | [diff] [blame] | 251 | InputHandlerClient::ScrollStatus LayerImpl::tryScroll(const gfx::PointF& screenSpacePoint, InputHandlerClient::ScrollInputType type) const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 252 | { |
| 253 | if (shouldScrollOnMainThread()) { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 254 | TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed shouldScrollOnMainThread"); |
| 255 | return InputHandlerClient::ScrollOnMainThread; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 256 | } |
| 257 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 258 | if (!screenSpaceTransform().IsInvertible()) { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 259 | TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored nonInvertibleTransform"); |
| 260 | return InputHandlerClient::ScrollIgnored; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 261 | } |
| 262 | |
[email protected] | d0f9836 | 2012-11-01 23:02:38 | [diff] [blame] | 263 | if (!nonFastScrollableRegion().IsEmpty()) { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 264 | bool clipped = false; |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 265 | gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(MathUtil::inverse(screenSpaceTransform()), screenSpacePoint, clipped); |
[email protected] | faf5635 | 2012-11-09 21:44:13 | [diff] [blame] | 266 | gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / contentsScaleX(), 1 / contentsScaleY()); |
[email protected] | a90aa70 | 2012-11-07 04:48:24 | [diff] [blame] | 267 | if (!clipped && nonFastScrollableRegion().Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace))) { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 268 | TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRegion"); |
| 269 | return InputHandlerClient::ScrollOnMainThread; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 270 | } |
| 271 | } |
| 272 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 273 | if (type == InputHandlerClient::Wheel && haveWheelEventHandlers()) { |
| 274 | TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed wheelEventHandlers"); |
| 275 | return InputHandlerClient::ScrollOnMainThread; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | if (!scrollable()) { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 279 | TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); |
| 280 | return InputHandlerClient::ScrollIgnored; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 281 | } |
| 282 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 283 | return InputHandlerClient::ScrollStarted; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 284 | } |
| 285 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 286 | bool LayerImpl::drawCheckerboardForMissingTiles() const |
[email protected] | 15dabb7 | 2012-10-04 20:07:29 | [diff] [blame] | 287 | { |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 288 | return m_drawCheckerboardForMissingTiles && !layerTreeImpl()->settings().backgroundColorInsteadOfCheckerboard; |
[email protected] | 15dabb7 | 2012-10-04 20:07:29 | [diff] [blame] | 289 | } |
| 290 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 291 | gfx::Rect LayerImpl::layerRectToContentRect(const gfx::RectF& layerRect) const |
[email protected] | e1324f25 | 2012-09-24 21:39:15 | [diff] [blame] | 292 | { |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 293 | gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), contentsScaleY()); |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 294 | // Intersect with content rect to avoid the extra pixel because for some |
| 295 | // values x and y, ceil((x / y) * y) may be x + 1. |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 296 | contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); |
| 297 | return gfx::ToEnclosingRect(contentRect); |
[email protected] | e1324f25 | 2012-09-24 21:39:15 | [diff] [blame] | 298 | } |
| 299 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 300 | std::string LayerImpl::indentString(int indent) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 301 | { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 302 | std::string str; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 303 | for (int i = 0; i != indent; ++i) |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 304 | str.append(" "); |
| 305 | return str; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 306 | } |
| 307 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 308 | void LayerImpl::dumpLayerProperties(std::string* str, int indent) const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 309 | { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 310 | std::string indentStr = indentString(indent); |
| 311 | str->append(indentStr); |
| 312 | base::StringAppendF(str, "layer ID: %d\n", m_layerId); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 313 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 314 | str->append(indentStr); |
| 315 | base::StringAppendF(str, "bounds: %d, %d\n", bounds().width(), bounds().height()); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 316 | |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 317 | if (m_drawProperties.render_target) { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 318 | str->append(indentStr); |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 319 | base::StringAppendF(str, "renderTarget: %d\n", m_drawProperties.render_target->m_layerId); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 320 | } |
| 321 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 322 | str->append(indentStr); |
[email protected] | 9a571043 | 2012-11-09 20:52:35 | [diff] [blame] | 323 | base::StringAppendF(str, "position: %f, %f\n", m_position.x(), m_position.y()); |
| 324 | |
| 325 | str->append(indentStr); |
| 326 | base::StringAppendF(str, "contentsOpaque: %d\n", m_contentsOpaque); |
| 327 | |
| 328 | str->append(indentStr); |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 329 | const gfx::Transform& transform = m_drawProperties.target_space_transform; |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 330 | base::StringAppendF(str, "drawTransform: %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f // %f, %f, %f, %f\n", |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 331 | transform.matrix().getDouble(0, 0), transform.matrix().getDouble(0, 1), transform.matrix().getDouble(0, 2), transform.matrix().getDouble(0, 3), |
| 332 | transform.matrix().getDouble(1, 0), transform.matrix().getDouble(1, 1), transform.matrix().getDouble(1, 2), transform.matrix().getDouble(1, 3), |
| 333 | transform.matrix().getDouble(2, 0), transform.matrix().getDouble(2, 1), transform.matrix().getDouble(2, 2), transform.matrix().getDouble(2, 3), |
| 334 | transform.matrix().getDouble(3, 0), transform.matrix().getDouble(3, 1), transform.matrix().getDouble(3, 2), transform.matrix().getDouble(3, 3)); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 335 | |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 336 | str->append(indentStr); |
| 337 | base::StringAppendF(str, "drawsContent: %s\n", m_drawsContent ? "yes" : "no"); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 338 | } |
| 339 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 340 | std::string LayerImpl::layerTreeAsText() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 341 | { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 342 | std::string str; |
| 343 | dumpLayer(&str, 0); |
| 344 | return str; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 345 | } |
| 346 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 347 | void LayerImpl::dumpLayer(std::string* str, int indent) const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 348 | { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 349 | str->append(indentString(indent)); |
| 350 | base::StringAppendF(str, "%s(%s)\n", layerTypeAsString(), m_debugName.data()); |
| 351 | dumpLayerProperties(str, indent+2); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 352 | if (m_replicaLayer) { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 353 | str->append(indentString(indent+2)); |
| 354 | str->append("Replica:\n"); |
| 355 | m_replicaLayer->dumpLayer(str, indent+3); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 356 | } |
| 357 | if (m_maskLayer) { |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 358 | str->append(indentString(indent+2)); |
| 359 | str->append("Mask:\n"); |
| 360 | m_maskLayer->dumpLayer(str, indent+3); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 361 | } |
| 362 | for (size_t i = 0; i < m_children.size(); ++i) |
[email protected] | 515e8d23 | 2012-09-10 19:15:27 | [diff] [blame] | 363 | m_children[i]->dumpLayer(str, indent+1); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 364 | } |
| 365 | |
[email protected] | 4a23c374c | 2012-12-08 08:38:55 | [diff] [blame] | 366 | base::DictionaryValue* LayerImpl::layerTreeAsJson() const |
| 367 | { |
| 368 | base::ListValue* list; |
| 369 | base::DictionaryValue* result = new base::DictionaryValue; |
| 370 | result->SetString("LayerType", layerTypeAsString()); |
| 371 | |
| 372 | list = new base::ListValue; |
| 373 | list->AppendInteger(bounds().width()); |
| 374 | list->AppendInteger(bounds().height()); |
| 375 | result->Set("Bounds", list); |
| 376 | |
| 377 | list = new base::ListValue; |
| 378 | list->AppendDouble(m_position.x()); |
| 379 | list->AppendDouble(m_position.y()); |
| 380 | result->Set("Position", list); |
| 381 | |
| 382 | const gfx::Transform& gfxTransform = m_drawProperties.target_space_transform; |
| 383 | double transform[16]; |
| 384 | gfxTransform.matrix().asColMajord(transform); |
| 385 | list = new base::ListValue; |
| 386 | for (int i = 0; i < 16; ++i) |
| 387 | list->AppendDouble(transform[i]); |
| 388 | result->Set("DrawTransform", list); |
| 389 | |
| 390 | result->SetBoolean("DrawsContent", m_drawsContent); |
| 391 | result->SetDouble("Opacity", opacity()); |
| 392 | |
| 393 | list = new base::ListValue; |
| 394 | for (size_t i = 0; i < m_children.size(); ++i) |
| 395 | list->Append(m_children[i]->layerTreeAsJson()); |
| 396 | result->Set("Children", list); |
| 397 | |
| 398 | return result; |
| 399 | } |
| 400 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 401 | void LayerImpl::setStackingOrderChanged(bool stackingOrderChanged) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 402 | { |
| 403 | // We don't need to store this flag; we only need to track that the change occurred. |
| 404 | if (stackingOrderChanged) |
| 405 | noteLayerPropertyChangedForSubtree(); |
| 406 | } |
| 407 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 408 | bool LayerImpl::layerSurfacePropertyChanged() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 409 | { |
| 410 | if (m_layerSurfacePropertyChanged) |
| 411 | return true; |
| 412 | |
| 413 | // If this layer's surface property hasn't changed, we want to see if |
| 414 | // some layer above us has changed this property. This is done for the |
| 415 | // case when such parent layer does not draw content, and therefore will |
| 416 | // not be traversed by the damage tracker. We need to make sure that |
| 417 | // property change on such layer will be caught by its descendants. |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 418 | LayerImpl* current = this->m_parent; |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 419 | while (current && !current->m_drawProperties.render_surface) { |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 420 | if (current->m_layerSurfacePropertyChanged) |
| 421 | return true; |
| 422 | current = current->m_parent; |
| 423 | } |
| 424 | |
| 425 | return false; |
| 426 | } |
| 427 | |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 428 | void LayerImpl::noteLayerSurfacePropertyChanged() |
| 429 | { |
| 430 | m_layerSurfacePropertyChanged = true; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 431 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | void LayerImpl::noteLayerPropertyChanged() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 435 | { |
| 436 | m_layerPropertyChanged = true; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 437 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | void LayerImpl::noteLayerPropertyChangedForSubtree() |
| 441 | { |
| 442 | noteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 443 | noteLayerPropertyChangedForDescendants(); |
| 444 | } |
| 445 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 446 | void LayerImpl::noteLayerPropertyChangedForDescendants() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 447 | { |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 448 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 449 | for (size_t i = 0; i < m_children.size(); ++i) |
| 450 | m_children[i]->noteLayerPropertyChangedForSubtree(); |
| 451 | } |
| 452 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 453 | const char* LayerImpl::layerTypeAsString() const |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 454 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 455 | return "Layer"; |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 456 | } |
| 457 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 458 | void LayerImpl::resetAllChangeTrackingForSubtree() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 459 | { |
| 460 | m_layerPropertyChanged = false; |
| 461 | m_layerSurfacePropertyChanged = false; |
| 462 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 463 | m_updateRect = gfx::RectF(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 464 | |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 465 | if (m_drawProperties.render_surface) |
| 466 | m_drawProperties.render_surface->resetPropertyChangedFlag(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 467 | |
| 468 | if (m_maskLayer) |
| 469 | m_maskLayer->resetAllChangeTrackingForSubtree(); |
| 470 | |
| 471 | if (m_replicaLayer) |
| 472 | m_replicaLayer->resetAllChangeTrackingForSubtree(); // also resets the replica mask, if it exists. |
| 473 | |
| 474 | for (size_t i = 0; i < m_children.size(); ++i) |
| 475 | m_children[i]->resetAllChangeTrackingForSubtree(); |
| 476 | } |
| 477 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 478 | bool LayerImpl::layerIsAlwaysDamaged() const |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 479 | { |
| 480 | return false; |
| 481 | } |
| 482 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 483 | int LayerImpl::id() const |
[email protected] | 49306751 | 2012-09-19 23:34:10 | [diff] [blame] | 484 | { |
| 485 | return m_layerId; |
| 486 | } |
| 487 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 488 | void LayerImpl::OnOpacityAnimated(float opacity) |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 489 | { |
| 490 | setOpacity(opacity); |
| 491 | } |
| 492 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 493 | void LayerImpl::OnTransformAnimated(const gfx::Transform& transform) |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 494 | { |
| 495 | setTransform(transform); |
| 496 | } |
| 497 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 498 | void LayerImpl::setBounds(const gfx::Size& bounds) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 499 | { |
| 500 | if (m_bounds == bounds) |
| 501 | return; |
| 502 | |
| 503 | m_bounds = bounds; |
| 504 | |
| 505 | if (masksToBounds()) |
| 506 | noteLayerPropertyChangedForSubtree(); |
| 507 | else |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 508 | noteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 509 | } |
| 510 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 511 | void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 512 | { |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 513 | int newLayerId = maskLayer ? maskLayer->id() : -1; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 514 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 515 | if (maskLayer) { |
| 516 | DCHECK_EQ(layerTreeImpl(), maskLayer->layerTreeImpl()); |
| 517 | DCHECK_NE(newLayerId, m_maskLayerId); |
| 518 | } else if (newLayerId == m_maskLayerId) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 519 | return; |
| 520 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 521 | m_maskLayer = maskLayer.Pass(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 522 | m_maskLayerId = newLayerId; |
| 523 | noteLayerPropertyChangedForSubtree(); |
| 524 | } |
| 525 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 526 | scoped_ptr<LayerImpl> LayerImpl::takeMaskLayer() |
| 527 | { |
| 528 | m_maskLayerId = -1; |
| 529 | return m_maskLayer.Pass(); |
| 530 | } |
| 531 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 532 | void LayerImpl::setReplicaLayer(scoped_ptr<LayerImpl> replicaLayer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 533 | { |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 534 | int newLayerId = replicaLayer ? replicaLayer->id() : -1; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 535 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 536 | if (replicaLayer) { |
| 537 | DCHECK_EQ(layerTreeImpl(), replicaLayer->layerTreeImpl()); |
| 538 | DCHECK_NE(newLayerId, m_replicaLayerId); |
| 539 | } else if (newLayerId == m_replicaLayerId) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 540 | return; |
| 541 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 542 | m_replicaLayer = replicaLayer.Pass(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 543 | m_replicaLayerId = newLayerId; |
| 544 | noteLayerPropertyChangedForSubtree(); |
| 545 | } |
| 546 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 547 | scoped_ptr<LayerImpl> LayerImpl::takeReplicaLayer() |
| 548 | { |
| 549 | m_replicaLayerId = -1; |
| 550 | return m_replicaLayer.Pass(); |
| 551 | } |
| 552 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 553 | void LayerImpl::setDrawsContent(bool drawsContent) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 554 | { |
| 555 | if (m_drawsContent == drawsContent) |
| 556 | return; |
| 557 | |
| 558 | m_drawsContent = drawsContent; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 559 | noteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 560 | } |
| 561 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 562 | void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 563 | { |
| 564 | if (m_anchorPoint == anchorPoint) |
| 565 | return; |
| 566 | |
| 567 | m_anchorPoint = anchorPoint; |
| 568 | noteLayerPropertyChangedForSubtree(); |
| 569 | } |
| 570 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 571 | void LayerImpl::setAnchorPointZ(float anchorPointZ) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 572 | { |
| 573 | if (m_anchorPointZ == anchorPointZ) |
| 574 | return; |
| 575 | |
| 576 | m_anchorPointZ = anchorPointZ; |
| 577 | noteLayerPropertyChangedForSubtree(); |
| 578 | } |
| 579 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 580 | void LayerImpl::setBackgroundColor(SkColor backgroundColor) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 581 | { |
| 582 | if (m_backgroundColor == backgroundColor) |
| 583 | return; |
| 584 | |
| 585 | m_backgroundColor = backgroundColor; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 586 | noteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 587 | } |
| 588 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 589 | void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 590 | { |
| 591 | if (m_filters == filters) |
| 592 | return; |
| 593 | |
[email protected] | 589029c | 2012-10-23 18:32:54 | [diff] [blame] | 594 | DCHECK(!m_filter); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 595 | m_filters = filters; |
| 596 | noteLayerPropertyChangedForSubtree(); |
| 597 | } |
| 598 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 599 | void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgroundFilters) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 600 | { |
| 601 | if (m_backgroundFilters == backgroundFilters) |
| 602 | return; |
| 603 | |
| 604 | m_backgroundFilters = backgroundFilters; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 605 | noteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 606 | } |
| 607 | |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 608 | void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter) |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 609 | { |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 610 | if (m_filter.get() == filter.get()) |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 611 | return; |
| 612 | |
[email protected] | 589029c | 2012-10-23 18:32:54 | [diff] [blame] | 613 | DCHECK(m_filters.isEmpty()); |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 614 | m_filter = filter; |
[email protected] | 4000abf | 2012-10-23 04:45:45 | [diff] [blame] | 615 | noteLayerPropertyChangedForSubtree(); |
| 616 | } |
| 617 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 618 | void LayerImpl::setMasksToBounds(bool masksToBounds) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 619 | { |
| 620 | if (m_masksToBounds == masksToBounds) |
| 621 | return; |
| 622 | |
| 623 | m_masksToBounds = masksToBounds; |
| 624 | noteLayerPropertyChangedForSubtree(); |
| 625 | } |
| 626 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 627 | void LayerImpl::setContentsOpaque(bool opaque) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 628 | { |
[email protected] | 048634c | 2012-10-02 22:33:14 | [diff] [blame] | 629 | if (m_contentsOpaque == opaque) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 630 | return; |
| 631 | |
[email protected] | 048634c | 2012-10-02 22:33:14 | [diff] [blame] | 632 | m_contentsOpaque = opaque; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 633 | noteLayerPropertyChangedForSubtree(); |
| 634 | } |
| 635 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 636 | void LayerImpl::setOpacity(float opacity) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 637 | { |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 638 | if (m_opacity == opacity) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 639 | return; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 640 | |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 641 | m_opacity = opacity; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 642 | noteLayerSurfacePropertyChanged(); |
[email protected] | 0a9fd4d | 2012-12-07 07:37:08 | [diff] [blame] | 643 | } |
| 644 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 645 | float LayerImpl::opacity() const |
| 646 | { |
| 647 | return m_opacity; |
| 648 | } |
| 649 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 650 | bool LayerImpl::opacityIsAnimating() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 651 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 652 | return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opacity); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 653 | } |
| 654 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 655 | void LayerImpl::setPosition(const gfx::PointF& position) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 656 | { |
| 657 | if (m_position == position) |
| 658 | return; |
| 659 | |
| 660 | m_position = position; |
| 661 | noteLayerPropertyChangedForSubtree(); |
| 662 | } |
| 663 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 664 | void LayerImpl::setPreserves3D(bool preserves3D) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 665 | { |
| 666 | if (m_preserves3D == preserves3D) |
| 667 | return; |
| 668 | |
| 669 | m_preserves3D = preserves3D; |
| 670 | noteLayerPropertyChangedForSubtree(); |
| 671 | } |
| 672 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 673 | void LayerImpl::setSublayerTransform(const gfx::Transform& sublayerTransform) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 674 | { |
| 675 | if (m_sublayerTransform == sublayerTransform) |
| 676 | return; |
| 677 | |
| 678 | m_sublayerTransform = sublayerTransform; |
| 679 | // sublayer transform does not affect the current layer; it affects only its children. |
| 680 | noteLayerPropertyChangedForDescendants(); |
| 681 | } |
| 682 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 683 | void LayerImpl::setTransform(const gfx::Transform& transform) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 684 | { |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 685 | if (m_transform == transform) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 686 | return; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 687 | |
[email protected] | df1ec1a | 2012-12-08 17:01:18 | [diff] [blame] | 688 | m_transform = transform; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 689 | noteLayerSurfacePropertyChanged(); |
[email protected] | 0a9fd4d | 2012-12-07 07:37:08 | [diff] [blame] | 690 | } |
| 691 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 692 | const gfx::Transform& LayerImpl::transform() const |
| 693 | { |
| 694 | return m_transform; |
| 695 | } |
| 696 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 697 | bool LayerImpl::transformIsAnimating() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 698 | { |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 699 | return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 700 | } |
| 701 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 702 | void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 703 | { |
[email protected] | 344e58d0 | 2012-12-16 04:52:53 | [diff] [blame] | 704 | if (this->contentBounds() == contentBounds) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 705 | return; |
| 706 | |
[email protected] | 344e58d0 | 2012-12-16 04:52:53 | [diff] [blame] | 707 | m_drawProperties.content_bounds = contentBounds; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 708 | noteLayerPropertyChanged(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 709 | } |
| 710 | |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 711 | void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) |
| 712 | { |
[email protected] | 344e58d0 | 2012-12-16 04:52:53 | [diff] [blame] | 713 | if (this->contentsScaleX() == contentsScaleX && this->contentsScaleY() == contentsScaleY) |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 714 | return; |
| 715 | |
[email protected] | 344e58d0 | 2012-12-16 04:52:53 | [diff] [blame] | 716 | m_drawProperties.contents_scale_x = contentsScaleX; |
| 717 | m_drawProperties.contents_scale_y = contentsScaleY; |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 718 | noteLayerPropertyChanged(); |
[email protected] | 904e913 | 2012-11-01 00:12:47 | [diff] [blame] | 719 | } |
| 720 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 721 | void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 722 | { |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 723 | if (m_scrollOffset == scrollOffset) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 724 | return; |
| 725 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 726 | m_scrollOffset = scrollOffset; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 727 | noteLayerPropertyChangedForSubtree(); |
| 728 | } |
| 729 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 730 | void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 731 | { |
| 732 | if (m_scrollDelta == scrollDelta) |
| 733 | return; |
| 734 | |
| 735 | m_scrollDelta = scrollDelta; |
| 736 | noteLayerPropertyChangedForSubtree(); |
| 737 | } |
| 738 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 739 | void LayerImpl::setImplTransform(const gfx::Transform& transform) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 740 | { |
[email protected] | 1c0c9bc | 2012-10-08 22:41:48 | [diff] [blame] | 741 | if (m_implTransform == transform) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 742 | return; |
| 743 | |
[email protected] | 1c0c9bc | 2012-10-08 22:41:48 | [diff] [blame] | 744 | m_implTransform = transform; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 745 | noteLayerPropertyChangedForSubtree(); |
| 746 | } |
| 747 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 748 | void LayerImpl::setDoubleSided(bool doubleSided) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 749 | { |
| 750 | if (m_doubleSided == doubleSided) |
| 751 | return; |
| 752 | |
| 753 | m_doubleSided = doubleSided; |
| 754 | noteLayerPropertyChangedForSubtree(); |
| 755 | } |
| 756 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 757 | Region LayerImpl::visibleContentOpaqueRegion() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 758 | { |
[email protected] | 048634c | 2012-10-02 22:33:14 | [diff] [blame] | 759 | if (contentsOpaque()) |
[email protected] | d0f9836 | 2012-11-01 23:02:38 | [diff] [blame] | 760 | return visibleContentRect(); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 761 | return Region(); |
| 762 | } |
| 763 | |
[email protected] | 3be2171d | 2012-12-06 06:13:20 | [diff] [blame] | 764 | void LayerImpl::didLoseOutputSurface() |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 765 | { |
| 766 | } |
| 767 | |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 768 | void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 769 | { |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 770 | if (m_maxScrollOffset == maxScrollOffset) |
| 771 | return; |
[email protected] | c9c1ebe | 2012-11-05 20:46:13 | [diff] [blame] | 772 | m_maxScrollOffset = maxScrollOffset; |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 773 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 774 | layerTreeImpl()->SetNeedsUpdateDrawProperties(); |
[email protected] | 0ede3bb | 2012-12-09 09:14:39 | [diff] [blame] | 775 | |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 776 | if (!m_scrollbarAnimationController) |
| 777 | return; |
| 778 | m_scrollbarAnimationController->updateScrollOffset(this); |
| 779 | } |
| 780 | |
[email protected] | da3a295 | 2012-11-21 04:19:52 | [diff] [blame] | 781 | ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() |
| 782 | { |
| 783 | return m_scrollbarAnimationController ? m_scrollbarAnimationController->horizontalScrollbarLayer() : 0; |
| 784 | } |
| 785 | |
| 786 | const ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 787 | { |
| 788 | return m_scrollbarAnimationController ? m_scrollbarAnimationController->horizontalScrollbarLayer() : 0; |
| 789 | } |
| 790 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 791 | void LayerImpl::setHorizontalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 792 | { |
| 793 | if (!m_scrollbarAnimationController) |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 794 | m_scrollbarAnimationController = ScrollbarAnimationController::create(this); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 795 | m_scrollbarAnimationController->setHorizontalScrollbarLayer(scrollbarLayer); |
| 796 | m_scrollbarAnimationController->updateScrollOffset(this); |
| 797 | } |
| 798 | |
[email protected] | da3a295 | 2012-11-21 04:19:52 | [diff] [blame] | 799 | ScrollbarLayerImpl* LayerImpl::verticalScrollbarLayer() |
| 800 | { |
| 801 | return m_scrollbarAnimationController ? m_scrollbarAnimationController->verticalScrollbarLayer() : 0; |
| 802 | } |
| 803 | |
| 804 | const ScrollbarLayerImpl* LayerImpl::verticalScrollbarLayer() const |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 805 | { |
| 806 | return m_scrollbarAnimationController ? m_scrollbarAnimationController->verticalScrollbarLayer() : 0; |
| 807 | } |
| 808 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 809 | void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 810 | { |
| 811 | if (!m_scrollbarAnimationController) |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 812 | m_scrollbarAnimationController = ScrollbarAnimationController::create(this); |
[email protected] | 94f206c1 | 2012-08-25 00:09:14 | [diff] [blame] | 813 | m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 814 | m_scrollbarAnimationController->updateScrollOffset(this); |
| 815 | } |
| 816 | |
[email protected] | bc5e77c | 2012-11-05 20:00:49 | [diff] [blame] | 817 | } // namespace cc |