summaryrefslogtreecommitdiff
path: root/libs/renderengine/ExternalTexture.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2021-04-16 16:36:21 +0000
committer Alec Mouri <alecmouri@google.com> 2021-04-16 12:02:14 -0700
commita90a570e5b35c72bc90bf20572dd989084c4db39 (patch)
treef50363c7d61cfe9a5e76f376b424cf100d311690 /libs/renderengine/ExternalTexture.cpp
parent7f0c9b1f96216f42425415afba5f5daffaafddef (diff)
Revert "Revert "Add ExternalTexture class into RenderEngine inte..."
Revert submission 14199598-revert-14086921-renderengine-external-tex-QJNBWQMQEU Reason for revert: Prepare for relanding Reverted Changes: I01e65a7f4:Revert "Update WaylandRenderSurface to accomodate ... I7d58118c1:Revert "Update Readback VTS to align with RenderEn... I1501890f4:Revert "Add ExternalTexture class into RenderEngin... Added the following fixes: 1. CachedSet renders to intermediate texture variable rather than mTexture directly, since mTexture is not guaranteed to be nonnull. 2. Add null check when setting new buffer in BLAST. Bug: 185524947 Bug: 180767535 Test: builds, boots Test: librenderengine_test Change-Id: I52ea82e24336b496d996bbe3e445db0affe1abb8
Diffstat (limited to 'libs/renderengine/ExternalTexture.cpp')
-rw-r--r--libs/renderengine/ExternalTexture.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/libs/renderengine/ExternalTexture.cpp b/libs/renderengine/ExternalTexture.cpp
new file mode 100644
index 0000000000..eabff58eba
--- /dev/null
+++ b/libs/renderengine/ExternalTexture.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2021 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 <renderengine/ExternalTexture.h>
+#include <renderengine/RenderEngine.h>
+#include <ui/GraphicBuffer.h>
+
+#include "log/log_main.h"
+
+namespace android::renderengine {
+
+ExternalTexture::ExternalTexture(const sp<GraphicBuffer>& buffer, RenderEngine& renderEngine,
+ uint32_t usage)
+ : mBuffer(buffer), mRenderEngine(renderEngine) {
+ LOG_ALWAYS_FATAL_IF(buffer == nullptr,
+ "Attempted to bind a null buffer to an external texture!");
+ // GLESRenderEngine has a separate texture cache for output buffers,
+ if (usage == Usage::WRITEABLE &&
+ (mRenderEngine.getRenderEngineType() == RenderEngine::RenderEngineType::GLES ||
+ mRenderEngine.getRenderEngineType() == RenderEngine::RenderEngineType::THREADED)) {
+ return;
+ }
+ mRenderEngine.mapExternalTextureBuffer(mBuffer, usage & Usage::WRITEABLE);
+}
+
+ExternalTexture::~ExternalTexture() {
+ mRenderEngine.unmapExternalTextureBuffer(mBuffer);
+}
+
+} // namespace android::renderengine