Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: cc/layers/painted_scrollbar_layer.h

Issue 2816063003: Replace layer id with Element id for tracking scrollbar animation controllers (Closed)
Patch Set: Address reviewer comments, pull element_id.h change to another patch Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_PAINTED_SCROLLBAR_LAYER_H_ 5 #ifndef CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_
6 #define CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ 6 #define CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "cc/cc_export.h" 9 #include "cc/cc_export.h"
10 #include "cc/input/scrollbar.h" 10 #include "cc/input/scrollbar.h"
11 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
12 #include "cc/layers/scrollbar_layer_interface.h" 12 #include "cc/layers/scrollbar_layer_interface.h"
13 #include "cc/layers/scrollbar_theme_painter.h" 13 #include "cc/layers/scrollbar_theme_painter.h"
14 #include "cc/resources/scoped_ui_resource.h" 14 #include "cc/resources/scoped_ui_resource.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, 18 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface,
19 public Layer { 19 public Layer {
20 public: 20 public:
21 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; 21 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
22 22
23 static scoped_refptr<PaintedScrollbarLayer> Create( 23 static scoped_refptr<PaintedScrollbarLayer> Create(
24 std::unique_ptr<Scrollbar> scrollbar, 24 std::unique_ptr<Scrollbar> scrollbar,
25 int scroll_layer_id); 25 int scroll_layer_id,
26 ElementId element_id = ElementId());
26 27
27 bool OpacityCanAnimateOnImplThread() const override; 28 bool OpacityCanAnimateOnImplThread() const override;
28 bool AlwaysUseActiveTreeOpacity() const override; 29 bool AlwaysUseActiveTreeOpacity() const override;
29 ScrollbarLayerInterface* ToScrollbarLayer() override; 30 ScrollbarLayerInterface* ToScrollbarLayer() override;
30 31
31 // ScrollbarLayerInterface 32 // ScrollbarLayerInterface
32 int ScrollLayerId() const override; 33 ElementId scroll_element_id() const override;
33 void SetScrollLayer(int layer_id) override; 34 // TODO(pdr): Remove layer_id and refactor scrollbars to just use element ids.
35 void SetScrollInfo(int layer_id, ElementId element_id) override;
34 36
35 ScrollbarOrientation orientation() const override; 37 ScrollbarOrientation orientation() const override;
36 38
37 // Layer interface 39 // Layer interface
38 bool Update() override; 40 bool Update() override;
39 void SetLayerTreeHost(LayerTreeHost* host) override; 41 void SetLayerTreeHost(LayerTreeHost* host) override;
40 void PushPropertiesTo(LayerImpl* layer) override; 42 void PushPropertiesTo(LayerImpl* layer) override;
41 43
42 const gfx::Size& internal_content_bounds() const { 44 const gfx::Size& internal_content_bounds() const {
43 return internal_content_bounds_; 45 return internal_content_bounds_;
44 } 46 }
45 47
46 protected: 48 protected:
47 PaintedScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar, 49 PaintedScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar,
48 int scroll_layer_id); 50 int scroll_layer_id,
51 ElementId scroll_element_id);
49 ~PaintedScrollbarLayer() override; 52 ~PaintedScrollbarLayer() override;
50 53
51 // For unit tests 54 // For unit tests
52 UIResourceId track_resource_id() { 55 UIResourceId track_resource_id() {
53 return track_resource_.get() ? track_resource_->id() : 0; 56 return track_resource_.get() ? track_resource_->id() : 0;
54 } 57 }
55 UIResourceId thumb_resource_id() { 58 UIResourceId thumb_resource_id() {
56 return thumb_resource_.get() ? thumb_resource_->id() : 0; 59 return thumb_resource_.get() ? thumb_resource_->id() : 0;
57 } 60 }
58 void UpdateInternalContentScale(); 61 void UpdateInternalContentScale();
(...skipping 11 matching lines...) Expand all
70 SetNeedsPushProperties(); 73 SetNeedsPushProperties();
71 return true; 74 return true;
72 } 75 }
73 76
74 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& layer_rect, 77 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& layer_rect,
75 const gfx::Rect& content_rect, 78 const gfx::Rect& content_rect,
76 ScrollbarPart part); 79 ScrollbarPart part);
77 80
78 std::unique_ptr<Scrollbar> scrollbar_; 81 std::unique_ptr<Scrollbar> scrollbar_;
79 int scroll_layer_id_; 82 int scroll_layer_id_;
83 ElementId scroll_element_id_;
80 84
81 float internal_contents_scale_; 85 float internal_contents_scale_;
82 gfx::Size internal_content_bounds_; 86 gfx::Size internal_content_bounds_;
83 87
84 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in 88 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in
85 // PushPropertiesTo. 89 // PushPropertiesTo.
86 int thumb_thickness_; 90 int thumb_thickness_;
87 int thumb_length_; 91 int thumb_length_;
88 gfx::Point location_; 92 gfx::Point location_;
89 gfx::Rect track_rect_; 93 gfx::Rect track_rect_;
90 bool is_overlay_; 94 bool is_overlay_;
91 bool has_thumb_; 95 bool has_thumb_;
92 96
93 std::unique_ptr<ScopedUIResource> track_resource_; 97 std::unique_ptr<ScopedUIResource> track_resource_;
94 std::unique_ptr<ScopedUIResource> thumb_resource_; 98 std::unique_ptr<ScopedUIResource> thumb_resource_;
95 99
96 float thumb_opacity_; 100 float thumb_opacity_;
97 101
98 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer); 102 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer);
99 }; 103 };
100 104
101 } // namespace cc 105 } // namespace cc
102 106
103 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ 107 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698