OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/scrollbar_layer_impl.h" | 7 #include "cc/scrollbar_layer_impl.h" |
8 | 8 |
9 #include "cc/quad_sink.h" | 9 #include "cc/quad_sink.h" |
10 #include "cc/scrollbar_animation_controller.h" | 10 #include "cc/scrollbar_animation_controller.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 m_isScrollViewScrollbar = scrollbar->isScrollViewScrollbar(); | 59 m_isScrollViewScrollbar = scrollbar->isScrollViewScrollbar(); |
60 m_enabled = scrollbar->enabled(); | 60 m_enabled = scrollbar->enabled(); |
61 m_isCustomScrollbar = scrollbar->isCustomScrollbar(); | 61 m_isCustomScrollbar = scrollbar->isCustomScrollbar(); |
62 m_isOverlayScrollbar = scrollbar->isOverlay(); | 62 m_isOverlayScrollbar = scrollbar->isOverlay(); |
63 | 63 |
64 scrollbar->getTickmarks(m_tickmarks); | 64 scrollbar->getTickmarks(m_tickmarks); |
65 | 65 |
66 m_geometry->update(scrollbar); | 66 m_geometry->update(scrollbar); |
67 } | 67 } |
68 | 68 |
69 static FloatRect toUVRect(const WebRect& r, const IntRect& bounds) | 69 static gfx::RectF toUVRect(const gfx::Rect& r, const gfx::Rect& bounds) |
70 { | 70 { |
71 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float
>(r.y) / bounds.height(), | 71 return gfx::ScaleRect(r, 1.0 / bounds.width(), 1.0 / bounds.height()); |
72 static_cast<float>(r.width) / bounds.width(), static_cast<f
loat>(r.height) / bounds.height()); | |
73 } | 72 } |
74 | 73 |
75 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append
QuadsData) | 74 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append
QuadsData) |
76 { | 75 { |
77 bool premultipledAlpha = false; | 76 bool premultipledAlpha = false; |
78 bool flipped = false; | 77 bool flipped = false; |
79 FloatRect uvRect(0, 0, 1, 1); | 78 gfx::RectF uvRect(0, 0, 1, 1); |
80 IntRect boundsRect(IntPoint(), bounds()); | 79 gfx::Rect boundsRect(gfx::Point(), bounds()); |
81 IntRect contentBoundsRect(IntPoint(), contentBounds()); | 80 gfx::Rect contentBoundsRect(gfx::Point(), contentBounds()); |
82 | 81 |
83 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); | 82 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
84 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 83 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
85 | 84 |
86 WebRect thumbRect, backTrackRect, foreTrackRect; | 85 WebRect thumbRect, backTrackRect, foreTrackRect; |
87 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); | 86 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); |
88 if (!m_geometry->hasThumb(&m_scrollbar)) | 87 if (!m_geometry->hasThumb(&m_scrollbar)) |
89 thumbRect = WebRect(); | 88 thumbRect = WebRect(); |
90 | 89 |
91 if (m_thumbResourceId && !thumbRect.isEmpty()) { | 90 if (m_thumbResourceId && !thumbRect.isEmpty()) { |
92 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedQuadSta
te, layerRectToContentRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvR
ect, flipped); | 91 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::create(sharedQuadSta
te, layerRectToContentRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvR
ect, flipped); |
93 quad->setNeedsBlending(); | 92 quad->setNeedsBlending(); |
94 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 93 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
95 } | 94 } |
96 | 95 |
97 if (!m_backTrackResourceId) | 96 if (!m_backTrackResourceId) |
98 return; | 97 return; |
99 | 98 |
100 // We only paint the track in two parts if we were given a texture for the f
orward track part. | 99 // We only paint the track in two parts if we were given a texture for the f
orward track part. |
101 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) | 100 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) |
102 quadSink.append(TextureDrawQuad::create(sharedQuadState, layerRectToCont
entRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreT
rackRect, boundsRect), flipped).PassAs<DrawQuad>(), appendQuadsData); | 101 quadSink.append(TextureDrawQuad::create(sharedQuadState, layerRectToCont
entRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreT
rackRect, boundsRect), flipped).PassAs<DrawQuad>(), appendQuadsData); |
103 | 102 |
104 // Order matters here: since the back track texture is being drawn to the en
tire contents rect, we must append it after the thumb and | 103 // Order matters here: since the back track texture is being drawn to the en
tire contents rect, we must append it after the thumb and |
105 // fore track quads. The back track texture contains (and displays) the butt
ons. | 104 // fore track quads. The back track texture contains (and displays) the butt
ons. |
106 if (!contentBoundsRect.isEmpty()) | 105 if (!contentBoundsRect.IsEmpty()) |
107 quadSink.append(TextureDrawQuad::create(sharedQuadState, IntRect(content
BoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped).PassAs<D
rawQuad>(), appendQuadsData); | 106 quadSink.append(TextureDrawQuad::create(sharedQuadState, gfx::Rect(conte
ntBoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped).PassAs
<DrawQuad>(), appendQuadsData); |
108 } | 107 } |
109 | 108 |
110 void ScrollbarLayerImpl::didLoseContext() | 109 void ScrollbarLayerImpl::didLoseContext() |
111 { | 110 { |
112 m_backTrackResourceId = 0; | 111 m_backTrackResourceId = 0; |
113 m_foreTrackResourceId = 0; | 112 m_foreTrackResourceId = 0; |
114 m_thumbResourceId = 0; | 113 m_thumbResourceId = 0; |
115 } | 114 } |
116 | 115 |
117 bool ScrollbarLayerImpl::Scrollbar::isOverlay() const | 116 bool ScrollbarLayerImpl::Scrollbar::isOverlay() const |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 { | 192 { |
194 return m_owner->m_isCustomScrollbar; | 193 return m_owner->m_isCustomScrollbar; |
195 } | 194 } |
196 | 195 |
197 const char* ScrollbarLayerImpl::layerTypeAsString() const | 196 const char* ScrollbarLayerImpl::layerTypeAsString() const |
198 { | 197 { |
199 return "ScrollbarLayer"; | 198 return "ScrollbarLayer"; |
200 } | 199 } |
201 | 200 |
202 } | 201 } |
OLD | NEW |