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

Side by Side Diff: tools/render_pictures_main.cpp

Issue 12433020: Improvements/additions to SkImageCache/SkLazyPixelRef. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Modified a comment. Created 7 years, 9 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
« include/lazy/SkImageCache.h ('K') | « tools/bench_pictures_main.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "CopyTilesRenderer.h" 8 #include "CopyTilesRenderer.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapFactory.h" 10 #include "SkBitmapFactory.h"
(...skipping 26 matching lines...) Expand all
37 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p ixels as " 37 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p ixels as "
38 "the picture rendered in simple mode."); 38 "the picture rendered in simple mode.");
39 39
40 static void make_output_filepath(SkString* path, const SkString& dir, 40 static void make_output_filepath(SkString* path, const SkString& dir,
41 const SkString& name) { 41 const SkString& name) {
42 sk_tools::make_filepath(path, dir, name); 42 sk_tools::make_filepath(path, dir, name);
43 // Remove ".skp" 43 // Remove ".skp"
44 path->remove(path->size() - 4, 4); 44 path->remove(path->size() - 4, 4);
45 } 45 }
46 46
47 #include "SkData.h" 47 // Defined in PictureRenderingFlags.cpp
48 #include "SkLruImageCache.h" 48 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap );
49
50 static SkLruImageCache gLruImageCache(1024*1024);
51
52 #ifdef SK_BUILD_FOR_ANDROID
53 #include "SkAshmemImageCache.h"
54 #include "SkImage.h"
55
56 static SkImageCache* cache_selector(const SkImage::Info& info) {
57 if (info.fWidth * info.fHeight > 32 * 1024) {
58 return SkAshmemImageCache::GetAshmemImageCache();
59 }
60 return &gLruImageCache;
61 }
62
63 #endif
64
65 static bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap ) {
66 void* copiedBuffer = sk_malloc_throw(size);
67 memcpy(copiedBuffer, buffer, size);
68 SkAutoDataUnref data(SkData::NewFromMalloc(copiedBuffer, size));
69 SkBitmapFactory factory(&SkImageDecoder::DecodeMemoryToTarget);
70 #ifdef SK_BUILD_FOR_ANDROID
71 factory.setCacheSelector(&cache_selector);
72 #else
73 factory.setImageCache(&gLruImageCache);
74 #endif
75 return factory.installPixelRef(data, bitmap);
76 }
77 49
78 static bool render_picture(const SkString& inputPath, const SkString* outputDir, 50 static bool render_picture(const SkString& inputPath, const SkString* outputDir,
79 sk_tools::PictureRenderer& renderer, 51 sk_tools::PictureRenderer& renderer,
80 SkBitmap** out) { 52 SkBitmap** out) {
81 SkString inputFilename; 53 SkString inputFilename;
82 sk_tools::get_basename(&inputFilename, inputPath); 54 sk_tools::get_basename(&inputFilename, inputPath);
83 55
84 SkFILEStream inputStream; 56 SkFILEStream inputStream;
85 inputStream.setPath(inputPath.c_str()); 57 inputStream.setPath(inputPath.c_str());
86 if (!inputStream.isValid()) { 58 if (!inputStream.isValid()) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 #endif 295 #endif
324 #endif 296 #endif
325 return 0; 297 return 0;
326 } 298 }
327 299
328 #if !defined SK_BUILD_FOR_IOS 300 #if !defined SK_BUILD_FOR_IOS
329 int main(int argc, char * const argv[]) { 301 int main(int argc, char * const argv[]) {
330 return tool_main(argc, (char**) argv); 302 return tool_main(argc, (char**) argv);
331 } 303 }
332 #endif 304 #endif
OLDNEW
« include/lazy/SkImageCache.h ('K') | « tools/bench_pictures_main.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698