| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, CCAppendQuadsData&
appendQuadsData) | 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(), bounds()); |
| 79 IntRect contentBoundsRect(IntPoint(), contentBounds()); |
| 79 | 80 |
| 80 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); | 81 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); |
| 81 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 82 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 82 | 83 |
| 83 WebRect thumbRect, backTrackRect, foreTrackRect; | 84 WebRect thumbRect, backTrackRect, foreTrackRect; |
| 84 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); | 85 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); |
| 85 if (!m_geometry->hasThumb(&m_scrollbar)) | 86 if (!m_geometry->hasThumb(&m_scrollbar)) |
| 86 thumbRect = WebRect(); | 87 thumbRect = WebRect(); |
| 87 | 88 |
| 88 if (m_thumbResourceId && !thumbRect.isEmpty()) { | 89 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); | 90 OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadSta
te, layerRectToContentRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvR
ect, flipped); |
| 90 quad->setNeedsBlending(); | 91 quad->setNeedsBlending(); |
| 91 quadSink.append(quad.release(), appendQuadsData); | 92 quadSink.append(quad.release(), appendQuadsData); |
| 92 } | 93 } |
| 93 | 94 |
| 94 if (!m_backTrackResourceId) | 95 if (!m_backTrackResourceId) |
| 95 return; | 96 return; |
| 96 | 97 |
| 97 // We only paint the track in two parts if we were given a texture for the f
orward track part. | 98 // 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()) | 99 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)
, appendQuadsData); | 100 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, layerRectToCo
ntentRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(for
eTrackRect, boundsRect), flipped), appendQuadsData); |
| 100 | 101 |
| 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 // 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. | 103 // fore track quads. The back track texture contains (and displays) the butt
ons. |
| 103 if (!boundsRect.isEmpty()) | 104 if (!contentBoundsRect.isEmpty()) |
| 104 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(bound
sRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appendQuadsD
ata); | 105 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(conte
ntBoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appen
dQuadsData); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void CCScrollbarLayerImpl::didLoseContext() | 108 void CCScrollbarLayerImpl::didLoseContext() |
| 108 { | 109 { |
| 109 m_backTrackResourceId = 0; | 110 m_backTrackResourceId = 0; |
| 110 m_foreTrackResourceId = 0; | 111 m_foreTrackResourceId = 0; |
| 111 m_thumbResourceId = 0; | 112 m_thumbResourceId = 0; |
| 112 } | 113 } |
| 113 | 114 |
| 114 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const | 115 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const |
| 115 { | 116 { |
| 116 return m_owner->m_isOverlayScrollbar; | 117 return m_owner->m_isOverlayScrollbar; |
| 117 } | 118 } |
| 118 | 119 |
| 119 int CCScrollbarLayerImpl::CCScrollbar::value() const | 120 int CCScrollbarLayerImpl::CCScrollbar::value() const |
| 120 { | 121 { |
| 121 return m_owner->m_currentPos; | 122 return m_owner->m_currentPos; |
| 122 } | 123 } |
| 123 | 124 |
| 124 WebKit::WebPoint CCScrollbarLayerImpl::CCScrollbar::location() const | 125 WebKit::WebPoint CCScrollbarLayerImpl::CCScrollbar::location() const |
| 125 { | 126 { |
| 126 return WebKit::WebPoint(); | 127 return WebKit::WebPoint(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 WebKit::WebSize CCScrollbarLayerImpl::CCScrollbar::size() const | 130 WebKit::WebSize CCScrollbarLayerImpl::CCScrollbar::size() const |
| 130 { | 131 { |
| 131 return WebKit::WebSize(m_owner->contentBounds().width(), m_owner->contentBou
nds().height()); | 132 return WebKit::WebSize(m_owner->bounds().width(), m_owner->bounds().height()
); |
| 132 } | 133 } |
| 133 | 134 |
| 134 bool CCScrollbarLayerImpl::CCScrollbar::enabled() const | 135 bool CCScrollbarLayerImpl::CCScrollbar::enabled() const |
| 135 { | 136 { |
| 136 return m_owner->m_enabled; | 137 return m_owner->m_enabled; |
| 137 } | 138 } |
| 138 | 139 |
| 139 int CCScrollbarLayerImpl::CCScrollbar::maximum() const | 140 int CCScrollbarLayerImpl::CCScrollbar::maximum() const |
| 140 { | 141 { |
| 141 return m_owner->m_maximum; | 142 return m_owner->m_maximum; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 return m_owner->m_orientation; | 187 return m_owner->m_orientation; |
| 187 } | 188 } |
| 188 | 189 |
| 189 bool CCScrollbarLayerImpl::CCScrollbar::isCustomScrollbar() const | 190 bool CCScrollbarLayerImpl::CCScrollbar::isCustomScrollbar() const |
| 190 { | 191 { |
| 191 return m_owner->m_isCustomScrollbar; | 192 return m_owner->m_isCustomScrollbar; |
| 192 } | 193 } |
| 193 | 194 |
| 194 } | 195 } |
| 195 #endif // USE(ACCELERATED_COMPOSITING) | 196 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |