| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "gpu/tools/compositor_model_bench/render_tree.h" | 5 #include "gpu/tools/compositor_model_bench/render_tree.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 node.GetList("children", &children); | 355 node.GetList("children", &children); |
| 356 for (unsigned int i = 0; i < children->GetSize(); ++i) { | 356 for (unsigned int i = 0; i < children->GetSize(); ++i) { |
| 357 const base::DictionaryValue* childNode; | 357 const base::DictionaryValue* childNode; |
| 358 if (!children->GetDictionary(i, &childNode)) | 358 if (!children->GetDictionary(i, &childNode)) |
| 359 continue; | 359 continue; |
| 360 std::unique_ptr<RenderNode> child = InterpretNode(*childNode); | 360 std::unique_ptr<RenderNode> child = InterpretNode(*childNode); |
| 361 if (child) | 361 if (child) |
| 362 n->add_child(child.release()); | 362 n->add_child(child.release()); |
| 363 } | 363 } |
| 364 | 364 |
| 365 return n; | 365 return std::move(n); |
| 366 } | 366 } |
| 367 | 367 |
| 368 std::unique_ptr<RenderNode> InterpretCanvasLayer( | 368 std::unique_ptr<RenderNode> InterpretCanvasLayer( |
| 369 const base::DictionaryValue& node) { | 369 const base::DictionaryValue& node) { |
| 370 auto n = base::MakeUnique<CCNode>(); | 370 auto n = base::MakeUnique<CCNode>(); |
| 371 if (!InterpretCommonContents(node, n.get())) | 371 if (!InterpretCommonContents(node, n.get())) |
| 372 return nullptr; | 372 return nullptr; |
| 373 | 373 |
| 374 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) | 374 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) |
| 375 return nullptr; | 375 return nullptr; |
| 376 | 376 |
| 377 std::string type; | 377 std::string type; |
| 378 node.GetString("type", &type); | 378 node.GetString("type", &type); |
| 379 assert(type == "CanvasLayer"); | 379 assert(type == "CanvasLayer"); |
| 380 | 380 |
| 381 if (!InterpretCCData(node, n.get())) | 381 if (!InterpretCCData(node, n.get())) |
| 382 return nullptr; | 382 return nullptr; |
| 383 | 383 |
| 384 return n; | 384 return std::move(n); |
| 385 } | 385 } |
| 386 | 386 |
| 387 std::unique_ptr<RenderNode> InterpretVideoLayer( | 387 std::unique_ptr<RenderNode> InterpretVideoLayer( |
| 388 const base::DictionaryValue& node) { | 388 const base::DictionaryValue& node) { |
| 389 auto n = base::MakeUnique<CCNode>(); | 389 auto n = base::MakeUnique<CCNode>(); |
| 390 if (!InterpretCommonContents(node, n.get())) | 390 if (!InterpretCommonContents(node, n.get())) |
| 391 return nullptr; | 391 return nullptr; |
| 392 | 392 |
| 393 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) | 393 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) |
| 394 return nullptr; | 394 return nullptr; |
| 395 | 395 |
| 396 std::string type; | 396 std::string type; |
| 397 node.GetString("type", &type); | 397 node.GetString("type", &type); |
| 398 assert(type == "VideoLayer"); | 398 assert(type == "VideoLayer"); |
| 399 | 399 |
| 400 if (!InterpretCCData(node, n.get())) | 400 if (!InterpretCCData(node, n.get())) |
| 401 return nullptr; | 401 return nullptr; |
| 402 | 402 |
| 403 return n; | 403 return std::move(n); |
| 404 } | 404 } |
| 405 | 405 |
| 406 std::unique_ptr<RenderNode> InterpretImageLayer( | 406 std::unique_ptr<RenderNode> InterpretImageLayer( |
| 407 const base::DictionaryValue& node) { | 407 const base::DictionaryValue& node) { |
| 408 auto n = base::MakeUnique<CCNode>(); | 408 auto n = base::MakeUnique<CCNode>(); |
| 409 if (!InterpretCommonContents(node, n.get())) | 409 if (!InterpretCommonContents(node, n.get())) |
| 410 return nullptr; | 410 return nullptr; |
| 411 | 411 |
| 412 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) | 412 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) |
| 413 return nullptr; | 413 return nullptr; |
| 414 | 414 |
| 415 std::string type; | 415 std::string type; |
| 416 node.GetString("type", &type); | 416 node.GetString("type", &type); |
| 417 assert(type == "ImageLayer"); | 417 assert(type == "ImageLayer"); |
| 418 | 418 |
| 419 if (!InterpretCCData(node, n.get())) | 419 if (!InterpretCCData(node, n.get())) |
| 420 return nullptr; | 420 return nullptr; |
| 421 | 421 |
| 422 return n; | 422 return std::move(n); |
| 423 } | 423 } |
| 424 | 424 |
| 425 std::unique_ptr<RenderNode> InterpretNode(const base::DictionaryValue& node) { | 425 std::unique_ptr<RenderNode> InterpretNode(const base::DictionaryValue& node) { |
| 426 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) | 426 if (!VerifyDictionaryEntry(node, "type", Value::Type::STRING)) |
| 427 return nullptr; | 427 return nullptr; |
| 428 | 428 |
| 429 std::string type; | 429 std::string type; |
| 430 node.GetString("type", &type); | 430 node.GetString("type", &type); |
| 431 if (type == "ContentLayer") | 431 if (type == "ContentLayer") |
| 432 return InterpretContentLayer(node); | 432 return InterpretContentLayer(node); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 << "\n(" << error_message << ")"; | 465 << "\n(" << error_message << ")"; |
| 466 } else { | 466 } else { |
| 467 LOG(ERROR) << path.LossyDisplayName() | 467 LOG(ERROR) << path.LossyDisplayName() |
| 468 << " doesn not encode a JSON dictionary."; | 468 << " doesn not encode a JSON dictionary."; |
| 469 } | 469 } |
| 470 return nullptr; | 470 return nullptr; |
| 471 } | 471 } |
| 472 | 472 |
| 473 return InterpretContentLayer(*root); | 473 return InterpretContentLayer(*root); |
| 474 } | 474 } |
| 475 | |
| OLD | NEW |