| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 { | 72 { |
| 73 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float
>(r.y) / bounds.height(), | 73 return FloatRect(static_cast<float>(r.x) / bounds.width(), static_cast<float
>(r.y) / bounds.height(), |
| 74 static_cast<float>(r.width) / bounds.width(), static_cast<f
loat>(r.height) / bounds.height()); | 74 static_cast<float>(r.width) / bounds.width(), static_cast<f
loat>(r.height) / bounds.height()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
appendQuadsData) | 77 void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
appendQuadsData) |
| 78 { | 78 { |
| 79 bool premultipledAlpha = false; | 79 bool premultipledAlpha = false; |
| 80 bool flipped = false; | 80 bool flipped = false; |
| 81 FloatRect uvRect(0, 0, 1, 1); | 81 FloatRect uvRect(0, 0, 1, 1); |
| 82 IntRect boundsRect(IntPoint(), contentBounds()); | 82 IntRect boundsRect(IntPoint(), bounds()); |
| 83 IntRect contentBoundsRect(IntPoint(), contentBounds()); |
| 83 | 84 |
| 84 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); | 85 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare
dQuadState()); |
| 85 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 86 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 86 | 87 |
| 87 WebRect thumbRect, backTrackRect, foreTrackRect; | 88 WebRect thumbRect, backTrackRect, foreTrackRect; |
| 88 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); | 89 m_geometry->splitTrack(&m_scrollbar, m_geometry->trackRect(&m_scrollbar), ba
ckTrackRect, thumbRect, foreTrackRect); |
| 89 if (!m_geometry->hasThumb(&m_scrollbar)) | 90 if (!m_geometry->hasThumb(&m_scrollbar)) |
| 90 thumbRect = WebRect(); | 91 thumbRect = WebRect(); |
| 91 | 92 |
| 92 if (m_thumbResourceId && !thumbRect.isEmpty()) { | 93 if (m_thumbResourceId && !thumbRect.isEmpty()) { |
| 93 OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadSta
te, IntRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height), m_thum
bResourceId, premultipledAlpha, uvRect, flipped); | 94 OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadSta
te, layerRectToContentRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvR
ect, flipped); |
| 94 quad->setNeedsBlending(); | 95 quad->setNeedsBlending(); |
| 95 quadSink.append(quad.release(), appendQuadsData); | 96 quadSink.append(quad.release(), appendQuadsData); |
| 96 } | 97 } |
| 97 | 98 |
| 98 if (!m_backTrackResourceId) | 99 if (!m_backTrackResourceId) |
| 99 return; | 100 return; |
| 100 | 101 |
| 101 // We only paint the track in two parts if we were given a texture for the f
orward track part. | 102 // We only paint the track in two parts if we were given a texture for the f
orward track part. |
| 102 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) | 103 if (m_foreTrackResourceId && !foreTrackRect.isEmpty()) |
| 103 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(foreT
rackRect.x, foreTrackRect.y, foreTrackRect.width, foreTrackRect.height), m_foreT
rackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped)
, appendQuadsData); | 104 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, layerRectToCo
ntentRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(for
eTrackRect, boundsRect), flipped), appendQuadsData); |
| 104 | 105 |
| 105 // 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 | 106 // 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 |
| 106 // fore track quads. The back track texture contains (and displays) the butt
ons. | 107 // fore track quads. The back track texture contains (and displays) the butt
ons. |
| 107 if (!boundsRect.isEmpty()) | 108 if (!contentBoundsRect.isEmpty()) |
| 108 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(bound
sRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appendQuadsD
ata); | 109 quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(conte
ntBoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appen
dQuadsData); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void CCScrollbarLayerImpl::didLoseContext() | 112 void CCScrollbarLayerImpl::didLoseContext() |
| 112 { | 113 { |
| 113 m_backTrackResourceId = 0; | 114 m_backTrackResourceId = 0; |
| 114 m_foreTrackResourceId = 0; | 115 m_foreTrackResourceId = 0; |
| 115 m_thumbResourceId = 0; | 116 m_thumbResourceId = 0; |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const | 119 bool CCScrollbarLayerImpl::CCScrollbar::isOverlay() const |
| 119 { | 120 { |
| 120 return m_owner->m_isOverlayScrollbar; | 121 return m_owner->m_isOverlayScrollbar; |
| 121 } | 122 } |
| 122 | 123 |
| 123 int CCScrollbarLayerImpl::CCScrollbar::value() const | 124 int CCScrollbarLayerImpl::CCScrollbar::value() const |
| 124 { | 125 { |
| 125 return m_owner->m_currentPos; | 126 return m_owner->m_currentPos; |
| 126 } | 127 } |
| 127 | 128 |
| 128 WebKit::WebPoint CCScrollbarLayerImpl::CCScrollbar::location() const | 129 WebKit::WebPoint CCScrollbarLayerImpl::CCScrollbar::location() const |
| 129 { | 130 { |
| 130 return WebKit::WebPoint(); | 131 return WebKit::WebPoint(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 WebKit::WebSize CCScrollbarLayerImpl::CCScrollbar::size() const | 134 WebKit::WebSize CCScrollbarLayerImpl::CCScrollbar::size() const |
| 134 { | 135 { |
| 135 return WebKit::WebSize(m_owner->contentBounds().width(), m_owner->contentBou
nds().height()); | 136 return WebKit::WebSize(m_owner->bounds().width(), m_owner->bounds().height()
); |
| 136 } | 137 } |
| 137 | 138 |
| 138 bool CCScrollbarLayerImpl::CCScrollbar::enabled() const | 139 bool CCScrollbarLayerImpl::CCScrollbar::enabled() const |
| 139 { | 140 { |
| 140 return m_owner->m_enabled; | 141 return m_owner->m_enabled; |
| 141 } | 142 } |
| 142 | 143 |
| 143 int CCScrollbarLayerImpl::CCScrollbar::maximum() const | 144 int CCScrollbarLayerImpl::CCScrollbar::maximum() const |
| 144 { | 145 { |
| 145 return m_owner->m_maximum; | 146 return m_owner->m_maximum; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 197 } |
| 197 | 198 |
| 198 const char* CCScrollbarLayerImpl::layerTypeAsString() const | 199 const char* CCScrollbarLayerImpl::layerTypeAsString() const |
| 199 { | 200 { |
| 200 return "ScrollbarLayer"; | 201 return "ScrollbarLayer"; |
| 201 } | 202 } |
| 202 | 203 |
| 203 } | 204 } |
| 204 | 205 |
| 205 #endif // USE(ACCELERATED_COMPOSITING) | 206 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |