OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_COMPOSITOR_LAYER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_H_ |
6 #define UI_COMPOSITOR_LAYER_H_ | 6 #define UI_COMPOSITOR_LAYER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // NULL, but the children are not deleted. | 64 // NULL, but the children are not deleted. |
65 class COMPOSITOR_EXPORT Layer | 65 class COMPOSITOR_EXPORT Layer |
66 : public LayerAnimationDelegate, | 66 : public LayerAnimationDelegate, |
67 NON_EXPORTED_BASE(public cc::ContentLayerClient), | 67 NON_EXPORTED_BASE(public cc::ContentLayerClient), |
68 NON_EXPORTED_BASE(public cc::TextureLayerClient), | 68 NON_EXPORTED_BASE(public cc::TextureLayerClient), |
69 NON_EXPORTED_BASE(public cc::LayerClient), | 69 NON_EXPORTED_BASE(public cc::LayerClient), |
70 NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) { | 70 NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) { |
71 public: | 71 public: |
72 Layer(); | 72 Layer(); |
73 explicit Layer(LayerType type); | 73 explicit Layer(LayerType type); |
74 virtual ~Layer(); | 74 ~Layer() override; |
75 | 75 |
76 static bool UsingPictureLayer(); | 76 static bool UsingPictureLayer(); |
77 | 77 |
78 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 78 // Retrieves the Layer's compositor. The Layer will walk up its parent chain |
79 // to locate it. Returns NULL if the Layer is not attached to a compositor. | 79 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
80 Compositor* GetCompositor(); | 80 Compositor* GetCompositor(); |
81 | 81 |
82 // Called by the compositor when the Layer is set as its root Layer. This can | 82 // Called by the compositor when the Layer is set as its root Layer. This can |
83 // only ever be called on the root layer. | 83 // only ever be called on the root layer. |
84 void SetCompositor(Compositor* compositor); | 84 void SetCompositor(Compositor* compositor); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 void OnDeviceScaleFactorChanged(float device_scale_factor); | 318 void OnDeviceScaleFactorChanged(float device_scale_factor); |
319 | 319 |
320 // Notifies the layer that one of its children has received a new | 320 // Notifies the layer that one of its children has received a new |
321 // delegated frame. | 321 // delegated frame. |
322 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip); | 322 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip); |
323 | 323 |
324 // Requets a copy of the layer's output as a texture or bitmap. | 324 // Requets a copy of the layer's output as a texture or bitmap. |
325 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); | 325 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request); |
326 | 326 |
327 // ContentLayerClient | 327 // ContentLayerClient |
328 virtual void PaintContents( | 328 void PaintContents( |
329 SkCanvas* canvas, | 329 SkCanvas* canvas, |
330 const gfx::Rect& clip, | 330 const gfx::Rect& clip, |
331 ContentLayerClient::GraphicsContextStatus gc_status) override; | 331 ContentLayerClient::GraphicsContextStatus gc_status) override; |
332 virtual void DidChangeLayerCanUseLCDText() override {} | 332 void DidChangeLayerCanUseLCDText() override {} |
333 virtual bool FillsBoundsCompletely() const override; | 333 bool FillsBoundsCompletely() const override; |
334 | 334 |
335 cc::Layer* cc_layer() { return cc_layer_; } | 335 cc::Layer* cc_layer() { return cc_layer_; } |
336 | 336 |
337 // TextureLayerClient | 337 // TextureLayerClient |
338 virtual bool PrepareTextureMailbox( | 338 bool PrepareTextureMailbox( |
339 cc::TextureMailbox* mailbox, | 339 cc::TextureMailbox* mailbox, |
340 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 340 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
341 bool use_shared_memory) override; | 341 bool use_shared_memory) override; |
342 | 342 |
343 float device_scale_factor() const { return device_scale_factor_; } | 343 float device_scale_factor() const { return device_scale_factor_; } |
344 | 344 |
345 // Forces a render surface to be used on this layer. This has no positive | 345 // Forces a render surface to be used on this layer. This has no positive |
346 // impact, and is only used for benchmarking/testing purpose. | 346 // impact, and is only used for benchmarking/testing purpose. |
347 void SetForceRenderSurface(bool force); | 347 void SetForceRenderSurface(bool force); |
348 bool force_render_surface() const { return force_render_surface_; } | 348 bool force_render_surface() const { return force_render_surface_; } |
349 | 349 |
350 // LayerClient | 350 // LayerClient |
351 virtual scoped_refptr<base::debug::ConvertableToTraceFormat> | 351 scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo() override; |
352 TakeDebugInfo() override; | |
353 | 352 |
354 // LayerAnimationEventObserver | 353 // LayerAnimationEventObserver |
355 virtual void OnAnimationStarted(const cc::AnimationEvent& event) override; | 354 void OnAnimationStarted(const cc::AnimationEvent& event) override; |
356 | 355 |
357 // Whether this layer has animations waiting to get sent to its cc::Layer. | 356 // Whether this layer has animations waiting to get sent to its cc::Layer. |
358 bool HasPendingThreadedAnimations() { | 357 bool HasPendingThreadedAnimations() { |
359 return pending_threaded_animations_.size() != 0; | 358 return pending_threaded_animations_.size() != 0; |
360 } | 359 } |
361 | 360 |
362 // Triggers a call to SwitchToLayer. | 361 // Triggers a call to SwitchToLayer. |
363 void SwitchCCLayerForTest(); | 362 void SwitchCCLayerForTest(); |
364 | 363 |
365 private: | 364 private: |
366 friend class LayerOwner; | 365 friend class LayerOwner; |
367 | 366 |
368 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators); | 367 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators); |
369 | 368 |
370 // Stacks |child| above or below |other|. Helper method for StackAbove() and | 369 // Stacks |child| above or below |other|. Helper method for StackAbove() and |
371 // StackBelow(). | 370 // StackBelow(). |
372 void StackRelativeTo(Layer* child, Layer* other, bool above); | 371 void StackRelativeTo(Layer* child, Layer* other, bool above); |
373 | 372 |
374 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 373 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
375 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 374 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
376 | 375 |
377 // Implementation of LayerAnimatorDelegate | 376 // Implementation of LayerAnimatorDelegate |
378 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) override; | 377 void SetBoundsFromAnimation(const gfx::Rect& bounds) override; |
379 virtual void SetTransformFromAnimation( | 378 void SetTransformFromAnimation(const gfx::Transform& transform) override; |
380 const gfx::Transform& transform) override; | 379 void SetOpacityFromAnimation(float opacity) override; |
381 virtual void SetOpacityFromAnimation(float opacity) override; | 380 void SetVisibilityFromAnimation(bool visibility) override; |
382 virtual void SetVisibilityFromAnimation(bool visibility) override; | 381 void SetBrightnessFromAnimation(float brightness) override; |
383 virtual void SetBrightnessFromAnimation(float brightness) override; | 382 void SetGrayscaleFromAnimation(float grayscale) override; |
384 virtual void SetGrayscaleFromAnimation(float grayscale) override; | 383 void SetColorFromAnimation(SkColor color) override; |
385 virtual void SetColorFromAnimation(SkColor color) override; | 384 void ScheduleDrawForAnimation() override; |
386 virtual void ScheduleDrawForAnimation() override; | 385 const gfx::Rect& GetBoundsForAnimation() const override; |
387 virtual const gfx::Rect& GetBoundsForAnimation() const override; | 386 gfx::Transform GetTransformForAnimation() const override; |
388 virtual gfx::Transform GetTransformForAnimation() const override; | 387 float GetOpacityForAnimation() const override; |
389 virtual float GetOpacityForAnimation() const override; | 388 bool GetVisibilityForAnimation() const override; |
390 virtual bool GetVisibilityForAnimation() const override; | 389 float GetBrightnessForAnimation() const override; |
391 virtual float GetBrightnessForAnimation() const override; | 390 float GetGrayscaleForAnimation() const override; |
392 virtual float GetGrayscaleForAnimation() const override; | 391 SkColor GetColorForAnimation() const override; |
393 virtual SkColor GetColorForAnimation() const override; | 392 float GetDeviceScaleFactor() const override; |
394 virtual float GetDeviceScaleFactor() const override; | 393 void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) override; |
395 virtual void AddThreadedAnimation( | 394 void RemoveThreadedAnimation(int animation_id) override; |
396 scoped_ptr<cc::Animation> animation) override; | 395 LayerAnimatorCollection* GetLayerAnimatorCollection() override; |
397 virtual void RemoveThreadedAnimation(int animation_id) override; | |
398 virtual LayerAnimatorCollection* GetLayerAnimatorCollection() override; | |
399 | 396 |
400 // Creates a corresponding composited layer for |type_|. | 397 // Creates a corresponding composited layer for |type_|. |
401 void CreateCcLayer(); | 398 void CreateCcLayer(); |
402 | 399 |
403 // Recomputes and sets to |cc_layer_|. | 400 // Recomputes and sets to |cc_layer_|. |
404 void RecomputeDrawsContentAndUVRect(); | 401 void RecomputeDrawsContentAndUVRect(); |
405 void RecomputePosition(); | 402 void RecomputePosition(); |
406 | 403 |
407 // Set all filters which got applied to the layer. | 404 // Set all filters which got applied to the layer. |
408 void SetLayerFilters(); | 405 void SetLayerFilters(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 // The size of the frame or texture in DIP, set when SetShowDelegatedContent | 507 // The size of the frame or texture in DIP, set when SetShowDelegatedContent |
511 // or SetTextureMailbox was called. | 508 // or SetTextureMailbox was called. |
512 gfx::Size frame_size_in_dip_; | 509 gfx::Size frame_size_in_dip_; |
513 | 510 |
514 DISALLOW_COPY_AND_ASSIGN(Layer); | 511 DISALLOW_COPY_AND_ASSIGN(Layer); |
515 }; | 512 }; |
516 | 513 |
517 } // namespace ui | 514 } // namespace ui |
518 | 515 |
519 #endif // UI_COMPOSITOR_LAYER_H_ | 516 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |