| OLD | NEW |
| 1 #include <cstdio> | 1 |
| 2 #include <string> | 2 /* |
| 3 * Copyright 2013 Google Inc. |
| 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. |
| 7 */ |
| 3 | 8 |
| 4 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
| 5 #include "ppapi/cpp/graphics_2d.h" | 10 #include "ppapi/cpp/graphics_2d.h" |
| 6 #include "ppapi/cpp/image_data.h" | 11 #include "ppapi/cpp/image_data.h" |
| 7 #include "ppapi/cpp/instance.h" | 12 #include "ppapi/cpp/instance.h" |
| 8 #include "ppapi/cpp/module.h" | 13 #include "ppapi/cpp/module.h" |
| 9 #include "ppapi/cpp/var.h" | 14 #include "ppapi/cpp/var.h" |
| 10 | 15 |
| 11 #include "SkCanvas.h" | 16 #include "SkCanvas.h" |
| 12 #include "SkBitmap.h" | 17 #include "SkBitmap.h" |
| 13 #include "SkString.h" | 18 #include "SkString.h" |
| 14 #include "SkThreadUtils.h" | 19 #include "SkThreadUtils.h" |
| 15 | 20 |
| 16 class SkiaInstance; | 21 class SkiaInstance; |
| 17 | 22 |
| 18 // Used by SkDebugf | 23 // Used by SkDebugf |
| 19 SkiaInstance* gPluginInstance; | 24 SkiaInstance* gPluginInstance; |
| 20 | 25 |
| 21 // Main entry point for the app we're linked into | 26 // Main entry point for the app we're linked into |
| 22 extern int tool_main(int, char**); | 27 extern int tool_main(int, char**); |
| 23 | 28 |
| 24 // Tokenize a command line and store it in argc and argv. | 29 // Tokenize a command line and store it in argc and argv. |
| 25 void SkStringToProgramArgs(const SkString commandLine, int* argc, char*** argv)
{ | 30 void SkStringToProgramArgs(const SkString commandLine, int* argc, char*** argv)
{ |
| 26 int numBreaks = 0; | 31 int numBreaks = 0; |
| 27 const char* commandChars = commandLine.c_str(); | 32 const char* commandChars = commandLine.c_str(); |
| 28 for (int i = 0; i < strlen(commandChars); i++) { | 33 for (size_t i = 0; i < strlen(commandChars); i++) { |
| 29 if (isspace(commandChars[i])) { | 34 if (isspace(commandChars[i])) { |
| 30 numBreaks++; | 35 numBreaks++; |
| 31 } | 36 } |
| 32 } | 37 } |
| 33 int numArgs; | 38 int numArgs; |
| 34 if (strlen(commandChars) > 0) { | 39 if (strlen(commandChars) > 0) { |
| 35 numArgs = numBreaks + 1; | 40 numArgs = numBreaks + 1; |
| 36 } else { | 41 } else { |
| 37 numArgs = 0; | 42 numArgs = 0; |
| 38 } | 43 } |
| 39 *argc = numArgs; | 44 *argc = numArgs; |
| 40 *argv = new char*[numArgs + 1]; | 45 *argv = new char*[numArgs + 1]; |
| 41 (*argv)[numArgs] = NULL; | 46 (*argv)[numArgs] = NULL; |
| 42 char* start = (char*) commandChars; | 47 char* start = (char*) commandChars; |
| 43 int length = 0; | 48 int length = 0; |
| 44 int argIndex = 0; | 49 int argIndex = 0; |
| 45 for (int i = 0; i < strlen(commandChars) + 1; i++) { | 50 for (size_t i = 0; i < strlen(commandChars) + 1; i++) { |
| 46 if (isspace(commandChars[i]) || '\0' == commandChars[i]) { | 51 if (isspace(commandChars[i]) || '\0' == commandChars[i]) { |
| 47 if (length > 0) { | 52 if (length > 0) { |
| 48 char* argument = new char[length + 1]; | 53 char* argument = new char[length + 1]; |
| 49 memcpy(argument, start, length); | 54 memcpy(argument, start, length); |
| 50 argument[length] = '\0'; | 55 argument[length] = '\0'; |
| 51 (*argv)[argIndex++] = argument; | 56 (*argv)[argIndex++] = argument; |
| 52 } | 57 } |
| 53 start = (char*) commandChars + i + 1; | 58 start = (char*) commandChars + i + 1; |
| 54 length = 0; | 59 length = 0; |
| 55 } else { | 60 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 virtual pp::Instance* CreateInstance(PP_Instance instance) { | 102 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
| 98 return new SkiaInstance(instance); | 103 return new SkiaInstance(instance); |
| 99 } | 104 } |
| 100 }; | 105 }; |
| 101 | 106 |
| 102 namespace pp { | 107 namespace pp { |
| 103 Module* CreateModule() { | 108 Module* CreateModule() { |
| 104 return new SkiaModule(); | 109 return new SkiaModule(); |
| 105 } | 110 } |
| 106 } // namespace pp | 111 } // namespace pp |
| OLD | NEW |