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

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

Issue 23453031: Rewrite SkTRegistry to take any trivially-copyable type. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reed+scroggo Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkImageDecoder_wbmp.cpp » ('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
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 return ok; 576 return ok;
577 } 577 }
578 578
579 579
580 /////////////////////////////////////////////////////////////////////////////// 580 ///////////////////////////////////////////////////////////////////////////////
581 DEFINE_DECODER_CREATOR(WEBPImageDecoder); 581 DEFINE_DECODER_CREATOR(WEBPImageDecoder);
582 DEFINE_ENCODER_CREATOR(WEBPImageEncoder); 582 DEFINE_ENCODER_CREATOR(WEBPImageEncoder);
583 /////////////////////////////////////////////////////////////////////////////// 583 ///////////////////////////////////////////////////////////////////////////////
584 584
585 #include "SkTRegistry.h"
586
587 static SkImageDecoder* sk_libwebp_dfactory(SkStream* stream) { 585 static SkImageDecoder* sk_libwebp_dfactory(SkStream* stream) {
588 int width, height, hasAlpha; 586 int width, height, hasAlpha;
589 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) { 587 if (!webp_parse_header(stream, &width, &height, &hasAlpha)) {
590 return NULL; 588 return NULL;
591 } 589 }
592 590
593 // Magic matches, call decoder 591 // Magic matches, call decoder
594 return SkNEW(SkWEBPImageDecoder); 592 return SkNEW(SkWEBPImageDecoder);
595 } 593 }
596 594
597 static SkImageDecoder::Format get_format_webp(SkStream* stream) { 595 static SkImageDecoder::Format get_format_webp(SkStream* stream) {
598 int width, height, hasAlpha; 596 int width, height, hasAlpha;
599 if (webp_parse_header(stream, &width, &height, &hasAlpha)) { 597 if (webp_parse_header(stream, &width, &height, &hasAlpha)) {
600 return SkImageDecoder::kWEBP_Format; 598 return SkImageDecoder::kWEBP_Format;
601 } 599 }
602 return SkImageDecoder::kUnknown_Format; 600 return SkImageDecoder::kUnknown_Format;
603 } 601 }
604 602
605 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { 603 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) {
606 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L; 604 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL L;
607 } 605 }
608 606
609 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libwebp_dfactory); 607 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory);
610 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_webp ); 608 static SkImageDecoder_FormatReg gFormatReg(get_format_webp);
611 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libwebp_efact ory); 609 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | src/images/SkImageDecoder_wbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698