Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/DesktopView.java

Issue 2007123003: [Android Client] Break down multi-threaded classes by thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename JniSecretFetcher to JniPairingSecretFetcher Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Canvas; 9 import android.graphics.Canvas;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 /** Request repainting of the desktop view. */ 195 /** Request repainting of the desktop view. */
196 void requestRepaint() { 196 void requestRepaint() {
197 synchronized (mRenderData) { 197 synchronized (mRenderData) {
198 if (mRepaintPending) { 198 if (mRepaintPending) {
199 return; 199 return;
200 } 200 }
201 mRepaintPending = true; 201 mRepaintPending = true;
202 } 202 }
203 mClient.redrawGraphics(); 203 mClient.getDisplay().redrawGraphics();
204 } 204 }
205 205
206 /** 206 /**
207 * Redraws the canvas. This should be done on a non-UI thread or it could 207 * Redraws the canvas. This should be done on a non-UI thread or it could
208 * cause the UI to lag. Specifically, it is currently invoked on the native 208 * cause the UI to lag. Specifically, it is currently invoked on the native
209 * graphics thread using a JNI. 209 * graphics thread using a JNI.
210 */ 210 */
211 public void paint() { 211 public void paint() {
212 long startTimeMs = SystemClock.uptimeMillis(); 212 long startTimeMs = SystemClock.uptimeMillis();
213 213
214 if (Looper.myLooper() == Looper.getMainLooper()) { 214 if (Looper.myLooper() == Looper.getMainLooper()) {
215 Log.w(TAG, "Canvas being redrawn on UI thread"); 215 Log.w(TAG, "Canvas being redrawn on UI thread");
216 } 216 }
217 217
218 Bitmap image = mClient.getVideoFrame(); 218 Bitmap image = mClient.getDisplay().getVideoFrame();
219 if (image == null) { 219 if (image == null) {
220 // This can happen if the client is connected, but a complete video frame has not yet 220 // This can happen if the client is connected, but a complete video frame has not yet
221 // been decoded. 221 // been decoded.
222 return; 222 return;
223 } 223 }
224 224
225 int width = image.getWidth(); 225 int width = image.getWidth();
226 int height = image.getHeight(); 226 int height = image.getHeight();
227 boolean sizeChanged = false; 227 boolean sizeChanged = false;
228 synchronized (mRenderData) { 228 synchronized (mRenderData) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 boolean feedbackAnimationRunning = mFeedbackAnimator.isAnimationRunning( ); 267 boolean feedbackAnimationRunning = mFeedbackAnimator.isAnimationRunning( );
268 if (feedbackAnimationRunning) { 268 if (feedbackAnimationRunning) {
269 float scaleFactor; 269 float scaleFactor;
270 synchronized (mRenderData) { 270 synchronized (mRenderData) {
271 scaleFactor = mRenderData.transform.mapRadius(1); 271 scaleFactor = mRenderData.transform.mapRadius(1);
272 } 272 }
273 mFeedbackAnimator.render(canvas, cursorPosition.x, cursorPosition.y, scaleFactor); 273 mFeedbackAnimator.render(canvas, cursorPosition.x, cursorPosition.y, scaleFactor);
274 } 274 }
275 275
276 if (drawCursor) { 276 if (drawCursor) {
277 Bitmap cursorBitmap = mClient.getCursorBitmap(); 277 Bitmap cursorBitmap = mClient.getDisplay().getCursorBitmap();
278 if (cursorBitmap != null) { 278 if (cursorBitmap != null) {
279 Point hotspot = mClient.getCursorHotspot(); 279 Point hotspot = mClient.getDisplay().getCursorHotspot();
280 canvas.drawBitmap(cursorBitmap, cursorPosition.x - hotspot.x, 280 canvas.drawBitmap(cursorBitmap, cursorPosition.x - hotspot.x,
281 cursorPosition.y - hotspot.y, new Paint()); 281 cursorPosition.y - hotspot.y, new Paint());
282 } 282 }
283 } 283 }
284 284
285 getHolder().unlockCanvasAndPost(canvas); 285 getHolder().unlockCanvasAndPost(canvas);
286 286
287 synchronized (mAnimationLock) { 287 synchronized (mAnimationLock) {
288 if (mInputAnimationRunning || feedbackAnimationRunning) { 288 if (mInputAnimationRunning || feedbackAnimationRunning) {
289 getHandler().postAtTime(new Runnable() { 289 getHandler().postAtTime(new Runnable() {
(...skipping 30 matching lines...) Expand all
320 mRenderData.screenWidth = width; 320 mRenderData.screenWidth = width;
321 mRenderData.screenHeight = height; 321 mRenderData.screenHeight = height;
322 } 322 }
323 323
324 attachRedrawCallback(); 324 attachRedrawCallback();
325 mInputHandler.onClientSizeChanged(width, height); 325 mInputHandler.onClientSizeChanged(width, height);
326 requestRepaint(); 326 requestRepaint();
327 } 327 }
328 328
329 public void attachRedrawCallback() { 329 public void attachRedrawCallback() {
330 mClient.provideRedrawCallback(new Runnable() { 330 mClient.getDisplay().provideRedrawCallback(new Runnable() {
331 @Override 331 @Override
332 public void run() { 332 public void run() {
333 paint(); 333 paint();
334 } 334 }
335 }); 335 });
336 } 336 }
337 337
338 /** Called when the canvas is first created. */ 338 /** Called when the canvas is first created. */
339 @Override 339 @Override
340 public void surfaceCreated(SurfaceHolder holder) { 340 public void surfaceCreated(SurfaceHolder holder) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 437
438 default: 438 default:
439 // Unreachable, but required by Google Java style and findbugs. 439 // Unreachable, but required by Google Java style and findbugs.
440 assert false : "Unreached"; 440 assert false : "Unreached";
441 } 441 }
442 442
443 // Ensure the cursor state is updated appropriately. 443 // Ensure the cursor state is updated appropriately.
444 requestRepaint(); 444 requestRepaint();
445 } 445 }
446 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698