1/*
2 * 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.
6 */
7
8#include "include/core/SkTypes.h"
9#if defined(SK_BUILD_FOR_WIN)
10
11#include "src/utils/win/SkAutoCoInitialize.h"
12
13#include <objbase.h>
14#include <winerror.h>
15
16SkAutoCoInitialize::SkAutoCoInitialize() :
17 fHR(
18 CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
19 )
20{ }
21
22SkAutoCoInitialize::~SkAutoCoInitialize() {
23 if (SUCCEEDED(this->fHR)) {
24 CoUninitialize();
25 }
26}
27
28bool SkAutoCoInitialize::succeeded() {
29 return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
30}
31
32#endif//defined(SK_BUILD_FOR_WIN)
33