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" |
11 #include "cc/layer_painter.h" | 11 #include "cc/layer_painter.h" |
12 #include "cc/layer_tree_host.h" | 12 #include "cc/layer_tree_host.h" |
| 13 #include "cc/resource_update_queue.h" |
13 #include "cc/scrollbar_layer_impl.h" | 14 #include "cc/scrollbar_layer_impl.h" |
14 #include "cc/texture_update_queue.h" | |
15 #include <public/WebRect.h> | 15 #include <public/WebRect.h> |
16 | 16 |
17 using WebKit::WebRect; | 17 using WebKit::WebRect; |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl() | 21 scoped_ptr<LayerImpl> ScrollbarLayer::createLayerImpl() |
22 { | 22 { |
23 return ScrollbarLayerImpl::create(id()).PassAs<LayerImpl>(); | 23 return ScrollbarLayerImpl::create(id()).PassAs<LayerImpl>(); |
24 } | 24 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (!m_foreTrack) | 202 if (!m_foreTrack) |
203 m_foreTrack = m_foreTrackUpdater->createResource(layerTreeHost()->co
ntentsTextureManager()); | 203 m_foreTrack = m_foreTrackUpdater->createResource(layerTreeHost()->co
ntentsTextureManager()); |
204 } | 204 } |
205 | 205 |
206 if (!m_thumbUpdater) | 206 if (!m_thumbUpdater) |
207 m_thumbUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarThumb
Painter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs<LayerPain
ter>()); | 207 m_thumbUpdater = CachingBitmapContentLayerUpdater::Create(ScrollbarThumb
Painter::create(m_scrollbar.get(), m_painter, m_geometry.get()).PassAs<LayerPain
ter>()); |
208 if (!m_thumb) | 208 if (!m_thumb) |
209 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur
eManager()); | 209 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur
eManager()); |
210 } | 210 } |
211 | 211 |
212 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer
Updater::Resource* texture, const IntRect& rect, TextureUpdateQueue& queue, Rend
eringStats& stats) | 212 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer
Updater::Resource* texture, const IntRect& rect, ResourceUpdateQueue& queue, Ren
deringStats& stats) |
213 { | 213 { |
214 // Skip painting and uploading if there are no invalidations and | 214 // Skip painting and uploading if there are no invalidations and |
215 // we already have valid texture data. | 215 // we already have valid texture data. |
216 if (texture->texture()->haveBackingTexture() | 216 if (texture->texture()->haveBackingTexture() |
217 && texture->texture()->size() == rect.size() | 217 && texture->texture()->size() == rect.size() |
218 && m_updateRect.isEmpty()) | 218 && m_updateRect.isEmpty()) |
219 return; | 219 return; |
220 | 220 |
221 // We should always have enough memory for UI. | 221 // We should always have enough memory for UI. |
222 DCHECK(texture->texture()->canAcquireBackingTexture()); | 222 DCHECK(texture->texture()->canAcquireBackingTexture()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); | 254 m_foreTrack->texture()->setDimensions(contentBounds(), m_textureFormat); |
255 m_foreTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit
y(drawsToRoot)); | 255 m_foreTrack->texture()->setRequestPriority(PriorityCalculator::uiPriorit
y(drawsToRoot)); |
256 } | 256 } |
257 if (m_thumb) { | 257 if (m_thumb) { |
258 IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrol
lbar.get())).size(); | 258 IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrol
lbar.get())).size(); |
259 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); | 259 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); |
260 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr
awsToRoot)); | 260 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr
awsToRoot)); |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 void ScrollbarLayer::update(TextureUpdateQueue& queue, const OcclusionTracker*,
RenderingStats& stats) | 264 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*,
RenderingStats& stats) |
265 { | 265 { |
266 if (contentBounds().isEmpty()) | 266 if (contentBounds().isEmpty()) |
267 return; | 267 return; |
268 | 268 |
269 createUpdaterIfNeeded(); | 269 createUpdaterIfNeeded(); |
270 | 270 |
271 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().
y); | 271 IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().
y); |
272 IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin
.x(), scrollbarOrigin.y(), bounds().width(), bounds().height())); | 272 IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin
.x(), scrollbarOrigin.y(), bounds().width(), bounds().height())); |
273 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue,
stats); | 273 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue,
stats); |
274 if (m_foreTrack && m_foreTrackUpdater) | 274 if (m_foreTrack && m_foreTrackUpdater) |
275 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); | 275 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); |
276 | 276 |
277 // Consider the thumb to be at the origin when painting. | 277 // Consider the thumb to be at the origin when painting. |
278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 278 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
279 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); | 279 IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumb
Rect.width, thumbRect.height)); |
280 if (!originThumbRect.isEmpty()) | 280 if (!originThumbRect.isEmpty()) |
281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 281 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
282 } | 282 } |
283 | 283 |
284 } | 284 } |
OLD | NEW |