Chromium Code Reviews| 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 #ifndef CC_LAYER_IMPL_H_ | 5 #ifndef CC_LAYER_IMPL_H_ |
| 6 #define CC_LAYER_IMPL_H_ | 6 #define CC_LAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 class LayerTreeImpl; | 40 class LayerTreeImpl; |
| 41 class QuadSink; | 41 class QuadSink; |
| 42 class Renderer; | 42 class Renderer; |
| 43 class ScrollbarAnimationController; | 43 class ScrollbarAnimationController; |
| 44 class ScrollbarLayerImpl; | 44 class ScrollbarLayerImpl; |
| 45 class Layer; | 45 class Layer; |
| 46 | 46 |
| 47 struct AppendQuadsData; | 47 struct AppendQuadsData; |
| 48 | 48 |
| 49 class CC_EXPORT LayerImpl : LayerAnimationValueObserver { | 49 class CC_EXPORT LayerImpl : LayerAnimationValueObserver { |
| 50 public: | 50 public: |
| 51 typedef ScopedPtrVector<LayerImpl> LayerList; | 51 typedef ScopedPtrVector<LayerImpl> LayerList; |
| 52 | 52 |
| 53 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) | 53 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 54 { | 54 return make_scoped_ptr(new LayerImpl(tree_impl, id)); |
| 55 return make_scoped_ptr(new LayerImpl(treeImpl, id)); | 55 } |
| 56 } | 56 |
| 57 | 57 virtual ~LayerImpl(); |
| 58 virtual ~LayerImpl(); | 58 |
| 59 | 59 int id() const { return layer_id_; } |
| 60 int id() const; | 60 |
| 61 | 61 // LayerAnimationValueObserver implementation. |
| 62 // LayerAnimationValueObserver implementation. | 62 virtual void OnOpacityAnimated(float opacity) OVERRIDE; |
| 63 virtual void OnOpacityAnimated(float) OVERRIDE; | 63 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; |
| 64 virtual void OnTransformAnimated(const gfx::Transform&) OVERRIDE; | 64 virtual bool IsActive() const OVERRIDE; |
| 65 virtual bool IsActive() const OVERRIDE; | 65 |
| 66 | 66 // Tree structure. |
| 67 // Tree structure. | 67 LayerImpl* parent() { return parent_; } |
| 68 LayerImpl* parent() { return m_parent; } | 68 const LayerImpl* parent() const { return parent_; } |
| 69 const LayerImpl* parent() const { return m_parent; } | 69 const LayerList& children() const { return children_; } |
| 70 const LayerList& children() const { return m_children; } | 70 LayerList& children() { return children_; } |
| 71 LayerList& children() { return m_children; } | 71 LayerImpl* child_at(size_t index) const { return children_[index]; } |
| 72 LayerImpl* childAt(size_t index) const; | 72 void AddChild(scoped_ptr<LayerImpl> child); |
| 73 void addChild(scoped_ptr<LayerImpl>); | 73 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); |
| 74 scoped_ptr<LayerImpl> removeChild(LayerImpl* child); | 74 void set_parent(LayerImpl* parent) { parent_ = parent; } |
| 75 void setParent(LayerImpl* parent) { m_parent = parent; } | 75 // Warning: This does not preserve tree structure invariants. |
| 76 void clearChildList(); // Warning: This does not preserve tree structure inv ariants. | 76 void ClearChildList(); |
| 77 | 77 |
| 78 void setMaskLayer(scoped_ptr<LayerImpl>); | 78 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); |
| 79 LayerImpl* maskLayer() { return m_maskLayer.get(); } | 79 LayerImpl* mask_layer() { return mask_layer_.get(); } |
| 80 const LayerImpl* maskLayer() const { return m_maskLayer.get(); } | 80 const LayerImpl* mask_layer() const { return mask_layer_.get(); } |
| 81 scoped_ptr<LayerImpl> takeMaskLayer(); | 81 scoped_ptr<LayerImpl> TakeMaskLayer(); |
| 82 | 82 |
| 83 void setReplicaLayer(scoped_ptr<LayerImpl>); | 83 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer); |
| 84 LayerImpl* replicaLayer() { return m_replicaLayer.get(); } | 84 LayerImpl* replica_layer() { return replica_layer_.get(); } |
| 85 const LayerImpl* replicaLayer() const { return m_replicaLayer.get(); } | 85 const LayerImpl* replica_layer() const { return replica_layer_.get(); } |
| 86 scoped_ptr<LayerImpl> takeReplicaLayer(); | 86 scoped_ptr<LayerImpl> TakeReplicaLayer(); |
| 87 | 87 |
| 88 bool hasMask() const { return m_maskLayer; } | 88 bool has_mask() const { return mask_layer_; } |
| 89 bool hasReplica() const { return m_replicaLayer; } | 89 bool has_replica() const { return replica_layer_; } |
| 90 bool replicaHasMask() const { return m_replicaLayer && (m_maskLayer || m_rep licaLayer->m_maskLayer); } | 90 bool replica_has_mask() const { return replica_layer_ && (mask_layer_ || repli ca_layer_->mask_layer_); } |
| 91 | 91 |
| 92 LayerTreeImpl* layerTreeImpl() const { return m_layerTreeImpl; } | 92 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } |
| 93 | 93 |
| 94 scoped_ptr<SharedQuadState> createSharedQuadState() const; | 94 scoped_ptr<SharedQuadState> CreateSharedQuadState() const; |
| 95 // willDraw must be called before appendQuads. If willDraw is called, | 95 // willDraw must be called before appendQuads. If willDraw is called, |
| 96 // didDraw is guaranteed to be called before another willDraw or before | 96 // didDraw is guaranteed to be called before another willDraw or before |
| 97 // the layer is destroyed. To enforce this, any class that overrides | 97 // the layer is destroyed. To enforce this, any class that overrides |
| 98 // willDraw/didDraw must call the base class version. | 98 // willDraw/didDraw must call the base class version. |
| 99 virtual void willDraw(ResourceProvider*); | 99 virtual void WillDraw(ResourceProvider* resource_provider); |
| 100 virtual void appendQuads(QuadSink&, AppendQuadsData&) { } | 100 virtual void AppendQuads(QuadSink* quad_sink, |
| 101 virtual void didDraw(ResourceProvider*); | 101 AppendQuadsData* append_quads_data) {} |
| 102 | 102 virtual void DidDraw(ResourceProvider* resource_provider); |
| 103 virtual ResourceProvider::ResourceId contentsResourceId() const; | 103 |
| 104 | 104 virtual ResourceProvider::ResourceId ContentsResourceId() const; |
| 105 virtual bool hasDelegatedContent() const; | 105 |
| 106 virtual bool hasContributingDelegatedRenderPasses() const; | 106 virtual bool HasDelegatedContent() const; |
| 107 virtual RenderPass::Id firstContributingRenderPassId() const; | 107 virtual bool HasContributingDelegatedRenderPasses() const; |
| 108 virtual RenderPass::Id nextContributingRenderPassId(RenderPass::Id) const; | 108 virtual RenderPass::Id FirstContributingRenderPassId() const; |
| 109 | 109 virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const; |
| 110 virtual void updateTilePriorities() { } | 110 |
| 111 | 111 virtual void UpdateTilePriorities() {} |
| 112 virtual ScrollbarLayerImpl* toScrollbarLayer(); | 112 |
| 113 | 113 virtual ScrollbarLayerImpl* ToScrollbarLayer(); |
| 114 // Returns true if this layer has content to draw. | 114 |
| 115 void setDrawsContent(bool); | 115 // Returns true if this layer has content to draw. |
| 116 bool drawsContent() const { return m_drawsContent; } | 116 void SetDrawsContent(bool draws_content); |
| 117 | 117 bool DrawsContent() const { return draws_content_; } |
| 118 bool forceRenderSurface() const { return m_forceRenderSurface; } | 118 |
| 119 void setForceRenderSurface(bool force) { m_forceRenderSurface = force; } | 119 bool force_render_surface() const { return force_render_surface_; } |
| 120 | 120 void SetForceRenderSurface(bool force) { force_render_surface_ = force; } |
| 121 void setAnchorPoint(const gfx::PointF&); | 121 |
| 122 const gfx::PointF& anchorPoint() const { return m_anchorPoint; } | 122 void SetAnchorPoint(gfx::PointF anchor_point); |
| 123 | 123 gfx::PointF anchor_point() const { return anchor_point_; } |
| 124 void setAnchorPointZ(float); | 124 |
| 125 float anchorPointZ() const { return m_anchorPointZ; } | 125 void SetAnchorPointZ(float anchor_point_z); |
| 126 | 126 float anchor_point_z() const { return anchor_point_z_; } |
| 127 void setBackgroundColor(SkColor); | 127 |
| 128 SkColor backgroundColor() const { return m_backgroundColor; } | 128 void SetBackgroundColor(SkColor background_color); |
| 129 | 129 SkColor background_color() const { return background_color_; } |
| 130 void setFilters(const WebKit::WebFilterOperations&); | 130 |
| 131 const WebKit::WebFilterOperations& filters() const { return m_filters; } | 131 void SetFilters(const WebKit::WebFilterOperations& filters); |
| 132 | 132 const WebKit::WebFilterOperations& filters() const { return filters_; } |
| 133 void setBackgroundFilters(const WebKit::WebFilterOperations&); | 133 |
| 134 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back groundFilters; } | 134 void SetBackgroundFilters(const WebKit::WebFilterOperations& filters); |
| 135 | 135 const WebKit::WebFilterOperations& background_filters() const { |
| 136 void setFilter(const skia::RefPtr<SkImageFilter>&); | 136 return background_filters_; |
| 137 skia::RefPtr<SkImageFilter> filter() const { return m_filter; } | 137 } |
| 138 | 138 |
| 139 void setMasksToBounds(bool); | 139 void SetFilter(const skia::RefPtr<SkImageFilter>& filter); |
| 140 bool masksToBounds() const { return m_masksToBounds; } | 140 skia::RefPtr<SkImageFilter> filter() const { return filter_; } |
| 141 | 141 |
| 142 void setContentsOpaque(bool); | 142 void SetMasksToBounds(bool masks_to_bounds); |
| 143 bool contentsOpaque() const { return m_contentsOpaque; } | 143 bool masks_to_bounds() const { return masks_to_bounds_; } |
| 144 | 144 |
| 145 void setOpacity(float); | 145 void SetContentsOpaque(bool opaque); |
| 146 float opacity() const; | 146 bool contents_opaque() const { return contents_opaque_; } |
| 147 bool opacityIsAnimating() const; | 147 |
| 148 | 148 void SetOpacity(float opacity); |
| 149 void setPosition(const gfx::PointF&); | 149 float opacity() const { return opacity_; } |
| 150 const gfx::PointF& position() const { return m_position; } | 150 bool OpacityIsAnimating() const; |
| 151 | 151 |
| 152 void setIsContainerForFixedPositionLayers(bool isContainerForFixedPositionLa yers) { m_isContainerForFixedPositionLayers = isContainerForFixedPositionLayers; } | 152 void SetPosition(gfx::PointF position); |
| 153 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe dPositionLayers; } | 153 gfx::PointF position() const { return position_; } |
| 154 | 154 |
| 155 void setFixedToContainerLayer(bool fixedToContainerLayer = true) { m_fixedTo ContainerLayer = fixedToContainerLayer;} | 155 void SetIsContainerForFixedPositionLayers(bool container) { |
| 156 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } | 156 is_container_for_fixed_position_layers_ = container; |
| 157 | 157 } |
| 158 void setPreserves3D(bool); | 158 bool is_container_for_fixed_position_layers() const { |
| 159 bool preserves3D() const { return m_preserves3D; } | 159 return is_container_for_fixed_position_layers_; |
| 160 | 160 } |
| 161 void setUseParentBackfaceVisibility(bool useParentBackfaceVisibility) { m_us eParentBackfaceVisibility = useParentBackfaceVisibility; } | 161 |
| 162 bool useParentBackfaceVisibility() const { return m_useParentBackfaceVisibil ity; } | 162 void SetFixedToContainerLayer(bool fixed) { |
| 163 | 163 fixed_to_container_layer_ = fixed; |
| 164 void setSublayerTransform(const gfx::Transform&); | 164 } |
| 165 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform ; } | 165 bool fixed_to_container_layer() const { return fixed_to_container_layer_; } |
| 166 | 166 |
| 167 // Debug layer name. | 167 void SetPreserves3d(bool preserves_3d); |
| 168 void setDebugName(const std::string& debugName) { m_debugName = debugName; } | 168 bool preserves_3d() const { return preserves_3d_; } |
| 169 std::string debugName() const { return m_debugName; } | 169 |
| 170 | 170 void SetUseParentBackfaceVisibility(bool use) { |
| 171 bool showDebugBorders() const; | 171 use_parent_backface_visibility_ = use; |
| 172 | 172 } |
| 173 // These invalidate the host's render surface layer list. The caller | 173 bool use_parent_backface_visibility() const { |
| 174 // is responsible for calling setNeedsUpdateDrawProperties on the host | 174 return use_parent_backface_visibility_; |
| 175 // so that its list can be recreated. | 175 } |
| 176 void createRenderSurface(); | 176 |
| 177 void clearRenderSurface() { m_drawProperties.render_surface.reset(); } | 177 void SetSublayerTransform(const gfx::Transform& sublayer_transform); |
| 178 | 178 const gfx::Transform& sublayer_transform() const { |
| 179 DrawProperties<LayerImpl, RenderSurfaceImpl>& drawProperties() { return m_dr awProperties; } | 179 return sublayer_transform_; |
| 180 const DrawProperties<LayerImpl, RenderSurfaceImpl>& drawProperties() const { return m_drawProperties; } | 180 } |
| 181 | 181 |
| 182 // The following are shortcut accessors to get various information from m_dr awProperties | 182 // Debug layer name. |
| 183 const gfx::Transform& drawTransform() const { return m_drawProperties.target _space_transform; } | 183 void SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; } |
| 184 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties .screen_space_transform; } | 184 std::string debug_name() const { return debug_name_; } |
| 185 float drawOpacity() const { return m_drawProperties.opacity; } | 185 |
| 186 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani mating; } | 186 bool ShowDebugBorders() const; |
| 187 bool drawTransformIsAnimating() const { return m_drawProperties.target_space _transform_is_animating; } | 187 |
| 188 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree n_space_transform_is_animating; } | 188 // These invalidate the host's render surface layer list. The caller |
| 189 bool screenSpaceOpacityIsAnimating() const { return m_drawProperties.screen_ space_opacity_is_animating; } | 189 // is responsible for calling setNeedsUpdateDrawProperties on the host |
| 190 bool canUseLCDText() const { return m_drawProperties.can_use_lcd_text; } | 190 // so that its list can be recreated. |
| 191 bool isClipped() const { return m_drawProperties.is_clipped; } | 191 void CreateRenderSurface(); |
| 192 const gfx::Rect& clipRect() const { return m_drawProperties.clip_rect; } | 192 void ClearRenderSurface() { draw_properties_.render_surface.reset(); } |
| 193 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa ble_content_rect; } | 193 |
| 194 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl e_content_rect; } | 194 DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() { |
| 195 LayerImpl* renderTarget() { DCHECK(!m_drawProperties.render_target || m_draw Properties.render_target->renderSurface()); return m_drawProperties.render_targe t; } | 195 return draw_properties_; |
| 196 const LayerImpl* renderTarget() const { DCHECK(!m_drawProperties.render_targ et || m_drawProperties.render_target->renderSurface()); return m_drawProperties. render_target; } | 196 } |
| 197 RenderSurfaceImpl* renderSurface() const { return m_drawProperties.render_su rface.get(); } | 197 const DrawProperties<LayerImpl, RenderSurfaceImpl>& draw_properties() const { |
| 198 | 198 return draw_properties_; |
| 199 // The client should be responsible for setting bounds, contentBounds and | 199 } |
| 200 // contentsScale to appropriate values. LayerImpl doesn't calculate any of | 200 |
| 201 // them from the other values. | 201 // The following are shortcut accessors to get various information from |
| 202 | 202 // draw_properties_ |
| 203 void setBounds(const gfx::Size&); | 203 const gfx::Transform& draw_transform() const { |
| 204 const gfx::Size& bounds() const { return m_bounds; } | 204 return draw_properties_.target_space_transform; |
| 205 | 205 } |
| 206 void setContentBounds(const gfx::Size&); | 206 const gfx::Transform& screen_space_transform() const { |
| 207 gfx::Size contentBounds() const { return m_drawProperties.content_bounds; } | 207 return draw_properties_.screen_space_transform; |
| 208 | 208 } |
| 209 float contentsScaleX() const { return m_drawProperties.contents_scale_x; } | 209 float draw_opacity() const { return draw_properties_.opacity; } |
| 210 float contentsScaleY() const { return m_drawProperties.contents_scale_y; } | 210 bool draw_opacity_is_animating() const { |
| 211 void setContentsScale(float contentsScaleX, float contentsScaleY); | 211 return draw_properties_.opacity_is_animating; |
| 212 | 212 } |
| 213 virtual void calculateContentsScale( | 213 bool draw_transform_is_animating() const { |
| 214 float idealContentsScale, | 214 return draw_properties_.target_space_transform_is_animating; |
| 215 bool animatingTransformToScreen, | 215 } |
| 216 float* contentsScaleX, | 216 bool screen_space_transform_is_animating() const { |
| 217 float* contentsScaleY, | 217 return draw_properties_.screen_space_transform_is_animating; |
| 218 gfx::Size* contentBounds); | 218 } |
| 219 | 219 bool screen_space_opacity_is_animating() const { |
| 220 gfx::Vector2d scrollOffset() const { return m_scrollOffset; } | 220 return draw_properties_.screen_space_opacity_is_animating; |
| 221 void setScrollOffset(gfx::Vector2d); | 221 } |
| 222 | 222 bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } |
| 223 gfx::Vector2d maxScrollOffset() const {return m_maxScrollOffset; } | 223 bool is_clipped() const { return draw_properties_.is_clipped; } |
| 224 void setMaxScrollOffset(gfx::Vector2d); | 224 gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } |
| 225 | 225 gfx::Rect drawable_content_rect() const { |
| 226 const gfx::Vector2dF& scrollDelta() const { return m_scrollDelta; } | 226 return draw_properties_.drawable_content_rect; |
| 227 void setScrollDelta(const gfx::Vector2dF&); | 227 } |
| 228 | 228 gfx::Rect visible_content_rect() const { |
| 229 const gfx::Transform& implTransform() const { return m_implTransform; } | 229 return draw_properties_.visible_content_rect; |
| 230 void setImplTransform(const gfx::Transform& transform); | 230 } |
| 231 | 231 LayerImpl* render_target() { |
| 232 const gfx::Vector2d& sentScrollDelta() const { return m_sentScrollDelta; } | 232 DCHECK(!draw_properties_.render_target || |
| 233 void setSentScrollDelta(const gfx::Vector2d& sentScrollDelta); | 233 draw_properties_.render_target->render_surface()); |
| 234 | 234 return draw_properties_.render_target; |
| 235 // Returns the delta of the scroll that was outside of the bounds of the ini tial scroll | 235 } |
| 236 gfx::Vector2dF scrollBy(const gfx::Vector2dF& scroll); | 236 const LayerImpl* render_target() const { |
| 237 | 237 DCHECK(!draw_properties_.render_target || |
| 238 bool scrollable() const { return m_scrollable; } | 238 draw_properties_.render_target->render_surface()); |
| 239 void setScrollable(bool scrollable) { m_scrollable = scrollable; } | 239 return draw_properties_.render_target; |
| 240 | 240 } |
| 241 bool shouldScrollOnMainThread() const { return m_shouldScrollOnMainThread; } | 241 RenderSurfaceImpl* render_surface() const { |
| 242 void setShouldScrollOnMainThread(bool shouldScrollOnMainThread) { m_shouldSc rollOnMainThread = shouldScrollOnMainThread; } | 242 return draw_properties_.render_surface.get(); |
| 243 | 243 } |
| 244 bool haveWheelEventHandlers() const { return m_haveWheelEventHandlers; } | 244 |
| 245 void setHaveWheelEventHandlers(bool haveWheelEventHandlers) { m_haveWheelEve ntHandlers = haveWheelEventHandlers; } | 245 // The client should be responsible for setting bounds, contentBounds and |
| 246 | 246 // contentsScale to appropriate values. LayerImpl doesn't calculate any of |
| 247 const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRe gion; } | 247 // them from the other values. |
| 248 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR egion = region; } | 248 |
| 249 | 249 void SetBounds(gfx::Size bounds); |
| 250 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe gion; } | 250 gfx::Size bounds() const { return bounds_; } |
| 251 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR egion = region; } | 251 |
| 252 | 252 void SetContentBounds(gfx::Size content_bounds); |
| 253 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo ardForMissingTiles = checkerboard; } | 253 gfx::Size content_bounds() const { return draw_properties_.content_bounds; } |
| 254 bool drawCheckerboardForMissingTiles() const; | 254 |
| 255 | 255 float contents_scale_x() const { return draw_properties_.contents_scale_x; } |
| 256 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi nt, InputHandlerClient::ScrollInputType) const; | 256 float contents_scale_y() const { return draw_properties_.contents_scale_y; } |
| 257 | 257 void SetContentsScale(float contents_scale_x, float contents_scale_y); |
| 258 bool doubleSided() const { return m_doubleSided; } | 258 |
| 259 void setDoubleSided(bool); | 259 virtual void CalculateContentsScale(float ideal_contents_scale, |
| 260 | 260 bool animating_transform_to_screen, |
| 261 void setTransform(const gfx::Transform&); | 261 float* contents_scale_x, |
| 262 const gfx::Transform& transform() const; | 262 float* contents_scale_y, |
| 263 bool transformIsAnimating() const; | 263 gfx::Size* contentBounds); |
| 264 | 264 |
| 265 const gfx::RectF& updateRect() const { return m_updateRect; } | 265 void SetScrollOffset(gfx::Vector2d scroll_offset); |
| 266 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect ; } | 266 gfx::Vector2d scroll_offset() const { return scroll_offset_; } |
| 267 | 267 |
| 268 std::string layerTreeAsText() const; | 268 void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset); |
| 269 virtual base::DictionaryValue* layerTreeAsJson() const; | 269 gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; } |
| 270 | 270 |
| 271 void setStackingOrderChanged(bool); | 271 void SetScrollDelta(gfx::Vector2dF scroll_delta); |
| 272 | 272 gfx::Vector2dF scroll_delta() const { return scroll_delta_; } |
| 273 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs AlwaysDamaged(); } | 273 |
| 274 bool layerSurfacePropertyChanged() const; | 274 void SetImplTransform(const gfx::Transform& transform); |
| 275 | 275 const gfx::Transform& impl_transform() const { return impl_transform_; } |
| 276 void resetAllChangeTrackingForSubtree(); | 276 |
| 277 | 277 void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta); |
| 278 virtual bool layerIsAlwaysDamaged() const; | 278 gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; } |
| 279 | 279 |
| 280 LayerAnimationController* layerAnimationController() { return m_layerAnimati onController.get(); } | 280 // Returns the delta of the scroll that was outside of the bounds of the |
| 281 | 281 // initial scroll |
| 282 virtual Region visibleContentOpaqueRegion() const; | 282 gfx::Vector2dF ScrollBy(gfx::Vector2dF scroll); |
| 283 | 283 |
| 284 virtual void didBecomeActive(); | 284 void SetScrollable(bool scrollable) { scrollable_ = scrollable; } |
| 285 | 285 bool scrollable() const { return scrollable_; } |
| 286 // Indicates that the surface previously used to render this layer | 286 |
| 287 // was lost and that a new one has been created. Won't be called | 287 void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread) { |
| 288 // until the new surface has been created successfully. | 288 should_scroll_on_main_thread_ = should_scroll_on_main_thread; |
| 289 virtual void didLoseOutputSurface(); | 289 } |
| 290 | 290 bool should_scroll_on_main_thread() const { |
| 291 ScrollbarAnimationController* scrollbarAnimationController() const { return m_scrollbarAnimationController.get(); } | 291 return should_scroll_on_main_thread_; |
| 292 | 292 } |
| 293 void setScrollbarOpacity(float opacity); | 293 |
| 294 | 294 void SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { |
| 295 void setHorizontalScrollbarLayer(ScrollbarLayerImpl*); | 295 have_wheel_event_handlers_ = have_wheel_event_handlers; |
| 296 ScrollbarLayerImpl* horizontalScrollbarLayer() { return m_horizontalScrollba rLayer; } | 296 } |
| 297 | 297 bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } |
| 298 void setVerticalScrollbarLayer(ScrollbarLayerImpl*); | 298 |
| 299 ScrollbarLayerImpl* verticalScrollbarLayer() { return m_verticalScrollbarLay er; } | 299 void SetNonFastScrollableRegion(const Region& region) { |
| 300 | 300 non_fast_scrollable_region_ = region; |
| 301 gfx::Rect layerRectToContentRect(const gfx::RectF& layerRect) const; | 301 } |
| 302 | 302 const Region& non_fast_scrollable_region() const { |
| 303 virtual skia::RefPtr<SkPicture> getPicture(); | 303 return non_fast_scrollable_region_; |
| 304 | 304 } |
| 305 virtual bool canClipSelf() const; | 305 |
| 306 | 306 void SetTouchEventHandlerRegion(const Region& region) { |
| 307 virtual bool areVisibleResourcesReady() const; | 307 touch_event_handler_region_ = region; |
| 308 | 308 } |
| 309 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeImpl*); | 309 const Region& touch_event_handler_region() const { |
| 310 virtual void pushPropertiesTo(LayerImpl*); | 310 return touch_event_handler_region_; |
| 311 | 311 } |
| 312 virtual scoped_ptr<base::Value> AsValue() const; | 312 |
| 313 | 313 void SetDrawCheckerboardForMissingTiles(bool checkerboard) { |
| 314 protected: | 314 draw_checkerboard_for_missing_tiles_ = checkerboard; |
| 315 LayerImpl(LayerTreeImpl* layerImpl, int); | 315 } |
| 316 | 316 bool DrawCheckerboardForMissingTiles() const; |
| 317 // Get the color and size of the layer's debug border. | 317 |
| 318 virtual void getDebugBorderProperties(SkColor*, float* width) const; | 318 InputHandlerClient::ScrollStatus TryScroll( |
| 319 | 319 gfx::PointF screen_space_point, |
| 320 void appendDebugBorderQuad(QuadSink&, const SharedQuadState*, AppendQuadsDat a&) const; | 320 InputHandlerClient::ScrollInputType type) const; |
| 321 | 321 |
| 322 virtual void dumpLayerProperties(std::string*, int indent) const; | 322 void SetDoubleSided(bool double_sided); |
| 323 static std::string indentString(int indent); | 323 bool double_sided() const { return double_sided_; } |
| 324 | 324 |
| 325 void AsValueInto(base::DictionaryValue* dict) const; | 325 void SetTransform(const gfx::Transform& transform); |
| 326 | 326 const gfx::Transform& transform() const { return transform_; } |
| 327 void noteLayerSurfacePropertyChanged(); | 327 bool TransformIsAnimating() const; |
| 328 void noteLayerPropertyChanged(); | 328 |
| 329 void noteLayerPropertyChangedForSubtree(); | 329 void set_update_rect(const gfx::RectF& update_rect) { |
| 330 | 330 update_rect_ = update_rect; |
| 331 // Note carefully this does not affect the current layer. | 331 } |
| 332 void noteLayerPropertyChangedForDescendants(); | 332 const gfx::RectF& update_rect() const { return update_rect_; } |
| 333 | 333 |
| 334 private: | 334 std::string LayerTreeAsText() const; |
| 335 void updateScrollbarPositions(); | 335 virtual base::DictionaryValue* LayerTreeAsJson() const; |
| 336 | 336 |
| 337 virtual const char* layerTypeAsString() const; | 337 void SetStackingOrderChanged(bool stacking_order_changed); |
| 338 | 338 |
| 339 void dumpLayer(std::string*, int indent) const; | 339 bool LayerPropertyChanged() const { |
| 340 | 340 return layer_property_changed_ || LayerIsAlwaysDamaged(); |
| 341 // Properties internal to LayerImpl | 341 } |
| 342 LayerImpl* m_parent; | 342 bool LayerSurfacePropertyChanged() const; |
| 343 LayerList m_children; | 343 |
| 344 // m_maskLayer can be temporarily stolen during tree sync, we need this ID t o confirm newly assigned layer is still the previous one | 344 void ResetAllChangeTrackingForSubtree(); |
| 345 int m_maskLayerId; | 345 |
| 346 scoped_ptr<LayerImpl> m_maskLayer; | 346 virtual bool LayerIsAlwaysDamaged() const; |
| 347 int m_replicaLayerId; // ditto | 347 |
| 348 scoped_ptr<LayerImpl> m_replicaLayer; | 348 LayerAnimationController* layer_animation_controller() { |
| 349 int m_layerId; | 349 return layer_animation_controller_.get(); |
| 350 LayerTreeImpl* m_layerTreeImpl; | 350 } |
| 351 | 351 |
| 352 // Properties synchronized from the associated Layer. | 352 virtual Region VisibleContentOpaqueRegion() const; |
| 353 gfx::PointF m_anchorPoint; | 353 |
| 354 float m_anchorPointZ; | 354 virtual void DidBecomeActive(); |
| 355 gfx::Size m_bounds; | 355 |
| 356 gfx::Vector2d m_scrollOffset; | 356 // Indicates that the surface previously used to render this layer |
| 357 bool m_scrollable; | 357 // was lost and that a new one has been created. Won't be called |
| 358 bool m_shouldScrollOnMainThread; | 358 // until the new surface has been created successfully. |
| 359 bool m_haveWheelEventHandlers; | 359 virtual void DidLoseOutputSurface(); |
| 360 Region m_nonFastScrollableRegion; | 360 |
| 361 Region m_touchEventHandlerRegion; | 361 ScrollbarAnimationController* scrollbar_animation_controller() const { |
| 362 SkColor m_backgroundColor; | 362 return scrollbar_animation_controller_.get(); |
| 363 bool m_stackingOrderChanged; | 363 } |
| 364 | 364 |
| 365 // Whether the "back" of this layer should draw. | 365 void SetScrollbarOpacity(float opacity); |
| 366 bool m_doubleSided; | 366 |
| 367 | 367 void SetHorizontalScrollbarLayer(ScrollbarLayerImpl* scrollbar_layer); |
| 368 // Tracks if drawing-related properties have changed since last redraw. | 368 ScrollbarLayerImpl* horizontal_scrollbar_layer() { |
| 369 bool m_layerPropertyChanged; | 369 return horizontal_scrollbar_layer_; |
| 370 | 370 } |
| 371 // Indicates that a property has changed on this layer that would not | 371 |
| 372 // affect the pixels on its target surface, but would require redrawing | 372 void SetVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbar_layer); |
| 373 // the targetSurface onto its ancestor targetSurface. | 373 ScrollbarLayerImpl* vertical_scrollbar_layer() { |
| 374 // For layers that do not own a surface this flag acts as m_layerPropertyCha nged. | 374 return vertical_scrollbar_layer_; |
| 375 bool m_layerSurfacePropertyChanged; | 375 } |
| 376 | 376 |
| 377 bool m_masksToBounds; | 377 gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; |
| 378 bool m_contentsOpaque; | 378 |
| 379 float m_opacity; | 379 virtual skia::RefPtr<SkPicture> GetPicture(); |
| 380 gfx::PointF m_position; | 380 |
| 381 bool m_preserves3D; | 381 virtual bool CanClipSelf() const; |
| 382 bool m_useParentBackfaceVisibility; | 382 |
| 383 bool m_drawCheckerboardForMissingTiles; | 383 virtual bool AreVisibleResourcesReady() const; |
| 384 gfx::Transform m_sublayerTransform; | 384 |
| 385 gfx::Transform m_transform; | 385 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
| 386 | 386 virtual void PushPropertiesTo(LayerImpl* layer); |
| 387 bool m_drawsContent; | 387 |
| 388 bool m_forceRenderSurface; | 388 virtual scoped_ptr<base::Value> AsValue() const; |
| 389 | 389 |
| 390 // Set for the layer that other layers are fixed to. | 390 protected: |
| 391 bool m_isContainerForFixedPositionLayers; | 391 LayerImpl(LayerTreeImpl* layer_impl, int id); |
| 392 // This is true if the layer should be fixed to the closest ancestor contain er. | 392 |
| 393 bool m_fixedToContainerLayer; | 393 // Get the color and size of the layer's debug border. |
| 394 | 394 virtual void GetDebugBorderProperties(SkColor* color, float* width) const; |
| 395 gfx::Vector2dF m_scrollDelta; | 395 |
| 396 gfx::Vector2d m_sentScrollDelta; | 396 void AppendDebugBorderQuad(QuadSink* quad_sink, |
| 397 gfx::Vector2d m_maxScrollOffset; | 397 const SharedQuadState* shared_quad_state, |
| 398 gfx::Transform m_implTransform; | 398 AppendQuadsData* append_quads_data) const; |
| 399 gfx::Vector2dF m_lastScrollOffset; | 399 |
| 400 | 400 virtual void DumpLayerProperties(std::string* str, int indent) const; |
| 401 // The global depth value of the center of the layer. This value is used | 401 static std::string IndentString(int indent); |
| 402 // to sort layers from back to front. | 402 |
| 403 float m_drawDepth; | 403 void AsValueInto(base::DictionaryValue* dict) const; |
| 404 | 404 |
| 405 // Debug layer name. | 405 void NoteLayerSurfacePropertyChanged(); |
| 406 std::string m_debugName; | 406 void NoteLayerPropertyChanged(); |
| 407 | 407 void NoteLayerPropertyChangedForSubtree(); |
| 408 WebKit::WebFilterOperations m_filters; | 408 |
| 409 WebKit::WebFilterOperations m_backgroundFilters; | 409 // Note carefully this does not affect the current layer. |
| 410 skia::RefPtr<SkImageFilter> m_filter; | 410 void NoteLayerPropertyChangedForDescendants(); |
| 411 | |
| 412 private: | |
| 413 void UpdateScrollbarPositions(); | |
| 414 | |
| 415 virtual const char* LayerTypeAsString() const; | |
| 416 | |
| 417 void DumpLayer(std::string* str, int indent) const; | |
| 418 | |
| 419 // Properties internal to LayerImpl | |
| 420 LayerImpl* parent_; | |
| 421 LayerList children_; | |
| 422 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to confirm newly assigned layer is still the previous one | |
|
enne (OOO)
2013/03/12 02:40:19
80 col
danakj
2013/03/12 02:47:16
Done.
| |
| 423 int mask_layer_id_; | |
| 424 scoped_ptr<LayerImpl> mask_layer_; | |
| 425 int replica_layer_id_; // ditto | |
| 426 scoped_ptr<LayerImpl> replica_layer_; | |
| 427 int layer_id_; | |
| 428 LayerTreeImpl* layer_tree_impl_; | |
| 429 | |
| 430 // Properties synchronized from the associated Layer. | |
| 431 gfx::PointF anchor_point_; | |
| 432 float anchor_point_z_; | |
| 433 gfx::Size bounds_; | |
| 434 gfx::Vector2d scroll_offset_; | |
| 435 bool scrollable_; | |
| 436 bool should_scroll_on_main_thread_; | |
| 437 bool have_wheel_event_handlers_; | |
| 438 Region non_fast_scrollable_region_; | |
| 439 Region touch_event_handler_region_; | |
| 440 SkColor background_color_; | |
| 441 bool stacking_order_changed_; | |
| 442 | |
| 443 // Whether the "back" of this layer should draw. | |
| 444 bool double_sided_; | |
| 445 | |
| 446 // Tracks if drawing-related properties have changed since last redraw. | |
| 447 bool layer_property_changed_; | |
| 448 | |
| 449 // Indicates that a property has changed on this layer that would not | |
| 450 // affect the pixels on its target surface, but would require redrawing | |
| 451 // the targetSurface onto its ancestor targetSurface. | |
| 452 // For layers that do not own a surface this flag acts as layer_property_chang ed_. | |
|
enne (OOO)
2013/03/12 02:40:19
80 col.
danakj
2013/03/12 02:47:16
Done.
| |
| 453 bool layer_surface_property_changed_; | |
| 454 | |
| 455 bool masks_to_bounds_; | |
| 456 bool contents_opaque_; | |
| 457 float opacity_; | |
| 458 gfx::PointF position_; | |
| 459 bool preserves_3d_; | |
| 460 bool use_parent_backface_visibility_; | |
| 461 bool draw_checkerboard_for_missing_tiles_; | |
| 462 gfx::Transform sublayer_transform_; | |
| 463 gfx::Transform transform_; | |
| 464 | |
| 465 bool draws_content_; | |
| 466 bool force_render_surface_; | |
| 467 | |
| 468 // Set for the layer that other layers are fixed to. | |
| 469 bool is_container_for_fixed_position_layers_; | |
| 470 // This is true if the layer should be fixed to the closest ancestor container . | |
|
enne (OOO)
2013/03/12 02:40:19
80 col.
danakj
2013/03/12 02:47:16
Done.
| |
| 471 bool fixed_to_container_layer_; | |
| 472 | |
| 473 gfx::Vector2dF scroll_delta_; | |
| 474 gfx::Vector2d sent_scroll_delta_; | |
| 475 gfx::Vector2d max_scroll_offset_; | |
| 476 gfx::Transform impl_transform_; | |
| 477 gfx::Vector2dF last_scroll_offset_; | |
| 478 | |
| 479 // The global depth value of the center of the layer. This value is used | |
| 480 // to sort layers from back to front. | |
| 481 float draw_depth_; | |
| 482 | |
| 483 // Debug layer name. | |
| 484 std::string debug_name_; | |
| 485 | |
| 486 WebKit::WebFilterOperations filters_; | |
| 487 WebKit::WebFilterOperations background_filters_; | |
| 488 skia::RefPtr<SkImageFilter> filter_; | |
| 411 | 489 |
| 412 #ifndef NDEBUG | 490 #ifndef NDEBUG |
| 413 bool m_betweenWillDrawAndDidDraw; | 491 bool between_will_draw_and_did_draw_; |
| 414 #endif | 492 #endif |
| 415 | 493 |
| 416 // Rect indicating what was repainted/updated during update. | 494 // Rect indicating what was repainted/updated during update. |
| 417 // Note that plugin layers bypass this and leave it empty. | 495 // Note that plugin layers bypass this and leave it empty. |
| 418 // Uses layer's content space. | 496 // Uses layer's content space. |
| 419 gfx::RectF m_updateRect; | 497 gfx::RectF update_rect_; |
| 420 | 498 |
| 421 // Manages animations for this layer. | 499 // Manages animations for this layer. |
| 422 scoped_refptr<LayerAnimationController> m_layerAnimationController; | 500 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
| 423 | 501 |
| 424 // Manages scrollbars for this layer | 502 // Manages scrollbars for this layer |
| 425 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; | 503 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; |
| 426 | 504 |
| 427 // Weak pointers to this layer's scrollbars, if it has them. Updated during | 505 // Weak pointers to this layer's scrollbars, if it has them. Updated during |
| 428 // tree synchronization. | 506 // tree synchronization. |
| 429 ScrollbarLayerImpl* m_horizontalScrollbarLayer; | 507 ScrollbarLayerImpl* horizontal_scrollbar_layer_; |
| 430 ScrollbarLayerImpl* m_verticalScrollbarLayer; | 508 ScrollbarLayerImpl* vertical_scrollbar_layer_; |
| 431 | 509 |
| 432 // Group of properties that need to be computed based on the layer tree | 510 // Group of properties that need to be computed based on the layer tree |
| 433 // hierarchy before layers can be drawn. | 511 // hierarchy before layers can be drawn. |
| 434 DrawProperties<LayerImpl, RenderSurfaceImpl> m_drawProperties; | 512 DrawProperties<LayerImpl, RenderSurfaceImpl> draw_properties_; |
| 435 | 513 |
| 436 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 514 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
| 437 }; | 515 }; |
| 438 | 516 |
| 439 } | 517 } |
| 440 | 518 |
| 441 #endif // CC_LAYER_IMPL_H_ | 519 #endif // CC_LAYER_IMPL_H_ |
| OLD | NEW |