| 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; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 9 import android.graphics.PointF; | 9 import android.graphics.PointF; |
| 10 import android.opengl.GLES20; | 10 import android.opengl.GLES20; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 float min = (a > b) ? b : a; | 368 float min = (a > b) ? b : a; |
| 369 float max = (a > b) ? a : b; | 369 float max = (a > b) ? a : b; |
| 370 if (value < min) { | 370 if (value < min) { |
| 371 value = min; | 371 value = min; |
| 372 } else if (value > max) { | 372 } else if (value > max) { |
| 373 value = max; | 373 value = max; |
| 374 } | 374 } |
| 375 return value; | 375 return value; |
| 376 } | 376 } |
| 377 | 377 |
| 378 |
| 378 /** | 379 /** |
| 379 * Check whether user is looking at desktop or not. | 380 * Return true if user is looking at the desktop. |
| 380 * This can be called on any thread. | 381 * This method can be called on any thread. |
| 381 */ | 382 */ |
| 382 public boolean isLookingAtDesktop() { | 383 public boolean isLookingAtDesktop() { |
| 383 synchronized (mEyePositionLock) { | 384 synchronized (mEyePositionLock) { |
| 384 return Math.abs(mEyePositionVector[0]) <= (mHalfDesktopWidth + EDGE_
MARGIN) | 385 return Math.abs(mEyePositionVector[0]) <= (mHalfDesktopWidth + EDGE_
MARGIN) |
| 385 && Math.abs(mEyePositionVector[1]) <= (HALF_DESKTOP_HEIGHT + EDG
E_MARGIN); | 386 && Math.abs(mEyePositionVector[1]) <= (HALF_DESKTOP_HEIGHT + EDG
E_MARGIN); |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 | 389 |
| 390 /* |
| 391 * Return true if user is looking at the space to the left of the dekstop. |
| 392 * This method can be called on any thread. |
| 393 */ |
| 394 public boolean isLookingLeftOfDesktop() { |
| 395 synchronized (mEyePositionLock) { |
| 396 return mEyePositionVector[0] >= (mHalfDesktopWidth + EDGE_MARGIN); |
| 397 } |
| 398 } |
| 399 |
| 400 /* |
| 401 * Return true if user is looking at the space to the right of the dekstop. |
| 402 * This method can be called on any thread. |
| 403 */ |
| 404 public boolean isLookingRightOfDesktop() { |
| 405 synchronized (mEyePositionLock) { |
| 406 return mEyePositionVector[0] <= -(mHalfDesktopWidth + EDGE_MARGIN); |
| 407 } |
| 408 } |
| 409 |
| 389 /** | 410 /** |
| 390 * Get position on desktop where user is looking at. | 411 * Get position on desktop where user is looking at. |
| 391 */ | 412 */ |
| 392 private void getLookingPosition() { | 413 private void getLookingPosition() { |
| 393 synchronized (mEyePositionLock) { | 414 synchronized (mEyePositionLock) { |
| 394 if (Math.abs(mForwardVector[2]) < 0.00001f) { | 415 if (Math.abs(mForwardVector[2]) < 0.00001f) { |
| 395 mEyePositionVector[0] = Math.signum(mForwardVector[0]) * Float.M
AX_VALUE; | 416 mEyePositionVector[0] = Math.signum(mForwardVector[0]) * Float.M
AX_VALUE; |
| 396 mEyePositionVector[1] = Math.signum(mForwardVector[1]) * Float.M
AX_VALUE; | 417 mEyePositionVector[1] = Math.signum(mForwardVector[1]) * Float.M
AX_VALUE; |
| 397 } else { | 418 } else { |
| 398 mEyePositionVector[0] = mForwardVector[0] * DESKTOP_POSITION_Z /
mForwardVector[2]; | 419 mEyePositionVector[0] = mForwardVector[0] * DESKTOP_POSITION_Z /
mForwardVector[2]; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 -mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, | 482 -mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, |
| 462 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, | 483 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, |
| 463 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, | 484 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, |
| 464 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, | 485 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, |
| 465 mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, | 486 mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, |
| 466 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f | 487 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f |
| 467 }); | 488 }); |
| 468 } | 489 } |
| 469 } | 490 } |
| 470 } | 491 } |
| OLD | NEW |