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

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

Issue 643583003: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: foramted. Created 6 years, 2 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 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 tiler_->TakeTile((*iter)->i(), (*iter)->j()); 229 tiler_->TakeTile((*iter)->i(), (*iter)->j());
230 230
231 // TiledLayer must push properties every frame, since viewport state and 231 // TiledLayer must push properties every frame, since viewport state and
232 // occlusion from anywhere in the tree can change what the layer decides to 232 // occlusion from anywhere in the tree can change what the layer decides to
233 // push to the impl tree. 233 // push to the impl tree.
234 needs_push_properties_ = true; 234 needs_push_properties_ = true;
235 } 235 }
236 236
237 PrioritizedResourceManager* TiledLayer::ResourceManager() { 237 PrioritizedResourceManager* TiledLayer::ResourceManager() {
238 if (!layer_tree_host()) 238 if (!layer_tree_host())
239 return NULL; 239 return nullptr;
240 return layer_tree_host()->contents_texture_manager(); 240 return layer_tree_host()->contents_texture_manager();
241 } 241 }
242 242
243 const PrioritizedResource* TiledLayer::ResourceAtForTesting(int i, 243 const PrioritizedResource* TiledLayer::ResourceAtForTesting(int i,
244 int j) const { 244 int j) const {
245 UpdatableTile* tile = TileAt(i, j); 245 UpdatableTile* tile = TileAt(i, j);
246 if (!tile) 246 if (!tile)
247 return NULL; 247 return nullptr;
248 return tile->managed_resource(); 248 return tile->managed_resource();
249 } 249 }
250 250
251 void TiledLayer::SetLayerTreeHost(LayerTreeHost* host) { 251 void TiledLayer::SetLayerTreeHost(LayerTreeHost* host) {
252 if (host && host != layer_tree_host()) { 252 if (host && host != layer_tree_host()) {
253 for (LayerTilingData::TileMap::const_iterator 253 for (LayerTilingData::TileMap::const_iterator
254 iter = tiler_->tiles().begin(); 254 iter = tiler_->tiles().begin();
255 iter != tiler_->tiles().end(); 255 iter != tiler_->tiles().end();
256 ++iter) { 256 ++iter) {
257 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second); 257 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 // Animation pre-paint. If the layer is small, try to paint it all 705 // Animation pre-paint. If the layer is small, try to paint it all
706 // immediately whether or not it is occluded, to avoid paint/upload 706 // immediately whether or not it is occluded, to avoid paint/upload
707 // hiccups while it is animating. 707 // hiccups while it is animating.
708 if (IsSmallAnimatedLayer()) { 708 if (IsSmallAnimatedLayer()) {
709 int left, top, right, bottom; 709 int left, top, right, bottom;
710 tiler_->ContentRectToTileIndices(gfx::Rect(content_bounds()), 710 tiler_->ContentRectToTileIndices(gfx::Rect(content_bounds()),
711 &left, 711 &left,
712 &top, 712 &top,
713 &right, 713 &right,
714 &bottom); 714 &bottom);
715 UpdateTiles(left, top, right, bottom, queue, NULL, &updated); 715 UpdateTiles(left, top, right, bottom, queue, nullptr, &updated);
716 if (updated) 716 if (updated)
717 return updated; 717 return updated;
718 // This was an attempt to paint the entire layer so if we fail it's okay, 718 // This was an attempt to paint the entire layer so if we fail it's okay,
719 // just fallback on painting visible etc. below. 719 // just fallback on painting visible etc. below.
720 failed_update_ = false; 720 failed_update_ = false;
721 } 721 }
722 722
723 if (predicted_visible_rect_.IsEmpty()) 723 if (predicted_visible_rect_.IsEmpty())
724 return updated; 724 return updated;
725 725
(...skipping 10 matching lines...) Expand all
736 if (skips_draw_ || updated) 736 if (skips_draw_ || updated)
737 return true; 737 return true;
738 738
739 // If we have already painting everything visible. Do some pre-painting while 739 // If we have already painting everything visible. Do some pre-painting while
740 // idle. 740 // idle.
741 gfx::Rect idle_paint_content_rect = IdlePaintRect(); 741 gfx::Rect idle_paint_content_rect = IdlePaintRect();
742 if (idle_paint_content_rect.IsEmpty()) 742 if (idle_paint_content_rect.IsEmpty())
743 return updated; 743 return updated;
744 744
745 // Prepaint anything that was occluded but inside the layer's visible region. 745 // Prepaint anything that was occluded but inside the layer's visible region.
746 if (!UpdateTiles(left, top, right, bottom, queue, NULL, &updated) || 746 if (!UpdateTiles(left, top, right, bottom, queue, nullptr, &updated) ||
747 updated) 747 updated)
748 return updated; 748 return updated;
749 749
750 int prepaint_left, prepaint_top, prepaint_right, prepaint_bottom; 750 int prepaint_left, prepaint_top, prepaint_right, prepaint_bottom;
751 tiler_->ContentRectToTileIndices(idle_paint_content_rect, 751 tiler_->ContentRectToTileIndices(idle_paint_content_rect,
752 &prepaint_left, 752 &prepaint_left,
753 &prepaint_top, 753 &prepaint_top,
754 &prepaint_right, 754 &prepaint_right,
755 &prepaint_bottom); 755 &prepaint_bottom);
756 756
757 // Then expand outwards one row/column at a time until we find a dirty 757 // Then expand outwards one row/column at a time until we find a dirty
758 // row/column to update. Increment along the major and minor scroll directions 758 // row/column to update. Increment along the major and minor scroll directions
759 // first. 759 // first.
760 gfx::Vector2d delta = -predicted_scroll_; 760 gfx::Vector2d delta = -predicted_scroll_;
761 delta = gfx::Vector2d(delta.x() == 0 ? 1 : delta.x(), 761 delta = gfx::Vector2d(delta.x() == 0 ? 1 : delta.x(),
762 delta.y() == 0 ? 1 : delta.y()); 762 delta.y() == 0 ? 1 : delta.y());
763 gfx::Vector2d major_delta = 763 gfx::Vector2d major_delta =
764 (std::abs(delta.x()) > std::abs(delta.y())) ? gfx::Vector2d(delta.x(), 0) 764 (std::abs(delta.x()) > std::abs(delta.y())) ? gfx::Vector2d(delta.x(), 0)
765 : gfx::Vector2d(0, delta.y()); 765 : gfx::Vector2d(0, delta.y());
766 gfx::Vector2d minor_delta = 766 gfx::Vector2d minor_delta =
767 (std::abs(delta.x()) <= std::abs(delta.y())) ? gfx::Vector2d(delta.x(), 0) 767 (std::abs(delta.x()) <= std::abs(delta.y())) ? gfx::Vector2d(delta.x(), 0)
768 : gfx::Vector2d(0, delta.y()); 768 : gfx::Vector2d(0, delta.y());
769 gfx::Vector2d deltas[4] = { major_delta, minor_delta, -major_delta, 769 gfx::Vector2d deltas[4] = { major_delta, minor_delta, -major_delta,
770 -minor_delta }; 770 -minor_delta };
771 for (int i = 0; i < 4; i++) { 771 for (int i = 0; i < 4; i++) {
772 if (deltas[i].y() > 0) { 772 if (deltas[i].y() > 0) {
773 while (bottom < prepaint_bottom) { 773 while (bottom < prepaint_bottom) {
774 ++bottom; 774 ++bottom;
775 if (!UpdateTiles( 775 if (!UpdateTiles(
776 left, bottom, right, bottom, queue, NULL, &updated) || 776 left, bottom, right, bottom, queue, nullptr, &updated) ||
777 updated) 777 updated)
778 return updated; 778 return updated;
779 } 779 }
780 } 780 }
781 if (deltas[i].y() < 0) { 781 if (deltas[i].y() < 0) {
782 while (top > prepaint_top) { 782 while (top > prepaint_top) {
783 --top; 783 --top;
784 if (!UpdateTiles( 784 if (!UpdateTiles(left, top, right, top, queue, nullptr, &updated) ||
785 left, top, right, top, queue, NULL, &updated) ||
786 updated) 785 updated)
787 return updated; 786 return updated;
788 } 787 }
789 } 788 }
790 if (deltas[i].x() < 0) { 789 if (deltas[i].x() < 0) {
791 while (left > prepaint_left) { 790 while (left > prepaint_left) {
792 --left; 791 --left;
793 if (!UpdateTiles( 792 if (!UpdateTiles(left, top, left, bottom, queue, nullptr, &updated) ||
794 left, top, left, bottom, queue, NULL, &updated) ||
795 updated) 793 updated)
796 return updated; 794 return updated;
797 } 795 }
798 } 796 }
799 if (deltas[i].x() > 0) { 797 if (deltas[i].x() > 0) {
800 while (right < prepaint_right) { 798 while (right < prepaint_right) {
801 ++right; 799 ++right;
802 if (!UpdateTiles( 800 if (!UpdateTiles(right, top, right, bottom, queue, nullptr, &updated) ||
803 right, top, right, bottom, queue, NULL, &updated) ||
804 updated) 801 updated)
805 return updated; 802 return updated;
806 } 803 }
807 } 804 }
808 } 805 }
809 return updated; 806 return updated;
810 } 807 }
811 808
812 void TiledLayer::OnOutputSurfaceCreated() { 809 void TiledLayer::OnOutputSurfaceCreated() {
813 // Ensure that all textures are of the right format. 810 // Ensure that all textures are of the right format.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 gfx::Rect prepaint_rect = visible_content_rect(); 860 gfx::Rect prepaint_rect = visible_content_rect();
864 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, 861 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns,
865 -tiler_->tile_size().height() * kPrepaintRows); 862 -tiler_->tile_size().height() * kPrepaintRows);
866 gfx::Rect content_rect(content_bounds()); 863 gfx::Rect content_rect(content_bounds());
867 prepaint_rect.Intersect(content_rect); 864 prepaint_rect.Intersect(content_rect);
868 865
869 return prepaint_rect; 866 return prepaint_rect;
870 } 867 }
871 868
872 } // namespace cc 869 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698