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

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

Issue 1018953003: Add SkEncodedFormat, used by SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use a common enum for SkImageEncoder and SkImageDecoder and SkCodec Created 5 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
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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 class SkWEBPImageDecoder: public SkImageDecoder { 93 class SkWEBPImageDecoder: public SkImageDecoder {
94 public: 94 public:
95 SkWEBPImageDecoder() { 95 SkWEBPImageDecoder() {
96 fOrigWidth = 0; 96 fOrigWidth = 0;
97 fOrigHeight = 0; 97 fOrigHeight = 0;
98 fHasAlpha = 0; 98 fHasAlpha = 0;
99 } 99 }
100 100
101 Format getFormat() const SK_OVERRIDE { 101 SkEncodedFormat getFormat() const SK_OVERRIDE {
102 return kWEBP_Format; 102 return kWEBP_SkEncodedFormat;
103 } 103 }
104 104
105 protected: 105 protected:
106 bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) S K_OVERRIDE; 106 bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) S K_OVERRIDE;
107 bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRIDE; 107 bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) SK_OVERRIDE;
108 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; 108 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
109 109
110 private: 110 private:
111 /** 111 /**
112 * Called when determining the output config to request to webp. 112 * Called when determining the output config to request to webp.
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 static SkImageDecoder* sk_libwebp_dfactory(SkStreamRewindable* stream) { 653 static SkImageDecoder* sk_libwebp_dfactory(SkStreamRewindable* stream) {
654 int width, height, hasAlpha; 654 int width, height, hasAlpha;
655 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) { 655 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) {
656 return NULL; 656 return NULL;
657 } 657 }
658 658
659 // Magic matches, call decoder 659 // Magic matches, call decoder
660 return SkNEW(SkWEBPImageDecoder); 660 return SkNEW(SkWEBPImageDecoder);
661 } 661 }
662 662
663 static SkImageDecoder::Format get_format_webp(SkStreamRewindable* stream) { 663 static SkEncodedFormat get_format_webp(SkStreamRewindable* stream) {
664 int width, height, hasAlpha; 664 int width, height, hasAlpha;
665 if (webp_parse_header(stream, &width, &height, &hasAlpha)) { 665 if (webp_parse_header(stream, &width, &height, &hasAlpha)) {
666 return SkImageDecoder::kWEBP_Format; 666 return kWEBP_SkEncodedFormat;
667 } 667 }
668 return SkImageDecoder::kUnknown_Format; 668 return kUnknown_SkEncodedFormat;
669 } 669 }
670 670
671 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 671 static SkImageEncoder* sk_libwebp_efactory(SkEncodedFormat t) {
672 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 672 return (kWEBP_SkEncodedFormat == t) ? SkNEW(SkWEBPImageEncoder) : NULL;
673 } 673 }
674 674
675 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); 675 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
676 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); 676 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
677 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); 677 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698