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