Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / layers / painted_scrollbar_layer.h
blobdbc581e6f05e2aa4c56aff7e01c3187d11c0cae3
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/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 Layer {
21 public:
22 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
24 static scoped_refptr<PaintedScrollbarLayer> Create(
25 const LayerSettings& settings,
26 scoped_ptr<Scrollbar> scrollbar,
27 int scroll_layer_id);
29 bool OpacityCanAnimateOnImplThread() const override;
30 ScrollbarLayerInterface* ToScrollbarLayer() override;
32 // ScrollbarLayerInterface
33 int ScrollLayerId() const override;
34 void SetScrollLayer(int layer_id) override;
35 void SetClipLayer(int layer_id) override;
37 ScrollbarOrientation orientation() const override;
39 // Layer interface
40 bool Update(ResourceUpdateQueue* queue,
41 const OcclusionTracker<Layer>* occlusion) override;
42 void SetLayerTreeHost(LayerTreeHost* host) override;
43 void PushPropertiesTo(LayerImpl* layer) override;
44 void PushScrollClipPropertiesTo(LayerImpl* layer) override;
46 const gfx::Size& internal_content_bounds() const {
47 return internal_content_bounds_;
50 protected:
51 PaintedScrollbarLayer(const LayerSettings& settings,
52 scoped_ptr<Scrollbar> scrollbar,
53 int scroll_layer_id);
54 ~PaintedScrollbarLayer() override;
56 // For unit tests
57 UIResourceId track_resource_id() {
58 return track_resource_.get() ? track_resource_->id() : 0;
60 UIResourceId thumb_resource_id() {
61 return thumb_resource_.get() ? thumb_resource_->id() : 0;
63 void UpdateInternalContentScale();
64 void UpdateThumbAndTrackGeometry();
66 private:
67 gfx::Rect ScrollbarLayerRectToContentRect(const gfx::Rect& layer_rect) const;
68 gfx::Rect OriginThumbRect() const;
70 template <typename T>
71 bool UpdateProperty(T value, T* prop) {
72 if (*prop == value)
73 return false;
74 *prop = value;
75 SetNeedsPushProperties();
76 return true;
79 int MaxTextureSize();
80 float ClampScaleToMaxTextureSize(float scale);
82 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& layer_rect,
83 const gfx::Rect& content_rect,
84 ScrollbarPart part);
86 scoped_ptr<Scrollbar> scrollbar_;
87 int scroll_layer_id_;
88 int clip_layer_id_;
90 float internal_contents_scale_;
91 gfx::Size internal_content_bounds_;
93 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in
94 // PushPropertiesTo.
95 int thumb_thickness_;
96 int thumb_length_;
97 gfx::Point location_;
98 gfx::Rect track_rect_;
99 bool is_overlay_;
100 bool has_thumb_;
102 scoped_ptr<ScopedUIResource> track_resource_;
103 scoped_ptr<ScopedUIResource> thumb_resource_;
105 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer);
108 } // namespace cc
110 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_