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/caching_bitmap_content_layer_updater.h"
10 #include "cc/cc_export.h"
11 #include "cc/contents_scaling_layer.h"
12 #include <public/WebScrollbar.h>
13 #include <public/WebScrollbarThemeGeometry.h>
14 #include <public/WebScrollbarThemePainter.h>
18 class ResourceUpdateQueue
;
20 class ScrollbarThemeComposite
;
22 class CC_EXPORT ScrollbarLayer
: public ContentsScalingLayer
{
24 virtual scoped_ptr
<LayerImpl
> createLayerImpl() OVERRIDE
;
26 static scoped_refptr
<ScrollbarLayer
> create(scoped_ptr
<WebKit::WebScrollbar
>, WebKit::WebScrollbarThemePainter
, scoped_ptr
<WebKit::WebScrollbarThemeGeometry
>, int scrollLayerId
);
29 virtual void setTexturePriorities(const PriorityCalculator
&) OVERRIDE
;
30 virtual void update(ResourceUpdateQueue
&, const OcclusionTracker
*, RenderingStats
&) OVERRIDE
;
31 virtual void setLayerTreeHost(LayerTreeHost
*) OVERRIDE
;
32 virtual void pushPropertiesTo(LayerImpl
*) OVERRIDE
;
33 virtual void setContentsScale(float contentsScale
) OVERRIDE
;
35 int scrollLayerId() const { return m_scrollLayerId
; }
36 void setScrollLayerId(int id
) { m_scrollLayerId
= id
; }
38 virtual ScrollbarLayer
* toScrollbarLayer() OVERRIDE
;
41 ScrollbarLayer(scoped_ptr
<WebKit::WebScrollbar
>, WebKit::WebScrollbarThemePainter
, scoped_ptr
<WebKit::WebScrollbarThemeGeometry
>, int scrollLayerId
);
42 virtual ~ScrollbarLayer();
45 void updatePart(CachingBitmapContentLayerUpdater
*, LayerUpdater::Resource
*, const gfx::Rect
&, ResourceUpdateQueue
&, RenderingStats
&);
46 void createUpdaterIfNeeded();
47 gfx::Rect
scrollbarLayerRectToContentRect(const gfx::Rect
& layerRect
) const;
50 float clampScaleToMaxTextureSize(float scale
);
52 scoped_ptr
<WebKit::WebScrollbar
> m_scrollbar
;
53 WebKit::WebScrollbarThemePainter m_painter
;
54 scoped_ptr
<WebKit::WebScrollbarThemeGeometry
> m_geometry
;
57 GLenum m_textureFormat
;
59 scoped_refptr
<CachingBitmapContentLayerUpdater
> m_backTrackUpdater
;
60 scoped_refptr
<CachingBitmapContentLayerUpdater
> m_foreTrackUpdater
;
61 scoped_refptr
<CachingBitmapContentLayerUpdater
> m_thumbUpdater
;
63 // All the parts of the scrollbar except the thumb
64 scoped_ptr
<LayerUpdater::Resource
> m_backTrack
;
65 scoped_ptr
<LayerUpdater::Resource
> m_foreTrack
;
66 scoped_ptr
<LayerUpdater::Resource
> m_thumb
;
70 #endif // CC_SCROLLBAR_LAYER_H_