OLD | NEW |
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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 static SkImageDecoder* sk_libwebp_dfactory(SkStream* stream) { | 580 static SkImageDecoder* sk_libwebp_dfactory(SkStream* stream) { |
581 int width, height, hasAlpha; | 581 int width, height, hasAlpha; |
582 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) { | 582 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) { |
583 return NULL; | 583 return NULL; |
584 } | 584 } |
585 | 585 |
586 // Magic matches, call decoder | 586 // Magic matches, call decoder |
587 return SkNEW(SkWEBPImageDecoder); | 587 return SkNEW(SkWEBPImageDecoder); |
588 } | 588 } |
589 | 589 |
| 590 static SkImageDecoder::Format get_format_webp(SkStream* stream) { |
| 591 int width, height, hasAlpha; |
| 592 if (webp_parse_header(stream, &width, &height, &hasAlpha)) { |
| 593 return SkImageDecoder::kWEBP_Format; |
| 594 } |
| 595 return SkImageDecoder::kUnknown_Format; |
| 596 } |
| 597 |
590 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 598 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
591 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; | 599 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; |
592 } | 600 } |
593 | 601 |
594 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory); | 602 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory); |
| 603 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp
); |
595 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact
ory); | 604 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact
ory); |
OLD | NEW |