summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 07:17:59 +0000
committervmpstr@chromium.org <vmpstr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 07:17:59 +0000
commitd0f83829a4419918c1afb3d81693eb27fd4c963b (patch)
treede523b1cbf1e7b27633625cad3690998fbed09e8
parent2aaadde0f6760c4a3419e5e9af964a6ff8ee9968 (diff)
downloadchromium_src-d0f83829a4419918c1afb3d81693eb27fd4c963b.zip
chromium_src-d0f83829a4419918c1afb3d81693eb27fd4c963b.tar.gz
chromium_src-d0f83829a4419918c1afb3d81693eb27fd4c963b.tar.bz2
cc: Updated code to properly serialize tiles to json
With --trace-all-rendered-frames enabled, (it seems) more tiles are being traced and some of those tiles have uninitialized values. This changed updates them to be valid. Additionally, some tile values are initialized to infinity, which doesn't serialize to JSON well. This change also adds a large, yet finite, number for those cases. Review URL: https://chromiumcodereview.appspot.com/12210152 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182637 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/math_util.cc10
-rw-r--r--cc/math_util.h6
-rw-r--r--cc/tile_manager.cc19
-rw-r--r--cc/tile_priority.cc10
4 files changed, 33 insertions, 12 deletions
diff --git a/cc/math_util.cc b/cc/math_util.cc
index ff24fa2..f5c0cb4 100644
--- a/cc/math_util.cc
+++ b/cc/math_util.cc
@@ -409,4 +409,14 @@ scoped_ptr<base::Value> MathUtil::asValue(gfx::QuadF q) {
return res.PassAs<base::Value>();
}
+scoped_ptr<base::Value> MathUtil::asValueSafely(double value) {
+ return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
+ std::min(value, std::numeric_limits<double>::max())));
+}
+
+scoped_ptr<base::Value> MathUtil::asValueSafely(float value) {
+ return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
+ std::min(value, std::numeric_limits<float>::max())));
+}
+
} // namespace cc
diff --git a/cc/math_util.h b/cc/math_util.h
index de6288a..8c1ca88 100644
--- a/cc/math_util.h
+++ b/cc/math_util.h
@@ -123,6 +123,12 @@ public:
static scoped_ptr<base::Value> asValue(gfx::Size s);
static scoped_ptr<base::Value> asValue(gfx::PointF q);
static scoped_ptr<base::Value> asValue(gfx::QuadF q);
+
+ // Returns a base::Value representation of the floating point value.
+ // If the value is inf, returns max double/float representation.
+ static scoped_ptr<base::Value> asValueSafely(double value);
+ static scoped_ptr<base::Value> asValueSafely(float value);
+
};
} // namespace cc
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index 6bb8b43..ef96035 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -11,6 +11,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "cc/math_util.h"
#include "cc/platform_color.h"
#include "cc/raster_worker_pool.h"
#include "cc/resource_pool.h"
@@ -97,7 +98,7 @@ scoped_ptr<base::Value> TileManagerBinAsValue(TileManagerBin bin) {
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"NEVER_BIN"));
default:
- DCHECK(false) << "Unrecognized TileManagerBin value";
+ DCHECK(false) << "Unrecognized TileManagerBin value " << bin;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown TileManagerBin value>"));
}
@@ -148,9 +149,13 @@ ManagedTileState::ManagedTileState()
contents_swizzled(false),
need_to_gather_pixel_refs(true),
gpu_memmgr_stats_bin(NEVER_BIN),
- raster_state(IDLE_STATE) {
- for (int i = 0; i < NUM_TREES; ++i)
+ raster_state(IDLE_STATE),
+ resolution(NON_IDEAL_RESOLUTION),
+ time_to_needed_in_seconds(std::numeric_limits<float>::infinity()) {
+ for (int i = 0; i < NUM_TREES; ++i) {
tree_bin[i] = NEVER_BIN;
+ bin[i] = NEVER_BIN;
+ }
}
ManagedTileState::~ManagedTileState() {
@@ -165,11 +170,11 @@ scoped_ptr<base::Value> ManagedTileState::AsValue() const {
state->SetBoolean("has_resource", resource.get() != 0);
state->SetBoolean("resource_is_being_initialized", resource_is_being_initialized);
state->Set("raster_state", TileRasterStateAsValue(raster_state).release());
- state->Set("bin.0", TileManagerBinAsValue(bin[0]).release());
- state->Set("bin.1", TileManagerBinAsValue(bin[0]).release());
- state->Set("gpu_memmgr_stats_bin", TileManagerBinAsValue(bin[0]).release());
+ state->Set("bin.0", TileManagerBinAsValue(bin[ACTIVE_TREE]).release());
+ state->Set("bin.1", TileManagerBinAsValue(bin[PENDING_TREE]).release());
+ state->Set("gpu_memmgr_stats_bin", TileManagerBinAsValue(bin[ACTIVE_TREE]).release());
state->Set("resolution", TileResolutionAsValue(resolution).release());
- state->SetDouble("time_to_needed_in_seconds", time_to_needed_in_seconds);
+ state->Set("time_to_needed_in_seconds", MathUtil::asValueSafely(time_to_needed_in_seconds).release());
return state.PassAs<base::Value>();
}
diff --git a/cc/tile_priority.cc b/cc/tile_priority.cc
index a6a05a5..1282053 100644
--- a/cc/tile_priority.cc
+++ b/cc/tile_priority.cc
@@ -65,7 +65,7 @@ scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) {
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"PENDING_TREE"));
default:
- DCHECK(false) << "Unrecognized WhichTree value";
+ DCHECK(false) << "Unrecognized WhichTree value " << tree;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown WhichTree value>"));
}
@@ -84,7 +84,7 @@ scoped_ptr<base::Value> TileResolutionAsValue(
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"NON_IDEAL_RESOLUTION"));
default:
- DCHECK(false) << "Unrecognized TileResolution value";
+ DCHECK(false) << "Unrecognized TileResolution value " << resolution;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown TileResolution value>"));
}
@@ -94,8 +94,8 @@ scoped_ptr<base::Value> TilePriority::AsValue() const {
scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
state->SetBoolean("is_live", is_live);
state->Set("resolution", TileResolutionAsValue(resolution).release());
- state->SetDouble("time_to_visible_in_seconds", time_to_visible_in_seconds);
- state->SetDouble("distance_to_visible_in_pixels", distance_to_visible_in_pixels);
+ state->Set("time_to_visible_in_seconds", MathUtil::asValueSafely(time_to_visible_in_seconds).release());
+ state->Set("distance_to_visible_in_pixels", MathUtil::asValueSafely(distance_to_visible_in_pixels).release());
state->Set("current_screen_quad", MathUtil::asValue(current_screen_quad).release());
return state.PassAs<base::Value>();
}
@@ -173,7 +173,7 @@ scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) {
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"NEW_CONTENT_TAKES_PRIORITY"));
default:
- DCHECK(false) << "Unrecognized priority value";
+ DCHECK(false) << "Unrecognized priority value " << prio;
return scoped_ptr<base::Value>(base::Value::CreateStringValue(
"<unknown>"));
}