| 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 <sstream> | 8 #include <sstream> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 12 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 13 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 | |
| 18 #include "gpu/tools/compositor_model_bench/shaders.h" | 17 #include "gpu/tools/compositor_model_bench/shaders.h" |
| 19 | 18 |
| 20 using base::JSONReader; | 19 using base::JSONReader; |
| 21 using base::JSONWriter; | 20 using base::JSONWriter; |
| 22 using base::ReadFileToString; | 21 using base::ReadFileToString; |
| 23 using std::string; | 22 using std::string; |
| 24 using std::vector; | 23 using std::vector; |
| 25 | 24 |
| 26 GLenum TextureFormatFromString(const std::string& format) { | 25 GLenum TextureFormatFromString(const std::string& format) { |
| 27 if (format == "RGBA") | 26 if (format == "RGBA") |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 451 } |
| 453 | 452 |
| 454 RenderNode* BuildRenderTreeFromFile(const base::FilePath& path) { | 453 RenderNode* BuildRenderTreeFromFile(const base::FilePath& path) { |
| 455 LOG(INFO) << "Reading " << path.LossyDisplayName(); | 454 LOG(INFO) << "Reading " << path.LossyDisplayName(); |
| 456 string contents; | 455 string contents; |
| 457 if (!ReadFileToString(path, &contents)) | 456 if (!ReadFileToString(path, &contents)) |
| 458 return NULL; | 457 return NULL; |
| 459 | 458 |
| 460 int error_code = 0; | 459 int error_code = 0; |
| 461 string error_message; | 460 string error_message; |
| 462 scoped_ptr<base::Value> root = JSONReader::ReadAndReturnError( | 461 std::unique_ptr<base::Value> root = JSONReader::ReadAndReturnError( |
| 463 contents, base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_message); | 462 contents, base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_message); |
| 464 if (!root) { | 463 if (!root) { |
| 465 LOG(ERROR) << "Failed to parse JSON file " << path.LossyDisplayName() << | 464 LOG(ERROR) << "Failed to parse JSON file " << path.LossyDisplayName() << |
| 466 "\n(" << error_message << ")"; | 465 "\n(" << error_message << ")"; |
| 467 return NULL; | 466 return NULL; |
| 468 } | 467 } |
| 469 | 468 |
| 470 if (root->IsType(base::Value::TYPE_DICTIONARY)) { | 469 if (root->IsType(base::Value::TYPE_DICTIONARY)) { |
| 471 base::DictionaryValue* v = static_cast<base::DictionaryValue*>(root.get()); | 470 base::DictionaryValue* v = static_cast<base::DictionaryValue*>(root.get()); |
| 472 RenderNode* tree = InterpretContentLayer(v); | 471 RenderNode* tree = InterpretContentLayer(v); |
| 473 return tree; | 472 return tree; |
| 474 } else { | 473 } else { |
| 475 LOG(ERROR) << path.LossyDisplayName() << | 474 LOG(ERROR) << path.LossyDisplayName() << |
| 476 " doesn not encode a JSON dictionary."; | 475 " doesn not encode a JSON dictionary."; |
| 477 return NULL; | 476 return NULL; |
| 478 } | 477 } |
| 479 } | 478 } |
| 480 | 479 |
| OLD | NEW |