Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: cc/scrollbar_layer.cc

Issue 11464041: cc: Don't use partial updates for scrollbars when they are not allowed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/scrollbar_layer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (!m_thumb) 240 if (!m_thumb)
241 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur eManager()); 241 m_thumb = m_thumbUpdater->createResource(layerTreeHost()->contentsTextur eManager());
242 } 242 }
243 243
244 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer Updater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue, RenderingStats& stats) 244 void ScrollbarLayer::updatePart(CachingBitmapContentLayerUpdater* painter, Layer Updater::Resource* resource, const gfx::Rect& rect, ResourceUpdateQueue& queue, RenderingStats& stats)
245 { 245 {
246 // Skip painting and uploading if there are no invalidations and 246 // Skip painting and uploading if there are no invalidations and
247 // we already have valid texture data. 247 // we already have valid texture data.
248 if (resource->texture()->haveBackingTexture() && 248 if (resource->texture()->haveBackingTexture() &&
249 resource->texture()->size() == rect.size() && 249 resource->texture()->size() == rect.size() &&
250 m_updateRect.IsEmpty()) 250 !isDirty())
251 return; 251 return;
252 252
253 // We should always have enough memory for UI. 253 // We should always have enough memory for UI.
254 DCHECK(resource->texture()->canAcquireBackingTexture()); 254 DCHECK(resource->texture()->canAcquireBackingTexture());
255 if (!resource->texture()->canAcquireBackingTexture()) 255 if (!resource->texture()->canAcquireBackingTexture())
256 return; 256 return;
257 257
258 // Paint and upload the entire part. 258 // Paint and upload the entire part.
259 gfx::Rect paintedOpaqueRect; 259 gfx::Rect paintedOpaqueRect;
260 painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY (), paintedOpaqueRect, stats); 260 painter->prepareToUpdate(rect, rect.size(), contentsScaleX(), contentsScaleY (), paintedOpaqueRect, stats);
261 if (!painter->pixelsDidChange() && resource->texture()->haveBackingTexture() ) { 261 if (!painter->pixelsDidChange() && resource->texture()->haveBackingTexture() ) {
262 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload needed"); 262 TRACE_EVENT_INSTANT0("cc","ScrollbarLayer::updatePart no texture upload needed");
263 return; 263 return;
264 } 264 }
265 265
266 bool partialUpdatesAllowed = layerTreeHost()->settings().maxPartialTextureUp dates > 0;
267 if (!partialUpdatesAllowed)
268 resource->texture()->returnBackingTexture();
269
266 gfx::Vector2d destOffset(0, 0); 270 gfx::Vector2d destOffset(0, 0);
267 resource->update(queue, rect, destOffset, false, stats); 271 resource->update(queue, rect, destOffset, partialUpdatesAllowed, stats);
268 } 272 }
269 273
270 gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layer Rect) const 274 gfx::Rect ScrollbarLayer::scrollbarLayerRectToContentRect(const gfx::Rect& layer Rect) const
271 { 275 {
272 // Don't intersect with the bounds as in layerRectToContentRect() because 276 // Don't intersect with the bounds as in layerRectToContentRect() because
273 // layerRect here might be in coordinates of the containing layer. 277 // layerRect here might be in coordinates of the containing layer.
274 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY()); 278 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content sScaleY());
275 return gfx::ToEnclosingRect(contentRect); 279 return gfx::ToEnclosingRect(contentRect);
276 } 280 }
277 281
(...skipping 17 matching lines...) Expand all
295 } 299 }
296 if (m_thumb) { 300 if (m_thumb) {
297 gfx::Size thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbR ect(m_scrollbar.get())).size(); 301 gfx::Size thumbSize = scrollbarLayerRectToContentRect(m_geometry->thumbR ect(m_scrollbar.get())).size();
298 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat); 302 m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
299 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr awsToRoot)); 303 m_thumb->texture()->setRequestPriority(PriorityCalculator::uiPriority(dr awsToRoot));
300 } 304 }
301 } 305 }
302 306
303 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats& stats) 307 void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats& stats)
304 { 308 {
309 m_dirtyRect.Union(m_updateRect);
enne (OOO) 2012/12/17 20:59:02 What does adding m_dirtyRect enable you to do that
danakj 2012/12/17 21:27:06 it lets you return when visibleContentRect() is em
enne (OOO) 2012/12/17 21:36:45 Ah, ok. I see. :)
305 if (contentBounds().IsEmpty()) 310 if (contentBounds().IsEmpty())
306 return; 311 return;
312 if (visibleContentRect().IsEmpty())
313 return;
314 if (!isDirty())
315 return;
307 316
308 createUpdaterIfNeeded(); 317 createUpdaterIfNeeded();
309 318
310 gfx::Rect contentRect = scrollbarLayerRectToContentRect(gfx::Rect(m_scrollba r->location(), bounds())); 319 gfx::Rect contentRect = scrollbarLayerRectToContentRect(gfx::Rect(m_scrollba r->location(), bounds()));
311 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats); 320 updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats);
312 if (m_foreTrack && m_foreTrackUpdater) 321 if (m_foreTrack && m_foreTrackUpdater)
313 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats); 322 updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, que ue, stats);
314 323
315 // Consider the thumb to be at the origin when painting. 324 // Consider the thumb to be at the origin when painting.
316 WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get()); 325 gfx::Rect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
317 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(0, 0, thumbRect.width, thumbRect.height)); 326 gfx::Rect originThumbRect = scrollbarLayerRectToContentRect(gfx::Rect(thumbR ect.size()));
318 if (!originThumbRect.IsEmpty()) 327 if (!originThumbRect.IsEmpty())
319 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats); 328 updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats);
329
330 m_dirtyRect = gfx::RectF();
320 } 331 }
321 332
322 } // namespace cc 333 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scrollbar_layer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698