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

Side by Side Diff: cc/resources/tile_manager.cc

Issue 291093008: cc: Prevent tiles that are required for activation from being placed in NEVER_BIN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | cc/resources/tile_manager_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 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/resources/tile_manager.h" 5 #include "cc/resources/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // Get the pending priority and bin. 583 // Get the pending priority and bin.
584 TilePriority pending_priority = tile->priority(PENDING_TREE); 584 TilePriority pending_priority = tile->priority(PENDING_TREE);
585 ManagedTileBin pending_bin = BinFromTilePriority(pending_priority); 585 ManagedTileBin pending_bin = BinFromTilePriority(pending_priority);
586 586
587 bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION; 587 bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION;
588 bool pending_is_non_ideal = 588 bool pending_is_non_ideal =
589 pending_priority.resolution == NON_IDEAL_RESOLUTION; 589 pending_priority.resolution == NON_IDEAL_RESOLUTION;
590 bool active_is_non_ideal = 590 bool active_is_non_ideal =
591 active_priority.resolution == NON_IDEAL_RESOLUTION; 591 active_priority.resolution == NON_IDEAL_RESOLUTION;
592 592
593 // Adjust pending bin state for low res tiles. This prevents
594 // pending tree low-res tiles from being initialized before
595 // high-res tiles.
596 if (pending_is_low_res)
597 pending_bin = std::max(pending_bin, EVENTUALLY_BIN);
598
599 // Adjust bin state based on if ready to draw. 593 // Adjust bin state based on if ready to draw.
600 active_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][active_bin]; 594 active_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][active_bin];
601 pending_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][pending_bin]; 595 pending_bin = kBinReadyToDrawMap[tile_is_ready_to_draw][pending_bin];
602 596
603 // Adjust bin state based on if active. 597 // Adjust bin state based on if active.
604 active_bin = kBinIsActiveMap[tile_is_active][active_bin]; 598 active_bin = kBinIsActiveMap[tile_is_active][active_bin];
605 pending_bin = kBinIsActiveMap[tile_is_active][pending_bin]; 599 pending_bin = kBinIsActiveMap[tile_is_active][pending_bin];
606 600
607 // We never want to paint new non-ideal tiles, as we always have 601 // We never want to paint new non-ideal tiles, as we always have
608 // a high-res tile covering that content (paint that instead). 602 // a high-res tile covering that content (paint that instead).
609 if (!tile_is_ready_to_draw && active_is_non_ideal) 603 if (!tile_is_ready_to_draw && active_is_non_ideal)
610 active_bin = NEVER_BIN; 604 active_bin = NEVER_BIN;
611 if (!tile_is_ready_to_draw && pending_is_non_ideal) 605 if (!tile_is_ready_to_draw && pending_is_non_ideal)
612 pending_bin = NEVER_BIN; 606 pending_bin = NEVER_BIN;
613 607
614 // Compute combined bin.
615 ManagedTileBin combined_bin = std::min(active_bin, pending_bin);
616
617 if (!tile_is_ready_to_draw || tile_version.requires_resource()) { 608 if (!tile_is_ready_to_draw || tile_version.requires_resource()) {
618 // The bin that the tile would have if the GPU memory manager had 609 // The bin that the tile would have if the GPU memory manager had
619 // a maximally permissive policy, send to the GPU memory manager 610 // a maximally permissive policy, send to the GPU memory manager
620 // to determine policy. 611 // to determine policy.
621 ManagedTileBin gpu_memmgr_stats_bin = combined_bin; 612 ManagedTileBin gpu_memmgr_stats_bin = std::min(active_bin, pending_bin);
622 if ((gpu_memmgr_stats_bin == NOW_BIN) || 613 if ((gpu_memmgr_stats_bin == NOW_BIN) ||
623 (gpu_memmgr_stats_bin == NOW_AND_READY_TO_DRAW_BIN)) 614 (gpu_memmgr_stats_bin == NOW_AND_READY_TO_DRAW_BIN))
624 memory_required_bytes_ += BytesConsumedIfAllocated(tile); 615 memory_required_bytes_ += BytesConsumedIfAllocated(tile);
625 if (gpu_memmgr_stats_bin != NEVER_BIN) 616 if (gpu_memmgr_stats_bin != NEVER_BIN)
626 memory_nice_to_have_bytes_ += BytesConsumedIfAllocated(tile); 617 memory_nice_to_have_bytes_ += BytesConsumedIfAllocated(tile);
627 } 618 }
628 619
629 ManagedTileBin tree_bin[NUM_TREES]; 620 ManagedTileBin tree_bin[NUM_TREES];
630 tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin]; 621 tree_bin[ACTIVE_TREE] = kBinPolicyMap[memory_policy][active_bin];
631 tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin]; 622 tree_bin[PENDING_TREE] = kBinPolicyMap[memory_policy][pending_bin];
632 623
624 // Adjust pending bin state for low res tiles. This prevents pending tree
625 // low-res tiles from being initialized before high-res tiles.
626 if (pending_is_low_res)
627 tree_bin[PENDING_TREE] = std::max(tree_bin[PENDING_TREE], EVENTUALLY_BIN);
628
633 TilePriority tile_priority; 629 TilePriority tile_priority;
634 switch (tree_priority) { 630 switch (tree_priority) {
635 case SAME_PRIORITY_FOR_BOTH_TREES: 631 case SAME_PRIORITY_FOR_BOTH_TREES:
636 mts.bin = kBinPolicyMap[memory_policy][combined_bin]; 632 mts.bin = std::min(tree_bin[ACTIVE_TREE], tree_bin[PENDING_TREE]);
637 tile_priority = tile->combined_priority(); 633 tile_priority = tile->combined_priority();
638 break; 634 break;
639 case SMOOTHNESS_TAKES_PRIORITY: 635 case SMOOTHNESS_TAKES_PRIORITY:
640 mts.bin = tree_bin[ACTIVE_TREE]; 636 mts.bin = tree_bin[ACTIVE_TREE];
641 tile_priority = active_priority; 637 tile_priority = active_priority;
642 break; 638 break;
643 case NEW_CONTENT_TAKES_PRIORITY: 639 case NEW_CONTENT_TAKES_PRIORITY:
644 mts.bin = tree_bin[PENDING_TREE]; 640 mts.bin = tree_bin[PENDING_TREE];
645 tile_priority = pending_priority; 641 tile_priority = pending_priority;
646 break; 642 break;
647 } 643 }
648 644
649 // Bump up the priority if we determined it's NEVER_BIN on one tree, 645 // Bump up the priority if we determined it's NEVER_BIN on one tree,
650 // but is still required on the other tree. 646 // but is still required on the other tree.
651 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN && 647 bool is_in_never_bin_on_both_trees = tree_bin[ACTIVE_TREE] == NEVER_BIN &&
652 tree_bin[PENDING_TREE] == NEVER_BIN; 648 tree_bin[PENDING_TREE] == NEVER_BIN;
653 649
654 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) 650 if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees)
655 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; 651 mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN;
656 652
657 mts.resolution = tile_priority.resolution; 653 mts.resolution = tile_priority.resolution;
658 mts.priority_bin = tile_priority.priority_bin; 654 mts.priority_bin = tile_priority.priority_bin;
659 mts.distance_to_visible = tile_priority.distance_to_visible; 655 mts.distance_to_visible = tile_priority.distance_to_visible;
660 mts.required_for_activation = tile_priority.required_for_activation; 656 mts.required_for_activation = tile_priority.required_for_activation;
661 657
662 mts.visible_and_ready_to_draw = 658 mts.visible_and_ready_to_draw =
663 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; 659 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN;
664 660
661 // Tiles that are required for activation shouldn't be in NEVER_BIN unless
662 // smoothness takes priority or memory policy allows nothing to be
663 // initialized.
664 DCHECK(!mts.required_for_activation || mts.bin != NEVER_BIN ||
665 tree_priority == SMOOTHNESS_TAKES_PRIORITY ||
666 memory_policy == ALLOW_NOTHING);
667
665 // If the tile is in NEVER_BIN and it does not have an active task, then we 668 // If the tile is in NEVER_BIN and it does not have an active task, then we
666 // can release the resources early. If it does have the task however, we 669 // can release the resources early. If it does have the task however, we
667 // should keep it in the prioritized tile set to ensure that AssignGpuMemory 670 // should keep it in the prioritized tile set to ensure that AssignGpuMemory
668 // can visit it. 671 // can visit it.
669 if (mts.bin == NEVER_BIN && 672 if (mts.bin == NEVER_BIN &&
670 !mts.tile_versions[mts.raster_mode].raster_task_) { 673 !mts.tile_versions[mts.raster_mode].raster_task_) {
671 FreeResourcesForTile(tile); 674 FreeResourcesForTile(tile);
672 continue; 675 continue;
673 } 676 }
674 677
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 } 1634 }
1632 1635
1633 void TileManager::SetRasterizersForTesting(Rasterizer* rasterizer, 1636 void TileManager::SetRasterizersForTesting(Rasterizer* rasterizer,
1634 Rasterizer* gpu_rasterizer) { 1637 Rasterizer* gpu_rasterizer) {
1635 Rasterizer* rasterizers[2] = {rasterizer, gpu_rasterizer}; 1638 Rasterizer* rasterizers[2] = {rasterizer, gpu_rasterizer};
1636 rasterizer_delegate_ = 1639 rasterizer_delegate_ =
1637 RasterizerDelegate::Create(this, rasterizers, arraysize(rasterizers)); 1640 RasterizerDelegate::Create(this, rasterizers, arraysize(rasterizers));
1638 } 1641 }
1639 1642
1640 } // namespace cc 1643 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698