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

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

Issue 15715031: cc: Remove memory state from tile management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 7 years, 6 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/resources/managed_tile_state.h ('k') | cc/resources/picture_layer_tiling_set_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/managed_tile_state.h" 5 #include "cc/resources/managed_tile_state.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 10
11 namespace cc { 11 namespace cc {
12 namespace {
13
14 scoped_ptr<base::Value> MemoryStateAsValue(TileVersionMemoryState state) {
15 switch (state) {
16 case NOT_ALLOWED_TO_USE_MEMORY:
17 return scoped_ptr<base::Value>(
18 base::Value::CreateStringValue("NOT_ALLOWED_TO_USE_MEMORY"));
19 case CAN_USE_MEMORY:
20 return scoped_ptr<base::Value>(
21 base::Value::CreateStringValue("CAN_USE_MEMORY"));
22 case USING_UNRELEASABLE_MEMORY:
23 return scoped_ptr<base::Value>(
24 base::Value::CreateStringValue("USING_UNRELEASABLE_MEMORY"));
25 case USING_RELEASABLE_MEMORY:
26 return scoped_ptr<base::Value>(
27 base::Value::CreateStringValue("USING_RELEASABLE_MEMORY"));
28 default:
29 NOTREACHED() << "Unrecognized TileVersionMemoryState value " << state;
30 return scoped_ptr<base::Value>(base::Value::CreateStringValue(
31 "<unknown TileVersionMemoryState value>"));
32 }
33 }
34
35 } // namespace
36 12
37 ManagedTileState::ManagedTileState() 13 ManagedTileState::ManagedTileState()
38 : picture_pile_analyzed(false), 14 : picture_pile_analyzed(false),
39 gpu_memmgr_stats_bin(NEVER_BIN), 15 gpu_memmgr_stats_bin(NEVER_BIN),
40 resolution(NON_IDEAL_RESOLUTION), 16 resolution(NON_IDEAL_RESOLUTION),
41 required_for_activation(false), 17 required_for_activation(false),
42 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()), 18 time_to_needed_in_seconds(std::numeric_limits<float>::infinity()),
43 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) { 19 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) {
44 for (int i = 0; i < NUM_TREES; ++i) { 20 for (int i = 0; i < NUM_TREES; ++i) {
45 tree_bin[i] = NEVER_BIN; 21 tree_bin[i] = NEVER_BIN;
46 bin[i] = NEVER_BIN; 22 bin[i] = NEVER_BIN;
47 } 23 }
48 } 24 }
49 25
50 ManagedTileState::TileVersion::TileVersion() 26 ManagedTileState::TileVersion::TileVersion()
51 : mode_(RESOURCE_MODE), 27 : mode_(RESOURCE_MODE),
52 resource_id_(0), 28 resource_id_(0),
53 resource_format_(GL_RGBA), 29 resource_format_(GL_RGBA),
54 memory_state_(NOT_ALLOWED_TO_USE_MEMORY),
55 forced_upload_(false) { 30 forced_upload_(false) {
56 } 31 }
57 32
58 ManagedTileState::TileVersion::~TileVersion() { 33 ManagedTileState::TileVersion::~TileVersion() {
59 DCHECK(!resource_); 34 DCHECK(!resource_);
60 DCHECK(memory_state_ == NOT_ALLOWED_TO_USE_MEMORY);
61 } 35 }
62 36
63 bool ManagedTileState::TileVersion::IsReadyToDraw() const { 37 bool ManagedTileState::TileVersion::IsReadyToDraw() const {
64 switch (mode_) { 38 switch (mode_) {
65 case RESOURCE_MODE: 39 case RESOURCE_MODE:
66 return resource_id_ && 40 return resource_id_ && (resource_ || forced_upload_);
67 (memory_state_ == USING_RELEASABLE_MEMORY ||
68 (memory_state_ == USING_UNRELEASABLE_MEMORY && forced_upload_));
69 case SOLID_COLOR_MODE: 41 case SOLID_COLOR_MODE:
70 case PICTURE_PILE_MODE: 42 case PICTURE_PILE_MODE:
71 return true; 43 return true;
72 default: 44 default:
73 NOTREACHED(); 45 NOTREACHED();
74 return false; 46 return false;
75 } 47 }
76 } 48 }
77 49
78 size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const { 50 size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const {
79 if (!resource_) 51 if (!resource_)
80 return 0; 52 return 0;
81 return resource_->bytes(); 53 return resource_->bytes();
82 } 54 }
83 55
84 ManagedTileState::~ManagedTileState() { 56 ManagedTileState::~ManagedTileState() {
85 } 57 }
86 58
87 scoped_ptr<base::Value> ManagedTileState::AsValue() const { 59 scoped_ptr<base::Value> ManagedTileState::AsValue() const {
88 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 60 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
89 state->SetBoolean("has_resource", tile_version.resource_.get() != 0); 61 state->SetBoolean("has_resource", tile_version.resource_.get() != 0);
90 state->Set("memory_state",
91 MemoryStateAsValue(tile_version.memory_state_).release());
92 state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); 62 state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release());
93 state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release()); 63 state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release());
94 state->Set("gpu_memmgr_stats_bin", 64 state->Set("gpu_memmgr_stats_bin",
95 TileManagerBinAsValue(bin[ACTIVE_TREE]).release()); 65 TileManagerBinAsValue(bin[ACTIVE_TREE]).release());
96 state->Set("resolution", TileResolutionAsValue(resolution).release()); 66 state->Set("resolution", TileResolutionAsValue(resolution).release());
97 state->Set("time_to_needed_in_seconds", 67 state->Set("time_to_needed_in_seconds",
98 MathUtil::AsValueSafely(time_to_needed_in_seconds).release()); 68 MathUtil::AsValueSafely(time_to_needed_in_seconds).release());
99 state->Set("distance_to_visible_in_pixels", 69 state->Set("distance_to_visible_in_pixels",
100 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release()); 70 MathUtil::AsValueSafely(distance_to_visible_in_pixels).release());
101 state->SetBoolean("required_for_activation", required_for_activation); 71 state->SetBoolean("required_for_activation", required_for_activation);
102 state->SetBoolean("is_picture_pile_analyzed", picture_pile_analyzed); 72 state->SetBoolean("is_picture_pile_analyzed", picture_pile_analyzed);
103 state->SetBoolean("is_solid_color", picture_pile_analysis.is_solid_color); 73 state->SetBoolean("is_solid_color", picture_pile_analysis.is_solid_color);
104 state->SetBoolean("is_transparent", 74 state->SetBoolean("is_transparent",
105 picture_pile_analysis.is_solid_color && 75 picture_pile_analysis.is_solid_color &&
106 !SkColorGetA(picture_pile_analysis.solid_color)); 76 !SkColorGetA(picture_pile_analysis.solid_color));
107 return state.PassAs<base::Value>(); 77 return state.PassAs<base::Value>();
108 } 78 }
109 79
110 } // namespace cc 80 } // namespace cc
111 81
OLDNEW
« no previous file with comments | « cc/resources/managed_tile_state.h ('k') | cc/resources/picture_layer_tiling_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698