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

Side by Side Diff: webrtc/sdk/android/api/org/webrtc/RendererCommon.java

Issue 2977153003: Add texture support to HardwareVideoEncoder. (Closed)
Patch Set: Fix logging and matrix helper Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 matrix4x4[0 * 4 + 1], matrix4x4[1 * 4 + 1], matrix4x4[3 * 4 + 1], 266 matrix4x4[0 * 4 + 1], matrix4x4[1 * 4 + 1], matrix4x4[3 * 4 + 1],
267 matrix4x4[0 * 4 + 3], matrix4x4[1 * 4 + 3], matrix4x4[3 * 4 + 3], 267 matrix4x4[0 * 4 + 3], matrix4x4[1 * 4 + 3], matrix4x4[3 * 4 + 3],
268 }; 268 };
269 // clang-format on 269 // clang-format on
270 270
271 android.graphics.Matrix matrix = new android.graphics.Matrix(); 271 android.graphics.Matrix matrix = new android.graphics.Matrix();
272 matrix.setValues(values); 272 matrix.setValues(values);
273 return matrix; 273 return matrix;
274 } 274 }
275 275
276 /** Converts android.graphics.Matrix to a float[16] matrix array. */
277 public static float[] convertMatrixFromAndroidGraphicsMatrix(android.graphics. Matrix matrix) {
278 float[] values = new float[9];
279 matrix.getValues(values);
280
281 // The android.graphics.Matrix looks like this:
282 // [x1 y1 w1]
283 // [x2 y2 w2]
284 // [x3 y3 w3]
285 // We want to contruct a matrix that looks like this:
286 // [x1 y1 0 w1]
287 // [x2 y2 0 w2]
288 // [ 0 0 1 0]
289 // [x3 y3 0 w3]
290 // Since it is stored in column-major order, it looks like this:
291 // [x1 x2 0 x3
292 // y1 y2 0 y3
293 // 0 0 1 0
294 // w1 w2 0 w3]
295 // clang-format off
296 float[] matrix4x4 = {
297 values[0 * 3 + 0], values[1 * 3 + 0], 0, values[2 * 3 + 0],
298 values[0 * 3 + 1], values[1 * 3 + 1], 0, values[2 * 3 + 1],
299 0, 0, 1, 0,
300 values[0 * 3 + 2], values[1 * 3 + 2], 0, values[2 * 3 + 2],
301 };
302 // clang-format on
303 return matrix4x4;
304 }
305
276 /** 306 /**
277 * Calculate display size based on scaling type, video aspect ratio, and maxim um display size. 307 * Calculate display size based on scaling type, video aspect ratio, and maxim um display size.
278 */ 308 */
279 public static Point getDisplaySize( 309 public static Point getDisplaySize(
280 ScalingType scalingType, float videoAspectRatio, int maxDisplayWidth, int maxDisplayHeight) { 310 ScalingType scalingType, float videoAspectRatio, int maxDisplayWidth, int maxDisplayHeight) {
281 return getDisplaySize(convertScalingTypeToVisibleFraction(scalingType), vide oAspectRatio, 311 return getDisplaySize(convertScalingTypeToVisibleFraction(scalingType), vide oAspectRatio,
282 maxDisplayWidth, maxDisplayHeight); 312 maxDisplayWidth, maxDisplayHeight);
283 } 313 }
284 314
285 /** 315 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return new Point(maxDisplayWidth, maxDisplayHeight); 354 return new Point(maxDisplayWidth, maxDisplayHeight);
325 } 355 }
326 // Each dimension is constrained on max display size and how much we are all owed to crop. 356 // Each dimension is constrained on max display size and how much we are all owed to crop.
327 final int width = Math.min( 357 final int width = Math.min(
328 maxDisplayWidth, Math.round(maxDisplayHeight / minVisibleFraction * vide oAspectRatio)); 358 maxDisplayWidth, Math.round(maxDisplayHeight / minVisibleFraction * vide oAspectRatio));
329 final int height = Math.min( 359 final int height = Math.min(
330 maxDisplayHeight, Math.round(maxDisplayWidth / minVisibleFraction / vide oAspectRatio)); 360 maxDisplayHeight, Math.round(maxDisplayWidth / minVisibleFraction / vide oAspectRatio));
331 return new Point(width, height); 361 return new Point(width, height);
332 } 362 }
333 } 363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698