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

Side by Side Diff: src/images/SkImageDecoder_libwebp.cpp

Issue 670453002: Remove image decoder and encoder autoregistration (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-decoder-01-skpicture
Patch Set: Created 6 years, 1 month 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 | « src/images/SkImageDecoder_libwebp.h ('k') | src/images/SkImageDecoder_pkm.h » ('j') | 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 2010, The Android Open Source Project 2 * Copyright 2010, The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 #include "SkImageDecoder.h" 17 #include "SkImageDecoder_libwebp.h"
18 #include "SkImageEncoder.h"
19 #include "SkColorPriv.h" 18 #include "SkColorPriv.h"
20 #include "SkScaledBitmapSampler.h" 19 #include "SkScaledBitmapSampler.h"
21 #include "SkStream.h" 20 #include "SkStream.h"
22 #include "SkTemplates.h" 21 #include "SkTemplates.h"
23 #include "SkUtils.h" 22 #include "SkUtils.h"
24 23
25 // A WebP decoder only, on top of (subset of) libwebp 24 // A WebP decoder only, on top of (subset of) libwebp
26 // For more information on WebP image format, and libwebp library, see: 25 // For more information on WebP image format, and libwebp library, see:
27 // http://code.google.com/speed/webp/ 26 // http://code.google.com/speed/webp/
28 // http://www.webmproject.org/code/#libwebp_webp_image_decoder_library 27 // http://www.webmproject.org/code/#libwebp_webp_image_decoder_library
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 ok = SkToBool(WebPPictureImportRGBA(&pic, rgb, rgbStride)); 656 ok = SkToBool(WebPPictureImportRGBA(&pic, rgb, rgbStride));
658 } 657 }
659 delete[] rgb; 658 delete[] rgb;
660 659
661 ok = ok && WebPEncode(&webp_config, &pic); 660 ok = ok && WebPEncode(&webp_config, &pic);
662 WebPPictureFree(&pic); 661 WebPPictureFree(&pic);
663 662
664 return ok; 663 return ok;
665 } 664 }
666 665
667 666 SkImageDecoder::Format SkDetectFormatWEBPImageDecoder(SkStreamRewindable* stream ) {
668 ///////////////////////////////////////////////////////////////////////////////
669 DEFINE_DECODER_CREATOR(WEBPImageDecoder);
670 DEFINE_ENCODER_CREATOR(WEBPImageEncoder);
671 ///////////////////////////////////////////////////////////////////////////////
672
673 static SkImageDecoder* sk_libwebp_dfactory(SkStreamRewindable* stream) {
674 int width, height, hasAlpha;
675 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) {
676 return NULL;
677 }
678
679 // Magic matches, call decoder
680 return SkNEW(SkWEBPImageDecoder);
681 }
682
683 static SkImageDecoder::Format get_format_webp(SkStreamRewindable* stream) {
684 int width, height, hasAlpha; 667 int width, height, hasAlpha;
685 if (webp_parse_header(stream, &width, &height, &hasAlpha)) { 668 if (webp_parse_header(stream, &width, &height, &hasAlpha)) {
686 return SkImageDecoder::kWEBP_Format; 669 return SkImageDecoder::kWEBP_Format;
687 } 670 }
688 return SkImageDecoder::kUnknown_Format; 671 return SkImageDecoder::kUnknown_Format;
689 } 672 }
690 673
691 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 674 SkImageDecoder* SkCreateWEBPImageDecoder(SkImageDecoder::Format format) {
692 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 675 SkASSERT(SkImageDecoder::kWEBP_Format == format);
676 return SkNEW(SkWEBPImageDecoder);
693 } 677 }
694 678
695 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 679 SkImageEncoder* SkCreateWEBPImageEncoder(SkImageEncoder::Type t) {
696 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 680 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NULL;
697 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 681 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libwebp.h ('k') | src/images/SkImageDecoder_pkm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698