gfx/skia/trunk/src/utils/win/SkHRESULT.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/utils/win/SkHRESULT.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +/*
     1.5 + * Copyright 2011 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#include "SkTypes.h"
    1.12 +
    1.13 +#include "SkHRESULT.h"
    1.14 +
    1.15 +void SkTraceHR(const char* file, unsigned long line,
    1.16 +               HRESULT hr, const char* msg) {
    1.17 +    SkDEBUGCODE(if (NULL != msg) SkDEBUGF(("%s\n", msg)));
    1.18 +    SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr));
    1.19 +
    1.20 +    LPSTR errorText = NULL;
    1.21 +    FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
    1.22 +                   FORMAT_MESSAGE_FROM_SYSTEM |
    1.23 +                   FORMAT_MESSAGE_IGNORE_INSERTS,
    1.24 +                   NULL,
    1.25 +                   hr,
    1.26 +                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    1.27 +                   (LPSTR) &errorText,
    1.28 +                   0,
    1.29 +                   NULL
    1.30 +    );
    1.31 +
    1.32 +    if (NULL == errorText) {
    1.33 +        SkDEBUGF(("<unknown>\n"));
    1.34 +    } else {
    1.35 +        SkDEBUGF(("%s", errorText));
    1.36 +        LocalFree(errorText);
    1.37 +        errorText = NULL;
    1.38 +    }
    1.39 +}

mercurial