aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Kiryanov <rkir@google.com>2018-09-27 16:18:58 -0700
committerRoman Kiryanov <rkir@google.com>2018-09-27 16:35:15 -0700
commitb6fce5b01177d690d844b8984c6c8747e77ec9ac (patch)
treecc876b1afc3c9227e9ee7b7990dc974ce4124e7e
parentd0769a591f8dd676866eb7e593fea7bb32ff7128 (diff)
downloaddevice_generic_goldfish-opengl-b6fce5b01177d690d844b8984c6c8747e77ec9ac.tar.gz
device_generic_goldfish-opengl-b6fce5b01177d690d844b8984c6c8747e77ec9ac.tar.bz2
device_generic_goldfish-opengl-b6fce5b01177d690d844b8984c6c8747e77ec9ac.zip
Create the AutoGoldfishDmaContext class
This class is a RAII wrapper over goldfish_dma_context. This class will be used next to FixedBuffer to provide a DMA buffer for OpenGL calls. Bug: 116046430 Test: make -j Change-Id: Ic461b7482490769ee3ca733787fb462e295520ec Signed-off-by: Roman Kiryanov <rkir@google.com>
-rw-r--r--shared/OpenglCodecCommon/Android.mk1
-rwxr-xr-xshared/OpenglCodecCommon/GLSharedGroup.h4
-rw-r--r--shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp51
-rw-r--r--shared/OpenglCodecCommon/auto_goldfish_dma_context.h39
4 files changed, 95 insertions, 0 deletions
diff --git a/shared/OpenglCodecCommon/Android.mk b/shared/OpenglCodecCommon/Android.mk
index 6eddf85b..2a27bbc2 100644
--- a/shared/OpenglCodecCommon/Android.mk
+++ b/shared/OpenglCodecCommon/Android.mk
@@ -12,6 +12,7 @@ commonSources := \
IndexRangeCache.cpp \
SocketStream.cpp \
TcpStream.cpp \
+ auto_goldfish_dma_context.cpp \
ifeq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
diff --git a/shared/OpenglCodecCommon/GLSharedGroup.h b/shared/OpenglCodecCommon/GLSharedGroup.h
index 0bb3bfaa..aabb2ccc 100755
--- a/shared/OpenglCodecCommon/GLSharedGroup.h
+++ b/shared/OpenglCodecCommon/GLSharedGroup.h
@@ -58,6 +58,10 @@ struct BufferData {
// Internal bookkeeping
FixedBuffer m_fixedBuffer; // actual buffer is shadowed here
IndexRangeCache m_indexRangeCache;
+
+ // DMA support
+
+
};
class ProgramData {
diff --git a/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp b/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp
new file mode 100644
index 00000000..7b838925
--- /dev/null
+++ b/shared/OpenglCodecCommon/auto_goldfish_dma_context.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2018 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include "auto_goldfish_dma_context.h"
+
+namespace {
+goldfish_dma_context empty() {
+ goldfish_dma_context ctx = {};
+ return ctx;
+}
+
+void destroy(goldfish_dma_context *ctx) {
+ goldfish_dma_unmap(ctx);
+ goldfish_dma_free(ctx);
+}
+} // namespace
+
+AutoGoldfishDmaContext::AutoGoldfishDmaContext() : m_ctx(empty()) {}
+
+AutoGoldfishDmaContext::AutoGoldfishDmaContext(goldfish_dma_context *ctx)
+ : m_ctx(*ctx) {
+ *ctx = empty();
+}
+
+AutoGoldfishDmaContext::~AutoGoldfishDmaContext() {
+ destroy(&m_ctx);
+}
+
+void AutoGoldfishDmaContext::reset(goldfish_dma_context *ctx) {
+ destroy(&m_ctx);
+ m_ctx = *ctx;
+ *ctx = empty();
+}
+
+goldfish_dma_context AutoGoldfishDmaContext::release() {
+ goldfish_dma_context copy = m_ctx;
+ m_ctx = empty();
+ return copy;
+}
+
diff --git a/shared/OpenglCodecCommon/auto_goldfish_dma_context.h b/shared/OpenglCodecCommon/auto_goldfish_dma_context.h
new file mode 100644
index 00000000..7d97fc28
--- /dev/null
+++ b/shared/OpenglCodecCommon/auto_goldfish_dma_context.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
+#define ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H
+
+#include <inttypes.h>
+#include "goldfish_dma.h"
+
+// A C++ wrapper for goldfish_dma_context that releases resources in dctor.
+class AutoGoldfishDmaContext {
+public:
+ AutoGoldfishDmaContext();
+ explicit AutoGoldfishDmaContext(goldfish_dma_context *ctx);
+ ~AutoGoldfishDmaContext();
+
+ const goldfish_dma_context &get() const { return m_ctx; }
+ void reset(goldfish_dma_context *ctx);
+ goldfish_dma_context release();
+
+private:
+ AutoGoldfishDmaContext(const AutoGoldfishDmaContext &rhs);
+ AutoGoldfishDmaContext& operator=(const AutoGoldfishDmaContext &rhs);
+
+ goldfish_dma_context m_ctx;
+};
+
+#endif // ANDROID_INCLUDE_HARDWARE_AUTO_GOLDFISH_DMA_CONTEXT_H