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 "cc/scrollbar_layer.h" | 5 #include "cc/scrollbar_layer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 if (!m_thumb) | 242 if (!m_thumb) |
243 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur
eManager()); | 243 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur
eManager()); |
244 } | 244 } |
245 | 245 |
246 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer
Updater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue,
RenderingStats& stats) | 246 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer
Updater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue,
RenderingStats& stats) |
247 { | 247 { |
248 // Skip painting and uploading if there are no invalidations and | 248 // Skip painting and uploading if there are no invalidations and |
249 // we already have valid texture data. | 249 // we already have valid texture data. |
250 if (resource->texture()->haveBackingTexture() && | 250 if (resource->texture()->haveBackingTexture() && |
251 resource->texture()->size() == rect.size() && | 251 resource->texture()->size() == rect.size() && |
252 m_updateRect.IsEmpty()) | 252 !isDirty()) |
253 return; | 253 return; |
254 | 254 |
255 // We should always have enough memory for UI. | 255 // We should always have enough memory for UI. |
256 DCHECK(resource->texture()->canAcquireBackingTexture()); | 256 DCHECK(resource->texture()->canAcquireBackingTexture()); |
257 if (!resource->texture()->canAcquireBackingTexture()) | 257 if (!resource->texture()->canAcquireBackingTexture()) |
258 return; | 258 return; |
259 | 259 |
260 // Paint and upload the entire part. | 260 // Paint and upload the entire part. |
261 gfx::Rect paintedOpaqueRect; | 261 gfx::Rect paintedOpaqueRect; |
262 painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY
(), paintedOpaqueRect, stats); | 262 painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY
(), paintedOpaqueRect, stats); |
263 if (!painter->pixelsDidChange() && resource->texture()->haveBackingTexture()
) { | 263 if (!painter->pixelsDidChange() && resource->texture()->haveBackingTexture()
) { |
264 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload
needed"); | 264 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload
needed"); |
265 return; | 265 return; |
266 } | 266 } |
267 | 267 |
| 268 bool partialUpdatesAllowed = layerTreeHost()->settings().maxPartialTextureUp
dates > 0; |
| 269 if (!partialUpdatesAllowed) |
| 270 resource->texture()->returnBackingTexture(); |
| 271 |
268 gfx::Vector2d destOffset(0, 0); | 272 gfx::Vector2d destOffset(0, 0); |
269 resource->update(queue, rect, destOffset, false, stats); | 273 resource->update(queue, rect, destOffset, partialUpdatesAllowed, stats); |
270 } | 274 } |
271 | 275 |
272 gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layer
Rect) const | 276 gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layer
Rect) const |
273 { | 277 { |
274 // Don't intersect with the bounds as in layerRectToContentRect() because | 278 // Don't intersect with the bounds as in layerRectToContentRect() because |
275 // layerRect here might be in coordinates of the containing layer. | 279 // layerRect here might be in coordinates of the containing layer. |
276 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); | 280 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); |
277 return gfx::ToEnclosingRect(contentRect); | 281 return gfx::ToEnclosingRect(contentRect); |
278 } | 282 } |
279 | 283 |
(...skipping 19 matching lines...) Expand all Loading... |
299 gfx::Size thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbR
ect(m_scrollbar.get())).size(); | 303 gfx::Size thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbR
ect(m_scrollbar.get())).size(); |
300 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); | 304 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); |
301 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr
awsToRoot)); | 305 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr
awsToRoot)); |
302 } | 306 } |
303 } | 307 } |
304 | 308 |
305 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*
occlusion, RenderingStats& stats) | 309 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*
occlusion, RenderingStats& stats) |
306 { | 310 { |
307 ContentsScalingLayer::update(queue, occlusion, stats); | 311 ContentsScalingLayer::update(queue, occlusion, stats); |
308 | 312 |
| 313 m_dirtyRect.Union(m_updateRect); |
309 if (contentBounds().IsEmpty()) | 314 if (contentBounds().IsEmpty()) |
310 return; | 315 return; |
| 316 if (visibleContentRect().IsEmpty()) |
| 317 return; |
| 318 if (!isDirty()) |
| 319 return; |
311 | 320 |
312 createUpdaterIfNeeded(); | 321 createUpdaterIfNeeded(); |
313 | 322 |
314 gfx::Rect contentRect = scrollbarLayerRectToContentRect(gfx::Rect(m_scrollba
r->location(), bounds())); | 323 gfx::Rect contentRect = scrollbarLayerRectToContentRect(gfx::Rect(m_scrollba
r->location(), bounds())); |
315 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue,
stats); | 324 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue,
stats); |
316 if (m_foreTrack && m_foreTrackUpdater) | 325 if (m_foreTrack && m_foreTrackUpdater) |
317 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); | 326 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que
ue, stats); |
318 | 327 |
319 // Consider the thumb to be at the origin when painting. | 328 // Consider the thumb to be at the origin when painting. |
320 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); | 329 gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); |
321 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(0, 0,
thumbRect.width, thumbRect.height)); | 330 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(thumbR
ect.size())); |
322 if (!originThumbRect.IsEmpty()) | 331 if (!originThumbRect.IsEmpty()) |
323 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); | 332 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue,
stats); |
| 333 |
| 334 m_dirtyRect = gfx::RectF(); |
324 } | 335 } |
325 | 336 |
326 } // namespace cc | 337 } // namespace cc |
OLD | NEW |