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

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

Powered by Google App Engine
This is Rietveld 408576698