From 48ec4e0b5ca7d5fb65645e06c92b0fd29c974b27 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 16 Jul 2019 14:28:47 -0700 Subject: ViewRootImpl: Add USE_BLAST flag. Add support for ViewRootImpl submitting buffers using BLAST and put this support behind a disabled-by-default FLAG. Bug: 135786080 Change-Id: Ia3f205e34db9f9aa574c9c2e2c499dd3046af220 --- .../java/android/graphics/BLASTBufferQueue.java | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 graphics/java/android/graphics/BLASTBufferQueue.java (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java new file mode 100644 index 000000000000..8c6a9371d53b --- /dev/null +++ b/graphics/java/android/graphics/BLASTBufferQueue.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.graphics; + +import android.view.Surface; +import android.view.SurfaceControl; + +/** + * @hide + */ +public final class BLASTBufferQueue { + // Note: This field is accessed by native code. + private long mNativeObject; // BLASTBufferQueue* + + private static native long nativeCreate(long surfaceControl, long width, long height); + private static native void nativeDestroy(long ptr); + private static native Surface nativeGetSurface(long ptr); + private static native void nativeSetNextTransaction(long ptr, long transactionPtr); + private static native void nativeUpdate(long ptr, long surfaceControl, long width, long height); + + /** Create a new connection with the surface flinger. */ + public BLASTBufferQueue(SurfaceControl sc, int width, int height) { + mNativeObject = nativeCreate(sc.mNativeObject, width, height); + } + + public void destroy() { + nativeDestroy(mNativeObject); + } + + public Surface getSurface() { + return nativeGetSurface(mNativeObject); + } + + public void setNextTransaction(SurfaceControl.Transaction t) { + nativeSetNextTransaction(mNativeObject, t.mNativeObject); + } + + public void update(SurfaceControl sc, int width, int height) { + nativeUpdate(mNativeObject, sc.mNativeObject, width, height); + } + + @Override + protected void finalize() throws Throwable { + try { + if (mNativeObject != 0) { + nativeDestroy(mNativeObject); + } + } finally { + super.finalize(); + } + } +} + -- cgit v1.2.3-59-g8ed1b