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

Side by Side Diff: cc/layers/scrollbar_layer.cc

Issue 12426024: cc: Switch RenderingStats collection in Layer::Update() to RenderingStatsInstrumentation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 190965 Created 7 years, 9 months 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
« no previous file with comments | « cc/layers/scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | 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/layers/scrollbar_layer.h" 5 #include "cc/layers/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/layers/scrollbar_layer_impl.h" 9 #include "cc/layers/scrollbar_layer_impl.h"
10 #include "cc/resources/caching_bitmap_content_layer_updater.h" 10 #include "cc/resources/caching_bitmap_content_layer_updater.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 texture_format_ = 264 texture_format_ =
265 layer_tree_host()->GetRendererCapabilities().best_texture_format; 265 layer_tree_host()->GetRendererCapabilities().best_texture_format;
266 266
267 if (!back_track_updater_) { 267 if (!back_track_updater_) {
268 back_track_updater_ = CachingBitmapContentLayerUpdater::Create( 268 back_track_updater_ = CachingBitmapContentLayerUpdater::Create(
269 ScrollbarBackgroundPainter::Create( 269 ScrollbarBackgroundPainter::Create(
270 scrollbar_.get(), 270 scrollbar_.get(),
271 painter_.get(), 271 painter_.get(),
272 geometry_.get(), 272 geometry_.get(),
273 WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>()); 273 WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>(),
274 rendering_stats_instrumentation());
274 } 275 }
275 if (!back_track_) { 276 if (!back_track_) {
276 back_track_ = back_track_updater_->CreateResource( 277 back_track_ = back_track_updater_->CreateResource(
277 layer_tree_host()->contents_texture_manager()); 278 layer_tree_host()->contents_texture_manager());
278 } 279 }
279 280
280 // Only create two-part track if we think the two parts could be different in 281 // Only create two-part track if we think the two parts could be different in
281 // appearance. 282 // appearance.
282 if (scrollbar_->isCustomScrollbar()) { 283 if (scrollbar_->isCustomScrollbar()) {
283 if (!fore_track_updater_) { 284 if (!fore_track_updater_) {
284 fore_track_updater_ = CachingBitmapContentLayerUpdater::Create( 285 fore_track_updater_ = CachingBitmapContentLayerUpdater::Create(
285 ScrollbarBackgroundPainter::Create( 286 ScrollbarBackgroundPainter::Create(
286 scrollbar_.get(), 287 scrollbar_.get(),
287 painter_.get(), 288 painter_.get(),
288 geometry_.get(), 289 geometry_.get(),
289 WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>()); 290 WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>(),
291 rendering_stats_instrumentation());
290 } 292 }
291 if (!fore_track_) { 293 if (!fore_track_) {
292 fore_track_ = fore_track_updater_->CreateResource( 294 fore_track_ = fore_track_updater_->CreateResource(
293 layer_tree_host()->contents_texture_manager()); 295 layer_tree_host()->contents_texture_manager());
294 } 296 }
295 } 297 }
296 298
297 if (!thumb_updater_) { 299 if (!thumb_updater_) {
298 thumb_updater_ = CachingBitmapContentLayerUpdater::Create( 300 thumb_updater_ = CachingBitmapContentLayerUpdater::Create(
299 ScrollbarThumbPainter::Create(scrollbar_.get(), 301 ScrollbarThumbPainter::Create(scrollbar_.get(),
300 painter_.get(), 302 painter_.get(),
301 geometry_.get()).PassAs<LayerPainter>()); 303 geometry_.get()).PassAs<LayerPainter>(),
304 rendering_stats_instrumentation());
302 } 305 }
303 if (!thumb_) { 306 if (!thumb_) {
304 thumb_ = thumb_updater_->CreateResource( 307 thumb_ = thumb_updater_->CreateResource(
305 layer_tree_host()->contents_texture_manager()); 308 layer_tree_host()->contents_texture_manager());
306 } 309 }
307 } 310 }
308 311
309 void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, 312 void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
310 LayerUpdater::Resource* resource, 313 LayerUpdater::Resource* resource,
311 gfx::Rect rect, 314 gfx::Rect rect,
312 ResourceUpdateQueue* queue, 315 ResourceUpdateQueue* queue) {
313 RenderingStats* stats) {
314 if (layer_tree_host()->settings().solid_color_scrollbars) 316 if (layer_tree_host()->settings().solid_color_scrollbars)
315 return; 317 return;
316 318
317 // Skip painting and uploading if there are no invalidations and 319 // Skip painting and uploading if there are no invalidations and
318 // we already have valid texture data. 320 // we already have valid texture data.
319 if (resource->texture()->have_backing_texture() && 321 if (resource->texture()->have_backing_texture() &&
320 resource->texture()->size() == rect.size() && 322 resource->texture()->size() == rect.size() &&
321 !is_dirty()) 323 !is_dirty())
322 return; 324 return;
323 325
324 // We should always have enough memory for UI. 326 // We should always have enough memory for UI.
325 DCHECK(resource->texture()->can_acquire_backing_texture()); 327 DCHECK(resource->texture()->can_acquire_backing_texture());
326 if (!resource->texture()->can_acquire_backing_texture()) 328 if (!resource->texture()->can_acquire_backing_texture())
327 return; 329 return;
328 330
329 // Paint and upload the entire part. 331 // Paint and upload the entire part.
330 gfx::Rect painted_opaque_rect; 332 gfx::Rect painted_opaque_rect;
331 painter->PrepareToUpdate(rect, 333 painter->PrepareToUpdate(rect,
332 rect.size(), 334 rect.size(),
333 contents_scale_x(), 335 contents_scale_x(),
334 contents_scale_y(), 336 contents_scale_y(),
335 &painted_opaque_rect, 337 &painted_opaque_rect);
336 stats);
337 if (!painter->pixels_did_change() && 338 if (!painter->pixels_did_change() &&
338 resource->texture()->have_backing_texture()) { 339 resource->texture()->have_backing_texture()) {
339 TRACE_EVENT_INSTANT0("cc", 340 TRACE_EVENT_INSTANT0("cc",
340 "ScrollbarLayer::UpdatePart no texture upload needed", 341 "ScrollbarLayer::UpdatePart no texture upload needed",
341 TRACE_EVENT_SCOPE_THREAD); 342 TRACE_EVENT_SCOPE_THREAD);
342 return; 343 return;
343 } 344 }
344 345
345 bool partial_updates_allowed = 346 bool partial_updates_allowed =
346 layer_tree_host()->settings().max_partial_texture_updates > 0; 347 layer_tree_host()->settings().max_partial_texture_updates > 0;
347 if (!partial_updates_allowed) 348 if (!partial_updates_allowed)
348 resource->texture()->ReturnBackingTexture(); 349 resource->texture()->ReturnBackingTexture();
349 350
350 gfx::Vector2d dest_offset(0, 0); 351 gfx::Vector2d dest_offset(0, 0);
351 resource->Update(queue, rect, dest_offset, partial_updates_allowed, stats); 352 resource->Update(queue, rect, dest_offset, partial_updates_allowed);
352 } 353 }
353 354
354 gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect( 355 gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect(
355 gfx::Rect layer_rect) const { 356 gfx::Rect layer_rect) const {
356 // Don't intersect with the bounds as in LayerRectToContentRect() because 357 // Don't intersect with the bounds as in LayerRectToContentRect() because
357 // layer_rect here might be in coordinates of the containing layer. 358 // layer_rect here might be in coordinates of the containing layer.
358 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, 359 gfx::RectF content_rect = gfx::ScaleRect(layer_rect,
359 contents_scale_y(), 360 contents_scale_y(),
360 contents_scale_y()); 361 contents_scale_y());
361 return gfx::ToEnclosingRect(content_rect); 362 return gfx::ToEnclosingRect(content_rect);
(...skipping 26 matching lines...) Expand all
388 gfx::Rect thumb_layer_rect = geometry_->thumbRect(scrollbar_.get()); 389 gfx::Rect thumb_layer_rect = geometry_->thumbRect(scrollbar_.get());
389 gfx::Size thumb_size = 390 gfx::Size thumb_size =
390 ScrollbarLayerRectToContentRect(thumb_layer_rect).size(); 391 ScrollbarLayerRectToContentRect(thumb_layer_rect).size();
391 thumb_->texture()->SetDimensions(thumb_size, texture_format_); 392 thumb_->texture()->SetDimensions(thumb_size, texture_format_);
392 thumb_->texture()->set_request_priority( 393 thumb_->texture()->set_request_priority(
393 PriorityCalculator::UIPriority(draws_to_root)); 394 PriorityCalculator::UIPriority(draws_to_root));
394 } 395 }
395 } 396 }
396 397
397 void ScrollbarLayer::Update(ResourceUpdateQueue* queue, 398 void ScrollbarLayer::Update(ResourceUpdateQueue* queue,
398 const OcclusionTracker* occlusion, 399 const OcclusionTracker* occlusion) {
399 RenderingStats* stats) { 400 ContentsScalingLayer::Update(queue, occlusion);
400 ContentsScalingLayer::Update(queue, occlusion, stats);
401 401
402 dirty_rect_.Union(update_rect_); 402 dirty_rect_.Union(update_rect_);
403 if (content_bounds().IsEmpty()) 403 if (content_bounds().IsEmpty())
404 return; 404 return;
405 if (visible_content_rect().IsEmpty()) 405 if (visible_content_rect().IsEmpty())
406 return; 406 return;
407 407
408 CreateUpdaterIfNeeded(); 408 CreateUpdaterIfNeeded();
409 409
410 gfx::Rect content_rect = ScrollbarLayerRectToContentRect( 410 gfx::Rect content_rect = ScrollbarLayerRectToContentRect(
411 gfx::Rect(scrollbar_->location(), bounds())); 411 gfx::Rect(scrollbar_->location(), bounds()));
412 UpdatePart(back_track_updater_.get(), 412 UpdatePart(back_track_updater_.get(),
413 back_track_.get(), 413 back_track_.get(),
414 content_rect, 414 content_rect,
415 queue, 415 queue);
416 stats);
417 if (fore_track_ && fore_track_updater_) { 416 if (fore_track_ && fore_track_updater_) {
418 UpdatePart(fore_track_updater_.get(), 417 UpdatePart(fore_track_updater_.get(),
419 fore_track_.get(), 418 fore_track_.get(),
420 content_rect, 419 content_rect,
421 queue, 420 queue);
422 stats);
423 } 421 }
424 422
425 // Consider the thumb to be at the origin when painting. 423 // Consider the thumb to be at the origin when painting.
426 gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get()); 424 gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get());
427 thumb_size_ = thumb_rect.size(); 425 thumb_size_ = thumb_rect.size();
428 gfx::Rect origin_thumb_rect = 426 gfx::Rect origin_thumb_rect =
429 ScrollbarLayerRectToContentRect(gfx::Rect(thumb_rect.size())); 427 ScrollbarLayerRectToContentRect(gfx::Rect(thumb_rect.size()));
430 if (!origin_thumb_rect.IsEmpty()) { 428 if (!origin_thumb_rect.IsEmpty()) {
431 UpdatePart(thumb_updater_.get(), 429 UpdatePart(thumb_updater_.get(),
432 thumb_.get(), 430 thumb_.get(),
433 origin_thumb_rect, 431 origin_thumb_rect,
434 queue, 432 queue);
435 stats);
436 } 433 }
437 434
438 dirty_rect_ = gfx::RectF(); 435 dirty_rect_ = gfx::RectF();
439 } 436 }
440 437
441 } // namespace cc 438 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698