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.graphics.Matrix; | 7 import android.graphics.Matrix; |
8 import android.graphics.PointF; | 8 import android.graphics.PointF; |
9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
10 import android.graphics.RectF; | 10 import android.graphics.RectF; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 if (rectScreen.bottom - rectScreen.top < viewportSize.y) { | 201 if (rectScreen.bottom - rectScreen.top < viewportSize.y) { |
202 yAdjust = -(bottomDelta + topDelta) / 2; | 202 yAdjust = -(bottomDelta + topDelta) / 2; |
203 } else if (topDelta > 0 && bottomDelta > 0) { | 203 } else if (topDelta > 0 && bottomDelta > 0) { |
204 yAdjust = -Math.min(topDelta, bottomDelta); | 204 yAdjust = -Math.min(topDelta, bottomDelta); |
205 } else if (topDelta < 0 && bottomDelta < 0) { | 205 } else if (topDelta < 0 && bottomDelta < 0) { |
206 yAdjust = Math.min(-topDelta, -bottomDelta); | 206 yAdjust = Math.min(-topDelta, -bottomDelta); |
207 } | 207 } |
208 | 208 |
209 mRenderData.transform.postTranslate(xAdjust, yAdjust); | 209 mRenderData.transform.postTranslate(xAdjust, yAdjust); |
210 | 210 |
211 mViewer.transformationChanged(); | 211 mViewer.transformationChanged(mRenderData.transform); |
Hzj_jie
2016/08/25 21:55:14
The safety of this logic depends on mRenderData wi
Yuwei
2016/08/25 22:44:16
But this is for WebRTC... Maybe have a simplified
joedow
2016/08/25 22:57:47
We no longer need any synchronization on the Java
Yuwei
2016/08/25 23:14:35
Looks like we do create anonymous thread for fetch
Hzj_jie
2016/08/26 18:34:58
Sorry, I have not followed up with Java code for a
| |
212 } | 212 } |
213 | 213 |
214 /** | 214 /** |
215 * Repositions the image by translating and zooming it, to keep the zoom lev el within sensible | 215 * Repositions the image by translating and zooming it, to keep the zoom lev el within sensible |
216 * limits. The minimum zoom level is chosen to avoid black space around all 4 sides. The | 216 * limits. The minimum zoom level is chosen to avoid black space around all 4 sides. The |
217 * maximum zoom level is set arbitrarily, so that the user can zoom out agai n in a reasonable | 217 * maximum zoom level is set arbitrarily, so that the user can zoom out agai n in a reasonable |
218 * time, and to prevent arithmetic overflow problems from displaying the ima ge. | 218 * time, and to prevent arithmetic overflow problems from displaying the ima ge. |
219 * | 219 * |
220 * @param centerViewport Determines whether the viewport will be translated to the desired | 220 * @param centerViewport Determines whether the viewport will be translated to the desired |
221 * center position before being adjusted to fit the sc reen boundaries. | 221 * center position before being adjusted to fit the sc reen boundaries. |
(...skipping 18 matching lines...) Expand all Loading... | |
240 // Displayed image is too small in both directions, so apply the min imum zoom | 240 // Displayed image is too small in both directions, so apply the min imum zoom |
241 // level needed to fit either the width or height. | 241 // level needed to fit either the width or height. |
242 float scale = Math.min((float) mRenderData.screenWidth / mRenderData .imageWidth, | 242 float scale = Math.min((float) mRenderData.screenWidth / mRenderData .imageWidth, |
243 (float) mRenderData.screenHeight / mRenderDat a.imageHeight); | 243 (float) mRenderData.screenHeight / mRenderDat a.imageHeight); |
244 mRenderData.transform.setScale(scale, scale); | 244 mRenderData.transform.setScale(scale, scale); |
245 } | 245 } |
246 | 246 |
247 repositionImage(centerViewport); | 247 repositionImage(centerViewport); |
248 } | 248 } |
249 } | 249 } |
OLD | NEW |