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

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

Issue 183563003: cc: Clean up OcclusionTracker template parameters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: occlusionparams: 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/tiled_layer.h ('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" 13 #include "cc/debug/overdraw_metrics.h"
14 #include "cc/layers/layer_impl.h" 14 #include "cc/layers/layer_impl.h"
15 #include "cc/layers/tiled_layer_impl.h" 15 #include "cc/layers/tiled_layer_impl.h"
16 #include "cc/resources/layer_updater.h" 16 #include "cc/resources/layer_updater.h"
17 #include "cc/resources/prioritized_resource.h" 17 #include "cc/resources/prioritized_resource.h"
18 #include "cc/resources/priority_calculator.h" 18 #include "cc/resources/priority_calculator.h"
19 #include "cc/trees/layer_tree_host.h" 19 #include "cc/trees/layer_tree_host.h"
20 #include "cc/trees/occlusion_tracker.h"
20 #include "third_party/khronos/GLES2/gl2.h" 21 #include "third_party/khronos/GLES2/gl2.h"
21 #include "ui/gfx/rect_conversions.h" 22 #include "ui/gfx/rect_conversions.h"
22 23
23 namespace cc { 24 namespace cc {
24 25
25 // Maximum predictive expansion of the visible area. 26 // Maximum predictive expansion of the visible area.
26 static const int kMaxPredictiveTilesCount = 2; 27 static const int kMaxPredictiveTilesCount = 2;
27 28
28 // Number of rows/columns of tiles to pre-paint. 29 // Number of rows/columns of tiles to pre-paint.
29 // We should increase these further as all textures are 30 // We should increase these further as all textures are
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 bool TiledLayer::TileOnlyNeedsPartialUpdate(UpdatableTile* tile) { 320 bool TiledLayer::TileOnlyNeedsPartialUpdate(UpdatableTile* tile) {
320 return !tile->dirty_rect.Contains(tiler_->TileRect(tile)) && 321 return !tile->dirty_rect.Contains(tiler_->TileRect(tile)) &&
321 tile->managed_resource()->have_backing_texture(); 322 tile->managed_resource()->have_backing_texture();
322 } 323 }
323 324
324 bool TiledLayer::UpdateTiles(int left, 325 bool TiledLayer::UpdateTiles(int left,
325 int top, 326 int top,
326 int right, 327 int right,
327 int bottom, 328 int bottom,
328 ResourceUpdateQueue* queue, 329 ResourceUpdateQueue* queue,
329 const OcclusionTracker* occlusion, 330 const OcclusionTracker<Layer>* occlusion,
330 bool* updated) { 331 bool* updated) {
331 CreateUpdaterIfNeeded(); 332 CreateUpdaterIfNeeded();
332 333
333 bool ignore_occlusions = !occlusion; 334 bool ignore_occlusions = !occlusion;
334 if (!HaveTexturesForTiles(left, top, right, bottom, ignore_occlusions)) { 335 if (!HaveTexturesForTiles(left, top, right, bottom, ignore_occlusions)) {
335 failed_update_ = true; 336 failed_update_ = true;
336 return false; 337 return false;
337 } 338 }
338 339
339 gfx::Rect update_rect; 340 gfx::Rect update_rect;
(...skipping 11 matching lines...) Expand all
351 UpdateTileTextures( 352 UpdateTileTextures(
352 update_rect, paint_rect, left, top, right, bottom, queue, occlusion); 353 update_rect, paint_rect, left, top, right, bottom, queue, occlusion);
353 return true; 354 return true;
354 } 355 }
355 356
356 void TiledLayer::MarkOcclusionsAndRequestTextures( 357 void TiledLayer::MarkOcclusionsAndRequestTextures(
357 int left, 358 int left,
358 int top, 359 int top,
359 int right, 360 int right,
360 int bottom, 361 int bottom,
361 const OcclusionTracker* occlusion) { 362 const OcclusionTracker<Layer>* occlusion) {
362 // There is some difficult dependancies between occlusions, recording 363 // There is some difficult dependancies between occlusions, recording
363 // occlusion metrics and requesting memory so those are encapsulated in this 364 // occlusion metrics and requesting memory so those are encapsulated in this
364 // function: - We only want to call RequestLate on unoccluded textures (to 365 // function: - We only want to call RequestLate on unoccluded textures (to
365 // preserve memory for other layers when near OOM). - We only want to record 366 // preserve memory for other layers when near OOM). - We only want to record
366 // occlusion metrics if all memory requests succeed. 367 // occlusion metrics if all memory requests succeed.
367 368
368 int occluded_tile_count = 0; 369 int occluded_tile_count = 0;
369 bool succeeded = true; 370 bool succeeded = true;
370 for (int j = top; j <= bottom; ++j) { 371 for (int j = top; j <= bottom; ++j) {
371 for (int i = left; i <= right; ++i) { 372 for (int i = left; i <= right; ++i) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 471 }
471 } 472 }
472 473
473 void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect, 474 void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect,
474 const gfx::Rect& paint_rect, 475 const gfx::Rect& paint_rect,
475 int left, 476 int left,
476 int top, 477 int top,
477 int right, 478 int right,
478 int bottom, 479 int bottom,
479 ResourceUpdateQueue* queue, 480 ResourceUpdateQueue* queue,
480 const OcclusionTracker* occlusion) { 481 const OcclusionTracker<Layer>* occlusion) {
481 // The update_rect should be in layer space. So we have to convert the 482 // The update_rect should be in layer space. So we have to convert the
482 // paint_rect from content space to layer space. 483 // paint_rect from content space to layer space.
483 float width_scale = 484 float width_scale =
484 paint_properties().bounds.width() / 485 paint_properties().bounds.width() /
485 static_cast<float>(content_bounds().width()); 486 static_cast<float>(content_bounds().width());
486 float height_scale = 487 float height_scale =
487 paint_properties().bounds.height() / 488 paint_properties().bounds.height() /
488 static_cast<float>(content_bounds().height()); 489 static_cast<float>(content_bounds().height());
489 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale); 490 update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale);
490 491
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 bound.Inset(-tiler_->tile_size().width() * kMaxPredictiveTilesCount, 726 bound.Inset(-tiler_->tile_size().width() * kMaxPredictiveTilesCount,
726 -tiler_->tile_size().height() * kMaxPredictiveTilesCount); 727 -tiler_->tile_size().height() * kMaxPredictiveTilesCount);
727 bound.Intersect(gfx::Rect(content_bounds())); 728 bound.Intersect(gfx::Rect(content_bounds()));
728 predicted_visible_rect_.Intersect(bound); 729 predicted_visible_rect_.Intersect(bound);
729 } 730 }
730 previous_content_bounds_ = content_bounds(); 731 previous_content_bounds_ = content_bounds();
731 previous_visible_rect_ = visible_content_rect(); 732 previous_visible_rect_ = visible_content_rect();
732 } 733 }
733 734
734 bool TiledLayer::Update(ResourceUpdateQueue* queue, 735 bool TiledLayer::Update(ResourceUpdateQueue* queue,
735 const OcclusionTracker* occlusion) { 736 const OcclusionTracker<Layer>* occlusion) {
736 DCHECK(!skips_draw_ && !failed_update_); // Did ResetUpdateState get skipped? 737 DCHECK(!skips_draw_ && !failed_update_); // Did ResetUpdateState get skipped?
737 738
738 // Tiled layer always causes commits to wait for activation, as it does 739 // Tiled layer always causes commits to wait for activation, as it does
739 // not support pending trees. 740 // not support pending trees.
740 SetNextCommitWaitsForActivation(); 741 SetNextCommitWaitsForActivation();
741 742
742 bool updated = false; 743 bool updated = false;
743 744
744 { 745 {
745 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, 746 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 gfx::Rect prepaint_rect = visible_content_rect(); 914 gfx::Rect prepaint_rect = visible_content_rect();
914 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 915 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
915 -tiler_->tile_size().height() * kPrepaintRows); 916 -tiler_->tile_size().height() * kPrepaintRows);
916 gfx::Rect content_rect(content_bounds()); 917 gfx::Rect content_rect(content_bounds());
917 prepaint_rect.Intersect(content_rect); 918 prepaint_rect.Intersect(content_rect);
918 919
919 return prepaint_rect; 920 return prepaint_rect;
920 } 921 }
921 922
922 } // namespace cc 923 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer.h ('k') | cc/layers/tiled_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698