| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SHELL_RENDERER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_RENDERER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_RENDERER_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_RENDERER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/android/vr_shell/ui_element_renderer.h" | 13 #include "chrome/browser/android/vr_shell/ui_element_renderer.h" |
| 14 #include "chrome/browser/android/vr_shell/vr_controller_model.h" | 14 #include "chrome/browser/android/vr_shell/vr_controller_model.h" |
| 15 #include "ui/gfx/transform.h" | 15 #include "ui/gfx/transform.h" |
| 16 #include "ui/gl/gl_bindings.h" | 16 #include "ui/gl/gl_bindings.h" |
| 17 | 17 |
| 18 namespace vr_shell { | 18 namespace vr_shell { |
| 19 | 19 |
| 20 // TODO(tiborg): set background color through JS API. | |
| 21 constexpr float kFogBrightness = 0.57f; | 20 constexpr float kFogBrightness = 0.57f; |
| 22 | 21 |
| 23 enum ShaderID { | 22 enum ShaderID { |
| 24 SHADER_UNRECOGNIZED = 0, | 23 SHADER_UNRECOGNIZED = 0, |
| 25 EXTERNAL_TEXTURED_QUAD_VERTEX_SHADER, | 24 EXTERNAL_TEXTURED_QUAD_VERTEX_SHADER, |
| 26 EXTERNAL_TEXTURED_QUAD_FRAGMENT_SHADER, | 25 EXTERNAL_TEXTURED_QUAD_FRAGMENT_SHADER, |
| 27 WEBVR_VERTEX_SHADER, | 26 WEBVR_VERTEX_SHADER, |
| 28 WEBVR_FRAGMENT_SHADER, | 27 WEBVR_FRAGMENT_SHADER, |
| 29 RETICLE_VERTEX_SHADER, | 28 RETICLE_VERTEX_SHADER, |
| 30 RETICLE_FRAGMENT_SHADER, | 29 RETICLE_FRAGMENT_SHADER, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 67 |
| 69 class BaseRenderer { | 68 class BaseRenderer { |
| 70 public: | 69 public: |
| 71 virtual ~BaseRenderer(); | 70 virtual ~BaseRenderer(); |
| 72 | 71 |
| 73 protected: | 72 protected: |
| 74 BaseRenderer(ShaderID vertex_id, ShaderID fragment_id); | 73 BaseRenderer(ShaderID vertex_id, ShaderID fragment_id); |
| 75 | 74 |
| 76 GLuint program_handle_; | 75 GLuint program_handle_; |
| 77 GLuint position_handle_; | 76 GLuint position_handle_; |
| 78 GLuint tex_coord_handle_; | |
| 79 | 77 |
| 80 DISALLOW_COPY_AND_ASSIGN(BaseRenderer); | 78 DISALLOW_COPY_AND_ASSIGN(BaseRenderer); |
| 81 }; | 79 }; |
| 82 | 80 |
| 83 class BaseQuadRenderer : public BaseRenderer { | 81 class BaseQuadRenderer : public BaseRenderer { |
| 84 public: | 82 public: |
| 85 BaseQuadRenderer(ShaderID vertex_id, ShaderID fragment_id); | 83 BaseQuadRenderer(ShaderID vertex_id, ShaderID fragment_id); |
| 86 ~BaseQuadRenderer() override; | 84 ~BaseQuadRenderer() override; |
| 87 | 85 |
| 88 static void SetVertexBuffer(); | 86 static void SetVertexBuffer(); |
| 89 | 87 |
| 90 protected: | 88 protected: |
| 91 void PrepareToDraw(GLuint view_proj_matrix_handle, | 89 void PrepareToDraw(GLuint view_proj_matrix_handle, |
| 92 const gfx::Transform& view_proj_matrix); | 90 const gfx::Transform& view_proj_matrix); |
| 93 | 91 |
| 94 static GLuint vertex_buffer_; | 92 static GLuint vertex_buffer_; |
| 93 static GLuint index_buffer_; |
| 95 | 94 |
| 96 DISALLOW_COPY_AND_ASSIGN(BaseQuadRenderer); | 95 DISALLOW_COPY_AND_ASSIGN(BaseQuadRenderer); |
| 97 }; | 96 }; |
| 98 | 97 |
| 99 class ExternalTexturedQuadRenderer : public BaseQuadRenderer { | 98 class ExternalTexturedQuadRenderer : public BaseQuadRenderer { |
| 100 public: | 99 public: |
| 101 ExternalTexturedQuadRenderer(); | 100 ExternalTexturedQuadRenderer(); |
| 102 ~ExternalTexturedQuadRenderer() override; | 101 ~ExternalTexturedQuadRenderer() override; |
| 103 | 102 |
| 104 // Draw the content rect in the texture quad. | 103 // Draw the content rect in the texture quad. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 ~ControllerRenderer() override; | 198 ~ControllerRenderer() override; |
| 200 | 199 |
| 201 void SetUp(std::unique_ptr<VrControllerModel> model); | 200 void SetUp(std::unique_ptr<VrControllerModel> model); |
| 202 void Draw(VrControllerModel::State state, | 201 void Draw(VrControllerModel::State state, |
| 203 float opacity, | 202 float opacity, |
| 204 const gfx::Transform& view_proj_matrix); | 203 const gfx::Transform& view_proj_matrix); |
| 205 bool IsSetUp() const { return setup_; } | 204 bool IsSetUp() const { return setup_; } |
| 206 | 205 |
| 207 private: | 206 private: |
| 208 GLuint model_view_proj_matrix_handle_; | 207 GLuint model_view_proj_matrix_handle_; |
| 208 GLuint tex_coord_handle_; |
| 209 GLuint tex_uniform_handle_; | 209 GLuint tex_uniform_handle_; |
| 210 GLuint opacity_handle_; | 210 GLuint opacity_handle_; |
| 211 GLuint indices_buffer_ = 0; | 211 GLuint indices_buffer_ = 0; |
| 212 GLuint vertex_buffer_ = 0; | 212 GLuint vertex_buffer_ = 0; |
| 213 GLint position_components_ = 0; | 213 GLint position_components_ = 0; |
| 214 GLenum position_type_ = GL_FLOAT; | 214 GLenum position_type_ = GL_FLOAT; |
| 215 GLsizei position_stride_ = 0; | 215 GLsizei position_stride_ = 0; |
| 216 const GLvoid* position_offset_ = nullptr; | 216 const GLvoid* position_offset_ = nullptr; |
| 217 GLint tex_coord_components_ = 0; | 217 GLint tex_coord_components_ = 0; |
| 218 GLenum tex_coord_type_ = GL_FLOAT; | 218 GLenum tex_coord_type_ = GL_FLOAT; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 std::unique_ptr<ControllerRenderer> controller_renderer_; | 308 std::unique_ptr<ControllerRenderer> controller_renderer_; |
| 309 std::unique_ptr<GradientQuadRenderer> gradient_quad_renderer_; | 309 std::unique_ptr<GradientQuadRenderer> gradient_quad_renderer_; |
| 310 std::unique_ptr<GradientGridRenderer> gradient_grid_renderer_; | 310 std::unique_ptr<GradientGridRenderer> gradient_grid_renderer_; |
| 311 | 311 |
| 312 DISALLOW_COPY_AND_ASSIGN(VrShellRenderer); | 312 DISALLOW_COPY_AND_ASSIGN(VrShellRenderer); |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 } // namespace vr_shell | 315 } // namespace vr_shell |
| 316 | 316 |
| 317 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_RENDERER_H_ | 317 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_RENDERER_H_ |
| OLD | NEW |