diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index d19ebe43dd..c6460228a8 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -7,6 +7,8 @@ A new header is inserted each time a *tag* is created.
## v1.21.2
+- remove deprecated `Stream` APIs, see `Texture::import()` for an alternative [⚠️ **API Change**].
+
## v1.21.1
- engine: Allow both screen-space refraction and screen-space reflections on the same object [⚠️ **Material breakage**].
diff --git a/android/filament-android/src/main/cpp/Stream.cpp b/android/filament-android/src/main/cpp/Stream.cpp
index a8a250d3ec..ecac11dc91 100644
--- a/android/filament-android/src/main/cpp/Stream.cpp
+++ b/android/filament-android/src/main/cpp/Stream.cpp
@@ -98,16 +98,6 @@ Java_com_google_android_filament_Stream_nBuilderStreamSource(JNIEnv* env,
builder->setStreamSource(env, streamSource);
}
-extern "C" JNIEXPORT void JNICALL
-Java_com_google_android_filament_Stream_nBuilderStream(JNIEnv*, jclass,
- jlong nativeStreamBuilder, jlong externalTextureId) {
- StreamBuilder* builder = (StreamBuilder*) nativeStreamBuilder;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- builder->builder()->stream(externalTextureId);
-#pragma clang diagnostic pop
-}
-
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Stream_nBuilderWidth(JNIEnv*, jclass,
jlong nativeStreamBuilder, jint width) {
@@ -143,41 +133,6 @@ Java_com_google_android_filament_Stream_nSetDimensions(JNIEnv*, jclass, jlong na
stream->setDimensions((uint32_t) width, (uint32_t) height);
}
-extern "C" JNIEXPORT jint JNICALL
-Java_com_google_android_filament_Stream_nReadPixels(JNIEnv *env, jclass,
- jlong nativeStream, jlong nativeEngine,
- jint xoffset, jint yoffset, jint width, jint height,
- jobject storage, jint remaining,
- jint left, jint top, jint type, jint alignment, jint stride, jint format,
- jobject handler, jobject runnable) {
- Stream *stream = (Stream *) nativeStream;
- Engine *engine = (Engine *) nativeEngine;
-
- stride = stride ? stride : width;
- size_t sizeInBytes = PixelBufferDescriptor::computeDataSize(
- (PixelDataFormat) format, (PixelDataType) type,
- (size_t) stride, (size_t) (height + top), (size_t) alignment);
-
- AutoBuffer nioBuffer(env, storage, 0);
- if (sizeInBytes > (remaining << nioBuffer.getShift())) {
- // BufferOverflowException
- return -1;
- }
-
- void *buffer = nioBuffer.getData();
- auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
-
- PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
- (backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
- (uint32_t) stride,
- callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
-
- stream->readPixels(uint32_t(xoffset), uint32_t(yoffset), uint32_t(width), uint32_t(height),
- std::move(desc));
-
- return 0;
-}
-
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Stream_nGetTimestamp(JNIEnv*, jclass, jlong nativeStream) {
Stream *stream = (Stream *) nativeStream;
diff --git a/android/filament-android/src/main/java/com/google/android/filament/Stream.java b/android/filament-android/src/main/java/com/google/android/filament/Stream.java
index 5ea8ca54a6..5e11fbf3d0 100644
--- a/android/filament-android/src/main/java/com/google/android/filament/Stream.java
+++ b/android/filament-android/src/main/java/com/google/android/filament/Stream.java
@@ -103,9 +103,6 @@ public class Stream {
/** Not synchronized but copy-free. Good for video. */
NATIVE,
- /** Synchronized, but GL-only and incurs copies. Good for AR on devices before API 26. */
- TEXTURE_ID,
-
/** Synchronized, copy-free, and take a release callback. Good for AR but requires API 26+. */
ACQUIRED,
};
@@ -121,7 +118,7 @@ public class Stream {
* By default, Stream objects are {@link StreamType#ACQUIRED ACQUIRED} and must have external images pushed to them via
* {@link #setAcquiredImage}.
*
- * To create a {@link StreamType#NATIVE NATIVE} or {@link StreamType#TEXTURE_ID TEXTURE_ID} stream, call one of the
stream
methods
+ * To create a {@link StreamType#NATIVE NATIVE} stream, call one of the stream
methods
* on the builder.
*/
public static class Builder {
@@ -156,27 +153,6 @@ public class Stream {
throw new IllegalArgumentException("Invalid stream source: " + streamSource);
}
- /**
- * Creates a {@link StreamType#TEXTURE_ID TEXTURE_ID} stream. A copy stream will sample data from the supplied
- * external texture and copy it into an internal private texture.
- *
- * Currently only OpenGL external texture ids are supported.
- *
- * @param externalTextureId An opaque texture id (typically a GLuint created with
- * glGenTextures()) in a context shared with
- * filament -- in that case this texture's target must be
- * GL_TEXTURE_EXTERNAL_OES.
- * @return This Builder, for chaining calls.
- * @see Texture#setExternalStream
- * @deprecated this method existed only for ARCore which doesn't need this anymore, use {@link Texture.Builder#importTexture(long)} instead.
- */
- @Deprecated
- @NonNull
- public Builder stream(long externalTextureId) {
- nBuilderStream(mNativeBuilder, externalTextureId);
- return this;
- }
-
/**
* @param width initial width of the incoming stream. Whether this value is used is
* stream dependent. On Android, it must be set when using
@@ -276,92 +252,6 @@ public class Stream {
nSetDimensions(getNativeObject(), width, height);
}
- /**
- * Reads back the content of the last frame of a Stream since the last call to
- * {@link Renderer#beginFrame}.
- *
- * The Stream must be a copy stream, which can be checked with {@link #getStreamType()}.
- * This function is a no-op otherwise.
- *
- *
- *
- * Stream buffer User buffer (PixelBufferDescriptor)
- * +--------------------+
- * | | .stride .alignment
- * | | ----------------------->-->
- * | | O----------------------+--+ low addresses
- * | | | | | |
- * | w | | | .top | |
- * | <---------> | | V | |
- * | +---------+ | | +---------+ | |
- * | | ^ | | ======> | | | | |
- * | x | h| | | |.left| | | |
- * +------>| v | | +---->| | | |
- * | +.........+ | | +.........+ | |
- * | ^ | | | |
- * | y | | +----------------------+--+ high addresses
- * O------------+-------+
- *
- *
- *
- * Typically readPixels() will be called after {@link Renderer#beginFrame}.
- *
- * After calling this method, the callback associated with buffer
- * will be invoked on the main thread, indicating that the read-back has completed.
- * Typically, this will happen after multiple calls to {@link Renderer#beginFrame},
- * {@link Renderer#render}, {@link Renderer#endFrame}.
- *
- * readPixels is intended for debugging and testing.
- * It will impact performance significantly.
- *
- * @param xoffset left offset of the sub-region to read back
- * @param yoffset bottom offset of the sub-region to read back
- * @param width width of the sub-region to read back
- * @param height height of the sub-region to read back
- * @param buffer client-side buffer where the read-back will be written
- *
- *
- * The following format are always supported:
- *
{@link Texture.Format#RGBA}
- * {@link Texture.Format#RGBA_INTEGER}
- *
- *
- *
- * The following types are always supported:
- *
{@link Texture.Type#UBYTE}
- * {@link Texture.Type#UINT}
- * {@link Texture.Type#INT}
- * {@link Texture.Type#FLOAT}
- *
- *
- * Other combination of format/type may be supported. If a combination is
- * not supported, this operation may fail silently. Use a DEBUG build
- * to get some logs about the failure.
- *
- * @exception BufferOverflowException if the specified parameters would result in reading
- * outside of buffer.
- */
- public void readPixels(
- @IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset,
- @IntRange(from = 0) int width, @IntRange(from = 0) int height,
- @NonNull Texture.PixelBufferDescriptor buffer) {
-
- if (buffer.storage.isReadOnly()) {
- throw new ReadOnlyBufferException();
- }
-
- int result = nReadPixels(getNativeObject(), mNativeEngine,
- xoffset, yoffset, width, height,
- buffer.storage, buffer.storage.remaining(),
- buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
- buffer.stride, buffer.format.ordinal(),
- buffer.handler, buffer.callback);
-
- if (result < 0) {
- throw new BufferOverflowException();
- }
- }
-
/**
* Returns the presentation time of the currently displayed frame in nanosecond.
*
@@ -387,7 +277,6 @@ public class Stream {
private static native long nCreateBuilder();
private static native void nDestroyBuilder(long nativeStreamBuilder);
private static native void nBuilderStreamSource(long nativeStreamBuilder, Object streamSource);
- private static native void nBuilderStream(long nativeStreamBuilder, long externalTextureId);
private static native void nBuilderWidth(long nativeStreamBuilder, int width);
private static native void nBuilderHeight(long nativeStreamBuilder, int height);
private static native long nBuilderBuild(long nativeStreamBuilder, long nativeEngine);
diff --git a/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/MainActivity.kt b/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/MainActivity.kt
index f07a4a545a..45237c0285 100644
--- a/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/MainActivity.kt
+++ b/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/MainActivity.kt
@@ -79,8 +79,6 @@ class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallba
// Performs the rendering and schedules new frames
private val frameScheduler = FrameCallback()
- private var externalTextureID: Int = 0
-
@RequiresApi(30)
class Api30Impl {
companion object {
@@ -103,8 +101,6 @@ class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallba
setupView()
setupScene()
- externalTextureID = createExternalTexture()
-
@Suppress("deprecation")
val display = if (Build.VERSION.SDK_INT >= 30) {
Api30Impl.getDisplay(this)
@@ -112,7 +108,7 @@ class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallba
windowManager.defaultDisplay!!
}
- streamHelper = StreamHelper(engine, materialInstance, display, externalTextureID)
+ streamHelper = StreamHelper(engine, materialInstance, display)
this.title = streamHelper.getTestName()
}
@@ -445,31 +441,4 @@ class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallba
check(EGL14.eglMakeCurrent(display, surface, surface, context)) { "Error making GL context." }
return context
}
-
- private fun createExternalTexture(): Int {
- val textures = IntArray(1)
- GLES30.glGenTextures(1, textures, 0)
- val result = textures[0]
-
- val textureTarget = GLES11Ext.GL_TEXTURE_EXTERNAL_OES
- GLES30.glBindTexture(textureTarget, result)
- GLES30.glTexParameteri(textureTarget, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE)
- GLES30.glTexParameteri(textureTarget, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE)
- GLES30.glTexParameteri(textureTarget, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST)
- GLES30.glTexParameteri(textureTarget, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_NEAREST)
-
- if (!GLES30.glIsTexture(result)) {
- throw RuntimeException("OpenGL error: $result is an invalid texture.")
- }
-
- val error = GLES30.glGetError()
- if (error != GLES30.GL_NO_ERROR) {
- val errorString = GLU.gluErrorString(error)
- throw RuntimeException("OpenGL error: $errorString!")
- }
-
- return result
- }
-
-
}
diff --git a/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/StreamHelper.kt b/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/StreamHelper.kt
index c18377f206..71ff121e18 100644
--- a/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/StreamHelper.kt
+++ b/android/samples/sample-stream-test/src/main/java/com/google/android/filament/streamtest/StreamHelper.kt
@@ -37,7 +37,6 @@ class StreamHelper(
private val filamentEngine: Engine,
private val filamentMaterial: MaterialInstance,
private val display: Display,
- private val externalTextureId: Int
) {
/**
* The StreamSource configures the source data for the texture.
@@ -51,7 +50,6 @@ class StreamHelper(
*/
enum class StreamSource {
CANVAS_STREAM_NATIVE, // copy-free but does not guarantee synchronization
- CANVAS_STREAM_TEXID, // synchronized but incurs a copy
CANVAS_STREAM_ACQUIRED, // synchronized and copy-free
}
@@ -127,10 +125,6 @@ class StreamHelper(
surface.unlockCanvasAndPost(canvas)
- if (streamSource == StreamSource.CANVAS_STREAM_TEXID) {
- surfaceTexture!!.updateTexImage()
- }
-
if (streamSource == StreamSource.CANVAS_STREAM_ACQUIRED) {
val image = imageReader!!.acquireLatestImage()
filamentStream!!.setAcquiredImage(
@@ -146,7 +140,7 @@ class StreamHelper(
fun nextTest() {
stopTest()
- streamSource = StreamSource.values()[(streamSource.ordinal + 1) % 3]
+ streamSource = StreamSource.values()[(streamSource.ordinal + 1) % StreamSource.values().size]
startTest()
}
@@ -213,23 +207,6 @@ class StreamHelper(
filamentTexture.setExternalStream(filamentEngine, filamentStream!!)
}
- if (streamSource == StreamSource.CANVAS_STREAM_TEXID) {
-
- // Create the Android surface that will hold the canvas image.
- surfaceTexture = SurfaceTexture(externalTextureId)
- surfaceTexture!!.setDefaultBufferSize(resolution.width, resolution.height)
- canvasSurface = Surface(surfaceTexture)
-
- // Create the Filament Stream object that gets bound to the Texture.
- filamentStream = Stream.Builder()
- .stream(externalTextureId.toLong())
- .width(resolution.width)
- .height(resolution.height)
- .build(filamentEngine)
-
- filamentTexture.setExternalStream(filamentEngine, filamentStream!!)
- }
-
if (streamSource == StreamSource.CANVAS_STREAM_ACQUIRED) {
filamentStream = Stream.Builder()
.width(resolution.width)
diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt
index fec59e8af8..19c0fcb183 100644
--- a/filament/backend/CMakeLists.txt
+++ b/filament/backend/CMakeLists.txt
@@ -65,8 +65,6 @@ if (FILAMENT_SUPPORTS_OPENGL AND NOT FILAMENT_USE_EXTERNAL_GLES3 AND NOT FILAMEN
src/opengl/gl_headers.h
src/opengl/GLUtils.cpp
src/opengl/GLUtils.h
- src/opengl/OpenGLBlitter.cpp
- src/opengl/OpenGLBlitter.h
src/opengl/OpenGLContext.cpp
src/opengl/OpenGLContext.h
src/opengl/OpenGLDriver.cpp
@@ -89,7 +87,6 @@ if (FILAMENT_SUPPORTS_OPENGL AND NOT FILAMENT_USE_EXTERNAL_GLES3 AND NOT FILAMEN
endif ()
if (ANDROID)
list(APPEND SRCS src/opengl/platforms/ExternalStreamManagerAndroid.cpp)
- list(APPEND SRCS src/android/ExternalTextureManagerAndroid.cpp)
list(APPEND SRCS src/opengl/platforms/PlatformEGLAndroid.cpp)
elseif (IOS)
list(APPEND SRCS src/opengl/platforms/PlatformCocoaTouchGL.mm)
diff --git a/filament/backend/include/backend/DriverEnums.h b/filament/backend/include/backend/DriverEnums.h
index b3d04798c0..4203424fa5 100644
--- a/filament/backend/include/backend/DriverEnums.h
+++ b/filament/backend/include/backend/DriverEnums.h
@@ -788,7 +788,6 @@ enum class BlendFunction : uint8_t {
//! Stream for external textures
enum class StreamType {
NATIVE, //!< Not synchronized but copy-free. Good for video.
- TEXTURE_ID, //!< Synchronized, but GL-only and incurs copies. Good for AR on devices before API 26.
ACQUIRED, //!< Synchronized, copy-free, and take a release callback. Good for AR but requires API 26+.
};
diff --git a/filament/backend/include/private/backend/DriverAPI.inc b/filament/backend/include/private/backend/DriverAPI.inc
index 92d2172920..856690b8f7 100644
--- a/filament/backend/include/private/backend/DriverAPI.inc
+++ b/filament/backend/include/private/backend/DriverAPI.inc
@@ -246,11 +246,6 @@ DECL_DRIVER_API_R_N(backend::SwapChainHandle, createSwapChainHeadless,
uint32_t, height,
uint64_t, flags)
-DECL_DRIVER_API_R_N(backend::StreamHandle, createStreamFromTextureId,
- intptr_t, externalTextureId,
- uint32_t, width,
- uint32_t, height)
-
DECL_DRIVER_API_R_0(backend::TimerQueryHandle, createTimerQuery)
@@ -461,14 +456,6 @@ DECL_DRIVER_API_N(readPixels,
uint32_t, height,
backend::PixelBufferDescriptor&&, data)
-DECL_DRIVER_API_N(readStreamPixels,
- backend::StreamHandle, sh,
- uint32_t, x,
- uint32_t, y,
- uint32_t, width,
- uint32_t, height,
- backend::PixelBufferDescriptor&&, data)
-
/*
* Rendering operations
* --------------------
diff --git a/filament/backend/include/private/backend/OpenGLPlatform.h b/filament/backend/include/private/backend/OpenGLPlatform.h
index 2619f18fe0..b7bb8d95c8 100644
--- a/filament/backend/include/private/backend/OpenGLPlatform.h
+++ b/filament/backend/include/private/backend/OpenGLPlatform.h
@@ -82,15 +82,6 @@ public:
virtual void detach(Stream* stream) noexcept = 0;
virtual void updateTexImage(Stream* stream, int64_t* timestamp) noexcept = 0;
- // external texture storage
- virtual ExternalTexture* createExternalTextureStorage() noexcept = 0;
-
- // this is called synchronously in the application thread (NOT the Driver thread)
- virtual void reallocateExternalStorage(ExternalTexture* ets,
- uint32_t w, uint32_t h, TextureFormat format) noexcept = 0;
-
- virtual void destroyExternalTextureStorage(ExternalTexture* ets) noexcept = 0;
-
// The method allows platforms to convert a user-supplied external image object into a new type
// (e.g. HardwareBuffer => EGLImage). It makes sense for the default implementation to do nothing.
virtual AcquiredImage transformAcquiredImage(AcquiredImage source) noexcept { return source; }
diff --git a/filament/backend/src/android/ExternalTextureManagerAndroid.cpp b/filament/backend/src/android/ExternalTextureManagerAndroid.cpp
deleted file mode 100644
index ed7fc2b1d2..0000000000
--- a/filament/backend/src/android/ExternalTextureManagerAndroid.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-
-#include "ExternalTextureManagerAndroid.h"
-
-#include
-#include
-#include
-
-#include
-
-using namespace utils;
-
-namespace filament::backend {
-
-template
-static void loadSymbol(T*& pfn, const char *symbol) noexcept {
- pfn = (T*)dlsym(RTLD_DEFAULT, symbol);
-}
-
-// ------------------------------------------------------------------------------------------------
-
-namespace ndk {
-/*
- * This mimics the GraphicBuffer class for pre-API 26
- */
-template
-struct ANativeObjectBase : public NATIVE_TYPE, public REF {
-};
-
-struct android_native_base_t {
- unsigned int magic;
- unsigned int version;
- void* reserved[4];
- void (* incRef)(struct android_native_base_t* base);
- void (* decRef)(struct android_native_base_t* base);
-};
-
-struct ANativeWindowBuffer {
- struct android_native_base_t common;
- unsigned int width;
- unsigned int height;
- unsigned int stride;
- unsigned int format;
- unsigned int usage_deprecated;
- uintptr_t layerCount;
- void* reserved[1];
- const void* handle;
- uint64_t usage;
- void* reserved_proc[8 - (sizeof(uint64_t) / sizeof(void*))];
-};
-
-struct RefBase {
- virtual ~RefBase() = default;
- void* ref;
-};
-
-struct GraphicBuffer : public ANativeObjectBase {
-};
-struct GraphicBufferWrapper {
- GraphicBuffer* graphicBuffer;
-};
-} // namespace ndk
-
-// ------------------------------------------------------------------------------------------------
-using namespace ndk;
-
-struct EGLExternalTexture : public ExternalTextureManagerAndroid::ExternalTexture {
- GraphicBufferWrapper* graphicBufferWrapper = nullptr;
-};
-
-ExternalTextureManagerAndroid& ExternalTextureManagerAndroid::create() noexcept {
- return *(new ExternalTextureManagerAndroid{});
-}
-
-void ExternalTextureManagerAndroid::destroy(ExternalTextureManagerAndroid* pExternalTextureManager) noexcept {
- delete pExternalTextureManager;
-}
-
-// called on gl thread
-ExternalTextureManagerAndroid::ExternalTextureManagerAndroid() noexcept
- : mVm(VirtualMachineEnv::get()) {
-}
-
-// not quite sure on which thread this is going to be called
-ExternalTextureManagerAndroid::~ExternalTextureManagerAndroid() noexcept {
- if (__builtin_available(android 26, *)) {
- } else {
- if (mGraphicBufferClass) {
- JNIEnv* env = VirtualMachineEnv::getThreadEnvironment();
- if (env) {
- env->DeleteGlobalRef(mGraphicBufferClass);
- }
- }
- }
-}
-
-// called on gl thread
-Platform::ExternalTexture* ExternalTextureManagerAndroid::createExternalTexture() noexcept {
- if (__builtin_available(android 26, *)) {
- } else {
- // initialize java stuff on-demand
- if (!mGraphicBufferClass) {
- JNIEnv* env = mVm.getEnvironment();
- mGraphicBufferClass = env->FindClass("android/view/GraphicBuffer");
- mGraphicBuffer_nCreateGraphicBuffer = env->GetStaticMethodID(
- mGraphicBufferClass, "nCreateGraphicBuffer", "(IIII)J");
- mGraphicBuffer_nDestroyGraphicBuffer = env->GetStaticMethodID(
- mGraphicBufferClass, "nDestroyGraphicBuffer", "(J)V");
-
- mGraphicBufferClass = static_cast(env->NewGlobalRef(mGraphicBufferClass));
- }
- }
- EGLExternalTexture* ets = new EGLExternalTexture;
- return ets;
-}
-
-// called on app thread
-void ExternalTextureManagerAndroid::reallocate(
- Platform::ExternalTexture* ets, uint32_t w, uint32_t h,
- TextureFormat format, uint64_t usage) noexcept {
- destroyStorage(ets);
- alloc(ets, w, h, format, usage);
-}
-
-// called on gl thread
-void ExternalTextureManagerAndroid::destroy(Platform::ExternalTexture* ets) noexcept {
- destroyStorage(ets);
- delete static_cast(ets);
-}
-
-// called on app thread
-void ExternalTextureManagerAndroid::alloc(
- Platform::ExternalTexture* t,
- uint32_t w, uint32_t h, TextureFormat format, uint64_t usage) noexcept {
-
- EGLExternalTexture* ets = static_cast(t);
-
- AHardwareBuffer_Desc desc = { w, h, 1, 0, usage, 0, 0, 0 };
- switch (format) {
- case TextureFormat::RGB8:
- // don't use R8G8B8 here because some drivers produce garbled images
- desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM;
- break;
- case TextureFormat::RGBA8:
- desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
- break;
- case TextureFormat::RGB565:
- desc.format = AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;
- break;
- case TextureFormat::RGB10_A2:
- desc.format = AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
- break;
- default:
- slog.e << "Unsupported format " << (int)format << ", use RGBA8 or RGB8 only."
- << io::endl;
- return;
- }
-
- if (__builtin_available(android 26, *)) {
- // allocate new storage...
- AHardwareBuffer* buffer = nullptr;
- if (AHardwareBuffer_allocate(&desc, &buffer) < 0) {
- slog.e << "AHardwareBuffer_allocate() failed" << io::endl;
- return;
- }
- ets->hardwareBuffer = buffer;
- } else {
- // note: This is called on the application thread (not the GL thread)
- JNIEnv* env = VirtualMachineEnv::getThreadEnvironment();
- if (!env) {
- return; // this should not happen
- }
-
- jlong graphicBufferWrapperJni = env->CallStaticLongMethod(mGraphicBufferClass,
- mGraphicBuffer_nCreateGraphicBuffer, w, h, desc.format, usage);
- VirtualMachineEnv::handleException(env);
-
- if (graphicBufferWrapperJni) {
- GraphicBuffer* const gb = ((GraphicBufferWrapper*)graphicBufferWrapperJni)->graphicBuffer;
- ets->graphicBufferWrapper = (GraphicBufferWrapper*)graphicBufferWrapperJni;
- ets->clientBuffer = static_cast(gb);
- }
- }
-}
-
-// called on gl thread
-void ExternalTextureManagerAndroid::destroyStorage(Platform::ExternalTexture* t) noexcept {
- EGLExternalTexture* ets = static_cast(t);
- if (__builtin_available(android 26, *)) {
- // destroy the current storage if any
- if (ets->hardwareBuffer) {
- AHardwareBuffer_release(ets->hardwareBuffer);
- ets->hardwareBuffer = nullptr;
- }
- } else {
- if (ets->graphicBufferWrapper) {
- JNIEnv* env = VirtualMachineEnv::get().getEnvironment();
- env->CallStaticVoidMethod(mGraphicBufferClass,
- mGraphicBuffer_nDestroyGraphicBuffer, (jlong)ets->graphicBufferWrapper);
- VirtualMachineEnv::handleException(env);
- ets->graphicBufferWrapper = nullptr;
- }
- }
-}
-
-} // namespace filament::backend
-
diff --git a/filament/backend/src/android/ExternalTextureManagerAndroid.h b/filament/backend/src/android/ExternalTextureManagerAndroid.h
deleted file mode 100644
index 86f5785f50..0000000000
--- a/filament/backend/src/android/ExternalTextureManagerAndroid.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#ifndef TNT_FILAMENT_DRIVER_ANDROID_EXTERNAL_TEXTURE_MANAGER_ANDROID_H
-#define TNT_FILAMENT_DRIVER_ANDROID_EXTERNAL_TEXTURE_MANAGER_ANDROID_H
-
-#include "private/backend/VirtualMachineEnv.h"
-
-#include
-#include
-
-#include
-#include
-
-namespace filament::backend {
-
-/*
- * ExternalTextureManagerAndroid::ExternalTexture is basically a wrapper for AHardwareBuffer.
- *
- * This class doesn't rely on GL or EGL, and could be used for other Android platform if needed
- * (e.g. Vulkan).
- *
- * ExternalTextureManagerAndroid handle allocation/destruction using either Java or the NDK,
- * whichever is available.
- */
-class ExternalTextureManagerAndroid {
-public:
-
- struct ExternalTexture : public Platform::ExternalTexture {
- void* clientBuffer = nullptr;
- AHardwareBuffer* hardwareBuffer = nullptr;
- };
-
- // must be called on backend thread
- static ExternalTextureManagerAndroid& create() noexcept;
-
- // must be called on backend thread
- static void destroy(ExternalTextureManagerAndroid* pExternalTextureManager) noexcept;
-
- // must be called on backend thread (only because we don't synchronize
- Platform::ExternalTexture* createExternalTexture() noexcept;
-
- // called on app thread
- void reallocate(
- Platform::ExternalTexture* ets, uint32_t w, uint32_t h,
- TextureFormat format, uint64_t usage) noexcept;
-
- // must be called on backend thread
- void destroy(Platform::ExternalTexture* ets) noexcept;
-
-private:
- ExternalTextureManagerAndroid() noexcept;
- ~ExternalTextureManagerAndroid() noexcept;
-
- // called on app thread
- void alloc(Platform::ExternalTexture* ets,
- uint32_t w, uint32_t h, TextureFormat format, uint64_t usage) noexcept;
-
- // called on gl thread
- void destroyStorage(Platform::ExternalTexture* ets) noexcept;
-
- VirtualMachineEnv& mVm;
-
- jclass mGraphicBufferClass = nullptr;
- jmethodID mGraphicBuffer_nCreateGraphicBuffer = nullptr;
- jmethodID mGraphicBuffer_nDestroyGraphicBuffer = nullptr;
-};
-
-} // namespace filament::backend
-
-#endif // TNT_FILAMENT_DRIVER_ANDROID_EXTERNAL_TEXTURE_MANAGER_ANDROID_H
diff --git a/filament/backend/src/metal/MetalDriver.mm b/filament/backend/src/metal/MetalDriver.mm
index 7b800eeea7..302885018d 100644
--- a/filament/backend/src/metal/MetalDriver.mm
+++ b/filament/backend/src/metal/MetalDriver.mm
@@ -359,10 +359,6 @@ void MetalDriver::createSwapChainHeadlessR(Handle sch,
construct_handle(sch, *mContext, width, height, flags);
}
-void MetalDriver::createStreamFromTextureIdR(Handle, intptr_t externalTextureId,
- uint32_t width, uint32_t height) {
-}
-
void MetalDriver::createTimerQueryR(Handle tqh, int) {
// nothing to do, timer query was constructed in createTimerQueryS
}
@@ -431,10 +427,6 @@ Handle MetalDriver::createSwapChainHeadlessS() noexcept {
return alloc_handle();
}
-Handle MetalDriver::createStreamFromTextureIdS() noexcept {
- return {};
-}
-
Handle MetalDriver::createTimerQueryS() noexcept {
// The handle must be constructed here, as a synchronous call to getTimerQueryValue might happen
// before createTimerQueryR is executed.
@@ -1053,11 +1045,6 @@ void MetalDriver::readPixels(Handle src, uint32_t x, uint32_t y,
}];
}
-void MetalDriver::readStreamPixels(Handle sh, uint32_t x, uint32_t y, uint32_t width,
- uint32_t height, PixelBufferDescriptor&& data) {
-
-}
-
void MetalDriver::blit(TargetBufferFlags buffers,
Handle dst, Viewport dstRect,
Handle src, Viewport srcRect,
diff --git a/filament/backend/src/noop/NoopDriver.cpp b/filament/backend/src/noop/NoopDriver.cpp
index 3445937533..b3f95099d9 100644
--- a/filament/backend/src/noop/NoopDriver.cpp
+++ b/filament/backend/src/noop/NoopDriver.cpp
@@ -308,11 +308,6 @@ void NoopDriver::readPixels(Handle src,
scheduleDestroy(std::move(p));
}
-void NoopDriver::readStreamPixels(Handle sh, uint32_t x, uint32_t y, uint32_t width,
- uint32_t height, PixelBufferDescriptor&& p) {
- scheduleDestroy(std::move(p));
-}
-
void NoopDriver::blit(TargetBufferFlags buffers,
Handle dst, Viewport dstRect,
Handle src, Viewport srcRect,
diff --git a/filament/backend/src/opengl/OpenGLBlitter.cpp b/filament/backend/src/opengl/OpenGLBlitter.cpp
deleted file mode 100644
index f40462f4ac..0000000000
--- a/filament/backend/src/opengl/OpenGLBlitter.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "OpenGLBlitter.h"
-
-#include "GLUtils.h"
-#include "OpenGLContext.h"
-
-#include
-#include
-
-#include