diff -r 000000000000 -r 6474c204b198 gfx/skia/trunk/src/utils/win/SkHRESULT.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gfx/skia/trunk/src/utils/win/SkHRESULT.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,36 @@ +/* + * 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" + +#include "SkHRESULT.h" + +void SkTraceHR(const char* file, unsigned long line, + HRESULT hr, const char* msg) { + SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg))); + SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr)); + + LPSTR errorText = NULL; + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + hr, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR) &errorText, + 0, + NULL + ); + + if (NULL == errorText) { + SkDEBUGF(("\n")); + } else { + SkDEBUGF(("%s", errorText)); + LocalFree(errorText); + errorText = NULL; + } +}