OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
8 import android.graphics.Canvas; | 8 import android.graphics.Canvas; |
9 import android.graphics.Color; | 9 import android.graphics.Color; |
10 import android.graphics.Paint; | 10 import android.graphics.Paint; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 mRepaintPending = true; | 74 mRepaintPending = true; |
75 } | 75 } |
76 mDisplay.redrawGraphics(); | 76 mDisplay.redrawGraphics(); |
77 } | 77 } |
78 | 78 |
79 /** | 79 /** |
80 * Redraws the canvas. This should be done on a non-UI thread or it could | 80 * Redraws the canvas. This should be done on a non-UI thread or it could |
81 * cause the UI to lag. Specifically, it is currently invoked on the native | 81 * cause the UI to lag. Specifically, it is currently invoked on the native |
82 * graphics thread using a JNI. | 82 * graphics thread using a JNI. |
83 */ | 83 */ |
84 public void paint() { | 84 private void paint() { |
85 long startTimeMs = SystemClock.uptimeMillis(); | 85 long startTimeMs = SystemClock.uptimeMillis(); |
86 | 86 |
87 if (Looper.myLooper() == Looper.getMainLooper()) { | 87 if (Looper.myLooper() == Looper.getMainLooper()) { |
88 Log.w(TAG, "Canvas being redrawn on UI thread"); | 88 Log.w(TAG, "Canvas being redrawn on UI thread"); |
89 } | 89 } |
90 | 90 |
91 Bitmap image = mDisplay.getVideoFrame(); | 91 Bitmap image = mDisplay.getVideoFrame(); |
92 synchronized (mRenderData) { | 92 synchronized (mRenderData) { |
93 mRepaintPending = false; | 93 mRepaintPending = false; |
94 } | 94 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 FeedbackAnimator.startAnimation(this, pos, radius); | 232 FeedbackAnimator.startAnimation(this, pos, radius); |
233 requestRepaint(); | 233 requestRepaint(); |
234 } | 234 } |
235 | 235 |
236 @Override | 236 @Override |
237 public void transformationChanged() { | 237 public void transformationChanged() { |
238 requestRepaint(); | 238 requestRepaint(); |
239 } | 239 } |
240 | 240 |
241 @Override | 241 @Override |
242 public void cursorMoved() { | 242 public void cursorMoved(boolean followedByViewportChange) { |
243 // For current implementation, cursorMoved() is always followed by trans
formationChanged() | 243 // For current implementation, cursorMoved() is always followed by trans
formationChanged() |
244 // even if the canvas isn't really changed. For future we should improve
this by not calling | 244 // even if the canvas isn't really changed. For future we should improve
this by not calling |
245 // transformationChanged() if the cursor is moved but the canvas is not
changed. | 245 // transformationChanged() if the cursor is moved but the canvas is not
changed. |
246 } | 246 } |
247 | 247 |
248 @Override | 248 @Override |
249 public void cursorVisibilityChanged() { | 249 public void cursorVisibilityChanged() { |
250 requestRepaint(); | 250 requestRepaint(); |
251 } | 251 } |
252 | 252 |
253 @Override | 253 @Override |
254 public void setAnimationEnabled(boolean enabled) { | 254 public void setAnimationEnabled(boolean enabled) { |
255 synchronized (mAnimationLock) { | 255 synchronized (mAnimationLock) { |
256 if (enabled && !mInputAnimationRunning) { | 256 if (enabled && !mInputAnimationRunning) { |
257 requestRepaint(); | 257 requestRepaint(); |
258 } | 258 } |
259 mInputAnimationRunning = enabled; | 259 mInputAnimationRunning = enabled; |
260 } | 260 } |
261 } | 261 } |
262 } | 262 } |
OLD | NEW |