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
3 // found in the LICENSE file.
6 #ifndef CC_SCROLLBAR_LAYER_H_
7 #define CC_SCROLLBAR_LAYER_H_
9 #include "cc/cc_export.h"
10 #include "cc/contents_scaling_layer.h"
11 #include "cc/layer_updater.h"
12 #include "cc/scrollbar_theme_painter.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGeometry.h"
17 class CachingBitmapContentLayerUpdater
;
18 class ResourceUpdateQueue
;
20 class ScrollbarThemeComposite
;
22 class CC_EXPORT ScrollbarLayer
: public ContentsScalingLayer
{
24 virtual scoped_ptr
<LayerImpl
> createLayerImpl(LayerTreeImpl
* treeImpl
) OVERRIDE
;
26 static scoped_refptr
<ScrollbarLayer
> create(
27 scoped_ptr
<WebKit::WebScrollbar
>,
28 scoped_ptr
<ScrollbarThemePainter
>,
29 scoped_ptr
<WebKit::WebScrollbarThemeGeometry
>,
32 int scrollLayerId() const { return m_scrollLayerId
; }
33 void setScrollLayerId(int id
);
35 WebKit::WebScrollbar::Orientation
orientation() const;
38 virtual void setTexturePriorities(const PriorityCalculator
&) OVERRIDE
;
39 virtual void update(ResourceUpdateQueue
&, const OcclusionTracker
*, RenderingStats
&) OVERRIDE
;
40 virtual void setLayerTreeHost(LayerTreeHost
*) OVERRIDE
;
41 virtual void pushPropertiesTo(LayerImpl
*) OVERRIDE
;
42 virtual void calculateContentsScale(
43 float idealContentsScale
,
44 float* contentsScaleX
,
45 float* contentsScaleY
,
46 gfx::Size
* contentBounds
) OVERRIDE
;
48 virtual ScrollbarLayer
* toScrollbarLayer() OVERRIDE
;
52 scoped_ptr
<WebKit::WebScrollbar
>,
53 scoped_ptr
<ScrollbarThemePainter
>,
54 scoped_ptr
<WebKit::WebScrollbarThemeGeometry
>,
56 virtual ~ScrollbarLayer();
59 void updatePart(CachingBitmapContentLayerUpdater
*, LayerUpdater::Resource
*, const gfx::Rect
&, ResourceUpdateQueue
&, RenderingStats
&);
60 void createUpdaterIfNeeded();
61 gfx::Rect
scrollbarLayerRectToContentRect(const gfx::Rect
& layerRect
) const;
63 bool isDirty() const { return !m_dirtyRect
.IsEmpty(); }
66 float clampScaleToMaxTextureSize(float scale
);
68 scoped_ptr
<WebKit::WebScrollbar
> m_scrollbar
;
69 scoped_ptr
<ScrollbarThemePainter
> m_painter
;
70 scoped_ptr
<WebKit::WebScrollbarThemeGeometry
> m_geometry
;
71 gfx::Size m_thumbSize
;
74 unsigned m_textureFormat
;
76 gfx::RectF m_dirtyRect
;
78 scoped_refptr
<CachingBitmapContentLayerUpdater
> m_backTrackUpdater
;
79 scoped_refptr
<CachingBitmapContentLayerUpdater
> m_foreTrackUpdater
;
80 scoped_refptr
<CachingBitmapContentLayerUpdater
> m_thumbUpdater
;
82 // All the parts of the scrollbar except the thumb
83 scoped_ptr
<LayerUpdater::Resource
> m_backTrack
;
84 scoped_ptr
<LayerUpdater::Resource
> m_foreTrack
;
85 scoped_ptr
<LayerUpdater::Resource
> m_thumb
;
89 #endif // CC_SCROLLBAR_LAYER_H_