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 #if USE(ACCELERATED_COMPOSITING) | 7 #if USE(ACCELERATED_COMPOSITING) |
8 | 8 |
9 #include "CCScrollbarLayerImpl.h" | 9 #include "CCScrollbarLayerImpl.h" |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 m_geometry->update(scrollbar); | 64 m_geometry->update(scrollbar); |
65 } | 65 } |
66 | 66 |
67 static FloatRect toUVRect(const WebRect& r, const IntRect& bounds) | 67 static FloatRect toUVRect(const WebRect& r, const IntRect& bounds) |
68 { | 68 { |
69 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float
>(r.y) / bounds.height(), | 69 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float
>(r.y) / bounds.height(), |
70 static_cast<float>(r.width) / bounds.width(), static_cast<f
loat>(r.height) / bounds.height()); | 70 static_cast<float>(r.width) / bounds.width(), static_cast<f
loat>(r.height) / bounds.height()); |
71 } | 71 } |
72 | 72 |
73 void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, bool&) | 73 void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
appendQuadsData) |
74 { | 74 { |
75 bool premultipledAlpha = false; | 75 bool premultipledAlpha = false; |
76 bool flipped = false; | 76 bool flipped = false; |
77 FloatRect uvRect(0, 0, 1, 1); | 77 FloatRect uvRect(0, 0, 1, 1); |
78 IntRect boundsRect(IntPoint(), contentBounds()); | 78 IntRect boundsRect(IntPoint(), contentBounds()); |
79 | 79 |
80 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); | 80 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); |
81 appendDebugBorderQuad(quadSink, sharedQuadState); | 81 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
82 | 82 |
83 WebRect thumbRect, backTrackRect, foreTrackRect; | 83 WebRect thumbRect, backTrackRect, foreTrackRect; |
84 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); | 84 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); |
85 if (!m_geometry->hasThumb(&m_scrollbar)) | 85 if (!m_geometry->hasThumb(&m_scrollbar)) |
86 thumbRect = WebRect(); | 86 thumbRect = WebRect(); |
87 | 87 |
88 if (m_thumbResourceId && !thumbRect.isEmpty()) { | 88 if (m_thumbResourceId && !thumbRect.isEmpty()) { |
89 OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadSta
te, IntRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height), m_thum
bResourceId, premultipledAlpha, uvRect, flipped); | 89 OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadSta
te, IntRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height), m_thum
bResourceId, premultipledAlpha, uvRect, flipped); |
90 quad->setNeedsBlending(); | 90 quad->setNeedsBlending(); |
91 quadSink.append(quad.release()); | 91 quadSink.append(quad.release(), appendQuadsData); |
92 } | 92 } |
93 | 93 |
94 if (!m_backTrackResourceId) | 94 if (!m_backTrackResourceId) |
95 return; | 95 return; |
96 | 96 |
97 // We only paint the track in two parts if we were given a texture for the f
orward track part. | 97 // We only paint the track in two parts if we were given a texture for the f
orward track part. |
98 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) | 98 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) |
99 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(foreT
rackRect.x, foreTrackRect.y, foreTrackRect.width, foreTrackRect.height), m_foreT
rackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped)
); | 99 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(foreT
rackRect.x, foreTrackRect.y, foreTrackRect.width, foreTrackRect.height), m_foreT
rackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped)
, appendQuadsData); |
100 | 100 |
101 // 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 | 101 // 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 |
102 // fore track quads. The back track texture contains (and displays) the butt
ons. | 102 // fore track quads. The back track texture contains (and displays) the butt
ons. |
103 if (!boundsRect.isEmpty()) | 103 if (!boundsRect.isEmpty()) |
104 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(bound
sRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped)); | 104 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(bound
sRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appendQuadsD
ata); |
105 } | 105 } |
106 | 106 |
107 void CCScrollbarLayerImpl::didLoseContext() | 107 void CCScrollbarLayerImpl::didLoseContext() |
108 { | 108 { |
109 m_backTrackResourceId = 0; | 109 m_backTrackResourceId = 0; |
110 m_foreTrackResourceId = 0; | 110 m_foreTrackResourceId = 0; |
111 m_thumbResourceId = 0; | 111 m_thumbResourceId = 0; |
112 } | 112 } |
113 | 113 |
114 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const | 114 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 return m_owner->m_orientation; | 186 return m_owner->m_orientation; |
187 } | 187 } |
188 | 188 |
189 bool CCScrollbarLayerImpl::CCScrollbar::isCustomScrollbar() const | 189 bool CCScrollbarLayerImpl::CCScrollbar::isCustomScrollbar() const |
190 { | 190 { |
191 return m_owner->m_isCustomScrollbar; | 191 return m_owner->m_isCustomScrollbar; |
192 } | 192 } |
193 | 193 |
194 } | 194 } |
195 #endif // USE(ACCELERATED_COMPOSITING) | 195 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |