Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: tools/lua/lua_pictures.cpp

Issue 19109002: Add the lazy decoder from PictureFlags to SkImageDecoder (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Move LazyDecodeBitmap to its own cpp/h. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 31 // PictureRenderingFlags.cpp
34 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap*); 32 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap*);
scroggo 2013/07/15 18:02:41 No longer needed.
35 33
36 // Example usage for the modulo flag: 34 // 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 35 // 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 " 36 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which "
39 "testIndex %% divisor == remainder."); 37 "testIndex %% divisor == remainder.");
40 DEFINE_string2(skpPath, r, "", "Read this .skp file or .skp files from this dir" ); 38 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"); 39 DEFINE_string2(luaFile, l, "", "File containing lua script to run");
42 DEFINE_string2(headCode, s, "", "Optional lua code to call at beginning"); 40 DEFINE_string2(headCode, s, "", "Optional lua code to call at beginning");
43 DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end"); 41 DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end");
44 42
45 static SkPicture* load_picture(const char path[]) { 43 static SkPicture* load_picture(const char path[]) {
46 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 44 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
47 SkPicture* pic = NULL; 45 SkPicture* pic = NULL;
48 if (stream.get()) { 46 if (stream.get()) {
49 pic = SkPicture::CreateFromStream(stream.get(), &lazy_decode_bitmap); 47 pic = SkPicture::CreateFromStream(stream.get(), &LazyDecodeBitmap);
50 } 48 }
51 return pic; 49 return pic;
52 } 50 }
53 51
54 static SkData* read_into_data(const char file[]) { 52 static SkData* read_into_data(const char file[]) {
55 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(file)); 53 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(file));
56 if (!stream.get()) { 54 if (!stream.get()) {
57 return SkData::NewEmpty(); 55 return SkData::NewEmpty();
58 } 56 }
59 size_t len = stream->getLength(); 57 size_t len = stream->getLength();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 165 }
168 } 166 }
169 return 0; 167 return 0;
170 } 168 }
171 169
172 #if !defined SK_BUILD_FOR_IOS 170 #if !defined SK_BUILD_FOR_IOS
173 int main(int argc, char * const argv[]) { 171 int main(int argc, char * const argv[]) {
174 return tool_main(argc, (char**) argv); 172 return tool_main(argc, (char**) argv);
175 } 173 }
176 #endif 174 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698