Skip to content

Commit

Permalink
contrib: ass: Fix Dwrite usage on WinRT/UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
chouquette committed Dec 14, 2016
1 parent 73d3b86 commit eedb57a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
48 changes: 48 additions & 0 deletions contrib/src/ass/dwrite.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--- libass/libass/ass_directwrite.c.orig 2016-12-14 12:09:24.569899227 +0100
+++ libass/libass/ass_directwrite.c 2016-12-14 12:21:28.429203219 +0100
@@ -23,6 +23,7 @@
#include <initguid.h>
#include <ole2.h>
#include <shobjidl.h>
+#include <winapifamily.h>

#include "dwrite_c.h"

@@ -742,8 +743,9 @@
ASS_FontProvider *provider = NULL;
DWriteCreateFactoryFn DWriteCreateFactoryPtr = NULL;
ProviderPrivate *priv = NULL;
-
- HMODULE directwrite_lib = LoadLibraryW(L"Dwrite.dll");
+ HMODULE directwrite_lib = NULL;
+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+ directwrite_lib = LoadLibraryW(L"Dwrite.dll");
if (!directwrite_lib)
goto cleanup;

@@ -751,6 +753,9 @@
"DWriteCreateFactory");
if (!DWriteCreateFactoryPtr)
goto cleanup;
+#else
+ DWriteCreateFactoryPtr = DWriteCreateFactory;
+#endif

hr = DWriteCreateFactoryPtr(DWRITE_FACTORY_TYPE_SHARED,
&IID_IDWriteFactory,
--- libass/libass/dwrite_c.h.orig 2016-12-14 12:36:59.215968100 +0100
+++ libass/libass/dwrite_c.h 2016-12-14 12:38:42.359500667 +0100
@@ -142,6 +142,13 @@
typedef struct DWRITE_TRIMMING DWRITE_TRIMMING;
typedef struct DWRITE_UNDERLINE DWRITE_UNDERLINE;

+DWRITEAPI HRESULT WINAPI DWriteCreateFactory(
+ DWRITE_FACTORY_TYPE factoryType,
+ REFIID iid,
+ IUnknown **factory
+);
+
+
#ifndef __MINGW_DEF_ARG_VAL
#ifdef __cplusplus
#define __MINGW_DEF_ARG_VAL(x) = x
10 changes: 8 additions & 2 deletions contrib/src/ass/rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ else
ifdef HAVE_WINSTORE
WITH_FONTCONFIG = 0
WITH_HARFBUZZ = 1
WITH_DWRITE = 1
else
WITH_FONTCONFIG = 1
WITH_HARFBUZZ = 1
Expand All @@ -43,20 +44,25 @@ libass: libass-$(ASS_VERSION).tar.gz .sum-ass
$(APPLY) $(SRC)/ass/ass-macosx.patch
ifdef HAVE_WIN32
$(APPLY) $(SRC)/ass/use-topendir.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/ass/dwrite.patch
endif
endif
$(UPDATE_AUTOCONFIG)
$(MOVE)

DEPS_ass = freetype2 $(DEPS_freetype2) fribidi

ASS_CONF=--disable-enca

ifneq ($(WITH_FONTCONFIG), 0)
DEPS_ass += fontconfig $(DEPS_fontconfig)
else
ASS_CONF += --disable-fontconfig --disable-require-system-font-provider
endif

ifneq ($(WITH_DWRITE), 0)
ASS_CONF += --enable-directwrite
endif

ifneq ($(WITH_HARFBUZZ), 0)
DEPS_ass += harfbuzz $(DEPS_harfbuzz)
else
Expand Down
3 changes: 3 additions & 0 deletions modules/codec/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ liblibass_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_libass)
liblibass_plugin_la_CFLAGS = $(AM_CFLAGS) $(LIBASS_CFLAGS)
liblibass_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
liblibass_plugin_la_LIBADD = $(LIBASS_LIBS) $(LIBS_libass) $(LIBS_freetype) $(FREETYPE_LIBS)
if HAVE_WINSTORE
liblibass_plugin_la_LIBADD += -ldwrite
endif
EXTRA_LTLIBRARIES += liblibass_plugin.la
codec_LTLIBRARIES += $(LTLIBlibass)

Expand Down

0 comments on commit eedb57a

Please sign in to comment.