RESOLVED FIXED Bug 37117
Add platform-independent JPEG/PNG image encoders
https://bugs.webkit.org/show_bug.cgi?id=37117
Summary Add platform-independent JPEG/PNG image encoders
Yong Li
Reported 2010-04-05 15:29:41 PDT
1. Add platform-independent JPEG/PNG image encoders 2. Implement toDataURL for ImageBufferOpenVG with platform-independent code
Attachments
the patch (13.58 KB, patch)
2010-04-06 08:34 PDT, Yong Li
no flags
fix style errors (13.68 KB, patch)
2010-04-06 09:34 PDT, Yong Li
abarth: review-
Updated again (13.58 KB, patch)
2010-06-23 13:24 PDT, Yong Li
no flags
Yong Li
Comment 1 2010-04-06 08:34:13 PDT
Created attachment 52642 [details] the patch
WebKit Review Bot
Comment 2 2010-04-06 08:38:45 PDT
Attachment 52642 [details] did not pass style-queue: Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1 WebCore/platform/image-encoders/PNGImageEncoder.h:21: #ifndef header guard has wrong style, please use: PNGImageEncoder_h [build/header_guard] [5] WebCore/platform/image-encoders/PNGImageEncoder.h:27: Code inside a namespace should not be indented. [whitespace/indent] [4] WebCore/platform/image-encoders/PNGImageEncoder.cpp:50: This { should be at the end of the previous line [whitespace/braces] [4] WebCore/platform/image-encoders/PNGImageEncoder.cpp:129: One space before end of line comments [whitespace/comments] [5] WebCore/platform/image-encoders/JPEGImageEncoder.h:22: #ifndef header guard has wrong style, please use: JPEGImageEncoder_h [build/header_guard] [5] WebCore/platform/image-encoders/JPEGImageEncoder.h:28: Code inside a namespace should not be indented. [whitespace/indent] [4] WebCore/platform/image-encoders/JPEGImageEncoder.cpp:28: Alphabetical sorting problem. [build/include_order] [4] WebCore/platform/image-encoders/JPEGImageEncoder.cpp:34: This { should be at the end of the previous line [whitespace/braces] [4] WebCore/platform/image-encoders/JPEGImageEncoder.cpp:47: This { should be at the end of the previous line [whitespace/braces] [4] WebCore/platform/image-encoders/JPEGImageEncoder.cpp:83: Declaration has space between type name and * in JPEGCompressErrorMgr *err [whitespace/declaration] [3] Total errors found: 10 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yong Li
Comment 3 2010-04-06 09:34:02 PDT
Created attachment 52646 [details] fix style errors
WebKit Review Bot
Comment 4 2010-04-06 09:39:18 PDT
Attachment 52646 [details] did not pass style-queue: Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1 WebCore/platform/image-encoders/JPEGImageEncoder.cpp:28: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yong Li
Comment 5 2010-04-06 09:57:27 PDT
(In reply to comment #4) > Attachment 52646 [details] did not pass style-queue: > > Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1 > WebCore/platform/image-encoders/JPEGImageEncoder.cpp:28: Alphabetical sorting > problem. [build/include_order] [4] > Total errors found: 1 in 5 files > > > If any of these errors are false positives, please file a bug against > check-webkit-style. this style error is a must. we cannot avoid this
Adam Barth
Comment 6 2010-06-20 10:15:58 PDT
Comment on attachment 52646 [details] fix style errors This code is nutty, but I think the image decoder libraries force you into some of this nuttiness. Some nits below. Please get pkasting to give your revised patch an informal review. WebCore/platform/image-encoders/JPEGImageEncoder.cpp:39 + jpeg_destination_mgr* base = this; Woah, crazy. Is this what we're supposed to do here? WebCore/platform/image-encoders/JPEGImageEncoder.cpp:50 + // Zero memory I like the static cast trick you did above. Can we do that here? In principle, we can get in trouble with this code if we add virtual functions to this class. WebCore/platform/image-encoders/JPEGImageEncoder.cpp:61 + dest->next_output_byte = reinterpret_cast<JOCTET*>(dest->m_buffer.data()); We don't usually align the = sign. We just have once space. WebCore/platform/image-encoders/JPEGImageEncoder.cpp:59 + JPEGDestinationManager* dest = (JPEGDestinationManager*)compressData->dest; Please use a C++ style cast like you do below. WebCore/platform/image-encoders/JPEGImageEncoder.cpp:83 + longjmp(err->m_setjmpBuffer, -1); Crazy! WebCore/platform/image-encoders/JPEGImageEncoder.cpp:88 + struct jpeg_compress_struct compressData= { 0 }; Missing space before = WebCore/platform/image-encoders/JPEGImageEncoder.cpp:109 + Vector<JSAMPLE, 600 * 3> rowBuffer; No space around * WebCore/platform/image-encoders/JPEGImageEncoder.cpp:108 + // rowBuffer must be defined here so that its destructor is always called even when "setjmp" catches an error. setjmp/longjmp are insane, especially when mixed with C++ constructs. WebCore/platform/image-encoders/JPEGImageEncoder.h:21 + Extra blank line here. WebCore/platform/image-encoders/PNGImageEncoder.cpp:51 + Vector<char>* m_out; Why is this called m_out but the corresponding variable for JPEG is called m_dump? WebCore/platform/image-encoders/PNGImageEncoder.cpp:62 + memcpy(&(*state->m_out)[oldSize], data, size); &(*state->m_out)[oldSize] is too hard to understand. Please use temporary variables to explain what this insanity does. WebCore/platform/image-encoders/PNGImageEncoder.cpp:87 + png_struct* pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, We usually put these sorts of things on one line.
Yong Li
Comment 7 2010-06-23 13:23:59 PDT
(In reply to comment #6) > (From update of attachment 52646 [details]) > This code is nutty, but I think the image decoder libraries force you into some of this nuttiness. Some nits below. Please get pkasting to give your revised patch an informal review. > > WebCore/platform/image-encoders/JPEGImageEncoder.cpp:39 > + jpeg_destination_mgr* base = this; > Woah, crazy. Is this what we're supposed to do here? > > WebCore/platform/image-encoders/JPEGImageEncoder.cpp:50 > + // Zero memory > I like the static cast trick you did above. Can we do that here? In principle, we can get in trouble with this code if we add virtual functions to this class. This doesn't need a static cast because it casts from child class to the parent class. Implicit cast is safer than static cast in most cases. No matter we add virtual functions to the class or add another parent class, "base" is always pointing to a good jpeg_destination_mgr object. > WebCore/platform/image-encoders/JPEGImageEncoder.cpp:83 > + longjmp(err->m_setjmpBuffer, -1); > Crazy! :) Yes it is. I don't like it either. But it's the way to handle libjpeg error. JPEG decoder also uses this. > WebCore/platform/image-encoders/JPEGImageEncoder.cpp:109 > + Vector<JSAMPLE, 600 * 3> rowBuffer; > No space around * Are you sure? I don't think check-webkit-style will accept 600*3 with no spaces. Thanks a lot for reviewing! I'll update the patch according to your suggestions.
Yong Li
Comment 8 2010-06-23 13:24:29 PDT
Created attachment 59557 [details] Updated again
WebKit Review Bot
Comment 9 2010-06-23 13:29:12 PDT
Attachment 59557 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1 WebCore/platform/image-encoders/JPEGImageEncoder.cpp:28: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yong Li
Comment 10 2010-06-24 13:09:14 PDT
(In reply to comment #9) > Attachment 59557 [details] did not pass style-queue: > Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1 > WebCore/platform/image-encoders/JPEGImageEncoder.cpp:28: Alphabetical sorting problem. [build/include_order] [4] > Total errors found: 1 in 5 files > If any of these errors are false positives, please file a bug against check-webkit-style. we cannot avoid this
George Staikos
Comment 11 2010-09-15 11:54:20 PDT
Comment on attachment 59557 [details] Updated again Will need a retest since it's so old.
WebKit Commit Bot
Comment 12 2010-09-16 04:48:03 PDT
Comment on attachment 59557 [details] Updated again Clearing flags on attachment: 59557 Committed r67606: <http://trac.webkit.org/changeset/67606>
WebKit Commit Bot
Comment 13 2010-09-16 04:48:09 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.