OLD | NEW |
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/test/layer_tree_json_parser.h" | 5 #include "cc/test/layer_tree_json_parser.h" |
6 | 6 |
7 #include "base/test/values_test_util.h" | 7 #include "base/test/values_test_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "cc/layers/content_layer.h" | 9 #include "cc/layers/content_layer.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
11 #include "cc/layers/nine_patch_layer.h" | 11 #include "cc/layers/nine_patch_layer.h" |
12 #include "cc/layers/picture_layer.h" | 12 #include "cc/layers/picture_layer.h" |
13 #include "cc/layers/solid_color_layer.h" | 13 #include "cc/layers/solid_color_layer.h" |
14 #include "cc/layers/texture_layer.h" | 14 #include "cc/layers/texture_layer.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, | 20 scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, |
21 ContentLayerClient* content_client) { | 21 ContentLayerClient* content_client) { |
22 base::DictionaryValue* dict; | 22 base::DictionaryValue* dict; |
23 bool success = true; | 23 bool success = true; |
24 success &= val->GetAsDictionary(&dict); | 24 success &= val->GetAsDictionary(&dict); |
25 std::string layer_type; | 25 std::string layer_type; |
26 success &= dict->GetString("LayerType", &layer_type); | 26 success &= dict->GetString("LayerType", &layer_type); |
27 base::ListValue* list; | 27 base::ListValue* list; |
28 success &= dict->GetList("Bounds", &list); | 28 success &= dict->GetList("Bounds", &list); |
29 int width, height; | 29 double width, height; |
30 success &= list->GetInteger(0, &width); | 30 success &= list->GetDouble(0, &width); |
31 success &= list->GetInteger(1, &height); | 31 success &= list->GetDouble(1, &height); |
32 success &= dict->GetList("Position", &list); | 32 success &= dict->GetList("Position", &list); |
33 double position_x, position_y; | 33 double position_x, position_y; |
34 success &= list->GetDouble(0, &position_x); | 34 success &= list->GetDouble(0, &position_x); |
35 success &= list->GetDouble(1, &position_y); | 35 success &= list->GetDouble(1, &position_y); |
36 | 36 |
37 bool draws_content; | 37 bool draws_content; |
38 success &= dict->GetBoolean("DrawsContent", &draws_content); | 38 success &= dict->GetBoolean("DrawsContent", &draws_content); |
39 | 39 |
40 scoped_refptr<Layer> new_layer; | 40 scoped_refptr<Layer> new_layer; |
41 if (layer_type == "SolidColorLayer") { | 41 if (layer_type == "SolidColorLayer") { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 } // namespace | 173 } // namespace |
174 | 174 |
175 scoped_refptr<Layer> ParseTreeFromJson(std::string json, | 175 scoped_refptr<Layer> ParseTreeFromJson(std::string json, |
176 ContentLayerClient* content_client) { | 176 ContentLayerClient* content_client) { |
177 scoped_ptr<base::Value> val = base::test::ParseJson(json); | 177 scoped_ptr<base::Value> val = base::test::ParseJson(json); |
178 return ParseTreeFromValue(val.get(), content_client); | 178 return ParseTreeFromValue(val.get(), content_client); |
179 } | 179 } |
180 | 180 |
181 } // namespace cc | 181 } // namespace cc |
OLD | NEW |