Chromium Code Reviews| 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 * Check whether user is looking at desktop or not. | 379 // This can be called on any thread. |
|
Lambros
2015/08/05 00:25:52
Undo this change?
shichengfeng
2015/08/05 23:06:31
Done.
| |
| 380 * This can be called on any thread. | |
| 381 */ | |
| 382 public boolean isLookingAtDesktop() { | 380 public boolean isLookingAtDesktop() { |
| 383 synchronized (mEyePositionLock) { | 381 synchronized (mEyePositionLock) { |
| 384 return Math.abs(mEyePositionVector[0]) <= (mHalfDesktopWidth + EDGE_ MARGIN) | 382 return Math.abs(mEyePositionVector[0]) <= (mHalfDesktopWidth + EDGE_ MARGIN) |
| 385 && Math.abs(mEyePositionVector[1]) <= (HALF_DESKTOP_HEIGHT + EDG E_MARGIN); | 383 && Math.abs(mEyePositionVector[1]) <= (HALF_DESKTOP_HEIGHT + EDG E_MARGIN); |
| 386 } | 384 } |
| 387 } | 385 } |
| 388 | 386 |
| 387 // This can be called on any thread. | |
|
Lambros
2015/08/05 00:25:52
I think Javadoc is better, since the method is pub
shichengfeng
2015/08/05 23:06:31
Done.
| |
| 388 public boolean isLookingLeftToDesktop() { | |
|
Lambros
2015/08/05 00:31:14
s/To/Of/
shichengfeng
2015/08/05 23:06:31
Done.
| |
| 389 synchronized (mEyePositionLock) { | |
| 390 return mEyePositionVector[0] >= (mHalfDesktopWidth + EDGE_MARGIN); | |
| 391 } | |
| 392 } | |
| 393 | |
| 394 // This can be called on any thread. | |
| 395 public boolean isLookingRightToDesktop() { | |
|
Lambros
2015/08/05 00:25:52
Same here.
shichengfeng
2015/08/05 23:06:31
Done.
| |
| 396 synchronized (mEyePositionLock) { | |
| 397 return mEyePositionVector[0] <= -(mHalfDesktopWidth + EDGE_MARGIN); | |
| 398 } | |
| 399 } | |
| 400 | |
| 389 /** | 401 /** |
| 390 * Get position on desktop where user is looking at. | 402 * Get position on desktop where user is looking at. |
| 391 */ | 403 */ |
| 392 private void getLookingPosition() { | 404 private void getLookingPosition() { |
| 393 synchronized (mEyePositionLock) { | 405 synchronized (mEyePositionLock) { |
| 394 if (Math.abs(mForwardVector[2]) < 0.00001f) { | 406 if (Math.abs(mForwardVector[2]) < 0.00001f) { |
| 395 mEyePositionVector[0] = Math.signum(mForwardVector[0]) * Float.M AX_VALUE; | 407 mEyePositionVector[0] = Math.signum(mForwardVector[0]) * Float.M AX_VALUE; |
| 396 mEyePositionVector[1] = Math.signum(mForwardVector[1]) * Float.M AX_VALUE; | 408 mEyePositionVector[1] = Math.signum(mForwardVector[1]) * Float.M AX_VALUE; |
| 397 } else { | 409 } else { |
| 398 mEyePositionVector[0] = mForwardVector[0] * DESKTOP_POSITION_Z / mForwardVector[2]; | 410 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, | 473 -mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, |
| 462 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, | 474 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, |
| 463 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, | 475 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f, |
| 464 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, | 476 -mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, |
| 465 mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, | 477 mHalfDesktopWidth, -HALF_DESKTOP_HEIGHT, 0.0f, |
| 466 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f | 478 mHalfDesktopWidth, HALF_DESKTOP_HEIGHT, 0.0f |
| 467 }); | 479 }); |
| 468 } | 480 } |
| 469 } | 481 } |
| 470 } | 482 } |
| OLD | NEW |