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

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

Issue 195803003: cc: Remove OverdrawMetrics and --trace-overdraw flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-overdraw: switches Created 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/scrollbar_layer_unittest.cc ('k') | cc/layers/tiled_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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/tiled_layer.h" 5 #include "cc/layers/tiled_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "cc/debug/overdraw_metrics.h"
14 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
15 #include "cc/layers/tiled_layer_impl.h" 14 #include "cc/layers/tiled_layer_impl.h"
16 #include "cc/resources/layer_updater.h" 15 #include "cc/resources/layer_updater.h"
17 #include "cc/resources/prioritized_resource.h" 16 #include "cc/resources/prioritized_resource.h"
18 #include "cc/resources/priority_calculator.h" 17 #include "cc/resources/priority_calculator.h"
19 #include "cc/trees/layer_tree_host.h" 18 #include "cc/trees/layer_tree_host.h"
20 #include "cc/trees/occlusion_tracker.h" 19 #include "cc/trees/occlusion_tracker.h"
21 #include "third_party/khronos/GLES2/gl2.h" 20 #include "third_party/khronos/GLES2/gl2.h"
22 #include "ui/gfx/rect_conversions.h" 21 #include "ui/gfx/rect_conversions.h"
23 22
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (!HaveTexturesForTiles(left, top, right, bottom, ignore_occlusions)) { 334 if (!HaveTexturesForTiles(left, top, right, bottom, ignore_occlusions)) {
336 failed_update_ = true; 335 failed_update_ = true;
337 return false; 336 return false;
338 } 337 }
339 338
340 gfx::Rect update_rect; 339 gfx::Rect update_rect;
341 gfx::Rect paint_rect; 340 gfx::Rect paint_rect;
342 MarkTilesForUpdate( 341 MarkTilesForUpdate(
343 &update_rect, &paint_rect, left, top, right, bottom, ignore_occlusions); 342 &update_rect, &paint_rect, left, top, right, bottom, ignore_occlusions);
344 343
345 if (occlusion)
346 occlusion->overdraw_metrics()->DidPaint(paint_rect);
347
348 if (paint_rect.IsEmpty()) 344 if (paint_rect.IsEmpty())
349 return true; 345 return true;
350 346
351 *updated = true; 347 *updated = true;
352 UpdateTileTextures( 348 UpdateTileTextures(
353 update_rect, paint_rect, left, top, right, bottom, queue, occlusion); 349 update_rect, paint_rect, left, top, right, bottom, queue, occlusion);
354 return true; 350 return true;
355 } 351 }
356 352
357 void TiledLayer::MarkOcclusionsAndRequestTextures( 353 void TiledLayer::MarkOcclusionsAndRequestTextures(
358 int left, 354 int left,
359 int top, 355 int top,
360 int right, 356 int right,
361 int bottom, 357 int bottom,
362 const OcclusionTracker<Layer>* occlusion) { 358 const OcclusionTracker<Layer>* occlusion) {
363 // There is some difficult dependancies between occlusions, recording
364 // occlusion metrics and requesting memory so those are encapsulated in this
365 // function: - We only want to call RequestLate on unoccluded textures (to
366 // preserve memory for other layers when near OOM). - We only want to record
367 // occlusion metrics if all memory requests succeed.
368
369 int occluded_tile_count = 0; 359 int occluded_tile_count = 0;
370 bool succeeded = true; 360 bool succeeded = true;
371 for (int j = top; j <= bottom; ++j) { 361 for (int j = top; j <= bottom; ++j) {
372 for (int i = left; i <= right; ++i) { 362 for (int i = left; i <= right; ++i) {
373 UpdatableTile* tile = TileAt(i, j); 363 UpdatableTile* tile = TileAt(i, j);
374 DCHECK(tile); // Did SetTexturePriorities get skipped? 364 DCHECK(tile); // Did SetTexturePriorities get skipped?
375 // TODO(enne): This should not ever be null. 365 // TODO(enne): This should not ever be null.
376 if (!tile) 366 if (!tile)
377 continue; 367 continue;
378 // Did ResetUpdateState get skipped? Are we doing more than one occlusion 368 // Did ResetUpdateState get skipped? Are we doing more than one occlusion
379 // pass? 369 // pass?
380 DCHECK(!tile->occluded); 370 DCHECK(!tile->occluded);
381 gfx::Rect visible_tile_rect = gfx::IntersectRects( 371 gfx::Rect visible_tile_rect = gfx::IntersectRects(
382 tiler_->tile_bounds(i, j), visible_content_rect()); 372 tiler_->tile_bounds(i, j), visible_content_rect());
383 if (!draw_transform_is_animating() && occlusion && 373 if (!draw_transform_is_animating() && occlusion &&
384 occlusion->Occluded( 374 occlusion->Occluded(
385 render_target(), visible_tile_rect, draw_transform())) { 375 render_target(), visible_tile_rect, draw_transform())) {
386 tile->occluded = true; 376 tile->occluded = true;
387 occluded_tile_count++; 377 occluded_tile_count++;
388 } else { 378 } else {
389 succeeded &= tile->managed_resource()->RequestLate(); 379 succeeded &= tile->managed_resource()->RequestLate();
390 } 380 }
391 } 381 }
392 } 382 }
393
394 if (!succeeded)
395 return;
396 if (occlusion)
397 occlusion->overdraw_metrics()->DidCullTilesForUpload(occluded_tile_count);
398 } 383 }
399 384
400 bool TiledLayer::HaveTexturesForTiles(int left, 385 bool TiledLayer::HaveTexturesForTiles(int left,
401 int top, 386 int top,
402 int right, 387 int right,
403 int bottom, 388 int bottom,
404 bool ignore_occlusions) { 389 bool ignore_occlusions) {
405 for (int j = top; j <= bottom; ++j) { 390 for (int j = top; j <= bottom; ++j) {
406 for (int i = left; i <= right; ++i) { 391 for (int i = left; i <= right; ++i) {
407 UpdatableTile* tile = TileAt(i, j); 392 UpdatableTile* tile = TileAt(i, j);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 544
560 // Offset from paint rectangle to this tile's dirty rectangle. 545 // Offset from paint rectangle to this tile's dirty rectangle.
561 gfx::Vector2d paint_offset = source_rect.origin() - paint_rect.origin(); 546 gfx::Vector2d paint_offset = source_rect.origin() - paint_rect.origin();
562 CHECK_GE(paint_offset.x(), 0); 547 CHECK_GE(paint_offset.x(), 0);
563 CHECK_GE(paint_offset.y(), 0); 548 CHECK_GE(paint_offset.y(), 0);
564 CHECK_LE(paint_offset.x() + source_rect.width(), paint_rect.width()); 549 CHECK_LE(paint_offset.x() + source_rect.width(), paint_rect.width());
565 CHECK_LE(paint_offset.y() + source_rect.height(), paint_rect.height()); 550 CHECK_LE(paint_offset.y() + source_rect.height(), paint_rect.height());
566 551
567 tile->updater_resource()->Update( 552 tile->updater_resource()->Update(
568 queue, source_rect, dest_offset, tile->partial_update); 553 queue, source_rect, dest_offset, tile->partial_update);
569 if (occlusion) {
570 occlusion->overdraw_metrics()->
571 DidUpload(gfx::Transform(), source_rect, tile->opaque_rect());
572 }
573 } 554 }
574 } 555 }
575 } 556 }
576 557
577 // This picks a small animated layer to be anything less than one viewport. This 558 // This picks a small animated layer to be anything less than one viewport. This
578 // is specifically for page transitions which are viewport-sized layers. The 559 // is specifically for page transitions which are viewport-sized layers. The
579 // extra tile of padding is due to these layers being slightly larger than the 560 // extra tile of padding is due to these layers being slightly larger than the
580 // viewport in some cases. 561 // viewport in some cases.
581 bool TiledLayer::IsSmallAnimatedLayer() const { 562 bool TiledLayer::IsSmallAnimatedLayer() const {
582 if (!draw_transform_is_animating() && !screen_space_transform_is_animating()) 563 if (!draw_transform_is_animating() && !screen_space_transform_is_animating())
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 gfx::Rect prepaint_rect = visible_content_rect(); 894 gfx::Rect prepaint_rect = visible_content_rect();
914 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 895 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
915 -tiler_->tile_size().height() * kPrepaintRows); 896 -tiler_->tile_size().height() * kPrepaintRows);
916 gfx::Rect content_rect(content_bounds()); 897 gfx::Rect content_rect(content_bounds());
917 prepaint_rect.Intersect(content_rect); 898 prepaint_rect.Intersect(content_rect);
918 899
919 return prepaint_rect; 900 return prepaint_rect;
920 } 901 }
921 902
922 } // namespace cc 903 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/scrollbar_layer_unittest.cc ('k') | cc/layers/tiled_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698