Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: chrome/browser/android/vr_shell/vr_controller_model.cc

Issue 2852103002: Revert of Implementing Binary glTF reader for the VR controller model (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/test/data/sample.glb ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/vr_controller_model.h" 5 #include "chrome/browser/android/vr_shell/vr_controller_model.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "chrome/browser/android/vr_shell/gltf_parser.h" 11 #include "chrome/browser/android/vr_shell/gltf_parser.h"
12 #include "components/component_updater/component_updater_paths.h" 12 #include "components/component_updater/component_updater_paths.h"
13 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkRect.h" 14 #include "third_party/skia/include/core/SkRect.h"
15 #include "third_party/skia/include/core/SkSurface.h" 15 #include "third_party/skia/include/core/SkSurface.h"
16 #include "ui/gfx/codec/png_codec.h" 16 #include "ui/gfx/codec/png_codec.h"
17 17
18 namespace vr_shell { 18 namespace vr_shell {
19 19
20 namespace { 20 namespace {
21 21
22 enum { 22 enum {
23 ELEMENTS_BUFFER_ID = 2, 23 ELEMENTS_BUFFER_ID = 0,
24 INDICES_BUFFER_ID = 3, 24 INDICES_BUFFER_ID = 1,
25 }; 25 };
26 26
27 constexpr char kPosition[] = "POSITION"; 27 constexpr char kPosition[] = "POSITION";
28 constexpr char kTexCoord[] = "TEXCOORD_0"; 28 constexpr char kTexCoord[] = "TEXCOORD_0";
29 29
30 // TODO(acondor): Remove these hardcoded paths once VrShell resources 30 // TODO(acondor): Remove these hardcoded paths once VrShell resources
31 // are delivered through component updater. 31 // are delivered through component updater.
32 constexpr char const kComponentName[] = "VrShell"; 32 constexpr char const kComponentName[] = "VrShell";
33 constexpr char const kDefaultVersion[] = "0"; 33 constexpr char const kDefaultVersion[] = "0";
34 34
35 constexpr char const kModelsDirectory[] = "models"; 35 constexpr char const kModelsDirectory[] = "models";
36 constexpr char const kModelFilename[] = "ddcontroller.glb"; 36 constexpr char const kModelFilename[] = "controller.gltf";
37 constexpr char const kTexturesDirectory[] = "tex"; 37 constexpr char const kTexturesDirectory[] = "tex";
38 constexpr char const kBaseTextureFilename[] = "ddcontroller_idle.png"; 38 constexpr char const kBaseTextureFilename[] = "ddcontroller_idle.png";
39 constexpr char const* kTexturePatchesFilenames[] = { 39 constexpr char const* kTexturePatchesFilenames[] = {
40 "", "ddcontroller_touchpad.png", "ddcontroller_app.png", 40 "", "ddcontroller_touchpad.png", "ddcontroller_app.png",
41 "ddcontroller_system.png", 41 "ddcontroller_system.png",
42 }; 42 };
43 const gfx::Point kPatchesLocations[] = {{}, {5, 5}, {47, 165}, {47, 234}}; 43 const gfx::Point kPatchesLocations[] = {{}, {5, 5}, {47, 165}, {47, 234}};
44 44
45 sk_sp<SkImage> LoadPng(const base::FilePath& path) { 45 sk_sp<SkImage> LoadPng(const base::FilePath& path) {
46 std::string data; 46 std::string data;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 .Append(kDefaultVersion) 160 .Append(kDefaultVersion)
161 .Append(kModelsDirectory); 161 .Append(kModelsDirectory);
162 auto model_path = models_path.Append(kModelFilename); 162 auto model_path = models_path.Append(kModelFilename);
163 163
164 // No further action if model file is not present 164 // No further action if model file is not present
165 if (!base::PathExists(model_path)) { 165 if (!base::PathExists(model_path)) {
166 LOG(WARNING) << "Controller model files not found"; 166 LOG(WARNING) << "Controller model files not found";
167 return nullptr; 167 return nullptr;
168 } 168 }
169 169
170 GltfParser gltf_parser;
170 std::vector<std::unique_ptr<gltf::Buffer>> buffers; 171 std::vector<std::unique_ptr<gltf::Buffer>> buffers;
171 172 auto asset = gltf_parser.Parse(model_path, &buffers);
172 std::string model_data;
173 base::ReadFileToString(model_path, &model_data);
174 auto asset = BinaryGltfParser::Parse(base::StringPiece(model_data), &buffers);
175 if (!asset) { 173 if (!asset) {
176 LOG(ERROR) << "Failed to read controller model"; 174 LOG(ERROR) << "Failed to read controller model";
177 return nullptr; 175 return nullptr;
178 } 176 }
179 177
180 auto controller_model = 178 auto controller_model =
181 base::MakeUnique<VrControllerModel>(std::move(asset), std::move(buffers)); 179 base::MakeUnique<VrControllerModel>(std::move(asset), std::move(buffers));
182 180
183 auto textures_path = models_path.Append(kTexturesDirectory); 181 auto textures_path = models_path.Append(kTexturesDirectory);
184 182
(...skipping 13 matching lines...) Expand all
198 LOG(ERROR) << "Failed to read controller texture patch"; 196 LOG(ERROR) << "Failed to read controller texture patch";
199 continue; 197 continue;
200 } 198 }
201 controller_model->SetTexturePatch(i, patch_image); 199 controller_model->SetTexturePatch(i, patch_image);
202 } 200 }
203 201
204 return controller_model; 202 return controller_model;
205 } 203 }
206 204
207 } // namespace vr_shell 205 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/test/data/sample.glb ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698