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