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

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: 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
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 texture_format_ = 265 texture_format_ =
266 layer_tree_host()->GetRendererCapabilities().best_texture_format; 266 layer_tree_host()->GetRendererCapabilities().best_texture_format;
267 267
268 if (!back_track_updater_) { 268 if (!back_track_updater_) {
269 back_track_updater_ = CachingBitmapContentLayerUpdater::Create( 269 back_track_updater_ = CachingBitmapContentLayerUpdater::Create(
270 ScrollbarBackgroundPainter::Create( 270 ScrollbarBackgroundPainter::Create(
271 scrollbar_.get(), 271 scrollbar_.get(),
272 painter_.get(), 272 painter_.get(),
273 geometry_.get(), 273 geometry_.get(),
274 WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>()); 274 WebKit::WebScrollbar::BackTrackPart).PassAs<LayerPainter>(),
275 rendering_stats_instrumentation());
275 } 276 }
276 if (!back_track_) { 277 if (!back_track_) {
277 back_track_ = back_track_updater_->CreateResource( 278 back_track_ = back_track_updater_->CreateResource(
278 layer_tree_host()->contents_texture_manager()); 279 layer_tree_host()->contents_texture_manager());
279 } 280 }
280 281
281 // Only create two-part track if we think the two parts could be different in 282 // Only create two-part track if we think the two parts could be different in
282 // appearance. 283 // appearance.
283 if (scrollbar_->isCustomScrollbar()) { 284 if (scrollbar_->isCustomScrollbar()) {
284 if (!fore_track_updater_) { 285 if (!fore_track_updater_) {
285 fore_track_updater_ = CachingBitmapContentLayerUpdater::Create( 286 fore_track_updater_ = CachingBitmapContentLayerUpdater::Create(
286 ScrollbarBackgroundPainter::Create( 287 ScrollbarBackgroundPainter::Create(
287 scrollbar_.get(), 288 scrollbar_.get(),
288 painter_.get(), 289 painter_.get(),
289 geometry_.get(), 290 geometry_.get(),
290 WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>()); 291 WebKit::WebScrollbar::ForwardTrackPart).PassAs<LayerPainter>(),
292 rendering_stats_instrumentation());
291 } 293 }
292 if (!fore_track_) { 294 if (!fore_track_) {
293 fore_track_ = fore_track_updater_->CreateResource( 295 fore_track_ = fore_track_updater_->CreateResource(
294 layer_tree_host()->contents_texture_manager()); 296 layer_tree_host()->contents_texture_manager());
295 } 297 }
296 } 298 }
297 299
298 if (!thumb_updater_) { 300 if (!thumb_updater_) {
299 thumb_updater_ = CachingBitmapContentLayerUpdater::Create( 301 thumb_updater_ = CachingBitmapContentLayerUpdater::Create(
300 ScrollbarThumbPainter::Create(scrollbar_.get(), 302 ScrollbarThumbPainter::Create(scrollbar_.get(),
301 painter_.get(), 303 painter_.get(),
302 geometry_.get()).PassAs<LayerPainter>()); 304 geometry_.get()).PassAs<LayerPainter>(),
305 rendering_stats_instrumentation());
303 } 306 }
304 if (!thumb_) { 307 if (!thumb_) {
305 thumb_ = thumb_updater_->CreateResource( 308 thumb_ = thumb_updater_->CreateResource(
306 layer_tree_host()->contents_texture_manager()); 309 layer_tree_host()->contents_texture_manager());
307 } 310 }
308 } 311 }
309 312
310 void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter, 313 void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
311 LayerUpdater::Resource* resource, 314 LayerUpdater::Resource* resource,
312 gfx::Rect rect, 315 gfx::Rect rect,
313 ResourceUpdateQueue* queue, 316 ResourceUpdateQueue* queue) {
314 RenderingStats* stats) {
315 if (layer_tree_host()->settings().solid_color_scrollbars) 317 if (layer_tree_host()->settings().solid_color_scrollbars)
316 return; 318 return;
317 319
318 // Skip painting and uploading if there are no invalidations and 320 // Skip painting and uploading if there are no invalidations and
319 // we already have valid texture data. 321 // we already have valid texture data.
320 if (resource->texture()->have_backing_texture() && 322 if (resource->texture()->have_backing_texture() &&
321 resource->texture()->size() == rect.size() && 323 resource->texture()->size() == rect.size() &&
322 !is_dirty()) 324 !is_dirty())
323 return; 325 return;
324 326
325 // We should always have enough memory for UI. 327 // We should always have enough memory for UI.
326 DCHECK(resource->texture()->can_acquire_backing_texture()); 328 DCHECK(resource->texture()->can_acquire_backing_texture());
327 if (!resource->texture()->can_acquire_backing_texture()) 329 if (!resource->texture()->can_acquire_backing_texture())
328 return; 330 return;
329 331
330 // Paint and upload the entire part. 332 // Paint and upload the entire part.
331 gfx::Rect painted_opaque_rect; 333 gfx::Rect painted_opaque_rect;
332 painter->PrepareToUpdate(rect, 334 painter->PrepareToUpdate(rect,
333 rect.size(), 335 rect.size(),
334 contents_scale_x(), 336 contents_scale_x(),
335 contents_scale_y(), 337 contents_scale_y(),
336 &painted_opaque_rect, 338 &painted_opaque_rect);
337 stats);
338 if (!painter->pixels_did_change() && 339 if (!painter->pixels_did_change() &&
339 resource->texture()->have_backing_texture()) { 340 resource->texture()->have_backing_texture()) {
340 TRACE_EVENT_INSTANT0("cc", 341 TRACE_EVENT_INSTANT0("cc",
341 "ScrollbarLayer::updatePart no texture upload needed"); 342 "ScrollbarLayer::updatePart no texture upload needed");
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

Powered by Google App Engine
This is Rietveld 408576698