aboutsummaryrefslogtreecommitdiffstats
path: root/shared/OpenglCodecCommon/auto_goldfish_dma_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/OpenglCodecCommon/auto_goldfish_dma_context.h')
-rw-r--r--shared/OpenglCodecCommon/auto_goldfish_dma_context.h39
1 files changed, 39 insertions, 0 deletions
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