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

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

Issue 2837973002: VRShell: Composing Daydream controller textures from patches (Closed)
Patch Set: Separate patches and doing patching in CPU Created 3 years, 8 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
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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_MODEL_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_MODEL_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_MODEL_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_MODEL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "chrome/browser/android/vr_shell/gltf_asset.h" 10 #include "chrome/browser/android/vr_shell/gltf_asset.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkImage.h"
12 #include "ui/gfx/geometry/point.h"
12 #include "ui/gl/gl_bindings.h" 13 #include "ui/gl/gl_bindings.h"
13 14
14 namespace vr_shell { 15 namespace vr_shell {
15 16
16 class VrControllerModel { 17 class VrControllerModel {
17 public: 18 public:
18 enum State { 19 enum State {
19 IDLE = 0, 20 IDLE = 0,
20 TOUCHPAD, 21 TOUCHPAD,
21 APP, 22 APP,
22 SYSTEM, 23 SYSTEM,
23 // New ControllerStates should be added here, before STATE_COUNT. 24 // New ControllerStates should be added here, before STATE_COUNT.
24 STATE_COUNT, 25 STATE_COUNT,
25 }; 26 };
26 27
27 // TODO(acondor): Remove these hardcoded paths once VrShell resources 28 struct Patch {
28 // are delivered through component updater. 29 sk_sp<SkImage> image;
29 static constexpr char const kComponentName[] = "VrShell"; 30 gfx::Point offset;
30 static constexpr char const kDefaultVersion[] = "0"; 31 Patch();
31 32 Patch(sk_sp<SkImage> image, const gfx::Point& offset);
32 static constexpr char const kModelsDirectory[] = "models"; 33 ~Patch();
cjgrant 2017/04/27 18:47:29 What happens if you just exclude the destructor he
acondor_ 2017/04/27 19:01:19 Chromium codestyle check asked me to provide const
acondor_ 2017/04/28 14:22:38 Actually, I don't need this class anymore.
33 static constexpr char const kModelFilename[] = "controller.gltf";
34 static constexpr char const kTexturesDirectory[] = "tex";
35 static constexpr char const* kTextureFilenames[] = {
36 "ddcontroller_idle.png", "ddcontroller_touchpad.png",
37 "ddcontroller_app.png", "ddcontroller_system.png",
38 }; 34 };
39 35
40 explicit VrControllerModel( 36 explicit VrControllerModel(
41 std::unique_ptr<gltf::Asset> gltf_asset, 37 std::unique_ptr<gltf::Asset> gltf_asset,
42 std::vector<std::unique_ptr<gltf::Buffer>> buffers); 38 std::vector<std::unique_ptr<gltf::Buffer>> buffers);
43 ~VrControllerModel(); 39 ~VrControllerModel();
44 40
45 const GLvoid* ElementsBuffer() const; 41 const GLvoid* ElementsBuffer() const;
46 GLsizeiptr ElementsBufferSize() const; 42 GLsizeiptr ElementsBufferSize() const;
47 const GLvoid* IndicesBuffer() const; 43 const GLvoid* IndicesBuffer() const;
48 GLenum DrawMode() const; 44 GLenum DrawMode() const;
49 GLsizeiptr IndicesBufferSize() const; 45 GLsizeiptr IndicesBufferSize() const;
50 const gltf::Accessor* IndicesAccessor() const; 46 const gltf::Accessor* IndicesAccessor() const;
51 const gltf::Accessor* PositionAccessor() const; 47 const gltf::Accessor* PositionAccessor() const;
52 const gltf::Accessor* TextureCoordinateAccessor() const; 48 const gltf::Accessor* TextureCoordinateAccessor() const;
53 void SetTexture(int state, std::unique_ptr<SkBitmap> bitmap); 49 void SetBaseTexture(sk_sp<SkImage> image);
54 const SkBitmap* GetTexture(int state) const; 50 void SetTexturePatch(int state, sk_sp<SkImage> image);
51 sk_sp<SkImage> GetTexture(int state) const;
55 52
56 static std::unique_ptr<VrControllerModel> LoadFromComponent(); 53 static std::unique_ptr<VrControllerModel> LoadFromComponent();
57 54
58 private: 55 private:
59 std::unique_ptr<gltf::Asset> gltf_asset_; 56 std::unique_ptr<gltf::Asset> gltf_asset_;
60 std::vector<std::unique_ptr<SkBitmap>> texture_bitmaps_; 57 sk_sp<SkImage> base_texture_;
58 sk_sp<SkImage> patches_[STATE_COUNT];
61 std::vector<std::unique_ptr<gltf::Buffer>> buffers_; 59 std::vector<std::unique_ptr<gltf::Buffer>> buffers_;
62 60
63 const char* Buffer() const; 61 const char* Buffer() const;
64 const gltf::Accessor* Accessor(const std::string& key) const; 62 const gltf::Accessor* Accessor(const std::string& key) const;
65 }; 63 };
66 64
67 } // namespace vr_shell 65 } // namespace vr_shell
68 66
69 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_MODEL_H_ 67 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698