blob: 83f23bda0bd00dcff31abfad2d34b512d499c7e3 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
bungeman@google.com9df621d2011-06-23 21:43:52 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
bungeman@google.com9df621d2011-06-23 21:43:52 +00007 */
8
mtklein1ee76512015-11-02 10:20:27 -08009#include "SkTypes.h"
10#if defined(SK_BUILD_FOR_WIN32)
11
epoger@google.comec3ed6a2011-07-28 14:26:00 +000012
bungeman@google.com9df621d2011-06-23 21:43:52 +000013#define WIN32_LEAN_AND_MEAN
bungeman@google.com0d9e3da2013-12-03 15:23:37 +000014#include <windows.h>
bungeman@google.com9df621d2011-06-23 21:43:52 +000015#include <ole2.h>
16#include "SkAutoCoInitialize.h"
17
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000018SkAutoCoInitialize::SkAutoCoInitialize() :
bungeman@google.com9df621d2011-06-23 21:43:52 +000019 fHR(
halcanary96fcdcc2015-08-27 07:41:13 -070020 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
bungeman@google.com9df621d2011-06-23 21:43:52 +000021 )
22{ }
23
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000024SkAutoCoInitialize::~SkAutoCoInitialize() {
bungeman@google.com9df621d2011-06-23 21:43:52 +000025 if (SUCCEEDED(this->fHR)) {
26 CoUninitialize();
27 }
28}
29
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000030bool SkAutoCoInitialize::succeeded() {
31 return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
32}
mtklein1ee76512015-11-02 10:20:27 -080033
34#endif//defined(SK_BUILD_FOR_WIN32)