xref: /aosp_15_r20/external/skia/src/ports/SkDebug_win.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2010 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/private/base/SkDebug.h"
9 #include "include/private/base/SkFeatures.h"
10 
11 #if defined(SK_BUILD_FOR_WIN)
12 
13 #include "src/base/SkLeanWindows.h"
14 
15 #include <stdarg.h>
16 #include <stdio.h>
17 
18 static const size_t kBufferSize = 2048;
19 
SkDebugf(const char format[],...)20 void SkDebugf(const char format[], ...) {
21     char    buffer[kBufferSize + 1];
22     va_list args;
23 
24     va_start(args, format);
25     vfprintf(stderr, format, args);
26     va_end(args);
27     fflush(stderr);  // stderr seems to be buffered on Windows.
28 
29     va_start(args, format);
30     vsnprintf(buffer, kBufferSize, format, args);
31     va_end(args);
32 
33     OutputDebugStringA(buffer);
34 }
35 #endif  // defined(SK_BUILD_FOR_WIN)
36