1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/ports/SkDebug_nacl.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2012 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 + 1.14 +#include "SkTypes.h" 1.15 + 1.16 +static const size_t kBufferSize = 2048; 1.17 + 1.18 +#include <stdarg.h> 1.19 +#include <stdio.h> 1.20 + 1.21 +#include "ppapi/cpp/instance.h" 1.22 +#include "ppapi/cpp/var.h" 1.23 + 1.24 +extern pp::Instance* gPluginInstance; 1.25 + 1.26 +namespace { 1.27 +static const char* kLogPrefix = "SkDebugf:"; 1.28 +} 1.29 + 1.30 +void SkDebugf(const char format[], ...) { 1.31 + if (gPluginInstance) { 1.32 + char buffer[kBufferSize + 1]; 1.33 + va_list args; 1.34 + va_start(args, format); 1.35 + sprintf(buffer, kLogPrefix); 1.36 + vsnprintf(buffer + strlen(kLogPrefix), kBufferSize, format, args); 1.37 + va_end(args); 1.38 + pp::Var msg = pp::Var(buffer); 1.39 + gPluginInstance->PostMessage(msg); 1.40 + } 1.41 +}