OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/codec/png_codec.h" | 5 #include "ui/gfx/codec/png_codec.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 | 581 |
582 // Make sure to not declare any locals here -- locals in the presence | 582 // Make sure to not declare any locals here -- locals in the presence |
583 // of setjmp() in C++ code makes gcc complain. | 583 // of setjmp() in C++ code makes gcc complain. |
584 | 584 |
585 if (setjmp(png_jmpbuf(png_ptr))) { | 585 if (setjmp(png_jmpbuf(png_ptr))) { |
586 delete[] row_buffer; | 586 delete[] row_buffer; |
587 return false; | 587 return false; |
588 } | 588 } |
589 | 589 |
590 png_set_compression_level(png_ptr, compression_level); | 590 png_set_compression_level(png_ptr, compression_level); |
591 if (compression_level <= Z_BEST_SPEED) | |
dcheng
2016/04/22 01:14:01
Alternatively, I could add another parameter to Do
| |
592 png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS); | |
591 | 593 |
592 // Set our callback for libpng to give us the data. | 594 // Set our callback for libpng to give us the data. |
593 png_set_write_fn(png_ptr, state, EncoderWriteCallback, FakeFlushCallback); | 595 png_set_write_fn(png_ptr, state, EncoderWriteCallback, FakeFlushCallback); |
594 png_set_error_fn(png_ptr, NULL, LogLibPNGEncodeError, LogLibPNGEncodeWarning); | 596 png_set_error_fn(png_ptr, NULL, LogLibPNGEncodeError, LogLibPNGEncodeWarning); |
595 | 597 |
596 png_set_IHDR(png_ptr, info_ptr, width, height, 8, png_output_color_type, | 598 png_set_IHDR(png_ptr, info_ptr, width, height, 8, png_output_color_type, |
597 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, | 599 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, |
598 PNG_FILTER_TYPE_DEFAULT); | 600 PNG_FILTER_TYPE_DEFAULT); |
599 | 601 |
600 #ifdef PNG_TEXT_SUPPORTED | 602 #ifdef PNG_TEXT_SUPPORTED |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
796 // static | 798 // static |
797 bool PNGCodec::FastEncodeBGRASkBitmap(const SkBitmap& input, | 799 bool PNGCodec::FastEncodeBGRASkBitmap(const SkBitmap& input, |
798 bool discard_transparency, | 800 bool discard_transparency, |
799 std::vector<unsigned char>* output) { | 801 std::vector<unsigned char>* output) { |
800 return InternalEncodeSkBitmap(input, | 802 return InternalEncodeSkBitmap(input, |
801 discard_transparency, | 803 discard_transparency, |
802 Z_BEST_SPEED, | 804 Z_BEST_SPEED, |
803 output); | 805 output); |
804 } | 806 } |
805 | 807 |
808 bool PNGCodec::NoCompressEncodeBGRASkBitmap( | |
809 const SkBitmap& input, | |
810 bool discard_transparency, | |
811 std::vector<unsigned char>* output) { | |
812 return InternalEncodeSkBitmap(input, discard_transparency, Z_NO_COMPRESSION, | |
813 output); | |
814 } | |
815 | |
806 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) | 816 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) |
807 : key(k), text(t) { | 817 : key(k), text(t) { |
808 } | 818 } |
809 | 819 |
810 PNGCodec::Comment::~Comment() { | 820 PNGCodec::Comment::~Comment() { |
811 } | 821 } |
812 | 822 |
813 } // namespace gfx | 823 } // namespace gfx |
OLD | NEW |