| 1 |
/* |
| 2 |
* Copyright (C) 2020 The Android Open Source Project |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package com.android.test |
| 18 |
|
| 19 |
import android.annotation.ColorInt |
| 20 |
import android.graphics.Color |
| 21 |
import android.graphics.Point |
| 22 |
import com.android.test.SurfaceViewBufferTestBase.Companion.ScalingMode |
| 23 |
import com.android.test.SurfaceViewBufferTestBase.Companion.Transform |
| 24 |
|
| 25 |
class SurfaceProxy { |
| 26 |
init { |
| 27 |
System.loadLibrary("surface_jni") |
| 28 |
} |
| 29 |
|
| 30 |
external fun setSurface(surface: Any) |
| 31 |
external fun waitUntilBufferDisplayed(frameNumber: Long, timeoutMs: Int): Int |
| 32 |
external fun draw() |
| 33 |
fun drawBuffer(slot: Int, @ColorInt c: Int) { |
| 34 |
drawBuffer(slot, intArrayOf(Color.red(c), Color.green(c), Color.blue(c), Color.alpha(c))) |
| 35 |
} |
| 36 |
external fun drawBuffer(slot: Int, color: IntArray) |
| 37 |
|
| 38 |
// android/native_window.h functions |
| 39 |
external fun ANativeWindowLock() |
| 40 |
external fun ANativeWindowUnlockAndPost() |
| 41 |
fun ANativeWindowSetBuffersGeometry(surface: Any, size: Point, format: Int) { |
| 42 |
ANativeWindowSetBuffersGeometry(surface, size.x, size.y, format) |
| 43 |
} |
| 44 |
external fun ANativeWindowSetBuffersGeometry(surface: Any, width: Int, height: Int, format: Int) |
| 45 |
fun ANativeWindowSetBuffersTransform(transform: Transform) { |
| 46 |
ANativeWindowSetBuffersTransform(transform.value) |
| 47 |
} |
| 48 |
external fun ANativeWindowSetBuffersTransform(transform: Int) |
| 49 |
|
| 50 |
// gui/Surface.h functions |
| 51 |
fun SurfaceSetScalingMode(scalingMode: ScalingMode) { |
| 52 |
SurfaceSetScalingMode(scalingMode.ordinal) |
| 53 |
} |
| 54 |
external fun SurfaceSetScalingMode(scalingMode: Int) |
| 55 |
external fun SurfaceDequeueBuffer(slot: Int, timeoutMs: Int): Int |
| 56 |
external fun SurfaceCancelBuffer(slot: Int) |
| 57 |
external fun SurfaceQueueBuffer(slot: Int, freeSlot: Boolean = true): Int |
| 58 |
external fun SurfaceSetAsyncMode(async: Boolean): Int |
| 59 |
external fun SurfaceSetDequeueTimeout(timeout: Long): Int |
| 60 |
external fun SurfaceQuery(what: Int): Int |
| 61 |
external fun SurfaceSetMaxDequeuedBufferCount(maxDequeuedBuffers: Int): Int |
| 62 |
|
| 63 |
// system/native_window.h functions |
| 64 |
external fun NativeWindowSetBufferCount(count: Int): Int |
| 65 |
external fun NativeWindowSetSharedBufferMode(shared: Boolean): Int |
| 66 |
external fun NativeWindowSetAutoRefresh(autoRefresh: Boolean): Int |
| 67 |
} |