blob: f6da67dcaea381821c6cda5ef348f2759433f0bd [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"
9#if defined(SK_BUILD_FOR_WIN32)
10
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
32#endif//defined(SK_BUILD_FOR_WIN32)