OLD | NEW |
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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 scoped_refptr<Layer> CreateLayer(float x, float y, int width, int height) { | 55 scoped_refptr<Layer> CreateLayer(float x, float y, int width, int height) { |
56 scoped_refptr<Layer> layer = Layer::create(); | 56 scoped_refptr<Layer> layer = Layer::create(); |
57 layer->setAnchorPoint(gfx::Point()); | 57 layer->setAnchorPoint(gfx::Point()); |
58 layer->setPosition(gfx::PointF(x, y)); | 58 layer->setPosition(gfx::PointF(x, y)); |
59 layer->setBounds(gfx::Size(width, height)); | 59 layer->setBounds(gfx::Size(width, height)); |
60 return layer; | 60 return layer; |
61 } | 61 } |
62 | 62 |
63 scoped_refptr<ContentLayer> CreateContentLayer(float x, float y, int width, in
t height) { | 63 scoped_refptr<ContentLayer> CreateContentLayer(float x, float y, int width, in
t height, bool drawable=true) { |
64 scoped_refptr<ContentLayer> layer = ContentLayer::create(&fake_delegate_); | 64 scoped_refptr<ContentLayer> layer = ContentLayer::create(&fake_delegate_); |
65 layer->setAnchorPoint(gfx::Point()); | 65 layer->setAnchorPoint(gfx::Point()); |
66 layer->setPosition(gfx::PointF(x, y)); | 66 layer->setPosition(gfx::PointF(x, y)); |
67 layer->setBounds(gfx::Size(width, height)); | 67 layer->setBounds(gfx::Size(width, height)); |
68 layer->setIsDrawable(true); | 68 layer->setIsDrawable(drawable); |
69 return layer; | 69 return layer; |
70 } | 70 } |
71 | 71 |
72 scoped_refptr<SolidColorLayer> CreateColorLayer(float x, float y, int width, i
nt height) { | 72 scoped_refptr<SolidColorLayer> CreateColorLayer(float x, float y, int width, i
nt height, bool drawable=true) { |
73 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::create(); | 73 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::create(); |
74 layer->setAnchorPoint(gfx::Point()); | 74 layer->setAnchorPoint(gfx::Point()); |
75 layer->setPosition(gfx::PointF(x, y)); | 75 layer->setPosition(gfx::PointF(x, y)); |
76 layer->setBounds(gfx::Size(width, height)); | 76 layer->setBounds(gfx::Size(width, height)); |
77 layer->setIsDrawable(true); | 77 layer->setIsDrawable(drawable); |
78 return layer; | 78 return layer; |
79 } | 79 } |
80 | 80 |
81 scoped_refptr<NinePatchLayer> CreateDecorationLayer(float x, float y, int widt
h, int height) { | 81 scoped_refptr<NinePatchLayer> CreateDecorationLayer(float x, float y, int widt
h, int height) { |
82 return CreateDecorationLayer(x, y, width, height, gfx::Rect(0, 0, width, hei
ght)); | 82 return CreateDecorationLayer(x, y, width, height, gfx::Rect(0, 0, width, hei
ght)); |
83 } | 83 } |
84 | 84 |
85 scoped_refptr<NinePatchLayer> CreateDecorationLayer(float x, float y, int widt
h, int height, gfx::Rect aperture) { | 85 scoped_refptr<NinePatchLayer> CreateDecorationLayer(float x, float y, int widt
h, int height, gfx::Rect aperture, bool drawable=true) { |
86 scoped_refptr<NinePatchLayer> layer = NinePatchLayer::create(); | 86 scoped_refptr<NinePatchLayer> layer = NinePatchLayer::create(); |
87 layer->setAnchorPoint(gfx::Point()); | 87 layer->setAnchorPoint(gfx::Point()); |
88 layer->setPosition(gfx::PointF(x, y)); | 88 layer->setPosition(gfx::PointF(x, y)); |
89 layer->setBounds(gfx::Size(width, height)); | 89 layer->setBounds(gfx::Size(width, height)); |
90 layer->setIsDrawable(true); | 90 layer->setIsDrawable(drawable); |
91 | 91 |
92 SkBitmap bitmap; | 92 SkBitmap bitmap; |
93 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 93 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); |
94 bitmap.allocPixels(NULL, NULL); | 94 bitmap.allocPixels(NULL, NULL); |
95 layer->setBitmap(bitmap, aperture); | 95 layer->setBitmap(bitmap, aperture); |
96 | 96 |
97 return layer; | 97 return layer; |
98 } | 98 } |
99 | 99 |
100 scoped_refptr<Layer> addChild(scoped_refptr<Layer> parent, scoped_refptr<Layer
> child) { | 100 scoped_refptr<Layer> addChild(scoped_refptr<Layer> parent, scoped_refptr<Layer
> child) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 ListValue* list; | 258 ListValue* list; |
259 success &= dict->GetList("Bounds", &list); | 259 success &= dict->GetList("Bounds", &list); |
260 int width, height; | 260 int width, height; |
261 success &= list->GetInteger(0, &width); | 261 success &= list->GetInteger(0, &width); |
262 success &= list->GetInteger(1, &height); | 262 success &= list->GetInteger(1, &height); |
263 success &= dict->GetList("Position", &list); | 263 success &= dict->GetList("Position", &list); |
264 double position_x, position_y; | 264 double position_x, position_y; |
265 success &= list->GetDouble(0, &position_x); | 265 success &= list->GetDouble(0, &position_x); |
266 success &= list->GetDouble(1, &position_y); | 266 success &= list->GetDouble(1, &position_y); |
267 | 267 |
| 268 bool draws_content; |
| 269 success &= dict->GetBoolean("DrawsContent", &draws_content); |
| 270 |
268 scoped_refptr<Layer> new_layer; | 271 scoped_refptr<Layer> new_layer; |
269 if (layer_type == "SolidColorLayer") { | 272 if (layer_type == "SolidColorLayer") { |
270 new_layer = CreateColorLayer(position_x, position_y, width, height); | 273 new_layer = CreateColorLayer(position_x, position_y, width, height, draws_
content); |
271 } else if (layer_type == "ContentLayer") { | 274 } else if (layer_type == "ContentLayer") { |
272 new_layer = CreateContentLayer(position_x, position_y, width, height); | 275 new_layer = CreateContentLayer(position_x, position_y, width, height, draw
s_content); |
273 } else if (layer_type == "NinePatchLayer") { | 276 } else if (layer_type == "NinePatchLayer") { |
274 success &= dict->GetList("ImageAperture", &list); | 277 success &= dict->GetList("ImageAperture", &list); |
275 int aperture_x, aperture_y, aperture_width, aperture_height; | 278 int aperture_x, aperture_y, aperture_width, aperture_height; |
276 success &= list->GetInteger(0, &aperture_x); | 279 success &= list->GetInteger(0, &aperture_x); |
277 success &= list->GetInteger(1, &aperture_y); | 280 success &= list->GetInteger(1, &aperture_y); |
278 success &= list->GetInteger(2, &aperture_width); | 281 success &= list->GetInteger(2, &aperture_width); |
279 success &= list->GetInteger(3, &aperture_height); | 282 success &= list->GetInteger(3, &aperture_height); |
280 | 283 |
281 new_layer = CreateDecorationLayer( | 284 new_layer = CreateDecorationLayer( |
282 position_x, position_y, width, height, | 285 position_x, position_y, width, height, |
283 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height)); | 286 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height), |
| 287 draws_content); |
284 | 288 |
285 } else { // Type "Layer" or "unknown" | 289 } else { // Type "Layer" or "unknown" |
286 new_layer = CreateLayer(position_x, position_y, width, height); | 290 new_layer = CreateLayer(position_x, position_y, width, height); |
287 } | 291 } |
288 | 292 |
| 293 double opacity; |
| 294 if (dict->GetDouble("Opacity", &opacity)) |
| 295 new_layer->setOpacity(opacity); |
| 296 |
289 success &= dict->GetList("DrawTransform", &list); | 297 success &= dict->GetList("DrawTransform", &list); |
290 double transform[16]; | 298 double transform[16]; |
291 for (int i = 0; i < 16; ++i) | 299 for (int i = 0; i < 16; ++i) |
292 success &= list->GetDouble(i, &transform[i]); | 300 success &= list->GetDouble(i, &transform[i]); |
293 | 301 |
294 gfx::Transform gfxTransform; | 302 gfx::Transform gfxTransform; |
295 gfxTransform.matrix().setColMajord(transform); | 303 gfxTransform.matrix().setColMajord(transform); |
296 new_layer->setTransform(gfxTransform); | 304 new_layer->setTransform(gfxTransform); |
297 | 305 |
298 success &= dict->GetList("Children", &list); | 306 success &= dict->GetList("Children", &list); |
(...skipping 18 matching lines...) Expand all Loading... |
317 scoped_ptr<base::Value> tree_; | 325 scoped_ptr<base::Value> tree_; |
318 }; | 326 }; |
319 | 327 |
320 TEST_F(LayerTreeHostPerfTestJsonReader, tenTenSingleThread) { | 328 TEST_F(LayerTreeHostPerfTestJsonReader, tenTenSingleThread) { |
321 readTestFile("10_10_layer_tree"); | 329 readTestFile("10_10_layer_tree"); |
322 runTest(false); | 330 runTest(false); |
323 } | 331 } |
324 | 332 |
325 } // namespace | 333 } // namespace |
326 } // namespace cc | 334 } // namespace cc |
OLD | NEW |