40 | 40 |
|
41 | 41 |
#include "base/logging.h"
|
42 | 42 |
#include "base/system_util.h"
|
43 | |
#include "base/win_util.h"
|
44 | 43 |
#include "protocol/renderer_style.pb.h"
|
45 | 44 |
#include "renderer/renderer_style_handler.h"
|
46 | 45 |
|
|
282 | 281 |
class DirectWriteTextRenderer : public TextRenderer {
|
283 | 282 |
public:
|
284 | 283 |
static DirectWriteTextRenderer *Create() {
|
285 | |
const auto d2d1 = WinUtil::LoadSystemLibrary(L"d2d1.dll");
|
286 | |
const auto d2d1_create_factory =
|
287 | |
reinterpret_cast<D2D1CreateFactoryPtr>(
|
288 | |
::GetProcAddress(d2d1, "D2D1CreateFactory"));
|
289 | |
if (d2d1_create_factory == nullptr) {
|
290 | |
return nullptr;
|
291 | |
}
|
292 | |
|
293 | |
const auto dwrite = WinUtil::LoadSystemLibrary(L"dwrite.dll");
|
294 | |
const auto dwrite_create_factory =
|
295 | |
reinterpret_cast<DWriteCreateFactoryPtr>(
|
296 | |
::GetProcAddress(dwrite, "DWriteCreateFactory"));
|
297 | |
if (dwrite_create_factory == nullptr) {
|
298 | |
return nullptr;
|
299 | |
}
|
300 | |
|
301 | 284 |
HRESULT hr = S_OK;
|
302 | 285 |
CComPtr<ID2D1Factory> d2d_factory;
|
303 | |
hr = d2d1_create_factory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
|
286 |
hr = ::D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
304 | 287 |
__uuidof(ID2D1Factory),
|
305 | 288 |
nullptr,
|
306 | 289 |
reinterpret_cast<void **>(&d2d_factory));
|
|
308 | 291 |
return nullptr;
|
309 | 292 |
}
|
310 | 293 |
CComPtr<IDWriteFactory> dwrite_factory;
|
311 | |
hr = dwrite_create_factory(
|
|
294 |
hr = ::DWriteCreateFactory(
|
312 | 295 |
DWRITE_FACTORY_TYPE_SHARED,
|
313 | 296 |
__uuidof(IDWriteFactory),
|
314 | 297 |
reinterpret_cast<IUnknown **>(&dwrite_factory));
|
|
326 | 309 |
}
|
327 | 310 |
|
328 | 311 |
private:
|
329 | |
typedef HRESULT (WINAPI *D2D1CreateFactoryPtr)(
|
330 | |
D2D1_FACTORY_TYPE factory_type,
|
331 | |
const IID &iid,
|
332 | |
const D2D1_FACTORY_OPTIONS *factory_options,
|
333 | |
void **factory);
|
334 | |
|
335 | |
typedef HRESULT (WINAPI *DWriteCreateFactoryPtr)(
|
336 | |
DWRITE_FACTORY_TYPE factory_type,
|
337 | |
const IID &iid,
|
338 | |
IUnknown **factory);
|
339 | |
|
340 | 312 |
DirectWriteTextRenderer(
|
341 | 313 |
ID2D1Factory *d2d2_factory,
|
342 | 314 |
IDWriteFactory *dwrite_factory,
|