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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 // Don't intersect with the bounds as in layerRectToContentRect() because | 95 // Don't intersect with the bounds as in layerRectToContentRect() because |
96 // layerRect here might be in coordinates of the containing layer. | 96 // layerRect here might be in coordinates of the containing layer. |
97 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY()); | 97 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY()); |
98 return gfx::ToEnclosingRect(contentRect); | 98 return gfx::ToEnclosingRect(contentRect); |
99 } | 99 } |
100 | 100 |
101 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append QuadsData) | 101 void ScrollbarLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& append QuadsData) |
102 { | 102 { |
103 bool premultipledAlpha = false; | 103 bool premultipledAlpha = false; |
104 bool flipped = false; | 104 bool flipped = false; |
105 gfx::RectF uvRect(0, 0, 1, 1); | 105 gfx::PointF uvTopLeft(0, 0); |
danakj
2013/01/15 01:48:42
nit: 0.f
Jerome
2013/01/15 17:58:12
Done.
| |
106 gfx::PointF uvBottomRight(1, 1); | |
danakj
2013/01/15 01:48:42
nit: 1.f
Jerome
2013/01/15 17:58:12
Done.
| |
106 gfx::Rect boundsRect(gfx::Point(), bounds()); | 107 gfx::Rect boundsRect(gfx::Point(), bounds()); |
107 gfx::Rect contentBoundsRect(gfx::Point(), contentBounds()); | 108 gfx::Rect contentBoundsRect(gfx::Point(), contentBounds()); |
108 | 109 |
109 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); | 110 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); |
110 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 111 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
111 | 112 |
112 WebRect thumbRect, backTrackRect, foreTrackRect; | 113 WebRect thumbRect, backTrackRect, foreTrackRect; |
113 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba ckTrackRect, thumbRect, foreTrackRect); | 114 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba ckTrackRect, thumbRect, foreTrackRect); |
114 if (!m_geometry->hasThumb(&m_scrollbar)) | 115 if (!m_geometry->hasThumb(&m_scrollbar)) |
115 thumbRect = WebRect(); | 116 thumbRect = WebRect(); |
116 | 117 |
117 if (m_thumbResourceId && !thumbRect.isEmpty()) { | 118 if (m_thumbResourceId && !thumbRect.isEmpty()) { |
118 gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect)); | 119 gfx::Rect quadRect(scrollbarLayerRectToContentRect(thumbRect)); |
119 gfx::Rect opaqueRect; | 120 gfx::Rect opaqueRect; |
120 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 121 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
121 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 122 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
122 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, p remultipledAlpha, uvRect, opacity, flipped); | 123 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_thumbResourceId, p remultipledAlpha, uvTopLeft, uvBottomRight, opacity, flipped); |
123 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 124 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
124 } | 125 } |
125 | 126 |
126 if (!m_backTrackResourceId) | 127 if (!m_backTrackResourceId) |
127 return; | 128 return; |
128 | 129 |
129 // We only paint the track in two parts if we were given a texture for the f orward track part. | 130 // We only paint the track in two parts if we were given a texture for the f orward track part. |
130 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) { | 131 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) { |
131 gfx::Rect quadRect(scrollbarLayerRectToContentRect(foreTrackRect)); | 132 gfx::Rect quadRect(scrollbarLayerRectToContentRect(foreTrackRect)); |
132 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); | 133 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); |
134 gfx::RectF uvRect(toUVRect(foreTrackRect, boundsRect)); | |
133 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 135 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
134 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 136 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
135 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceI d, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), opacity, flipped); | 137 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_foreTrackResourceI d, premultipledAlpha, uvRect.origin(), uvRect.bottom_right(), opacity, flipped); |
136 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 138 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
137 } | 139 } |
138 | 140 |
139 // 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 | 141 // 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 |
140 // fore track quads. The back track texture contains (and displays) the butt ons. | 142 // fore track quads. The back track texture contains (and displays) the butt ons. |
141 if (!contentBoundsRect.IsEmpty()) { | 143 if (!contentBoundsRect.IsEmpty()) { |
142 gfx::Rect quadRect(contentBoundsRect); | 144 gfx::Rect quadRect(contentBoundsRect); |
143 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); | 145 gfx::Rect opaqueRect(contentsOpaque() ? quadRect : gfx::Rect()); |
144 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 146 const float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
145 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 147 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
146 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceI d, premultipledAlpha, uvRect, opacity, flipped); | 148 quad->SetNew(sharedQuadState, quadRect, opaqueRect, m_backTrackResourceI d, premultipledAlpha, uvTopLeft, uvBottomRight, opacity, flipped); |
147 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 149 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
148 } | 150 } |
149 } | 151 } |
150 | 152 |
151 void ScrollbarLayerImpl::didLoseOutputSurface() | 153 void ScrollbarLayerImpl::didLoseOutputSurface() |
152 { | 154 { |
153 m_backTrackResourceId = 0; | 155 m_backTrackResourceId = 0; |
154 m_foreTrackResourceId = 0; | 156 m_foreTrackResourceId = 0; |
155 m_thumbResourceId = 0; | 157 m_thumbResourceId = 0; |
156 } | 158 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 { | 236 { |
235 return m_owner->m_isCustomScrollbar; | 237 return m_owner->m_isCustomScrollbar; |
236 } | 238 } |
237 | 239 |
238 const char* ScrollbarLayerImpl::layerTypeAsString() const | 240 const char* ScrollbarLayerImpl::layerTypeAsString() const |
239 { | 241 { |
240 return "ScrollbarLayer"; | 242 return "ScrollbarLayer"; |
241 } | 243 } |
242 | 244 |
243 } // namespace cc | 245 } // namespace cc |
OLD | NEW |