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_LAYERS_LAYER_IMPL_H_ | 5 #ifndef CC_LAYERS_LAYER_IMPL_H_ |
6 #define CC_LAYERS_LAYER_IMPL_H_ | 6 #define CC_LAYERS_LAYER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class LayerTreeHostImpl; | 42 class LayerTreeHostImpl; |
43 class LayerTreeImpl; | 43 class LayerTreeImpl; |
44 class QuadSink; | 44 class QuadSink; |
45 class Renderer; | 45 class Renderer; |
46 class ScrollbarAnimationController; | 46 class ScrollbarAnimationController; |
47 class ScrollbarLayerImpl; | 47 class ScrollbarLayerImpl; |
48 class Layer; | 48 class Layer; |
49 | 49 |
50 struct AppendQuadsData; | 50 struct AppendQuadsData; |
51 | 51 |
| 52 enum DrawMode { |
| 53 DRAW_MODE_NONE, |
| 54 DRAW_MODE_HARDWARE, |
| 55 DRAW_MODE_SOFTWARE, |
| 56 DRAW_MODE_RESOURCELESS_SOFTWARE |
| 57 }; |
| 58 |
52 class CC_EXPORT LayerImpl : LayerAnimationValueObserver { | 59 class CC_EXPORT LayerImpl : LayerAnimationValueObserver { |
53 public: | 60 public: |
54 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 61 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
55 return make_scoped_ptr(new LayerImpl(tree_impl, id)); | 62 return make_scoped_ptr(new LayerImpl(tree_impl, id)); |
56 } | 63 } |
57 | 64 |
58 virtual ~LayerImpl(); | 65 virtual ~LayerImpl(); |
59 | 66 |
60 int id() const { return layer_id_; } | 67 int id() const { return layer_id_; } |
61 | 68 |
(...skipping 30 matching lines...) Expand all Loading... |
92 | 99 |
93 bool has_mask() const { return mask_layer_; } | 100 bool has_mask() const { return mask_layer_; } |
94 bool has_replica() const { return replica_layer_; } | 101 bool has_replica() const { return replica_layer_; } |
95 bool replica_has_mask() const { | 102 bool replica_has_mask() const { |
96 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); | 103 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); |
97 } | 104 } |
98 | 105 |
99 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } | 106 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } |
100 | 107 |
101 scoped_ptr<SharedQuadState> CreateSharedQuadState() const; | 108 scoped_ptr<SharedQuadState> CreateSharedQuadState() const; |
102 // WillDraw must be called before AppendQuads. If WillDraw is called, | 109 // WillDraw must be called before AppendQuads. If WillDraw returns false, |
| 110 // AppendQuads and DidDraw will not be called. If WillDraw returns true, |
103 // DidDraw is guaranteed to be called before another WillDraw or before | 111 // DidDraw is guaranteed to be called before another WillDraw or before |
104 // the layer is destroyed. To enforce this, any class that overrides | 112 // the layer is destroyed. To enforce this, any class that overrides |
105 // WillDraw/DqidDraw must call the base class version. | 113 // WillDraw/DidDraw must call the base class version only if WillDraw |
106 virtual void WillDraw(ResourceProvider* resource_provider); | 114 // returns true. |
| 115 virtual bool WillDraw(DrawMode draw_mode, |
| 116 ResourceProvider* resource_provider); |
107 virtual void AppendQuads(QuadSink* quad_sink, | 117 virtual void AppendQuads(QuadSink* quad_sink, |
108 AppendQuadsData* append_quads_data) {} | 118 AppendQuadsData* append_quads_data) {} |
109 virtual void DidDraw(ResourceProvider* resource_provider); | 119 virtual void DidDraw(ResourceProvider* resource_provider); |
110 | 120 |
111 virtual ResourceProvider::ResourceId ContentsResourceId() const; | 121 virtual ResourceProvider::ResourceId ContentsResourceId() const; |
112 | 122 |
113 virtual bool HasDelegatedContent() const; | 123 virtual bool HasDelegatedContent() const; |
114 virtual bool HasContributingDelegatedRenderPasses() const; | 124 virtual bool HasContributingDelegatedRenderPasses() const; |
115 virtual RenderPass::Id FirstContributingRenderPassId() const; | 125 virtual RenderPass::Id FirstContributingRenderPassId() const; |
116 virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const; | 126 virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 float draw_depth_; | 533 float draw_depth_; |
524 | 534 |
525 // Debug layer name. | 535 // Debug layer name. |
526 std::string debug_name_; | 536 std::string debug_name_; |
527 CompositingReasons compositing_reasons_; | 537 CompositingReasons compositing_reasons_; |
528 | 538 |
529 WebKit::WebFilterOperations filters_; | 539 WebKit::WebFilterOperations filters_; |
530 WebKit::WebFilterOperations background_filters_; | 540 WebKit::WebFilterOperations background_filters_; |
531 skia::RefPtr<SkImageFilter> filter_; | 541 skia::RefPtr<SkImageFilter> filter_; |
532 | 542 |
533 #ifndef NDEBUG | 543 protected: |
534 bool between_will_draw_and_did_draw_; | 544 DrawMode current_draw_mode_; |
535 #endif | |
536 | 545 |
| 546 private: |
537 // Rect indicating what was repainted/updated during update. | 547 // Rect indicating what was repainted/updated during update. |
538 // Note that plugin layers bypass this and leave it empty. | 548 // Note that plugin layers bypass this and leave it empty. |
539 // Uses layer's content space. | 549 // Uses layer's content space. |
540 gfx::RectF update_rect_; | 550 gfx::RectF update_rect_; |
541 | 551 |
542 // Manages animations for this layer. | 552 // Manages animations for this layer. |
543 scoped_refptr<LayerAnimationController> layer_animation_controller_; | 553 scoped_refptr<LayerAnimationController> layer_animation_controller_; |
544 | 554 |
545 // Manages scrollbars for this layer | 555 // Manages scrollbars for this layer |
546 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; | 556 scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_; |
547 | 557 |
548 // Weak pointers to this layer's scrollbars, if it has them. Updated during | 558 // Weak pointers to this layer's scrollbars, if it has them. Updated during |
549 // tree synchronization. | 559 // tree synchronization. |
550 ScrollbarLayerImpl* horizontal_scrollbar_layer_; | 560 ScrollbarLayerImpl* horizontal_scrollbar_layer_; |
551 ScrollbarLayerImpl* vertical_scrollbar_layer_; | 561 ScrollbarLayerImpl* vertical_scrollbar_layer_; |
552 | 562 |
553 ScopedPtrVector<CopyOutputRequest> copy_requests_; | 563 ScopedPtrVector<CopyOutputRequest> copy_requests_; |
554 | 564 |
555 // Group of properties that need to be computed based on the layer tree | 565 // Group of properties that need to be computed based on the layer tree |
556 // hierarchy before layers can be drawn. | 566 // hierarchy before layers can be drawn. |
557 DrawProperties<LayerImpl, RenderSurfaceImpl> draw_properties_; | 567 DrawProperties<LayerImpl, RenderSurfaceImpl> draw_properties_; |
558 | 568 |
559 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 569 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
560 }; | 570 }; |
561 | 571 |
562 } // namespace cc | 572 } // namespace cc |
563 | 573 |
564 #endif // CC_LAYERS_LAYER_IMPL_H_ | 574 #endif // CC_LAYERS_LAYER_IMPL_H_ |
OLD | NEW |