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

Side by Side Diff: third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp

Issue 2392623002: reflow comments in platform/image-encoders (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.h ('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 (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return nullptr; 53 return nullptr;
54 54
55 png_struct* png = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); 55 png_struct* png = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
56 png_info* info = png_create_info_struct(png); 56 png_info* info = png_create_info_struct(png);
57 if (!png || !info || setjmp(png_jmpbuf(png))) { 57 if (!png || !info || setjmp(png_jmpbuf(png))) {
58 png_destroy_write_struct(png ? &png : 0, info ? &info : 0); 58 png_destroy_write_struct(png ? &png : 0, info ? &info : 0);
59 return nullptr; 59 return nullptr;
60 } 60 }
61 61
62 // Optimize compression for speed. 62 // Optimize compression for speed.
63 // The parameters are the same as what libpng uses by default for RGB and RGBA images, except: 63 // The parameters are the same as what libpng uses by default for RGB and RGBA
64 // The zlib compression level is set to 3 instead of 6, to avoid the lazy Ziv- Lempel match searching. 64 // images, except:
65 // The zlib compression level is set to 3 instead of 6, to avoid the lazy
66 // Ziv-Lempel match searching.
65 png_set_compression_level(png, 3); 67 png_set_compression_level(png, 3);
66 68
67 // The zlib memory level is set to 8. This actually matches the default, we a re just future-proofing. 69 // The zlib memory level is set to 8. This actually matches the default, we
70 // are just future-proofing.
68 png_set_compression_mem_level(png, 8); 71 png_set_compression_mem_level(png, 8);
69 72
70 // The zlib strategy is set to Z_FILTERED, which does not match the default. 73 // The zlib strategy is set to Z_FILTERED, which does not match the default.
71 // Avoid the zlib strategies Z_HUFFMAN_ONLY or Z_RLE. 74 // Avoid the zlib strategies Z_HUFFMAN_ONLY or Z_RLE.
72 // Although they are the fastest for poorly-compressible images (e.g. photogra phs), 75 // Although they are the fastest for poorly-compressible images (e.g.
73 // they are very slow for highly-compressible images (e.g. text, drawings or b usiness graphics) 76 // photographs), they are very slow for highly-compressible images (e.g. text,
77 // drawings or business graphics)
74 png_set_compression_strategy(png, Z_FILTERED); 78 png_set_compression_strategy(png, Z_FILTERED);
75 79
76 // The delta filter is PNG_FILTER_SUB instead of PNG_ALL_FILTERS, to reduce th e filter computations. 80 // The delta filter is PNG_FILTER_SUB instead of PNG_ALL_FILTERS, to reduce
81 // the filter computations.
77 png_set_filter(png, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB); 82 png_set_filter(png, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB);
78 83
79 png_set_write_fn(png, output, writeOutput, 0); 84 png_set_write_fn(png, output, writeOutput, 0);
80 png_set_IHDR(png, info, imageSize.width(), imageSize.height(), 8, 85 png_set_IHDR(png, info, imageSize.width(), imageSize.height(), 8,
81 PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0); 86 PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0);
82 png_write_info(png, info); 87 png_write_info(png, info);
83 88
84 return wrapUnique(new PNGImageEncoderState(png, info)); 89 return wrapUnique(new PNGImageEncoderState(png, info));
85 } 90 }
86 91
(...skipping 27 matching lines...) Expand all
114 119
115 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, 120 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData,
116 Vector<unsigned char>* output) { 121 Vector<unsigned char>* output) {
117 if (!imageData.pixels()) 122 if (!imageData.pixels())
118 return false; 123 return false;
119 124
120 return encodePixels(imageData.size(), imageData.pixels(), output); 125 return encodePixels(imageData.size(), imageData.pixels(), output);
121 } 126 }
122 127
123 } // namespace blink 128 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698