| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/gltf_asset.h" | 5 #include "chrome/browser/android/vr_shell/gltf_asset.h" |
| 6 | 6 |
| 7 #include <unordered_map> | 7 #include <unordered_map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 namespace vr_shell { | 11 namespace vr_shell { |
| 12 | 12 |
| 13 namespace gltf { | 13 namespace gltf { |
| 14 | 14 |
| 15 namespace { |
| 16 |
| 15 const std::unordered_map<std::string, Type> kTypeMap = { | 17 const std::unordered_map<std::string, Type> kTypeMap = { |
| 16 {"SCALAR", SCALAR}, {"VEC2", VEC2}, {"VEC3", VEC3}, {"VEC4", VEC4}, | 18 {"SCALAR", SCALAR}, {"VEC2", VEC2}, {"VEC3", VEC3}, {"VEC4", VEC4}, |
| 17 {"MAT2", MAT2}, {"MAT3", MAT3}, {"MAT4", MAT4}, | 19 {"MAT2", MAT2}, {"MAT3", MAT3}, {"MAT4", MAT4}, |
| 18 }; | 20 }; |
| 19 | 21 |
| 22 const std::vector<int> kTypeComponents = { |
| 23 0, |
| 24 1, // SCALAR |
| 25 2, // VEC2 |
| 26 3, // VEC3 |
| 27 4, // VEC4 |
| 28 4, // MAT2 |
| 29 9, // MAT3 |
| 30 16, // MAT4 |
| 31 }; |
| 32 |
| 33 } // namespace |
| 34 |
| 20 Type GetType(const std::string& type) { | 35 Type GetType(const std::string& type) { |
| 21 auto it = kTypeMap.find(type); | 36 auto it = kTypeMap.find(type); |
| 22 if (it == kTypeMap.end()) | 37 if (it == kTypeMap.end()) |
| 23 return UNKNOWN; | 38 return UNKNOWN; |
| 24 return it->second; | 39 return it->second; |
| 25 } | 40 } |
| 26 | 41 |
| 42 GLint GetTypeComponents(Type type) { |
| 43 return kTypeComponents[type]; |
| 44 } |
| 45 |
| 27 Mesh::Primitive::Primitive() : indices(nullptr), mode(4) {} | 46 Mesh::Primitive::Primitive() : indices(nullptr), mode(4) {} |
| 28 | 47 |
| 29 Mesh::Primitive::~Primitive() = default; | 48 Mesh::Primitive::~Primitive() = default; |
| 30 | 49 |
| 31 Mesh::Mesh() {} | 50 Mesh::Mesh() {} |
| 32 | 51 |
| 33 Mesh::~Mesh() = default; | 52 Mesh::~Mesh() = default; |
| 34 | 53 |
| 35 Node::Node() {} | 54 Node::Node() {} |
| 36 | 55 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 116 } |
| 98 | 117 |
| 99 const Node* Asset::GetNode(std::size_t id) const { | 118 const Node* Asset::GetNode(std::size_t id) const { |
| 100 return id < nodes_.size() ? nodes_[id].get() : nullptr; | 119 return id < nodes_.size() ? nodes_[id].get() : nullptr; |
| 101 } | 120 } |
| 102 | 121 |
| 103 const Scene* Asset::GetScene(std::size_t id) const { | 122 const Scene* Asset::GetScene(std::size_t id) const { |
| 104 return id < scenes_.size() ? scenes_[id].get() : nullptr; | 123 return id < scenes_.size() ? scenes_[id].get() : nullptr; |
| 105 } | 124 } |
| 106 | 125 |
| 126 void Asset::FreeBuffers() { |
| 127 buffers_.clear(); |
| 128 } |
| 129 |
| 107 } // namespace gltf | 130 } // namespace gltf |
| 108 | 131 |
| 109 } // namespace vr_shell | 132 } // namespace vr_shell |
| OLD | NEW |