aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/win/SkAutoCoInitialize.cpp
blob: 3b7b42b74f2a847ba18ab1eab4baa15d92741b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)


#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>
#include "SkAutoCoInitialize.h"

SkAutoCoInitialize::SkAutoCoInitialize() :
    fHR(
        CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
    )
{ }

SkAutoCoInitialize::~SkAutoCoInitialize() {
    if (SUCCEEDED(this->fHR)) {
        CoUninitialize();
    }
}

bool SkAutoCoInitialize::succeeded() {
    return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
}

#endif//defined(SK_BUILD_FOR_WIN32)