Now entering Valhalla.

This commit is contained in:
Pietro Gagliardi 2015-12-22 16:00:51 -05:00
parent a1d2c2b9fd
commit 5267489f0b
5 changed files with 41 additions and 23 deletions

View File

@ -40,6 +40,9 @@ CFILES += \
windows/utilwin.c \
windows/window.c
CXXFILES += \
windows/drawtext.cpp
HFILES += \
windows/area.h \
windows/compilerver.h \

View File

@ -24,21 +24,6 @@ void uninitDraw(void)
ID2D1Factory_Release(d2dfactory);
}
static IDWriteFactory *dwfactory = NULL;
HRESULT initDrawText(void)
{
// TOOD use DWRITE_FACTORY_TYPE_ISOLATED instead?
return DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
&IID_IDWriteFactory,
(IUnknown **) (&dwfactory));
}
void uninitDrawText(void)
{
IDWriteFactory_Release(dwfactory);
}
ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd)
{
D2D1_RENDER_TARGET_PROPERTIES props;

20
windows/drawtext.cpp Normal file
View File

@ -0,0 +1,20 @@
// 22 december 2015
// Before we begin, you may be wondering why this file is C++.
// Simple: <dwrite.h> is C++ only! Thanks Microsoft!
// And unlike UI Automation which accidentally just forgets the 'struct' and 'enum' tags in places, <dwrite.h> is a full C++ header file, with class definitions and the use of __uuidof. Oh well :/
#include "uipriv_windows.h"
static IDWriteFactory *dwfactory = NULL;
HRESULT initDrawText(void)
{
// TOOD use DWRITE_FACTORY_TYPE_ISOLATED instead?
return DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
__uuidof (IDWriteFactory),
(IUnknown **) (&dwfactory));
}
void uninitDrawText(void)
{
dwfactory->Release();
}

View File

@ -6,6 +6,10 @@
#include "resources.h"
#include "compilerver.h"
#ifdef __cplusplus
extern "C" {
#endif
// ui internal window messages
enum {
// redirected WM_COMMAND and WM_NOTIFY
@ -127,8 +131,14 @@ extern int registerAreaFilter(void);
// draw.c
extern HRESULT initDraw(void);
extern void uninitDraw(void);
extern HRESULT initDrawText(void);
extern void uninitDrawText(void);
extern ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd);
extern uiDrawContext *newContext(ID2D1RenderTarget *);
extern void freeContext(uiDrawContext *);
// drawtext.cpp
extern HRESULT initDrawText(void);
extern void uninitDrawText(void);
#ifdef __cplusplus
}
#endif

View File

@ -3,9 +3,12 @@
#define _UNICODE
#define STRICT
#define STRICT_TYPED_ITEMIDS
#ifndef __cplusplus
#define CINTERFACE
#define COBJMACROS
#endif
// see https://github.com/golang/go/issues/9916#issuecomment-74812211
// TODO get rid of this
#define INITGUID
#define _USE_MATH_DEFINES
// for the manifest
@ -16,10 +19,6 @@
#define _WIN32_WINDOWS 0x0600 /* according to Microsoft's pdh.h */
#define _WIN32_IE 0x0700 /* according to Microsoft's sdkddkver.h */
#define NTDDI_VERSION 0x06000000 /* according to Microsoft's sdkddkver.h */
// TODO cl.exe spews garbage warnings for system headers; figure out which flags cause it
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <windows.h>
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
#ifndef RC_INVOKED
@ -38,7 +37,8 @@
#include <math.h>
#include <d2d1.h>
#include <float.h>
// see drawtext.cpp for details
#ifdef __cplusplus
#include <dwrite.h>
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif