Commit b559e85a authored by Felix Paul Kühne's avatar Felix Paul Kühne

MVK: rebase libvlc

parent 9087b528
From 045f95e1f7f184b3a1128272a4905e4da3f1cf11 Mon Sep 17 00:00:00 2001
From f055c1f8dc684e9c987fddc2c5240b8d8e0c0390 Mon Sep 17 00:00:00 2001
From: David Geldreich <david.geldreich@free.fr>
Date: Fri, 20 Apr 2012 16:41:19 +0200
Subject: [PATCH 01/18] arm_neon: added function macro to handle the underscore
Subject: [PATCH 01/19] arm_neon: added function macro to handle the underscore
prefix for the iOS ARM ABI
---
......
From ddffd018ab92a2472af73c8614a54ee0aea55ab6 Mon Sep 17 00:00:00 2001
From a0b9482684aaa98f169c93189cea903ae0977fc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Fri, 10 Aug 2012 16:02:07 +0200
Subject: [PATCH 02/18] deinterlace/merge: use a macro to fix compilation for
Subject: [PATCH 02/19] deinterlace/merge: use a macro to fix compilation for
iOS
---
......
From 0df1c371030c0d52f0c73728a77f944538f2c007 Mon Sep 17 00:00:00 2001
From db56c4bb86896a1c88e5f34e6223550c0324dbf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Tue, 9 Dec 2014 22:14:55 +0100
Subject: [PATCH 03/18] lib/media player: inherit deinterlace variable to
Subject: [PATCH 03/19] lib/media player: inherit deinterlace variable to
achieve correct value on first use
---
......
From 98e468e52db1a67e51dd0dfa50c52a9f5339ef28 Mon Sep 17 00:00:00 2001
From 10ceb20b36c49c7ebdd6b3a863215c9a85c40e0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Thu, 18 Dec 2014 22:14:55 +0100
Subject: [PATCH 04/18] arm_neon: work-around libtool issue
Subject: [PATCH 04/19] arm_neon: work-around libtool issue
---
modules/arm_neon/Makefile.am | 2 ++
......
From aad02413132c0c0f6fd8a62c6d2de0449510f02f Mon Sep 17 00:00:00 2001
From c7b9d8f602628f7a2aced2b1e1d685678d2e74f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Wed, 10 Dec 2014 22:14:55 +0100
Subject: [PATCH 05/18] arm_neon: fix iOS linking
Subject: [PATCH 05/19] arm_neon: fix iOS linking
---
modules/arm_neon/amplify.S | 7 ++---
......
From 34d77b21a8d145c2d191a88739e3be29d399c999 Mon Sep 17 00:00:00 2001
From d8e53c29b0787a2aa1718fe022c45d3b5d58a5a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Wed, 10 Dec 2014 22:14:55 +0100
Subject: [PATCH 06/18] disable neon volume plugin
Subject: [PATCH 06/19] disable neon volume plugin
---
modules/arm_neon/Makefile.am | 1 -
......
From 96c73dc8a0bb7f78a39f177c024ae9fcb14008a8 Mon Sep 17 00:00:00 2001
From 55c6947c307d503699b8c81132feb959225962a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Thu, 10 Sep 2015 19:58:40 +0200
Subject: [PATCH 07/18] src/misc: fix compilation for OS without fork()
Subject: [PATCH 07/19] src/misc: fix compilation for OS without fork()
---
src/misc/cpu.c | 2 +-
......
From 34c0318ef16a90b9f21b01fb07db8b455eb7256e Mon Sep 17 00:00:00 2001
From 2bd5fd310d804155b71a47263107d15456624627 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Fri, 11 Sep 2015 18:34:26 +0200
Subject: [PATCH 08/18] libvlc: hack to disable daemon mode
Subject: [PATCH 08/19] libvlc: hack to disable daemon mode
---
src/libvlc.c | 4 ++++
......
From ff22f55729255a2e2f91392d0c399c08dbc3602f Mon Sep 17 00:00:00 2001
From f6031c2bdd5aaa2248809be6bef9d55ded65360d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Mon, 23 Nov 2015 16:09:24 +0100
Subject: [PATCH 09/18] libvlc: expose a base set of freetype options to
Subject: [PATCH 09/19] libvlc: expose a base set of freetype options to
overwrite the default font
---
......@@ -14,10 +14,10 @@ Subject: [PATCH 09/18] libvlc: expose a base set of freetype options to
6 files changed, 163 insertions(+), 4 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 2718a33..0e00fa9 100644
index 9153196..b873656 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1487,6 +1487,32 @@ LIBVLC_API float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
@@ -1511,6 +1511,32 @@ LIBVLC_API float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
LIBVLC_API void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
unsigned option, float value );
......
From c576ce81ce688b3791bcb1877a65c2f88e806118 Mon Sep 17 00:00:00 2001
From 6aac2625e742076991348a3a8cc90497d3b65bb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Wed, 4 May 2016 16:00:40 +0200
Subject: [PATCH 10/18] libvlc: create VT-zero-copy variable
Subject: [PATCH 10/19] libvlc: create VT-zero-copy variable
---
lib/media_player.c | 1 +
......
From 51007d631b26f98020ba2b2056b4c5c2a9c3552d Mon Sep 17 00:00:00 2001
From 297f587954d7583082bb625a4ac936a8d306be37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sun, 7 Dec 2014 20:02:18 +0100
Subject: [PATCH 11/18] contrib/gcrypt: work-around a libtool limitation
Subject: [PATCH 11/19] contrib/gcrypt: work-around a libtool limitation
---
contrib/src/gcrypt/rules.mak | 1 +
......
From 060e372ab993b64c20fece40094e698b4290adce Mon Sep 17 00:00:00 2001
From 9c6678ce3b4554b05b5209ac906912cb2817cc62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Sat, 3 Oct 2015 22:45:14 +0200
Subject: [PATCH 12/18] contrib/gcrypt: fix tvOS compilation
Subject: [PATCH 12/19] contrib/gcrypt: fix tvOS compilation
---
contrib/src/gcrypt/fix-sha1-ssse3-for-clang.patch | 16 ++++++++++++++++
......
From fe4b6fefeef168d5c1881379aed9d8ff36be2f08 Mon Sep 17 00:00:00 2001
From 73b3e9b96af1060079928ad86158cd66a4f1df5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Tue, 12 Jul 2016 13:50:54 +0200
Subject: [PATCH 13/18] contrib/avcodec: enforce use of FFmpeg
Subject: [PATCH 13/19] contrib/avcodec: enforce use of FFmpeg
---
contrib/src/ffmpeg/rules.mak | 4 ++--
......
From a5f3ea3be888ae5756f4633dbfc57cfd2a106b0b Mon Sep 17 00:00:00 2001
From 7f9294a28333031d110a12f11e03ebf2a2963247 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Fri, 22 Jul 2016 11:11:44 +0200
Subject: [PATCH 14/18] Enable System DL
Subject: [PATCH 14/19] Enable System DL
---
contrib/src/ffmpeg/patch-as-patch-can.patch | 20 ++++++++++++++++++++
......
From 18c5badc3e4fb4b50b876da57f86b3962b2f516e Mon Sep 17 00:00:00 2001
From 77d9e27e1b168b81aafec847d62b9be94b89a753 Mon Sep 17 00:00:00 2001
From: Aman Gupta <aman@tmm1.net>
Date: Tue, 1 Mar 2016 16:31:13 +0100
Subject: [PATCH 15/18] Add AC-3 pass-through
Subject: [PATCH 15/19] Add AC-3 pass-through
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
......@@ -29,10 +29,10 @@ index 1528861..66077d5 100755
visual
fb
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 0e00fa9..e949e32 100644
index b873656..e5f1b5b 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1822,6 +1822,16 @@ LIBVLC_API int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi );
@@ -1846,6 +1846,16 @@ LIBVLC_API int64_t libvlc_audio_get_delay( libvlc_media_player_t *p_mi );
LIBVLC_API int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay );
/**
......
From 95c7630fbc49729a3a89137198b0ad9f928afa7d Mon Sep 17 00:00:00 2001
From 41c1fd071f18424edc260862f0db01cbe2922914 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Fri, 22 Jul 2016 11:20:24 +0200
Subject: [PATCH 16/18] taglib: DO NOT PUSH: works with networks accesses
Subject: [PATCH 16/19] taglib: DO NOT PUSH: works with networks accesses
---
modules/meta_engine/taglib.cpp | 15 ++++-----------
......
From 17a93e88bcc14eece4a7deb741412d5e30c15efb Mon Sep 17 00:00:00 2001
From c77322f5671e144ff03a54ff7ce5d80ecfb99647 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Mon, 12 Sep 2016 17:03:37 +0200
Subject: [PATCH 17/18] contrib/gcrypt: update patches
Subject: [PATCH 17/19] contrib/gcrypt: update patches
---
contrib/src/gcrypt/fix-sha1-ssse3-for-clang.patch | 308 ++++++++++++++++++++-
......
From 0601de3b49cefb08632e34d0691f1a1ff4e113da Mon Sep 17 00:00:00 2001
From b19b7792926ef1376893545cefadacd965c6224a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Mon, 12 Sep 2016 17:04:05 +0200
Subject: [PATCH 18/18] deinterlace-merge-arm64: fix linking on appleOS
Subject: [PATCH 18/19] deinterlace-merge-arm64: fix linking on appleOS
---
modules/arm_neon/asm64.S | 46 ++++++++++++++++++++++++++
......
From 6c787c63d5cacf5983b7a94e5bddff076a7cb48b Mon Sep 17 00:00:00 2001
From: Adrien Maglo <magsoft@videolan.org>
Date: Fri, 16 Sep 2016 14:00:21 +0200
Subject: [PATCH 19/19] ios2 vout: add subpicture rendering in the zero copy
pipeline
---
modules/video_output/ios2.m | 301 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 291 insertions(+), 10 deletions(-)
diff --git a/modules/video_output/ios2.m b/modules/video_output/ios2.m
index 5e56ca5..75d9f9c 100644
--- a/modules/video_output/ios2.m
+++ b/modules/video_output/ios2.m
@@ -46,6 +46,7 @@
#import <vlc_vout_display.h>
#import <vlc_opengl.h>
#import <vlc_dialog.h>
+#import <vlc_memory.h>
#import "opengl.h"
/**
@@ -110,6 +111,19 @@ static NSString *const fragmentShaderString = @" \
} \
";
+static NSString *const fragmentShaderRGBAString = @" \
+varying highp vec2 texCoordVarying; \
+precision mediump float; \
+\
+uniform sampler2D Texture; \
+\
+void main() \
+{ \
+ gl_FragColor = texture2D(Texture, texCoordVarying); \
+} \
+";
+
+
static NSString *const vertexShaderString = @" \
attribute vec4 position; \
attribute vec2 texCoord; \
@@ -139,7 +153,7 @@ static void OpenglESSwap(vlc_gl_t *);
static picture_pool_t *ZeroCopyPicturePool(vout_display_t *, unsigned);
static void DestroyZeroCopyPoolPicture(picture_t *);
-static void ZeroCopyClean(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
+static void ZeroCopyPrepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture);
static void ZeroCopyDisplay(vout_display_t *, picture_t *, subpicture_t *);
/**
@@ -178,6 +192,7 @@ vlc_module_end ()
@property (readonly) EAGLContext* eaglContext;
@property (readonly) BOOL isAppActive;
@property GLuint shaderProgram;
+@property GLuint shaderProgramSub;
- (id)initWithFrame:(CGRect)frame zeroCopy:(bool)zero_copy voutDisplay:(vout_display_t *)vd;
@@ -191,6 +206,24 @@ vlc_module_end ()
- (void)displayPixelBuffer:(CVPixelBufferRef)pixelBuffer;
@end
+typedef struct {
+ GLuint texture;
+ unsigned format;
+ unsigned type;
+ unsigned width;
+ unsigned height;
+
+ float alpha;
+
+ float top;
+ float left;
+ float bottom;
+ float right;
+
+ float tex_width;
+ float tex_height;
+} gl_region_t;
+
struct vout_display_sys_t
{
VLCOpenGLES2VideoView *glESView;
@@ -205,8 +238,22 @@ struct vout_display_sys_t
bool zero_copy;
vout_display_place_t place;
+
+ // Subpicture
+ int region_count;
+ gl_region_t *region;
+
+ uint8_t *texture_temp_buf;
+ int texture_temp_buf_size;
};
+static inline int GetAlignedSize(unsigned size)
+{
+ /* Return the smallest larger or equal power of 2 */
+ unsigned align = 1 << (8 * sizeof (unsigned) - clz(size));
+ return ((align >> 1) == size) ? size : align;
+}
+
static void *OurGetProcAddress(vlc_gl_t *gl, const char *name)
{
VLC_UNUSED(gl);
@@ -281,7 +328,7 @@ static int Open(vlc_object_t *this)
if (sys->zero_copy) {
vd->pool = ZeroCopyPicturePool;
- vd->prepare = ZeroCopyClean;
+ vd->prepare = ZeroCopyPrepare;
vd->display = ZeroCopyDisplay;
} else {
vd->pool = PicturePool;
@@ -325,6 +372,15 @@ void Close (vlc_object_t *this)
vout_display_sys_t *sys = vd->sys;
@autoreleasepool {
+ glDeleteProgram(sys->glESView.shaderProgram);
+ glDeleteProgram(sys->glESView.shaderProgramSub);
+
+ for (int i = 0; i < sys->region_count; i++) {
+ if (sys->region[i].texture)
+ glDeleteTextures(1, &sys->region[i].texture);
+ }
+ free(sys->region);
+
if (sys->tapRecognizer) {
[sys->tapRecognizer.view removeGestureRecognizer:sys->tapRecognizer];
[sys->tapRecognizer release];
@@ -356,7 +412,8 @@ void Close (vlc_object_t *this)
picture_pool_Release(sys->picturePool);
sys->picturePool = NULL;
}
-
+
+ free(sys->texture_temp_buf);
free(sys);
}
}
@@ -548,11 +605,154 @@ static void DestroyZeroCopyPoolPicture(picture_t *picture)
free(picture);
}
-static void ZeroCopyClean(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
+#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
+static void Upload(vout_display_sys_t *sys,
+ int in_width, int in_height,
+ int in_full_width, int in_full_height,
+ int w_num, int w_den, int h_num, int h_den,
+ int pitch, int pixel_pitch,
+ int full_upload, const uint8_t *pixels,
+ int tex_target, int tex_format, int tex_type)
+{
+ int width = in_width * w_num / w_den;
+ int full_width = in_full_width * w_num / w_den;
+ int height = in_height * h_num / h_den;
+ int full_height = in_full_height * h_num / h_den;
+ // This unpack alignment is the default, but setting it just in case.
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ int dst_width = full_upload ? full_width : width;
+ int dst_pitch = ALIGN(dst_width * pixel_pitch, 4);
+ if ( pitch != dst_pitch )
+ {
+ int buf_size = dst_pitch * full_height * pixel_pitch;
+ const uint8_t *source = pixels;
+ uint8_t *destination;
+ if( !sys->texture_temp_buf || sys->texture_temp_buf_size < buf_size )
+ {
+ free( sys->texture_temp_buf );
+ sys->texture_temp_buf = xmalloc( buf_size );
+ sys->texture_temp_buf_size = buf_size;
+ }
+ destination = sys->texture_temp_buf;
+
+ for( int h = 0; h < height ; h++ )
+ {
+ memcpy( destination, source, width * pixel_pitch );
+ source += pitch;
+ destination += dst_pitch;
+ }
+ if (full_upload)
+ glTexImage2D( tex_target, 0, tex_format,
+ full_width, full_height,
+ 0, tex_format, tex_type, sys->texture_temp_buf );
+ else
+ glTexSubImage2D( tex_target, 0,
+ 0, 0,
+ width, height,
+ tex_format, tex_type, sys->texture_temp_buf );
+ } else {
+ if (full_upload)
+ glTexImage2D(tex_target, 0, tex_format,
+ full_width, full_height,
+ 0, tex_format, tex_type, pixels);
+ else
+ glTexSubImage2D(tex_target, 0,
+ 0, 0,
+ width, height,
+ tex_format, tex_type, pixels);
+ }
+}
+
+static void ZeroCopyPrepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
if (likely([sys->glESView isAppActive]))
[sys->glESView resetBuffers];
+
+ // Subpictures
+ int last_count = sys->region_count;
+ gl_region_t *last = sys->region;
+
+ sys->region_count = 0;
+ sys->region = NULL;
+
+ if (subpicture)
+ {
+ int count = 0;
+ for (subpicture_region_t *r = subpicture->p_region; r; r = r->p_next)
+ count++;
+
+ sys->region_count = count;
+ sys->region = calloc(count, sizeof(*sys->region));
+
+ glActiveTexture(GL_TEXTURE0 + 0);
+
+ int i = 0;
+ for (subpicture_region_t *r = subpicture->p_region; r; r = r->p_next, i++) {
+ gl_region_t *glr = &sys->region[i];
+
+ glr->format = GL_RGBA;
+ glr->type = GL_UNSIGNED_BYTE;
+ glr->width = r->fmt.i_visible_width;
+ glr->height = r->fmt.i_visible_height;
+
+ glr->width = GetAlignedSize(glr->width);
+ //glr->height = GetAlignedSize(glr->height);
+
+ glr->tex_width = (float) r->fmt.i_visible_width / glr->width;
+ glr->tex_height = (float) r->fmt.i_visible_height / glr->height;
+
+ glr->alpha = (float)subpicture->i_alpha * r->i_alpha / 255 / 255;
+ glr->left = 2.0 * (r->i_x ) / subpicture->i_original_picture_width - 1.0;
+ glr->top = -2.0 * (r->i_y ) / subpicture->i_original_picture_height + 1.0;
+ glr->right = 2.0 * (r->i_x + r->fmt.i_visible_width ) / subpicture->i_original_picture_width - 1.0;
+ glr->bottom = -2.0 * (r->i_y + r->fmt.i_visible_height) / subpicture->i_original_picture_height + 1.0;
+
+ glr->texture = 0;
+ /* Try to recycle the textures allocated by the previous
+ call to this function. */
+ for (int j = 0; j < last_count; j++) {
+ if (last[j].texture &&
+ last[j].width == glr->width &&
+ last[j].height == glr->height &&
+ last[j].format == glr->format &&
+ last[j].type == glr->type) {
+ glr->texture = last[j].texture;
+ memset(&last[j], 0, sizeof(last[j]));
+ break;
+ }
+ }
+
+ const int pixels_offset = r->fmt.i_y_offset * r->p_picture->p->i_pitch +
+ r->fmt.i_x_offset * r->p_picture->p->i_pixel_pitch;
+ if (glr->texture) {
+ /* A texture was successfully recycled, reuse it. */
+ glBindTexture(GL_TEXTURE_2D, glr->texture);
+ Upload(sys, r->fmt.i_visible_width, r->fmt.i_visible_height, glr->width, glr->height, 1, 1, 1, 1,
+ r->p_picture->p->i_pitch, r->p_picture->p->i_pixel_pitch, 0,
+ &r->p_picture->p->p_pixels[pixels_offset], GL_TEXTURE_2D, glr->format, glr->type);
+ } else {
+ /* Could not recycle a previous texture, generate a new one. */
+ glGenTextures(1, &glr->texture);
+ glBindTexture(GL_TEXTURE_2D, glr->texture);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ Upload(sys, r->fmt.i_visible_width, r->fmt.i_visible_height, glr->width, glr->height, 1, 1, 1, 1,
+ r->p_picture->p->i_pitch, r->p_picture->p->i_pixel_pitch, 1,
+ &r->p_picture->p->p_pixels[pixels_offset], GL_TEXTURE_2D, glr->format, glr->type);
+ }
+ }
+ }
+
+ for (int i = 0; i < last_count; i++) {
+ if (last[i].texture)
+ glDeleteTextures(1, &last[i].texture);
+ }
+ free(last);
}
static void ZeroCopyDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
@@ -961,6 +1161,8 @@ static void ZeroCopyDisplay(vout_display_t *vd, picture_t *pic, subpicture_t *su
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ [self drawSubpictures];
+
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer);
[_eaglContext presentRenderbuffer:GL_RENDERBUFFER];
@@ -971,6 +1173,54 @@ done:
[EAGLContext setCurrentContext:previousContext];
}
+- (void)drawSubpictures
+{
+ vout_display_sys_t *sys = _voutDisplay->sys;
+
+ /* Draw the subpictures */
+
+ glUseProgram(self.shaderProgramSub);
+
+ GLfloat transformMatrix[16];
+ orientationTransformMatrix(transformMatrix, _voutDisplay->fmt.orientation);
+ glUniformMatrix4fv(glGetUniformLocation(self.shaderProgramSub, "transformMatrix"), 1, GL_FALSE, transformMatrix);
+
+ glUniform1i(glGetUniformLocation(self.shaderProgramSub, "Texture"), 0);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glActiveTexture(GL_TEXTURE0 + 0);
+ for (int i = 0; i < sys->region_count; i++) {
+ gl_region_t *glr = &sys->region[i];
+ const GLfloat vertexCoord[] = {
+ glr->left, glr->top,
+ glr->left, glr->bottom,
+ glr->right, glr->top,
+ glr->right, glr->bottom,
+ };
+ const GLfloat textureCoord[] = {
+ 0.0, 0.0,
+ 0.0, glr->tex_height,
+ glr->tex_width, 0.0,
+ glr->tex_width, glr->tex_height,
+ };
+
+ glBindTexture(GL_TEXTURE_2D, glr->texture);
+ glUniform4f(glGetUniformLocation(self.shaderProgramSub, "FillColor"), 1.0f, 1.0f, 1.0f, glr->alpha);
+
+ glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, vertexCoord);
+ glEnableVertexAttribArray(ATTRIB_VERTEX);
+
+ glVertexAttribPointer(ATTRIB_TEXCOORD, 2, GL_FLOAT, 0, 0, textureCoord);
+ glEnableVertexAttribArray(ATTRIB_TEXCOORD);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ }
+ glDisable(GL_BLEND);
+}
+
+
- (void)setupZeroCopyGL
{
EAGLContext *previousContext = [EAGLContext currentContext];
@@ -1017,11 +1267,11 @@ done:
- (BOOL)loadShaders
{
- GLuint vertShader, fragShader;
- NSURL *vertShaderURL, *fragShaderURL;
+ GLuint vertShader, fragShader, fragShaderSub;
// Create the shader program.
self.shaderProgram = glCreateProgram();
+ self.shaderProgramSub = glCreateProgram();
// Create and compile the vertex shader.
if (![self compileShader:&vertShader type:GL_VERTEX_SHADER sourceString:vertexShaderString]) {
@@ -1037,15 +1287,25 @@ done:
return NO;