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

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

Issue 2136233002: [Remoting Android] Fix Painting After Rotation Bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. 81 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings.
82 setFocusableInTouchMode(true); 82 setFocusableInTouchMode(true);
83 83
84 mRenderData = new RenderData(); 84 mRenderData = new RenderData();
85 mInputHandler = new TouchInputHandler(this, context, mRenderData); 85 mInputHandler = new TouchInputHandler(this, context, mRenderData);
86 86
87 mRepaintPending = false; 87 mRepaintPending = false;
88 88
89 getHolder().addCallback(this); 89 getHolder().addCallback(this);
90
91 attachRedrawCallback();
90 } 92 }
91 93
92 @Override 94 @Override
93 public void init(Desktop desktop, Client client) { 95 public void init(Desktop desktop, Client client) {
94 Preconditions.isNull(mDesktop); 96 Preconditions.isNull(mDesktop);
95 Preconditions.isNull(mClient); 97 Preconditions.isNull(mClient);
96 Preconditions.notNull(desktop); 98 Preconditions.notNull(desktop);
97 Preconditions.notNull(client); 99 Preconditions.notNull(client);
98 mDesktop = desktop; 100 mDesktop = desktop;
99 mClient = client; 101 mClient = client;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 * graphics thread using a JNI. 135 * graphics thread using a JNI.
134 */ 136 */
135 public void paint() { 137 public void paint() {
136 long startTimeMs = SystemClock.uptimeMillis(); 138 long startTimeMs = SystemClock.uptimeMillis();
137 139
138 if (Looper.myLooper() == Looper.getMainLooper()) { 140 if (Looper.myLooper() == Looper.getMainLooper()) {
139 Log.w(TAG, "Canvas being redrawn on UI thread"); 141 Log.w(TAG, "Canvas being redrawn on UI thread");
140 } 142 }
141 143
142 Bitmap image = mDisplay.getVideoFrame(); 144 Bitmap image = mDisplay.getVideoFrame();
145 synchronized (mRenderData) {
146 mRepaintPending = false;
Yuwei 2016/07/11 20:21:42 mRepaintPending would also be frozen if image == n
147 }
143 if (image == null) { 148 if (image == null) {
144 // This can happen if the client is connected, but a complete video frame has not yet 149 // This can happen if the client is connected, but a complete video frame has not yet
145 // been decoded. 150 // been decoded.
146 return; 151 return;
147 } 152 }
148 153
149 int width = image.getWidth(); 154 int width = image.getWidth();
150 int height = image.getHeight(); 155 int height = image.getHeight();
151 boolean sizeChanged = false; 156 boolean sizeChanged = false;
152 synchronized (mRenderData) { 157 synchronized (mRenderData) {
153 if (mRenderData.imageWidth != width || mRenderData.imageHeight != he ight) { 158 if (mRenderData.imageWidth != width || mRenderData.imageHeight != he ight) {
154 // TODO(lambroslambrou): Move this code into a sizeChanged() cal lback, to be 159 // TODO(lambroslambrou): Move this code into a sizeChanged() cal lback, to be
155 // triggered from native code (on the display thread) when the r emote screen size 160 // triggered from native code (on the display thread) when the r emote screen size
156 // changes. 161 // changes.
157 mRenderData.imageWidth = width; 162 mRenderData.imageWidth = width;
158 mRenderData.imageHeight = height; 163 mRenderData.imageHeight = height;
159 sizeChanged = true; 164 sizeChanged = true;
160 } 165 }
161 } 166 }
162 if (sizeChanged) { 167 if (sizeChanged) {
163 mOnHostSizeChanged.raise(new SizeChangedEventParameter(width, height )); 168 mOnHostSizeChanged.raise(new SizeChangedEventParameter(width, height ));
164 } 169 }
165 170
166 Canvas canvas; 171 Canvas canvas;
167 Point cursorPosition; 172 Point cursorPosition;
168 boolean drawCursor; 173 boolean drawCursor;
169 synchronized (mRenderData) { 174 synchronized (mRenderData) {
170 mRepaintPending = false;
171 // Don't try to lock the canvas before it is ready, as the implement ation of 175 // Don't try to lock the canvas before it is ready, as the implement ation of
172 // lockCanvas() may throttle these calls to a slow rate in order to avoid consuming CPU. 176 // lockCanvas() may throttle these calls to a slow rate in order to avoid consuming CPU.
173 // Note that a successful call to lockCanvas() will prevent the fram ework from 177 // Note that a successful call to lockCanvas() will prevent the fram ework from
174 // destroying the Surface until it is unlocked. 178 // destroying the Surface until it is unlocked.
175 if (!mSurfaceCreated) { 179 if (!mSurfaceCreated) {
176 return; 180 return;
177 } 181 }
178 canvas = getHolder().lockCanvas(); 182 canvas = getHolder().lockCanvas();
179 if (canvas == null) { 183 if (canvas == null) {
180 return; 184 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * Called after the canvas is initially created, then after every subsequent resize, as when 237 * Called after the canvas is initially created, then after every subsequent resize, as when
234 * the display is rotated. 238 * the display is rotated.
235 */ 239 */
236 @Override 240 @Override
237 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { 241 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
238 synchronized (mRenderData) { 242 synchronized (mRenderData) {
239 mRenderData.screenWidth = width; 243 mRenderData.screenWidth = width;
240 mRenderData.screenHeight = height; 244 mRenderData.screenHeight = height;
241 } 245 }
242 246
243 attachRedrawCallback();
244 mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height)) ; 247 mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height)) ;
245 requestRepaint(); 248 requestRepaint();
246 } 249 }
247 250
248 public void attachRedrawCallback() { 251 public void attachRedrawCallback() {
249 mDisplay.provideRedrawCallback(new Runnable() { 252 mDisplay.provideRedrawCallback(new Runnable() {
250 @Override 253 @Override
251 public void run() { 254 public void run() {
252 paint(); 255 paint();
253 } 256 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 @Override 342 @Override
340 public void setAnimationEnabled(boolean enabled) { 343 public void setAnimationEnabled(boolean enabled) {
341 synchronized (mAnimationLock) { 344 synchronized (mAnimationLock) {
342 if (enabled && !mInputAnimationRunning) { 345 if (enabled && !mInputAnimationRunning) {
343 requestRepaint(); 346 requestRepaint();
344 } 347 }
345 mInputAnimationRunning = enabled; 348 mInputAnimationRunning = enabled;
346 } 349 }
347 } 350 }
348 } 351 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698