| 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.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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 Bitmap cursorBitmap = mClient.getDisplay().getCursorBitmap(); | 194 Bitmap cursorBitmap = mClient.getDisplay().getCursorBitmap(); |
| 195 if (cursorBitmap != null) { | 195 if (cursorBitmap != null) { |
| 196 Point hotspot = mClient.getDisplay().getCursorHotspot(); | 196 Point hotspot = mClient.getDisplay().getCursorHotspot(); |
| 197 canvas.drawBitmap(cursorBitmap, cursorPosition.x - hotspot.x, | 197 canvas.drawBitmap(cursorBitmap, cursorPosition.x - hotspot.x, |
| 198 cursorPosition.y - hotspot.y, new Paint()); | 198 cursorPosition.y - hotspot.y, new Paint()); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 getHolder().unlockCanvasAndPost(canvas); | 202 getHolder().unlockCanvasAndPost(canvas); |
| 203 | 203 |
| 204 if (!mOnPaint.isEmpty()) { | 204 synchronized (mAnimationLock) { |
| 205 requestRepaint(); | 205 if (mInputAnimationRunning) { |
| 206 } else { | 206 getHandler().postAtTime(new Runnable() { |
| 207 synchronized (mAnimationLock) { | 207 @Override |
| 208 if (mInputAnimationRunning) { | 208 public void run() { |
| 209 getHandler().postAtTime(new Runnable() { | 209 processAnimation(); |
| 210 @Override | 210 } |
| 211 public void run() { | 211 }, startTimeMs + 30); |
| 212 processAnimation(); | |
| 213 } | |
| 214 }, startTimeMs + 30); | |
| 215 } | |
| 216 } | 212 } |
| 217 } | 213 } |
| 218 } | 214 } |
| 219 | 215 |
| 220 private void processAnimation() { | 216 private void processAnimation() { |
| 221 boolean running; | 217 boolean running; |
| 222 synchronized (mAnimationLock) { | 218 synchronized (mAnimationLock) { |
| 223 running = mInputAnimationRunning; | 219 running = mInputAnimationRunning; |
| 224 } | 220 } |
| 225 if (running) { | 221 if (running) { |
| 226 mInputHandler.processAnimation(); | 222 mInputHandler.processAnimation(); |
| 227 requestRepaint(); | 223 requestRepaint(); |
| 224 } else if (!mOnPaint.isEmpty()) { |
| 225 requestRepaint(); |
| 228 } | 226 } |
| 229 } | 227 } |
| 230 | 228 |
| 231 /** | 229 /** |
| 232 * Called after the canvas is initially created, then after every subsequent
resize, as when | 230 * Called after the canvas is initially created, then after every subsequent
resize, as when |
| 233 * the display is rotated. | 231 * the display is rotated. |
| 234 */ | 232 */ |
| 235 @Override | 233 @Override |
| 236 public void surfaceChanged(SurfaceHolder holder, int format, int width, int
height) { | 234 public void surfaceChanged(SurfaceHolder holder, int format, int width, int
height) { |
| 237 synchronized (mRenderData) { | 235 synchronized (mRenderData) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 @Override | 324 @Override |
| 327 public void setAnimationEnabled(boolean enabled) { | 325 public void setAnimationEnabled(boolean enabled) { |
| 328 synchronized (mAnimationLock) { | 326 synchronized (mAnimationLock) { |
| 329 if (enabled && !mInputAnimationRunning) { | 327 if (enabled && !mInputAnimationRunning) { |
| 330 requestRepaint(); | 328 requestRepaint(); |
| 331 } | 329 } |
| 332 mInputAnimationRunning = enabled; | 330 mInputAnimationRunning = enabled; |
| 333 } | 331 } |
| 334 } | 332 } |
| 335 } | 333 } |
| OLD | NEW |