blob: 4949e6c6ffe1897169c6b6c0fbac49b7b1e6947d [file] [log] [blame]
bungeman@google.com9df621d2011-06-23 21:43:52 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
bungeman@google.com9df621d2011-06-23 21:43:52 +00006 */
7
mtklein1ee76512015-11-02 10:20:27 -08008#include "SkTypes.h"
Mike Klein8f11d4d2018-01-24 12:42:55 -05009#if defined(SK_BUILD_FOR_WIN)
mtklein1ee76512015-11-02 10:20:27 -080010
bungeman@google.com9df621d2011-06-23 21:43:52 +000011#include "SkAutoCoInitialize.h"
12
halcanary4dbbd042016-06-07 17:21:10 -070013#include <objbase.h>
14#include <winerror.h>
15
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000016SkAutoCoInitialize::SkAutoCoInitialize() :
bungeman@google.com9df621d2011-06-23 21:43:52 +000017 fHR(
halcanary96fcdcc2015-08-27 07:41:13 -070018 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
bungeman@google.com9df621d2011-06-23 21:43:52 +000019 )
20{ }
21
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000022SkAutoCoInitialize::~SkAutoCoInitialize() {
bungeman@google.com9df621d2011-06-23 21:43:52 +000023 if (SUCCEEDED(this->fHR)) {
24 CoUninitialize();
25 }
26}
27
bungeman@google.com2e2f3f52011-09-16 15:37:20 +000028bool SkAutoCoInitialize::succeeded() {
29 return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
30}
mtklein1ee76512015-11-02 10:20:27 -080031
Mike Klein8f11d4d2018-01-24 12:42:55 -050032#endif//defined(SK_BUILD_FOR_WIN)