Codebase list mozc / 9d6223e
Directly call DirectDwrite/Direct2D APIs Since we no longer support Windows Vista, DirectDwrite/Direct2D APIs are guaranteed to be available on all the platforms that we take care of. BUG=#372 TEST= REF_BUG=23803925,27053168 REF_CL=114071758,114073282 REF_TIME=2016-02-07T17:26:30-08:00 REF_TIME_RAW=1454894790 -0800 Yohei Yukawa 8 years ago
3 changed file(s) with 13 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
00 MAJOR=2
11 MINOR=17
2 BUILD=2455
2 BUILD=2456
33 REVISION=102
44 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
55 # downloaded by NaCl Mozc.
360360 '../protocol/protocol.gyp:renderer_proto',
361361 'renderer_style_handler',
362362 ],
363 'link_settings': {
364 'msvs_settings': {
365 'VCLinkerTool': {
366 'AdditionalDependencies': [
367 'd2d1.lib',
368 'dwrite.lib',
369 ],
370 },
371 },
372 },
363373 },
364374 {
365375 'target_name': 'gen_pbgra32_bitmap',
4040
4141 #include "base/logging.h"
4242 #include "base/system_util.h"
43 #include "base/win_util.h"
4443 #include "protocol/renderer_style.pb.h"
4544 #include "renderer/renderer_style_handler.h"
4645
282281 class DirectWriteTextRenderer : public TextRenderer {
283282 public:
284283 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
301284 HRESULT hr = S_OK;
302285 CComPtr<ID2D1Factory> d2d_factory;
303 hr = d2d1_create_factory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
286 hr = ::D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
304287 __uuidof(ID2D1Factory),
305288 nullptr,
306289 reinterpret_cast<void **>(&d2d_factory));
308291 return nullptr;
309292 }
310293 CComPtr<IDWriteFactory> dwrite_factory;
311 hr = dwrite_create_factory(
294 hr = ::DWriteCreateFactory(
312295 DWRITE_FACTORY_TYPE_SHARED,
313296 __uuidof(IDWriteFactory),
314297 reinterpret_cast<IUnknown **>(&dwrite_factory));
326309 }
327310
328311 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
340312 DirectWriteTextRenderer(
341313 ID2D1Factory *d2d2_factory,
342314 IDWriteFactory *dwrite_factory,