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 "cc/scrollbar_layer_impl.h" | 5 #include "cc/scrollbar_layer_impl.h" |
6 | 6 |
7 #include "cc/quad_sink.h" | 7 #include "cc/quad_sink.h" |
8 #include "cc/scrollbar_animation_controller.h" | 8 #include "cc/scrollbar_animation_controller.h" |
9 #include "cc/texture_draw_quad.h" | 9 #include "cc/texture_draw_quad.h" |
10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Don't intersect with the bounds as in layerRectToContentRect() because | 110 // Don't intersect with the bounds as in layerRectToContentRect() because |
111 // layerRect here might be in coordinates of the containing layer. | 111 // layerRect here might be in coordinates of the containing layer. |
112 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); | 112 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); |
113 return gfx::ToEnclosingRect(contentRect); | 113 return gfx::ToEnclosingRect(contentRect); |
114 } | 114 } |
115 | 115 |
116 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append
QuadsData) | 116 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append
QuadsData) |
117 { | 117 { |
118 bool premultipledAlpha = false; | 118 bool premultipledAlpha = false; |
119 bool flipped = false; | 119 bool flipped = false; |
120 gfx::RectF uvRect(0, 0, 1, 1); | 120 gfx::PointF uvTopLeft(0.f, 0.f); |
| 121 gfx::PointF uvBottomRight(1.f, 1.f); |
121 gfx::Rect boundsRect(gfx::Point(), bounds()); | 122 gfx::Rect boundsRect(gfx::Point(), bounds()); |
122 gfx::Rect contentBoundsRect(gfx::Point(), contentBounds()); | 123 gfx::Rect contentBoundsRect(gfx::Point(), contentBounds()); |
123 | 124 |
124 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); | 125 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
125 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 126 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
126 | 127 |
127 WebRect thumbRect, backTrackRect, foreTrackRect; | 128 WebRect thumbRect, backTrackRect, foreTrackRect; |
128 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); | 129 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); |
129 if (!m_geometry->hasThumb(&m_scrollbar)) | 130 if (!m_geometry->hasThumb(&m_scrollbar)) |
130 thumbRect = WebRect(); | 131 thumbRect = WebRect(); |
131 | 132 |
132 if (m_thumbResourceId && !thumbRect.isEmpty()) { | 133 if (m_thumbResourceId && !thumbRect.isEmpty()) { |
133 gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect)); | 134 gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect)); |
134 gfx::Rect opaqueRect; | 135 gfx::Rect opaqueRect; |
135 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 136 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
136 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 137 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
137 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, p
remultipledAlpha, uvRect, opacity, flipped); | 138 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, p
remultipledAlpha, uvTopLeft, uvBottomRight, opacity, flipped); |
138 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 139 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
139 } | 140 } |
140 | 141 |
141 if (!m_backTrackResourceId) | 142 if (!m_backTrackResourceId) |
142 return; | 143 return; |
143 | 144 |
144 // We only paint the track in two parts if we were given a texture for the f
orward track part. | 145 // We only paint the track in two parts if we were given a texture for the f
orward track part. |
145 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) { | 146 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) { |
146 gfx::Rect quadRect(scrollbarLayerRectToContentRect(foreTrackRect)); | 147 gfx::Rect quadRect(scrollbarLayerRectToContentRect(foreTrackRect)); |
147 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); | 148 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); |
| 149 gfx::RectF uvRect(toUVRect(foreTrackRect, boundsRect)); |
148 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 150 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
149 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 151 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
150 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceI
d, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), opacity, flipped); | 152 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceI
d, premultipledAlpha, uvRect.origin(), uvRect.bottom_right(), opacity, flipped); |
151 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 153 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
152 } | 154 } |
153 | 155 |
154 // 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 | 156 // 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 |
155 // fore track quads. The back track texture contains (and displays) the butt
ons. | 157 // fore track quads. The back track texture contains (and displays) the butt
ons. |
156 if (!contentBoundsRect.IsEmpty()) { | 158 if (!contentBoundsRect.IsEmpty()) { |
157 gfx::Rect quadRect(contentBoundsRect); | 159 gfx::Rect quadRect(contentBoundsRect); |
158 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); | 160 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); |
159 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 161 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
160 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 162 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
161 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceI
d, premultipledAlpha, uvRect, opacity, flipped); | 163 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceI
d, premultipledAlpha, uvTopLeft, uvBottomRight, opacity, flipped); |
162 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 164 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 void ScrollbarLayerImpl::didLoseOutputSurface() | 168 void ScrollbarLayerImpl::didLoseOutputSurface() |
167 { | 169 { |
168 m_backTrackResourceId = 0; | 170 m_backTrackResourceId = 0; |
169 m_foreTrackResourceId = 0; | 171 m_foreTrackResourceId = 0; |
170 m_thumbResourceId = 0; | 172 m_thumbResourceId = 0; |
171 } | 173 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 { | 251 { |
250 return m_owner->m_isCustomScrollbar; | 252 return m_owner->m_isCustomScrollbar; |
251 } | 253 } |
252 | 254 |
253 const char* ScrollbarLayerImpl::layerTypeAsString() const | 255 const char* ScrollbarLayerImpl::layerTypeAsString() const |
254 { | 256 { |
255 return "ScrollbarLayer"; | 257 return "ScrollbarLayer"; |
256 } | 258 } |
257 | 259 |
258 } // namespace cc | 260 } // namespace cc |
OLD | NEW |