| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chromoting.cardboard; | 5 package org.chromium.chromoting.cardboard; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.graphics.Point; | 8 import android.graphics.Point; |
| 9 import android.graphics.PointF; | 9 import android.graphics.PointF; |
| 10 import android.opengl.GLES20; | 10 import android.opengl.GLES20; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 private Photosphere mPhotosphere; | 99 private Photosphere mPhotosphere; |
| 100 private Cursor mCursor; | 100 private Cursor mCursor; |
| 101 | 101 |
| 102 // Lock for eye position related operations. | 102 // Lock for eye position related operations. |
| 103 // This protects access to mEyeDesktopPosition. | 103 // This protects access to mEyeDesktopPosition. |
| 104 private final Object mEyeDesktopPositionLock = new Object(); | 104 private final Object mEyeDesktopPositionLock = new Object(); |
| 105 | 105 |
| 106 // Flag to indicate whether to show menu bar. | 106 // Flag to indicate whether to show menu bar. |
| 107 private boolean mMenuBarVisible; | 107 private boolean mMenuBarVisible; |
| 108 | 108 |
| 109 public CardboardRenderer(Activity activity, Client client) { | 109 public CardboardRenderer(Activity activity, Client client, Display display)
{ |
| 110 mActivity = activity; | 110 mActivity = activity; |
| 111 mClient = client; | 111 mClient = client; |
| 112 mDisplay = (Display) client.getDisplay(); | 112 mDisplay = display; |
| 113 mCameraPosition = 0.0f; | 113 mCameraPosition = 0.0f; |
| 114 | 114 |
| 115 mCameraMatrix = new float[16]; | 115 mCameraMatrix = new float[16]; |
| 116 mViewMatrix = new float[16]; | 116 mViewMatrix = new float[16]; |
| 117 mProjectionMatrix = new float[16]; | 117 mProjectionMatrix = new float[16]; |
| 118 mDesktopModelMatrix = new float[16]; | 118 mDesktopModelMatrix = new float[16]; |
| 119 mDesktopCombinedMatrix = new float[16]; | 119 mDesktopCombinedMatrix = new float[16]; |
| 120 mEyePointModelMatrix = new float[16]; | 120 mEyePointModelMatrix = new float[16]; |
| 121 mEyePointCombinedMatrix = new float[16]; | 121 mEyePointCombinedMatrix = new float[16]; |
| 122 mPhotosphereCombinedMatrix = new float[16]; | 122 mPhotosphereCombinedMatrix = new float[16]; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 147 | 147 |
| 148 // Use culling to remove back faces. | 148 // Use culling to remove back faces. |
| 149 GLES20.glEnable(GLES20.GL_CULL_FACE); | 149 GLES20.glEnable(GLES20.GL_CULL_FACE); |
| 150 | 150 |
| 151 // Enable depth testing. | 151 // Enable depth testing. |
| 152 GLES20.glEnable(GLES20.GL_DEPTH_TEST); | 152 GLES20.glEnable(GLES20.GL_DEPTH_TEST); |
| 153 | 153 |
| 154 mDesktop = new Desktop(mDisplay); | 154 mDesktop = new Desktop(mDisplay); |
| 155 mMenuBar = new MenuBar(mActivity); | 155 mMenuBar = new MenuBar(mActivity); |
| 156 mPhotosphere = new Photosphere(mActivity); | 156 mPhotosphere = new Photosphere(mActivity); |
| 157 mCursor = new Cursor(mClient); | 157 mCursor = new Cursor(mClient, mDisplay); |
| 158 | 158 |
| 159 initializeRedrawCallback(); | 159 initializeRedrawCallback(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 @Override | 162 @Override |
| 163 public void onSurfaceChanged(int width, int height) { | 163 public void onSurfaceChanged(int width, int height) { |
| 164 } | 164 } |
| 165 | 165 |
| 166 @Override | 166 @Override |
| 167 public void onNewFrame(HeadTransform headTransform) { | 167 public void onNewFrame(HeadTransform headTransform) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 theta = Math.atan(mDesktop.getHalfWidth() | 428 theta = Math.atan(mDesktop.getHalfWidth() |
| 429 / (DESKTOP_POSITION_Z - mCameraPosition)); | 429 / (DESKTOP_POSITION_Z - mCameraPosition)); |
| 430 } | 430 } |
| 431 | 431 |
| 432 // Calculate current looking angle. | 432 // Calculate current looking angle. |
| 433 double phi = Math.atan(mForwardVector[0] / mForwardVector[2]); | 433 double phi = Math.atan(mForwardVector[0] / mForwardVector[2]); |
| 434 | 434 |
| 435 return Math.abs(phi) > FARAWAY_ANGLE_RATIO * Math.abs(theta); | 435 return Math.abs(phi) > FARAWAY_ANGLE_RATIO * Math.abs(theta); |
| 436 } | 436 } |
| 437 } | 437 } |
| OLD | NEW |