| 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 "ScrollbarLayerChromium.h" | 9 #include "ScrollbarLayerChromium.h" |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 , m_trackPart(trackPart) | 124 , m_trackPart(trackPart) |
| 125 { | 125 { |
| 126 } | 126 } |
| 127 | 127 |
| 128 WebKit::WebScrollbar* m_scrollbar; | 128 WebKit::WebScrollbar* m_scrollbar; |
| 129 WebKit::WebScrollbarThemePainter m_painter; | 129 WebKit::WebScrollbarThemePainter m_painter; |
| 130 WebKit::WebScrollbarThemeGeometry* m_geometry; | 130 WebKit::WebScrollbarThemeGeometry* m_geometry; |
| 131 WebKit::WebScrollbar::ScrollbarPart m_trackPart; | 131 WebKit::WebScrollbar::ScrollbarPart m_trackPart; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 bool ScrollbarLayerChromium::needsContentsScale() const | |
| 135 { | |
| 136 return true; | |
| 137 } | |
| 138 | |
| 139 IntSize ScrollbarLayerChromium::contentBounds() const | |
| 140 { | |
| 141 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds()
.height() * contentsScale())); | |
| 142 } | |
| 143 | |
| 144 class ScrollbarThumbPainter : public LayerPainterChromium { | 134 class ScrollbarThumbPainter : public LayerPainterChromium { |
| 145 WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter); | 135 WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter); |
| 146 public: | 136 public: |
| 147 static PassOwnPtr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll
bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry
* geometry) | 137 static PassOwnPtr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll
bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry
* geometry) |
| 148 { | 138 { |
| 149 return adoptPtr(new ScrollbarThumbPainter(scrollbar, painter, geometry))
; | 139 return adoptPtr(new ScrollbarThumbPainter(scrollbar, painter, geometry))
; |
| 150 } | 140 } |
| 151 | 141 |
| 152 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
& opaque) OVERRIDE | 142 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
& opaque) OVERRIDE |
| 153 { | 143 { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 && texture->texture()->size() == rect.size() | 206 && texture->texture()->size() == rect.size() |
| 217 && m_updateRect.isEmpty()) | 207 && m_updateRect.isEmpty()) |
| 218 return; | 208 return; |
| 219 | 209 |
| 220 // We should always have enough memory for UI. | 210 // We should always have enough memory for UI. |
| 221 ASSERT(texture->texture()->canAcquireBackingTexture()); | 211 ASSERT(texture->texture()->canAcquireBackingTexture()); |
| 222 if (!texture->texture()->canAcquireBackingTexture()) | 212 if (!texture->texture()->canAcquireBackingTexture()) |
| 223 return; | 213 return; |
| 224 | 214 |
| 225 // Paint and upload the entire part. | 215 // Paint and upload the entire part. |
| 226 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); | |
| 227 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); | |
| 228 IntRect paintedOpaqueRect; | 216 IntRect paintedOpaqueRect; |
| 229 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted
OpaqueRect, stats); | 217 painter->prepareToUpdate(rect, rect.size(), 1, 1, paintedOpaqueRect, stats); |
| 230 texture->prepareRect(rect, stats); | 218 texture->prepareRect(rect, stats); |
| 231 | 219 |
| 232 IntSize destOffset(0, 0); | 220 IntSize destOffset(0, 0); |
| 233 TextureUploader::Parameters upload = { texture, rect, destOffset }; | 221 TextureUploader::Parameters upload = { texture, rect, destOffset }; |
| 234 queue.appendFullUpload(upload); | 222 queue.appendFullUpload(upload); |
| 235 } | 223 } |
| 236 | 224 |
| 237 | 225 |
| 238 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&) | 226 void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&) |
| 239 { | 227 { |
| 240 if (contentBounds().isEmpty()) | 228 if (contentBounds().isEmpty()) |
| 241 return; | 229 return; |
| 242 | 230 |
| 243 createTextureUpdaterIfNeeded(); | 231 createTextureUpdaterIfNeeded(); |
| 244 | 232 |
| 245 bool drawsToRoot = !renderTarget()->parent(); | 233 bool drawsToRoot = !renderTarget()->parent(); |
| 246 if (m_backTrack) { | 234 if (m_backTrack) { |
| 247 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat); | 235 m_backTrack->texture()->setDimensions(contentBounds(), m_textureFormat); |
| 248 m_backTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior
ity(drawsToRoot)); | 236 m_backTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior
ity(drawsToRoot)); |
| 249 } | 237 } |
| 250 if (m_foreTrack) { | 238 if (m_foreTrack) { |
| 251 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); | 239 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); |
| 252 m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior
ity(drawsToRoot)); | 240 m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPrior
ity(drawsToRoot)); |
| 253 } | 241 } |
| 254 if (m_thumb) { | 242 if (m_thumb) { |
| 255 IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrol
lbar.get())).size(); | 243 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
| 256 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); | 244 m_thumb->texture()->setDimensions(IntSize(thumbRect.width, thumbRect.hei
ght), m_textureFormat); |
| 257 m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(
drawsToRoot)); | 245 m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(
drawsToRoot)); |
| 258 } | 246 } |
| 259 } | 247 } |
| 260 | 248 |
| 261 void ScrollbarLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusi
onTracker*, CCRenderingStats& stats) | 249 void ScrollbarLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusi
onTracker*, CCRenderingStats& stats) |
| 262 { | 250 { |
| 263 if (contentBounds().isEmpty()) | 251 if (contentBounds().isEmpty()) |
| 264 return; | 252 return; |
| 265 | 253 |
| 266 createTextureUpdaterIfNeeded(); | 254 createTextureUpdaterIfNeeded(); |
| 267 | 255 |
| 268 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().
y); | 256 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().
y); |
| 269 IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin
.x(), scrollbarOrigin.y(), bounds().width(), bounds().height())); | 257 IntRect contentRect(scrollbarOrigin, contentBounds()); |
| 270 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue,
stats); | 258 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue,
stats); |
| 271 if (m_foreTrack && m_foreTrackUpdater) | 259 if (m_foreTrack && m_foreTrackUpdater) |
| 272 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); | 260 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); |
| 273 | 261 |
| 274 // Consider the thumb to be at the origin when painting. | 262 // Consider the thumb to be at the origin when painting. |
| 275 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 263 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
| 276 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); | 264 IntRect originThumbRect = IntRect(0, 0, thumbRect.width, thumbRect.height); |
| 277 if (!originThumbRect.isEmpty()) | 265 if (!originThumbRect.isEmpty()) |
| 278 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 266 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
| 279 } | 267 } |
| 280 | 268 |
| 281 } | 269 } |
| 282 #endif // USE(ACCELERATED_COMPOSITING) | 270 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |