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

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

Issue 128303003: Prepare for including compositing reasons in GraphicsLayerDebugInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | no next file » | 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "cc/animation/animation_registrar.h" 10 #include "cc/animation/animation_registrar.h"
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 gfx::BoxF box(bounds().width(), bounds().height(), 0.f); 1374 gfx::BoxF box(bounds().width(), bounds().height(), 0.f);
1375 gfx::BoxF inflated; 1375 gfx::BoxF inflated;
1376 if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated)) 1376 if (layer_animation_controller_->AnimatedBoundsForBox(box, &inflated))
1377 state->Set("animated_bounds", MathUtil::AsValue(inflated).release()); 1377 state->Set("animated_bounds", MathUtil::AsValue(inflated).release());
1378 } 1378 }
1379 1379
1380 if (debug_info_.get()) { 1380 if (debug_info_.get()) {
1381 std::string str; 1381 std::string str;
1382 debug_info_->AppendAsTraceFormat(&str); 1382 debug_info_->AppendAsTraceFormat(&str);
1383 base::JSONReader json_reader; 1383 base::JSONReader json_reader;
1384 // Parsing the JSON and re-encoding it is not very efficient, 1384 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
1385 // but it's the simplest way to achieve the desired effect, which 1385
1386 // is to output: 1386 // TODO(vollick): The TYPE_LIST code below is brittle; it assumes the only
1387 // {..., layout_rects: [{geometry_rect: ...}, ...], ...} 1387 // debug info is the layout rects. In future, this will be generalized, and
1388 // rather than: 1388 // debug info will return a dictionary to be merged into state. Until then,
1389 // {layout_rects: "[{geometry_rect: ...}, ...]", ...} 1389 // we unfortunately have to support both situations. Once we've migrated,
1390 state->Set("layout_rects", json_reader.ReadToValue(str)); 1390 // the TYPE_LIST branch will be deleted.
1391 if (debug_info_value->IsType(base::Value::TYPE_LIST)) {
1392 // Parsing the JSON and re-encoding it is not very efficient,
1393 // but it's the simplest way to achieve the desired effect, which
1394 // is to output:
1395 // {..., layout_rects: [{geometry_rect: ...}, ...], ...}
1396 // rather than:
1397 // {layout_rects: "[{geometry_rect: ...}, ...]", ...}
1398 state->Set("layout_rects", debug_info_value.release());
1399 } else if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
1400 base::DictionaryValue* dictionary_value = NULL;
1401 bool converted_to_dictionary =
1402 debug_info_value->GetAsDictionary(&dictionary_value);
1403 DCHECK(converted_to_dictionary);
1404 state->MergeDictionary(dictionary_value);
1405 } else {
1406 NOTREACHED();
1407 }
1391 } 1408 }
1392 } 1409 }
1393 1410
1394 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1411 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1395 1412
1396 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1413 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1397 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1414 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1398 AsValueInto(state.get()); 1415 AsValueInto(state.get());
1399 return state.PassAs<base::Value>(); 1416 return state.PassAs<base::Value>();
1400 } 1417 }
1401 1418
1402 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { 1419 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) {
1403 benchmark->RunOnLayer(this); 1420 benchmark->RunOnLayer(this);
1404 } 1421 }
1405 1422
1406 } // namespace cc 1423 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698