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"
17 class ScrollbarThemeComposite
;
19 class CC_EXPORT PaintedScrollbarLayer
: public ScrollbarLayerInterface
,
20 public ContentsScalingLayer
{
22 scoped_ptr
<LayerImpl
> CreateLayerImpl(LayerTreeImpl
* tree_impl
) override
;
24 static scoped_refptr
<PaintedScrollbarLayer
> Create(
25 scoped_ptr
<Scrollbar
> scrollbar
,
28 bool OpacityCanAnimateOnImplThread() const override
;
29 ScrollbarLayerInterface
* ToScrollbarLayer() override
;
31 // ScrollbarLayerInterface
32 int ScrollLayerId() const override
;
33 void SetScrollLayer(int layer_id
) override
;
34 void SetClipLayer(int layer_id
) override
;
36 ScrollbarOrientation
orientation() const override
;
39 bool Update(ResourceUpdateQueue
* queue
,
40 const OcclusionTracker
<Layer
>* occlusion
) override
;
41 void SetLayerTreeHost(LayerTreeHost
* host
) override
;
42 void PushPropertiesTo(LayerImpl
* layer
) override
;
43 void PushScrollClipPropertiesTo(LayerImpl
* layer
) override
;
44 void CalculateContentsScale(float ideal_contents_scale
,
45 float* contents_scale_x
,
46 float* contents_scale_y
,
47 gfx::Size
* content_bounds
) override
;
50 PaintedScrollbarLayer(scoped_ptr
<Scrollbar
> scrollbar
, int scroll_layer_id
);
51 ~PaintedScrollbarLayer() override
;
54 UIResourceId
track_resource_id() {
55 return track_resource_
.get() ? track_resource_
->id() : 0;
57 UIResourceId
thumb_resource_id() {
58 return thumb_resource_
.get() ? thumb_resource_
->id() : 0;
60 void UpdateThumbAndTrackGeometry();
63 gfx::Rect
ScrollbarLayerRectToContentRect(const gfx::Rect
& layer_rect
) const;
64 gfx::Rect
OriginThumbRect() const;
66 template<typename T
> void UpdateProperty(T value
, T
* prop
) {
70 SetNeedsPushProperties();
74 float ClampScaleToMaxTextureSize(float scale
);
76 UIResourceBitmap
RasterizeScrollbarPart(const gfx::Rect
& layer_rect
,
77 const gfx::Rect
& content_rect
,
80 scoped_ptr
<Scrollbar
> scrollbar_
;
84 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in
89 gfx::Rect track_rect_
;
93 scoped_ptr
<ScopedUIResource
> track_resource_
;
94 scoped_ptr
<ScopedUIResource
> thumb_resource_
;
96 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer
);
101 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_