OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #include "LazyDecodeBitmap.h" |
8 #include "SkLua.h" | 9 #include "SkLua.h" |
9 #include "SkLuaCanvas.h" | 10 #include "SkLuaCanvas.h" |
10 #include "SkPicture.h" | 11 #include "SkPicture.h" |
11 #include "SkCommandLineFlags.h" | 12 #include "SkCommandLineFlags.h" |
12 #include "SkGraphics.h" | 13 #include "SkGraphics.h" |
13 #include "SkStream.h" | 14 #include "SkStream.h" |
14 #include "SkData.h" | 15 #include "SkData.h" |
15 #include "picture_utils.h" | 16 #include "picture_utils.h" |
16 #include "SkOSFile.h" | 17 #include "SkOSFile.h" |
17 #include "SkImageDecoder.h" | 18 #include "SkImageDecoder.h" |
18 #include "SkForceLinking.h" | |
19 | |
20 __SK_FORCE_IMAGE_DECODER_LINKING; | |
21 | 19 |
22 extern "C" { | 20 extern "C" { |
23 #include "lua.h" | 21 #include "lua.h" |
24 #include "lualib.h" | 22 #include "lualib.h" |
25 #include "lauxlib.h" | 23 #include "lauxlib.h" |
26 } | 24 } |
27 | 25 |
28 static const char gStartCanvasFunc[] = "sk_scrape_startcanvas"; | 26 static const char gStartCanvasFunc[] = "sk_scrape_startcanvas"; |
29 static const char gEndCanvasFunc[] = "sk_scrape_endcanvas"; | 27 static const char gEndCanvasFunc[] = "sk_scrape_endcanvas"; |
30 static const char gAccumulateFunc[] = "sk_scrape_accumulate"; | 28 static const char gAccumulateFunc[] = "sk_scrape_accumulate"; |
31 static const char gSummarizeFunc[] = "sk_scrape_summarize"; | 29 static const char gSummarizeFunc[] = "sk_scrape_summarize"; |
32 | 30 |
33 // PictureRenderingFlags.cpp | |
34 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap*); | |
35 | |
36 // Example usage for the modulo flag: | 31 // Example usage for the modulo flag: |
37 // for i in {0..5}; do lua_pictures --skpPath SKP_PATH -l YOUR_SCRIPT --modulo $
i 6 &; done | 32 // for i in {0..5}; do lua_pictures --skpPath SKP_PATH -l YOUR_SCRIPT --modulo $
i 6 &; done |
38 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " | 33 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " |
39 "testIndex %% divisor == remainder."); | 34 "testIndex %% divisor == remainder."); |
40 DEFINE_string2(skpPath, r, "", "Read this .skp file or .skp files from this dir"
); | 35 DEFINE_string2(skpPath, r, "", "Read this .skp file or .skp files from this dir"
); |
41 DEFINE_string2(luaFile, l, "", "File containing lua script to run"); | 36 DEFINE_string2(luaFile, l, "", "File containing lua script to run"); |
42 DEFINE_string2(headCode, s, "", "Optional lua code to call at beginning"); | 37 DEFINE_string2(headCode, s, "", "Optional lua code to call at beginning"); |
43 DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end"); | 38 DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end"); |
44 | 39 |
45 static SkPicture* load_picture(const char path[]) { | 40 static SkPicture* load_picture(const char path[]) { |
46 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | 41 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); |
47 SkPicture* pic = NULL; | 42 SkPicture* pic = NULL; |
48 if (stream.get()) { | 43 if (stream.get()) { |
49 pic = SkPicture::CreateFromStream(stream.get(), &lazy_decode_bitmap); | 44 pic = SkPicture::CreateFromStream(stream.get(), &sk_tools::LazyDecodeBit
map); |
50 } | 45 } |
51 return pic; | 46 return pic; |
52 } | 47 } |
53 | 48 |
54 static SkData* read_into_data(const char file[]) { | 49 static SkData* read_into_data(const char file[]) { |
55 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(file)); | 50 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(file)); |
56 if (!stream.get()) { | 51 if (!stream.get()) { |
57 return SkData::NewEmpty(); | 52 return SkData::NewEmpty(); |
58 } | 53 } |
59 size_t len = stream->getLength(); | 54 size_t len = stream->getLength(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 162 } |
168 } | 163 } |
169 return 0; | 164 return 0; |
170 } | 165 } |
171 | 166 |
172 #if !defined SK_BUILD_FOR_IOS | 167 #if !defined SK_BUILD_FOR_IOS |
173 int main(int argc, char * const argv[]) { | 168 int main(int argc, char * const argv[]) { |
174 return tool_main(argc, (char**) argv); | 169 return tool_main(argc, (char**) argv); |
175 } | 170 } |
176 #endif | 171 #endif |
OLD | NEW |