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

Unified Diff: cc/managed_tile_state.cc

Issue 12353003: cc: Refactored Tile::GetResourceId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: cc/managed_tile_state.cc
diff --git a/cc/managed_tile_state.cc b/cc/managed_tile_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5cdc2b18bab069e3e03f5f94d0cb74cf63aabf07
--- /dev/null
+++ b/cc/managed_tile_state.cc
@@ -0,0 +1,72 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/managed_tile_state.h"
+#include "cc/math_util.h"
+
+namespace cc {
+
+ManagedTileState::ManagedTileState()
+ : can_use_gpu_memory(false),
+ need_to_gather_pixel_refs(true),
+ gpu_memmgr_stats_bin(NEVER_BIN),
+ raster_state(IDLE_STATE),
+ resolution(NON_IDEAL_RESOLUTION),
+ time_to_needed_in_seconds(std::numeric_limits<float>::infinity()),
+ distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()),
+ picture_pile_analyzed(false) {
+ for (int i = 0; i < NUM_TREES; ++i) {
+ tree_bin[i] = NEVER_BIN;
+ bin[i] = NEVER_BIN;
+ }
+}
+
+bool ManagedTileState::DrawingInfo::IsReadyToDraw() const {
+ switch(mode_) {
reveman 2013/03/12 22:47:02 nit: space between switch and (
+ case TEXTURE_MODE:
+ return resource_ &&
+ !resource_is_being_initialized_ &&
+ resource_->id();
+ case SOLID_COLOR_MODE:
+ case TRANSPARENT_MODE:
+ case PICTURE_PILE_MODE:
+ return true;
+ default:
+ NOTREACHED();
+ return false;
+ }
+}
+
+ManagedTileState::~ManagedTileState() {
+ DCHECK(!drawing_info.resource_);
+ DCHECK(!drawing_info.resource_is_being_initialized_);
+}
+
+scoped_ptr<base::Value> ManagedTileState::AsValue() const {
+ scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
+ state->SetBoolean("can_use_gpu_memory", can_use_gpu_memory);
+ state->SetBoolean("can_be_freed", drawing_info.can_be_freed_);
+ state->SetBoolean("has_resource", drawing_info.resource_.get() != 0);
+ state->SetBoolean("resource_is_being_initialized",
+ drawing_info.resource_is_being_initialized_);
+ state->Set("raster_state", TileRasterStateAsValue(raster_state).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->Set("time_to_needed_in_seconds",
+ MathUtil::asValueSafely(time_to_needed_in_seconds).release());
+ state->Set("distance_to_visible_in_pixels",
+ MathUtil::asValueSafely(distance_to_visible_in_pixels).release());
+ state->SetBoolean("is_picture_pile_analyzed", picture_pile_analyzed);
+ state->SetBoolean("is_cheap_to_raster",
+ picture_pile_analysis.is_cheap_to_raster);
+ state->SetBoolean("is_transparent", picture_pile_analysis.is_transparent);
+ state->SetBoolean("is_solid_color", picture_pile_analysis.is_solid_color);
+ return state.PassAs<base::Value>();
+}
+
+} // namespace cc
+

Powered by Google App Engine
This is Rietveld 408576698