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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_VR_ELEMENTS_LASER_H_ 6 #define CHROME_BROWSER_VR_ELEMENTS_LASER_H_ 7 8 #include "chrome/browser/vr/elements/ui_element.h" 9 #include "chrome/browser/vr/renderers/base_quad_renderer.h" 10 #include "ui/gfx/geometry/point3_f.h" 11 12 namespace vr { 13 14 struct Model; 15 16 class Laser : public UiElement { 17 public: 18 explicit Laser(Model* model); 19 ~Laser() override; 20 21 class Renderer : public BaseQuadRenderer { 22 public: 23 Renderer(); 24 ~Renderer() override; 25 26 void Draw(float opacity, const gfx::Transform& view_proj_matrix); 27 28 private: 29 GLuint model_view_proj_matrix_handle_; 30 GLuint texture_unit_handle_; 31 GLuint texture_data_handle_; 32 GLuint color_handle_; 33 GLuint fade_point_handle_; 34 GLuint fade_end_handle_; 35 GLuint opacity_handle_; 36 37 DISALLOW_COPY_AND_ASSIGN(Renderer); 38 }; 39 40 private: 41 void Render(UiElementRenderer* renderer, 42 const CameraModel& model) const final; 43 44 // Since the laser needs to render in response to model changes that occur 45 // after the scene update (i.e., after input), we cannot rely on the usual 46 // data binding flow since that would result in a frame of latency. Opacity 47 // changes, however, are not latency sensitive and are bound in the usual way 48 // (they also do not update due to input). 49 Model* model_; 50 51 DISALLOW_COPY_AND_ASSIGN(Laser); 52 }; 53 54 } // namespace vr 55 56 #endif // CHROME_BROWSER_VR_ELEMENTS_LASER_H_ 57