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

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

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add fix for empty scroll-layer bounds. Created 6 years, 11 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 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 "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_layer_interface.h"
12 #include "cc/layers/scrollbar_theme_painter.h" 12 #include "cc/layers/scrollbar_theme_painter.h"
13 #include "cc/resources/layer_updater.h" 13 #include "cc/resources/layer_updater.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 class ScrollbarThemeComposite; 17 class ScrollbarThemeComposite;
18 18
19 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, 19 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface,
20 public ContentsScalingLayer { 20 public ContentsScalingLayer {
21 public: 21 public:
22 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 22 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
23 OVERRIDE; 23 OVERRIDE;
24 24
25 static scoped_refptr<PaintedScrollbarLayer> Create( 25 static scoped_refptr<PaintedScrollbarLayer> Create(
26 scoped_ptr<Scrollbar> scrollbar, 26 scoped_ptr<Scrollbar> scrollbar,
27 int scroll_layer_id); 27 Layer* scroll_layer);
28 28
29 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; 29 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE;
30 virtual ScrollbarLayerInterface* ToScrollbarLayer() OVERRIDE; 30 virtual ScrollbarLayerInterface* ToScrollbarLayer() OVERRIDE;
31 31
32 // ScrollbarLayerInterface 32 // ScrollbarLayerInterface
33 virtual int ScrollLayerId() const OVERRIDE; 33 virtual int ScrollLayerId() const OVERRIDE;
34 virtual void SetScrollLayerId(int id) OVERRIDE; 34 virtual void SetScrollLayer(scoped_refptr<Layer> layer) OVERRIDE;
35 virtual void SetClipLayer(scoped_refptr<Layer> layer) OVERRIDE;
35 36
36 virtual ScrollbarOrientation orientation() const OVERRIDE; 37 virtual ScrollbarOrientation orientation() const OVERRIDE;
37 38
38 // Layer interface 39 // Layer interface
39 virtual bool Update(ResourceUpdateQueue* queue, 40 virtual bool Update(ResourceUpdateQueue* queue,
40 const OcclusionTracker* occlusion) OVERRIDE; 41 const OcclusionTracker* occlusion) OVERRIDE;
41 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; 42 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
42 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; 43 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
44 virtual void PushScrollClipPropertiesTo(LayerImpl* layer) OVERRIDE;
43 virtual void CalculateContentsScale(float ideal_contents_scale, 45 virtual void CalculateContentsScale(float ideal_contents_scale,
44 float device_scale_factor, 46 float device_scale_factor,
45 float page_scale_factor, 47 float page_scale_factor,
46 bool animating_transform_to_screen, 48 bool animating_transform_to_screen,
47 float* contents_scale_x, 49 float* contents_scale_x,
48 float* contents_scale_y, 50 float* contents_scale_y,
49 gfx::Size* content_bounds) OVERRIDE; 51 gfx::Size* content_bounds) OVERRIDE;
50 52
51 protected: 53 protected:
52 PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id); 54 PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, Layer* scroll_layer);
53 virtual ~PaintedScrollbarLayer(); 55 virtual ~PaintedScrollbarLayer();
54 56
55 // For unit tests 57 // For unit tests
56 UIResourceId track_resource_id() { 58 UIResourceId track_resource_id() {
57 return track_resource_.get() ? track_resource_->id() : 0; 59 return track_resource_.get() ? track_resource_->id() : 0;
58 } 60 }
59 UIResourceId thumb_resource_id() { 61 UIResourceId thumb_resource_id() {
60 return thumb_resource_.get() ? thumb_resource_->id() : 0; 62 return thumb_resource_.get() ? thumb_resource_->id() : 0;
61 } 63 }
62 void UpdateThumbAndTrackGeometry(); 64 void UpdateThumbAndTrackGeometry();
63 65
64 private: 66 private:
65 gfx::Rect ScrollbarLayerRectToContentRect(const gfx::Rect& layer_rect) const; 67 gfx::Rect ScrollbarLayerRectToContentRect(const gfx::Rect& layer_rect) const;
66 gfx::Rect OriginThumbRect() const; 68 gfx::Rect OriginThumbRect() const;
67 69
68 template<typename T> void UpdateProperty(T value, T* prop) { 70 template<typename T> void UpdateProperty(T value, T* prop) {
69 if (*prop == value) 71 if (*prop == value)
70 return; 72 return;
71 *prop = value; 73 *prop = value;
72 SetNeedsPushProperties(); 74 SetNeedsPushProperties();
73 } 75 }
74 76
75 int MaxTextureSize(); 77 int MaxTextureSize();
76 float ClampScaleToMaxTextureSize(float scale); 78 float ClampScaleToMaxTextureSize(float scale);
77 79
78 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& rect, 80 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& rect,
79 ScrollbarPart part); 81 ScrollbarPart part);
80 82
81 scoped_ptr<Scrollbar> scrollbar_; 83 scoped_ptr<Scrollbar> scrollbar_;
82 int scroll_layer_id_; 84 scoped_refptr<Layer> scroll_layer_;
aelias_OOO_until_Jul13 2014/01/16 03:44:04 Can this be a weak pointer instead? Refptrs risk
wjmaclean 2014/01/16 15:07:32 I will investigate, and re-use the one in Scrollba
85 scoped_refptr<Layer> clip_layer_;
83 86
84 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in 87 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in
85 // PushPropertiesTo. 88 // PushPropertiesTo.
86 int thumb_thickness_; 89 int thumb_thickness_;
87 int thumb_length_; 90 int thumb_length_;
88 gfx::Point location_; 91 gfx::Point location_;
89 gfx::Rect track_rect_; 92 gfx::Rect track_rect_;
90 bool is_overlay_; 93 bool is_overlay_;
91 bool has_thumb_; 94 bool has_thumb_;
92 95
93 scoped_ptr<ScopedUIResource> track_resource_; 96 scoped_ptr<ScopedUIResource> track_resource_;
94 scoped_ptr<ScopedUIResource> thumb_resource_; 97 scoped_ptr<ScopedUIResource> thumb_resource_;
95 98
96 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer); 99 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer);
97 }; 100 };
98 101
99 } // namespace cc 102 } // namespace cc
100 103
101 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ 104 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698