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

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

Issue 18341009: Refactor cc scrollbar layers to separate solid-color vs desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments; plumb scrollbar color via flag. Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 CC_LAYERS_SCROLLBAR_LAYER_H_ 5 #ifndef CC_LAYERS_SCROLLBAR_LAYER_H_
6 #define CC_LAYERS_SCROLLBAR_LAYER_H_ 6 #define CC_LAYERS_SCROLLBAR_LAYER_H_
7 7
8 #include "cc/base/cc_export.h" 8 #include "cc/base/cc_export.h"
9 #include "cc/input/scrollbar.h" 9 #include "cc/input/scrollbar.h"
10 #include "cc/layers/contents_scaling_layer.h" 10 #include "cc/layers/contents_scaling_layer.h"
11 #include "cc/layers/scrollbar_layer_interface.h"
11 #include "cc/layers/scrollbar_theme_painter.h" 12 #include "cc/layers/scrollbar_theme_painter.h"
12 #include "cc/resources/layer_updater.h" 13 #include "cc/resources/layer_updater.h"
13 #include "cc/resources/scoped_ui_resource.h" 14 #include "cc/resources/scoped_ui_resource.h"
14 15
15 namespace cc { 16 namespace cc {
16 class ScrollbarThemeComposite; 17 class ScrollbarThemeComposite;
17 18
18 class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer { 19 class CC_EXPORT ScrollbarLayer : public ScrollbarLayerInterface,
20 public ContentsScalingLayer {
19 public: 21 public:
20 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 22 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
21 OVERRIDE; 23 OVERRIDE;
22 24
23 static scoped_refptr<ScrollbarLayer> Create( 25 static scoped_refptr<ScrollbarLayer> Create(
24 scoped_ptr<Scrollbar> scrollbar, 26 scoped_ptr<Scrollbar> scrollbar,
25 int scroll_layer_id); 27 int scroll_layer_id);
26 28
27 int scroll_layer_id() const { return scroll_layer_id_; } 29 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE;
28 void SetScrollLayerId(int id); 30 virtual ScrollbarLayerInterface* ToScrollbarLayer() OVERRIDE;
29 31
30 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; 32 // ScrollbarLayerInterface
33 virtual int ScrollLayerId() const OVERRIDE;
34 virtual void SetScrollLayerId(int id) OVERRIDE;
31 35
32 ScrollbarOrientation Orientation() const; 36 virtual ScrollbarOrientation orientation() const OVERRIDE;
33 37
34 // Layer interface 38 // Layer interface
35 virtual bool Update(ResourceUpdateQueue* queue, 39 virtual bool Update(ResourceUpdateQueue* queue,
36 const OcclusionTracker* occlusion) OVERRIDE; 40 const OcclusionTracker* occlusion) OVERRIDE;
37 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; 41 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
38 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; 42 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
39 virtual void CalculateContentsScale(float ideal_contents_scale, 43 virtual void CalculateContentsScale(float ideal_contents_scale,
40 float device_scale_factor, 44 float device_scale_factor,
41 float page_scale_factor, 45 float page_scale_factor,
42 bool animating_transform_to_screen, 46 bool animating_transform_to_screen,
43 float* contents_scale_x, 47 float* contents_scale_x,
44 float* contents_scale_y, 48 float* contents_scale_y,
45 gfx::Size* content_bounds) OVERRIDE; 49 gfx::Size* content_bounds) OVERRIDE;
46 50
47 virtual ScrollbarLayer* ToScrollbarLayer() OVERRIDE;
48
49 protected: 51 protected:
50 ScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id); 52 ScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id);
51 virtual ~ScrollbarLayer(); 53 virtual ~ScrollbarLayer();
52 54
53 // For unit tests 55 // For unit tests
54 UIResourceId track_resource_id() { 56 UIResourceId track_resource_id() {
55 return track_resource_.get() ? track_resource_->id() : 0; 57 return track_resource_.get() ? track_resource_->id() : 0;
56 } 58 }
57 UIResourceId thumb_resource_id() { 59 UIResourceId thumb_resource_id() {
58 return thumb_resource_.get() ? thumb_resource_->id() : 0; 60 return thumb_resource_.get() ? thumb_resource_->id() : 0;
59 } 61 }
60 62
61 private: 63 private:
62 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; 64 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const;
63 gfx::Rect OriginThumbRect() const; 65 gfx::Rect OriginThumbRect() const;
64 66
65 int MaxTextureSize(); 67 int MaxTextureSize();
66 float ClampScaleToMaxTextureSize(float scale); 68 float ClampScaleToMaxTextureSize(float scale);
67 69
68 scoped_refptr<UIResourceBitmap> RasterizeScrollbarPart(gfx::Rect rect, 70 scoped_refptr<UIResourceBitmap> RasterizeScrollbarPart(gfx::Rect rect,
69 ScrollbarPart part); 71 ScrollbarPart part);
70 72
73 int scroll_layer_id_;
74
71 scoped_ptr<Scrollbar> scrollbar_; 75 scoped_ptr<Scrollbar> scrollbar_;
72 76
73 int thumb_thickness_; 77 int thumb_thickness_;
74 int thumb_length_; 78 int thumb_length_;
75 gfx::Rect track_rect_; 79 gfx::Rect track_rect_;
76 int scroll_layer_id_;
77 80
78 scoped_ptr<ScopedUIResource> track_resource_; 81 scoped_ptr<ScopedUIResource> track_resource_;
79 scoped_ptr<ScopedUIResource> thumb_resource_; 82 scoped_ptr<ScopedUIResource> thumb_resource_;
80 83
81 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayer); 84 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayer);
82 }; 85 };
83 86
84 } // namespace cc 87 } // namespace cc
85 88
86 #endif // CC_LAYERS_SCROLLBAR_LAYER_H_ 89 #endif // CC_LAYERS_SCROLLBAR_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698