Skip to content

Commit 030395d

Browse files
committed
vulkan watermark
1 parent 2323b5c commit 030395d

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

PluginSource/RenderAPI_OpenGLWatermark.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
#ifndef RENDERAPI_OPENGLWATERMARK_H
2+
#define RENDERAPI_OPENGLWATERMARK_H
23

34
#if defined(UNITY_IPHONE)
45
#include <OpenGLES/ES2/gl.h>
@@ -22,18 +23,20 @@ class OpenGLWatermark
2223
void cleanup();
2324

2425
void draw(GLuint framebuffer, unsigned width, unsigned height);
25-
26+
2627
void randomizePosition();
2728

2829
private:
2930
void updateVertexBuffer();
30-
31+
3132
GLuint program = 0;
3233
GLuint vbo = 0;
3334
GLuint tex = 0;
3435
GLuint posAttrib = 0;
3536
GLuint uvAttrib = 0;
36-
37+
3738
float xOffset = -1.f;
3839
float yOffset = 1.f;
3940
};
41+
42+
#endif /* RENDERAPI_OPENGLWATERMARK_H */

PluginSource/RenderAPI_Vulkan.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,32 @@ bool RenderAPI_Vulkan::setup(void **opaque, const libvlc_video_setup_device_cfg_
215215
auto *that = static_cast<RenderAPI_Vulkan*>(*opaque);
216216
that->width = 0;
217217
that->height = 0;
218-
return true;
218+
219+
bool ret = true;
220+
221+
#if defined(SHOW_WATERMARK)
222+
that->makeCurrent(true);
223+
224+
ret &= that->watermark.setup();
225+
226+
that->makeCurrent(false);
227+
#endif
228+
229+
return ret;
219230
}
220231

221232
void RenderAPI_Vulkan::cleanup(void* opaque)
222233
{
223234
DEBUG("[Vulkan] output callback cleanup");
224235
auto *that = static_cast<RenderAPI_Vulkan*>(opaque);
236+
237+
that->ensureCurrentContext();
225238
that->releaseHardwareBufferResources();
239+
240+
#if defined(SHOW_WATERMARK)
241+
that->watermark.cleanup();
242+
#endif
243+
that->makeCurrent(false);
226244
}
227245

228246
bool RenderAPI_Vulkan::resize(void* opaque, const libvlc_video_render_cfg_t *cfg,
@@ -271,9 +289,14 @@ void RenderAPI_Vulkan::swap(void* opaque)
271289
{
272290
DEBUG_VERBOSE("[Vulkan] swap callback");
273291
RenderAPI_Vulkan* that = reinterpret_cast<RenderAPI_Vulkan*>(opaque);
274-
glFlush();
275292
std::lock_guard<std::mutex> lock(that->text_lock);
276293
that->updated = true;
294+
295+
#if defined(SHOW_WATERMARK)
296+
that->watermark.draw(that->buffers[that->idx_render].fbo, that->width, that->height);
297+
#endif
298+
299+
glFlush();
277300
std::swap(that->idx_swap, that->idx_render);
278301
glBindFramebuffer(GL_FRAMEBUFFER, that->buffers[that->idx_render].fbo);
279302
DEBUG_VERBOSE("[Vulkan] swap callback complete");

PluginSource/RenderAPI_Vulkan.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include "RenderAPI_OpenGLEGL.h"
66
#include "PlatformBase.h"
77

8+
#if defined(SHOW_WATERMARK)
9+
# include "RenderAPI_OpenGLWatermark.h"
10+
#endif
11+
812
#if defined(UNITY_ANDROID)
913
#include <android/hardware_buffer.h>
1014
#include <android/native_window_jni.h>
@@ -144,6 +148,10 @@ class RenderAPI_Vulkan : public RenderAPI_OpenEGL
144148
static PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
145149
static PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
146150
#endif
151+
152+
#if defined(SHOW_WATERMARK)
153+
OpenGLWatermark watermark;
154+
#endif
147155
};
148156

149157
#endif // UNITY_ANDROID

0 commit comments

Comments
 (0)