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