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

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

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! Created 6 years, 11 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/tiled_layer.h ('k') | cc/layers/tiled_layer_impl.h » ('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"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 CHECK(TileAt(i, j)); 287 CHECK(TileAt(i, j));
288 288
289 return added_tile; 289 return added_tile;
290 } 290 }
291 291
292 void TiledLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { 292 void TiledLayer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) {
293 InvalidateContentRect(LayerRectToContentRect(dirty_rect)); 293 InvalidateContentRect(LayerRectToContentRect(dirty_rect));
294 ContentsScalingLayer::SetNeedsDisplayRect(dirty_rect); 294 ContentsScalingLayer::SetNeedsDisplayRect(dirty_rect);
295 } 295 }
296 296
297 void TiledLayer::InvalidateContentRect(gfx::Rect content_rect) { 297 void TiledLayer::InvalidateContentRect(const gfx::Rect& content_rect) {
298 UpdateBounds(); 298 UpdateBounds();
299 if (tiler_->is_empty() || content_rect.IsEmpty() || skips_draw_) 299 if (tiler_->is_empty() || content_rect.IsEmpty() || skips_draw_)
300 return; 300 return;
301 301
302 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); 302 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin();
303 iter != tiler_->tiles().end(); 303 iter != tiler_->tiles().end();
304 ++iter) { 304 ++iter) {
305 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 305 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
306 DCHECK(tile); 306 DCHECK(tile);
307 // TODO(enne): This should not ever be null. 307 // TODO(enne): This should not ever be null.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 tile->managed_resource()->ReturnBackingTexture(); 461 tile->managed_resource()->ReturnBackingTexture();
462 } 462 }
463 } 463 }
464 464
465 paint_rect->Union(tile->dirty_rect); 465 paint_rect->Union(tile->dirty_rect);
466 tile->MarkForUpdate(); 466 tile->MarkForUpdate();
467 } 467 }
468 } 468 }
469 } 469 }
470 470
471 void TiledLayer::UpdateTileTextures(gfx::Rect update_rect, 471 void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect,
472 gfx::Rect paint_rect, 472 const gfx::Rect& paint_rect,
473 int left, 473 int left,
474 int top, 474 int top,
475 int right, 475 int right,
476 int bottom, 476 int bottom,
477 ResourceUpdateQueue* queue, 477 ResourceUpdateQueue* queue,
478 const OcclusionTracker* occlusion) { 478 const OcclusionTracker* occlusion) {
479 // The update_rect should be in layer space. So we have to convert the 479 // The update_rect should be in layer space. So we have to convert the
480 // paint_rect from content space to layer space. 480 // paint_rect from content space to layer space.
481 float width_scale = 481 float width_scale =
482 paint_properties().bounds.width() / 482 paint_properties().bounds.width() /
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return content_rect.width() <= 586 return content_rect.width() <=
587 viewport_size.width() + tiler_->tile_size().width() && 587 viewport_size.width() + tiler_->tile_size().width() &&
588 content_rect.height() <= 588 content_rect.height() <=
589 viewport_size.height() + tiler_->tile_size().height(); 589 viewport_size.height() + tiler_->tile_size().height();
590 } 590 }
591 591
592 namespace { 592 namespace {
593 // TODO(epenner): Remove this and make this based on distance once distance can 593 // TODO(epenner): Remove this and make this based on distance once distance can
594 // be calculated for offscreen layers. For now, prioritize all small animated 594 // be calculated for offscreen layers. For now, prioritize all small animated
595 // layers after 512 pixels of pre-painting. 595 // layers after 512 pixels of pre-painting.
596 void SetPriorityForTexture(gfx::Rect visible_rect, 596 void SetPriorityForTexture(const gfx::Rect& visible_rect,
597 gfx::Rect tile_rect, 597 const gfx::Rect& tile_rect,
598 bool draws_to_root, 598 bool draws_to_root,
599 bool is_small_animated_layer, 599 bool is_small_animated_layer,
600 PrioritizedResource* texture) { 600 PrioritizedResource* texture) {
601 int priority = PriorityCalculator::LowestPriority(); 601 int priority = PriorityCalculator::LowestPriority();
602 if (!visible_rect.IsEmpty()) { 602 if (!visible_rect.IsEmpty()) {
603 priority = PriorityCalculator::PriorityFromDistance( 603 priority = PriorityCalculator::PriorityFromDistance(
604 visible_rect, tile_rect, draws_to_root); 604 visible_rect, tile_rect, draws_to_root);
605 } 605 }
606 606
607 if (is_small_animated_layer) { 607 if (is_small_animated_layer) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ++iter) { 677 ++iter) {
678 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 678 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
679 // TODO(enne): This should not ever be null. 679 // TODO(enne): This should not ever be null.
680 if (!tile) 680 if (!tile)
681 continue; 681 continue;
682 tile->ResetUpdateState(); 682 tile->ResetUpdateState();
683 } 683 }
684 } 684 }
685 685
686 namespace { 686 namespace {
687 gfx::Rect ExpandRectByDelta(gfx::Rect rect, gfx::Vector2d delta) { 687 gfx::Rect ExpandRectByDelta(const gfx::Rect& rect, gfx::Vector2d delta) {
688 int width = rect.width() + std::abs(delta.x()); 688 int width = rect.width() + std::abs(delta.x());
689 int height = rect.height() + std::abs(delta.y()); 689 int height = rect.height() + std::abs(delta.y());
690 int x = rect.x() + ((delta.x() < 0) ? delta.x() : 0); 690 int x = rect.x() + ((delta.x() < 0) ? delta.x() : 0);
691 int y = rect.y() + ((delta.y() < 0) ? delta.y() : 0); 691 int y = rect.y() + ((delta.y() < 0) ? delta.y() : 0);
692 return gfx::Rect(x, y, width, height); 692 return gfx::Rect(x, y, width, height);
693 } 693 }
694 } 694 }
695 695
696 void TiledLayer::UpdateScrollPrediction() { 696 void TiledLayer::UpdateScrollPrediction() {
697 // This scroll prediction is very primitive and should be replaced by a 697 // This scroll prediction is very primitive and should be replaced by a
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 gfx::Rect prepaint_rect = visible_content_rect(); 911 gfx::Rect prepaint_rect = visible_content_rect();
912 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 912 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
913 -tiler_->tile_size().height() * kPrepaintRows); 913 -tiler_->tile_size().height() * kPrepaintRows);
914 gfx::Rect content_rect(content_bounds()); 914 gfx::Rect content_rect(content_bounds());
915 prepaint_rect.Intersect(content_rect); 915 prepaint_rect.Intersect(content_rect);
916 916
917 return prepaint_rect; 917 return prepaint_rect;
918 } 918 }
919 919
920 } // namespace cc 920 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer.h ('k') | cc/layers/tiled_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698