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_SCALED_DEPTH_ADJUSTER_H_ 6 #define CHROME_BROWSER_VR_ELEMENTS_SCALED_DEPTH_ADJUSTER_H_ 7 8 #include <sstream> 9 10 #include "base/macros.h" 11 #include "chrome/browser/vr/elements/ui_element.h" 12 #include "chrome/browser/vr/vr_ui_export.h" 13 #include "ui/gfx/transform.h" 14 15 namespace vr { 16 17 // A Scaler adjusts the depth of its descendents by applying a scale. This 18 // permits dimensions in the subtree to be expressed in DM directly. Its main 19 // contribution is a tailored local transform that accounts for adjustments made 20 // by other ScaledDepthAdjuster elements on its ancestor chain. 21 class VR_UI_EXPORT ScaledDepthAdjuster : public UiElement { 22 public: 23 explicit ScaledDepthAdjuster(float delta_z); 24 ~ScaledDepthAdjuster() override; 25 26 private: 27 gfx::Transform LocalTransform() const override; 28 gfx::Transform GetTargetLocalTransform() const override; 29 bool OnBeginFrame(const gfx::Transform& head_pose) override; 30 void OnSetType() override; 31 32 #ifndef NDEBUG 33 void DumpGeometry(std::ostringstream* os) const override; 34 #endif 35 36 gfx::Transform transform_; 37 38 // This is relative to its ancestor ScaledDepthAdjuster. For example, if we 39 // have a single ScaledDepthAdjuster ancestor and it translates to depth 2.5, 40 // if we use a delta_z_ of -0.1, this will cause our descendants to be 41 // positioned at depth 2.4. 42 float delta_z_; 43 44 DISALLOW_COPY_AND_ASSIGN(ScaledDepthAdjuster); 45 }; 46 47 } // namespace vr 48 49 #endif // CHROME_BROWSER_VR_ELEMENTS_SCALED_DEPTH_ADJUSTER_H_ 50