michael@0: michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: michael@0: #include "SkTypes.h" michael@0: michael@0: static const size_t kBufferSize = 2048; michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "ppapi/cpp/instance.h" michael@0: #include "ppapi/cpp/var.h" michael@0: michael@0: extern pp::Instance* gPluginInstance; michael@0: michael@0: namespace { michael@0: static const char* kLogPrefix = "SkDebugf:"; michael@0: } michael@0: michael@0: void SkDebugf(const char format[], ...) { michael@0: if (gPluginInstance) { michael@0: char buffer[kBufferSize + 1]; michael@0: va_list args; michael@0: va_start(args, format); michael@0: sprintf(buffer, kLogPrefix); michael@0: vsnprintf(buffer + strlen(kLogPrefix), kBufferSize, format, args); michael@0: va_end(args); michael@0: pp::Var msg = pp::Var(buffer); michael@0: gPluginInstance->PostMessage(msg); michael@0: } michael@0: }