Abstract GoogleURLTracker & google_util Profile dependencies
[chromium-blink-merge.git] / cc / layers / painted_scrollbar_layer.h
blobd684d322fada7f039e887176c7f6402abcad394e
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
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_
6 #define CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/input/scrollbar.h"
10 #include "cc/layers/contents_scaling_layer.h"
11 #include "cc/layers/scrollbar_layer_interface.h"
12 #include "cc/layers/scrollbar_theme_painter.h"
13 #include "cc/resources/layer_updater.h"
14 #include "cc/resources/scoped_ui_resource.h"
16 namespace cc {
17 class ScrollbarThemeComposite;
19 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface,
20 public ContentsScalingLayer {
21 public:
22 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
23 OVERRIDE;
25 static scoped_refptr<PaintedScrollbarLayer> Create(
26 scoped_ptr<Scrollbar> scrollbar,
27 int scroll_layer_id);
29 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE;
30 virtual ScrollbarLayerInterface* ToScrollbarLayer() OVERRIDE;
32 // ScrollbarLayerInterface
33 virtual int ScrollLayerId() const OVERRIDE;
34 virtual void SetScrollLayer(int layer_id) OVERRIDE;
35 virtual void SetClipLayer(int layer_id) OVERRIDE;
37 virtual ScrollbarOrientation orientation() const OVERRIDE;
39 // Layer interface
40 virtual bool Update(ResourceUpdateQueue* queue,
41 const OcclusionTracker<Layer>* occlusion) OVERRIDE;
42 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
43 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
44 virtual void PushScrollClipPropertiesTo(LayerImpl* layer) OVERRIDE;
45 virtual void CalculateContentsScale(float ideal_contents_scale,
46 float device_scale_factor,
47 float page_scale_factor,
48 float maximum_animation_contents_scale,
49 bool animating_transform_to_screen,
50 float* contents_scale_x,
51 float* contents_scale_y,
52 gfx::Size* content_bounds) OVERRIDE;
54 protected:
55 PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id);
56 virtual ~PaintedScrollbarLayer();
58 // For unit tests
59 UIResourceId track_resource_id() {
60 return track_resource_.get() ? track_resource_->id() : 0;
62 UIResourceId thumb_resource_id() {
63 return thumb_resource_.get() ? thumb_resource_->id() : 0;
65 void UpdateThumbAndTrackGeometry();
67 private:
68 gfx::Rect ScrollbarLayerRectToContentRect(const gfx::Rect& layer_rect) const;
69 gfx::Rect OriginThumbRect() const;
71 template<typename T> void UpdateProperty(T value, T* prop) {
72 if (*prop == value)
73 return;
74 *prop = value;
75 SetNeedsPushProperties();
78 int MaxTextureSize();
79 float ClampScaleToMaxTextureSize(float scale);
81 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& layer_rect,
82 const gfx::Rect& content_rect,
83 ScrollbarPart part);
85 scoped_ptr<Scrollbar> scrollbar_;
86 int scroll_layer_id_;
87 int clip_layer_id_;
89 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in
90 // PushPropertiesTo.
91 int thumb_thickness_;
92 int thumb_length_;
93 gfx::Point location_;
94 gfx::Rect track_rect_;
95 bool is_overlay_;
96 bool has_thumb_;
98 scoped_ptr<ScopedUIResource> track_resource_;
99 scoped_ptr<ScopedUIResource> thumb_resource_;
101 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer);
104 } // namespace cc
106 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_