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 <public/WebFilterOperations.h> | 8 #include <public/WebFilterOperations.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "cc/cc_export.h" | 13 #include "cc/cc_export.h" |
| 14 #include "cc/draw_properties.h" |
14 #include "cc/input_handler.h" | 15 #include "cc/input_handler.h" |
15 #include "cc/layer_animation_controller.h" | 16 #include "cc/layer_animation_controller.h" |
16 #include "cc/region.h" | 17 #include "cc/region.h" |
17 #include "cc/render_pass.h" | 18 #include "cc/render_pass.h" |
18 #include "cc/render_surface_impl.h" | 19 #include "cc/render_surface_impl.h" |
19 #include "cc/resource_provider.h" | 20 #include "cc/resource_provider.h" |
20 #include "cc/scoped_ptr_vector.h" | 21 #include "cc/scoped_ptr_vector.h" |
21 #include "cc/shared_quad_state.h" | 22 #include "cc/shared_quad_state.h" |
22 #include "skia/ext/refptr.h" | 23 #include "skia/ext/refptr.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 154 |
154 void setSublayerTransform(const gfx::Transform&); | 155 void setSublayerTransform(const gfx::Transform&); |
155 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } | 156 const gfx::Transform& sublayerTransform() const { return m_sublayerTransform
; } |
156 | 157 |
157 // Debug layer name. | 158 // Debug layer name. |
158 void setDebugName(const std::string& debugName) { m_debugName = debugName; } | 159 void setDebugName(const std::string& debugName) { m_debugName = debugName; } |
159 std::string debugName() const { return m_debugName; } | 160 std::string debugName() const { return m_debugName; } |
160 | 161 |
161 bool showDebugBorders() const; | 162 bool showDebugBorders() const; |
162 | 163 |
163 RenderSurfaceImpl* renderSurface() const { return m_renderSurface.get(); } | |
164 void createRenderSurface(); | 164 void createRenderSurface(); |
165 void clearRenderSurface() { m_renderSurface.reset(); } | 165 void clearRenderSurface() { m_drawProperties.render_surface.reset(); } |
166 | 166 |
167 float drawOpacity() const { return m_drawOpacity; } | 167 DrawProperties<LayerImpl, RenderSurfaceImpl>& drawProperties() { return m_dr
awProperties; } |
168 void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } | 168 const DrawProperties<LayerImpl, RenderSurfaceImpl>& drawProperties() const {
return m_drawProperties; } |
169 | 169 |
170 bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; } | 170 // The following are shortcut accessors to get various information from m_dr
awProperties |
171 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityI
sAnimating = drawOpacityIsAnimating; } | 171 const gfx::Transform& drawTransform() const { return m_drawProperties.target
_space_transform; } |
172 | 172 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties
.screen_space_transform; } |
173 void setRenderTarget(LayerImpl* target) { m_renderTarget = target; } | 173 float drawOpacity() const { return m_drawProperties.opacity; } |
174 LayerImpl* renderTarget() { DCHECK(!m_renderTarget || m_renderTarget->render
Surface()); return m_renderTarget; } | 174 bool drawOpacityIsAnimating() const { return m_drawProperties.opacity_is_ani
mating; } |
175 const LayerImpl* renderTarget() const { DCHECK(!m_renderTarget || m_renderTa
rget->renderSurface()); return m_renderTarget; } | 175 bool drawTransformIsAnimating() const { return m_drawProperties.target_space
_transform_is_animating; } |
| 176 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree
n_space_transform_is_animating; } |
| 177 bool isClipped() const { return m_drawProperties.is_clipped; } |
| 178 const gfx::Rect& clipRect() const { return m_drawProperties.clip_rect; } |
| 179 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa
ble_content_rect; } |
| 180 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl
e_content_rect; } |
| 181 LayerImpl* renderTarget() { DCHECK(!m_drawProperties.render_target || m_draw
Properties.render_target->renderSurface()); return m_drawProperties.render_targe
t; } |
| 182 const LayerImpl* renderTarget() const { DCHECK(!m_drawProperties.render_targ
et || m_drawProperties.render_target->renderSurface()); return m_drawProperties.
render_target; } |
| 183 RenderSurfaceImpl* renderSurface() const { return m_drawProperties.render_su
rface.get(); } |
176 | 184 |
177 // The client should be responsible for setting bounds, contentBounds and | 185 // The client should be responsible for setting bounds, contentBounds and |
178 // contentsScale to appropriate values. LayerImpl doesn't calculate any of | 186 // contentsScale to appropriate values. LayerImpl doesn't calculate any of |
179 // them from the other values. | 187 // them from the other values. |
180 | 188 |
181 void setBounds(const gfx::Size&); | 189 void setBounds(const gfx::Size&); |
182 const gfx::Size& bounds() const { return m_bounds; } | 190 const gfx::Size& bounds() const { return m_bounds; } |
183 | 191 |
184 // ContentBounds may be [0, 1) pixels larger than bounds * contentsScale. | 192 // ContentBounds may be [0, 1) pixels larger than bounds * contentsScale. |
185 // Don't calculate scale from it. Use contentsScale instead for accuracy. | 193 // Don't calculate scale from it. Use contentsScale instead for accuracy. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR
egion = region; } | 229 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR
egion = region; } |
222 | 230 |
223 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe
gion; } | 231 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe
gion; } |
224 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR
egion = region; } | 232 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR
egion = region; } |
225 | 233 |
226 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo
ardForMissingTiles = checkerboard; } | 234 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo
ardForMissingTiles = checkerboard; } |
227 bool drawCheckerboardForMissingTiles() const; | 235 bool drawCheckerboardForMissingTiles() const; |
228 | 236 |
229 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi
nt, InputHandlerClient::ScrollInputType) const; | 237 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi
nt, InputHandlerClient::ScrollInputType) const; |
230 | 238 |
231 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } | |
232 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC
ontentRect = visibleContentRect; } | |
233 | |
234 bool doubleSided() const { return m_doubleSided; } | 239 bool doubleSided() const { return m_doubleSided; } |
235 void setDoubleSided(bool); | 240 void setDoubleSided(bool); |
236 | 241 |
237 void setTransform(const gfx::Transform&); | 242 void setTransform(const gfx::Transform&); |
238 bool transformIsAnimating() const; | 243 bool transformIsAnimating() const; |
239 | 244 |
240 const gfx::Transform& drawTransform() const { return m_drawTransform; } | |
241 void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matr
ix; } | |
242 const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTra
nsform; } | |
243 void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTr
ansform = matrix; } | |
244 | |
245 bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; } | |
246 void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimatin
g = animating; } | |
247 bool screenSpaceTransformIsAnimating() const { return m_screenSpaceTransform
IsAnimating; } | |
248 void setScreenSpaceTransformIsAnimating(bool animating) { m_screenSpaceTrans
formIsAnimating = animating; } | |
249 | |
250 bool isClipped() const { return m_isClipped; } | |
251 void setIsClipped(bool isClipped) { m_isClipped = isClipped; } | |
252 | |
253 const gfx::Rect& clipRect() const { return m_clipRect; } | |
254 void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; } | |
255 | |
256 const gfx::Rect& drawableContentRect() const { return m_drawableContentRect;
} | |
257 void setDrawableContentRect(const gfx::Rect& rect) { m_drawableContentRect =
rect; } | |
258 | |
259 const gfx::RectF& updateRect() const { return m_updateRect; } | 245 const gfx::RectF& updateRect() const { return m_updateRect; } |
260 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect
; } | 246 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect
; } |
261 | 247 |
262 std::string layerTreeAsText() const; | 248 std::string layerTreeAsText() const; |
263 | 249 |
264 void setStackingOrderChanged(bool); | 250 void setStackingOrderChanged(bool); |
265 | 251 |
266 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs
AlwaysDamaged(); } | 252 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs
AlwaysDamaged(); } |
267 bool layerSurfacePropertyChanged() const; | 253 bool layerSurfacePropertyChanged() const; |
268 | 254 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 335 |
350 // Tracks if drawing-related properties have changed since last redraw. | 336 // Tracks if drawing-related properties have changed since last redraw. |
351 bool m_layerPropertyChanged; | 337 bool m_layerPropertyChanged; |
352 | 338 |
353 // Indicates that a property has changed on this layer that would not | 339 // Indicates that a property has changed on this layer that would not |
354 // affect the pixels on its target surface, but would require redrawing | 340 // affect the pixels on its target surface, but would require redrawing |
355 // but would require redrawing the targetSurface onto its ancestor targetSur
face. | 341 // but would require redrawing the targetSurface onto its ancestor targetSur
face. |
356 // For layers that do not own a surface this flag acts as m_layerPropertyCha
nged. | 342 // For layers that do not own a surface this flag acts as m_layerPropertyCha
nged. |
357 bool m_layerSurfacePropertyChanged; | 343 bool m_layerSurfacePropertyChanged; |
358 | 344 |
359 // Uses layer's content space. | |
360 gfx::Rect m_visibleContentRect; | |
361 bool m_masksToBounds; | 345 bool m_masksToBounds; |
362 bool m_contentsOpaque; | 346 bool m_contentsOpaque; |
363 float m_opacity; | 347 float m_opacity; |
364 gfx::PointF m_position; | 348 gfx::PointF m_position; |
365 bool m_preserves3D; | 349 bool m_preserves3D; |
366 bool m_useParentBackfaceVisibility; | 350 bool m_useParentBackfaceVisibility; |
367 bool m_drawCheckerboardForMissingTiles; | 351 bool m_drawCheckerboardForMissingTiles; |
368 gfx::Transform m_sublayerTransform; | 352 gfx::Transform m_sublayerTransform; |
369 gfx::Transform m_transform; | 353 gfx::Transform m_transform; |
370 bool m_useLCDText; | 354 bool m_useLCDText; |
371 | 355 |
372 bool m_drawsContent; | 356 bool m_drawsContent; |
373 bool m_forceRenderSurface; | 357 bool m_forceRenderSurface; |
374 | 358 |
375 // Set for the layer that other layers are fixed to. | 359 // Set for the layer that other layers are fixed to. |
376 bool m_isContainerForFixedPositionLayers; | 360 bool m_isContainerForFixedPositionLayers; |
377 // This is true if the layer should be fixed to the closest ancestor contain
er. | 361 // This is true if the layer should be fixed to the closest ancestor contain
er. |
378 bool m_fixedToContainerLayer; | 362 bool m_fixedToContainerLayer; |
379 | 363 |
380 gfx::Vector2dF m_scrollDelta; | 364 gfx::Vector2dF m_scrollDelta; |
381 gfx::Vector2d m_sentScrollDelta; | 365 gfx::Vector2d m_sentScrollDelta; |
382 gfx::Vector2d m_maxScrollOffset; | 366 gfx::Vector2d m_maxScrollOffset; |
383 gfx::Transform m_implTransform; | 367 gfx::Transform m_implTransform; |
384 | 368 |
385 // The layer whose coordinate space this layer draws into. This can be | |
386 // either the same layer (m_renderTarget == this) or an ancestor of this | |
387 // layer. | |
388 LayerImpl* m_renderTarget; | |
389 | |
390 // The global depth value of the center of the layer. This value is used | 369 // The global depth value of the center of the layer. This value is used |
391 // to sort layers from back to front. | 370 // to sort layers from back to front. |
392 float m_drawDepth; | 371 float m_drawDepth; |
393 float m_drawOpacity; | |
394 bool m_drawOpacityIsAnimating; | |
395 | 372 |
396 // Debug layer name. | 373 // Debug layer name. |
397 std::string m_debugName; | 374 std::string m_debugName; |
398 | 375 |
399 WebKit::WebFilterOperations m_filters; | 376 WebKit::WebFilterOperations m_filters; |
400 WebKit::WebFilterOperations m_backgroundFilters; | 377 WebKit::WebFilterOperations m_backgroundFilters; |
401 skia::RefPtr<SkImageFilter> m_filter; | 378 skia::RefPtr<SkImageFilter> m_filter; |
402 | 379 |
403 gfx::Transform m_drawTransform; | |
404 gfx::Transform m_screenSpaceTransform; | |
405 bool m_drawTransformIsAnimating; | |
406 bool m_screenSpaceTransformIsAnimating; | |
407 | |
408 #ifndef NDEBUG | 380 #ifndef NDEBUG |
409 bool m_betweenWillDrawAndDidDraw; | 381 bool m_betweenWillDrawAndDidDraw; |
410 #endif | 382 #endif |
411 | 383 |
412 // Render surface associated with this layer. The layer and its descendants | |
413 // will render to this surface. | |
414 scoped_ptr<RenderSurfaceImpl> m_renderSurface; | |
415 | |
416 // Uses target surface's space. | |
417 gfx::Rect m_drawableContentRect; | |
418 gfx::Rect m_clipRect; | |
419 | |
420 // True if the layer is clipped by m_clipRect. | |
421 bool m_isClipped; | |
422 | |
423 // Rect indicating what was repainted/updated during update. | 384 // Rect indicating what was repainted/updated during update. |
424 // Note that plugin layers bypass this and leave it empty. | 385 // Note that plugin layers bypass this and leave it empty. |
425 // Uses layer's content space. | 386 // Uses layer's content space. |
426 gfx::RectF m_updateRect; | 387 gfx::RectF m_updateRect; |
427 | 388 |
428 // Manages animations for this layer. | 389 // Manages animations for this layer. |
429 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 390 scoped_ptr<LayerAnimationController> m_layerAnimationController; |
430 | 391 |
431 // Manages scrollbars for this layer | 392 // Manages scrollbars for this layer |
432 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; | 393 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; |
433 | 394 |
| 395 // Group of properties that need to be computed based on the layer tree |
| 396 // hierarchy before layers can be drawn. |
| 397 DrawProperties<LayerImpl, RenderSurfaceImpl> m_drawProperties; |
| 398 |
434 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 399 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
435 }; | 400 }; |
436 | 401 |
437 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*>
::iterator end, LayerSorter*); | 402 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*>
::iterator end, LayerSorter*); |
438 | 403 |
439 } | 404 } |
440 | 405 |
441 #endif // CC_LAYER_IMPL_H_ | 406 #endif // CC_LAYER_IMPL_H_ |
OLD | NEW |