| 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 #include "cc/scrollbar_layer.h" | 7 #include "cc/scrollbar_layer.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return this; | 73 return this; |
| 74 } | 74 } |
| 75 | 75 |
| 76 class ScrollbarBackgroundPainter : public LayerPainter { | 76 class ScrollbarBackgroundPainter : public LayerPainter { |
| 77 public: | 77 public: |
| 78 static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s
crollbar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeo
metry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart) | 78 static scoped_ptr<ScrollbarBackgroundPainter> create(WebKit::WebScrollbar* s
crollbar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeo
metry* geometry, WebKit::WebScrollbar::ScrollbarPart trackPart) |
| 79 { | 79 { |
| 80 return make_scoped_ptr(new ScrollbarBackgroundPainter(scrollbar, painter
, geometry, trackPart)); | 80 return make_scoped_ptr(new ScrollbarBackgroundPainter(scrollbar, painter
, geometry, trackPart)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
&) OVERRIDE | 83 virtual void paint(SkCanvas* skCanvas, const gfx::Rect& contentRect, gfx::Re
ctF&) OVERRIDE |
| 84 { | 84 { |
| 85 WebKit::WebCanvas* canvas = skCanvas; | 85 WebKit::WebCanvas* canvas = skCanvas; |
| 86 // The following is a simplification of ScrollbarThemeComposite::paint. | 86 // The following is a simplification of ScrollbarThemeComposite::paint. |
| 87 WebKit::WebRect contentWebRect(contentRect.x(), contentRect.y(), content
Rect.width(), contentRect.height()); | 87 m_painter.paintScrollbarBackground(canvas, contentRect); |
| 88 m_painter.paintScrollbarBackground(canvas, contentWebRect); | |
| 89 | 88 |
| 90 if (m_geometry->hasButtons(m_scrollbar)) { | 89 if (m_geometry->hasButtons(m_scrollbar)) { |
| 91 WebRect backButtonStartPaintRect = m_geometry->backButtonStartRect(m
_scrollbar); | 90 WebRect backButtonStartPaintRect = m_geometry->backButtonStartRect(m
_scrollbar); |
| 92 m_painter.paintBackButtonStart(canvas, backButtonStartPaintRect); | 91 m_painter.paintBackButtonStart(canvas, backButtonStartPaintRect); |
| 93 | 92 |
| 94 WebRect backButtonEndPaintRect = m_geometry->backButtonEndRect(m_scr
ollbar); | 93 WebRect backButtonEndPaintRect = m_geometry->backButtonEndRect(m_scr
ollbar); |
| 95 m_painter.paintBackButtonEnd(canvas, backButtonEndPaintRect); | 94 m_painter.paintBackButtonEnd(canvas, backButtonEndPaintRect); |
| 96 | 95 |
| 97 WebRect forwardButtonStartPaintRect = m_geometry->forwardButtonStart
Rect(m_scrollbar); | 96 WebRect forwardButtonStartPaintRect = m_geometry->forwardButtonStart
Rect(m_scrollbar); |
| 98 m_painter.paintForwardButtonStart(canvas, forwardButtonStartPaintRec
t); | 97 m_painter.paintForwardButtonStart(canvas, forwardButtonStartPaintRec
t); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds()
.height() * contentsScale())); | 140 return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds()
.height() * contentsScale())); |
| 142 } | 141 } |
| 143 | 142 |
| 144 class ScrollbarThumbPainter : public LayerPainter { | 143 class ScrollbarThumbPainter : public LayerPainter { |
| 145 public: | 144 public: |
| 146 static scoped_ptr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll
bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry
* geometry) | 145 static scoped_ptr<ScrollbarThumbPainter> create(WebKit::WebScrollbar* scroll
bar, WebKit::WebScrollbarThemePainter painter, WebKit::WebScrollbarThemeGeometry
* geometry) |
| 147 { | 146 { |
| 148 return make_scoped_ptr(new ScrollbarThumbPainter(scrollbar, painter, geo
metry)); | 147 return make_scoped_ptr(new ScrollbarThumbPainter(scrollbar, painter, geo
metry)); |
| 149 } | 148 } |
| 150 | 149 |
| 151 virtual void paint(SkCanvas* skCanvas, const IntRect& contentRect, FloatRect
& opaque) OVERRIDE | 150 virtual void paint(SkCanvas* skCanvas, const gfx::Rect& contentRect, gfx::Re
ctF& opaque) OVERRIDE |
| 152 { | 151 { |
| 153 WebKit::WebCanvas* canvas = skCanvas; | 152 WebKit::WebCanvas* canvas = skCanvas; |
| 154 | 153 |
| 155 // Consider the thumb to be at the origin when painting. | 154 // Consider the thumb to be at the origin when painting. |
| 156 WebRect thumbRect = m_geometry->thumbRect(m_scrollbar); | 155 WebRect thumbRect = m_geometry->thumbRect(m_scrollbar); |
| 157 thumbRect.x = 0; | 156 thumbRect.x = 0; |
| 158 thumbRect.y = 0; | 157 thumbRect.y = 0; |
| 159 m_painter.paintThumb(canvas, thumbRect); | 158 m_painter.paintThumb(canvas, thumbRect); |
| 160 } | 159 } |
| 161 | 160 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 return; | 218 return; |
| 220 | 219 |
| 221 // We should always have enough memory for UI. | 220 // We should always have enough memory for UI. |
| 222 DCHECK(texture->texture()->canAcquireBackingTexture()); | 221 DCHECK(texture->texture()->canAcquireBackingTexture()); |
| 223 if (!texture->texture()->canAcquireBackingTexture()) | 222 if (!texture->texture()->canAcquireBackingTexture()) |
| 224 return; | 223 return; |
| 225 | 224 |
| 226 // Paint and upload the entire part. | 225 // Paint and upload the entire part. |
| 227 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); | 226 float widthScale = static_cast<float>(contentBounds().width()) / bounds().wi
dth(); |
| 228 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); | 227 float heightScale = static_cast<float>(contentBounds().height()) / bounds().
height(); |
| 229 IntRect paintedOpaqueRect; | 228 gfx::Rect paintedOpaqueRect; |
| 230 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted
OpaqueRect, stats); | 229 painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, painted
OpaqueRect, stats); |
| 231 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture())
{ | 230 if (!painter->pixelsDidChange() && texture->texture()->haveBackingTexture())
{ |
| 232 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload
needed"); | 231 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload
needed"); |
| 233 return; | 232 return; |
| 234 } | 233 } |
| 235 | 234 |
| 236 IntSize destOffset(0, 0); | 235 gfx::Vector2d destOffset(0, 0); |
| 237 texture->update(queue, rect, destOffset, false, stats); | 236 texture->update(queue, rect, destOffset, false, stats); |
| 238 } | 237 } |
| 239 | 238 |
| 240 | 239 |
| 241 void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&) | 240 void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&) |
| 242 { | 241 { |
| 243 if (contentBounds().isEmpty()) | 242 if (contentBounds().isEmpty()) |
| 244 return; | 243 return; |
| 245 | 244 |
| 246 createUpdaterIfNeeded(); | 245 createUpdaterIfNeeded(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 275 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); | 274 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); |
| 276 | 275 |
| 277 // Consider the thumb to be at the origin when painting. | 276 // Consider the thumb to be at the origin when painting. |
| 278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 277 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
| 279 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); | 278 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); |
| 280 if (!originThumbRect.isEmpty()) | 279 if (!originThumbRect.isEmpty()) |
| 281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 280 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
| 282 } | 281 } |
| 283 | 282 |
| 284 } | 283 } |
| OLD | NEW |