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

Side by Side Diff: skia/ports/SkImageDecoder_Factory.cpp

Issue 113827: Remove the remainder of the skia source code from the Chromium repo.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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 | « skia/ports/SkGlobals_global.cpp ('k') | skia/ports/SkImageRef_ashmem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* libs/graphics/ports/SkImageDecoder_Factory.cpp
2 **
3 ** Copyright 2006, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #include "SkImageDecoder.h"
19 #include "SkMovie.h"
20 #include "SkStream.h"
21
22 extern SkImageDecoder* SkImageDecoder_GIF_Factory(SkStream*);
23 extern SkImageDecoder* SkImageDecoder_BMP_Factory(SkStream*);
24 extern SkImageDecoder* SkImageDecoder_ICO_Factory(SkStream*);
25 extern SkImageDecoder* SkImageDecoder_PNG_Factory(SkStream*);
26 extern SkImageDecoder* SkImageDecoder_WBMP_Factory(SkStream*);
27 extern SkImageDecoder* SkImageDecoder_JPEG_Factory(SkStream*);
28
29 typedef SkImageDecoder* (*SkImageDecoderFactoryProc)(SkStream*);
30
31 struct CodecFormat {
32 SkImageDecoderFactoryProc fProc;
33 SkImageDecoder::Format fFormat;
34 };
35
36 #ifdef SK_SUPPORT_IMAGE_DECODE
37 static const CodecFormat gPairs[] = {
38 { SkImageDecoder_GIF_Factory, SkImageDecoder::kGIF_Format },
39 { SkImageDecoder_PNG_Factory, SkImageDecoder::kPNG_Format },
40 { SkImageDecoder_ICO_Factory, SkImageDecoder::kICO_Format },
41 { SkImageDecoder_WBMP_Factory, SkImageDecoder::kWBMP_Format },
42 { SkImageDecoder_BMP_Factory, SkImageDecoder::kBMP_Format },
43 { SkImageDecoder_JPEG_Factory, SkImageDecoder::kJPEG_Format }
44 };
45 #endif
46
47 SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) {
48 #ifdef SK_SUPPORT_IMAGE_DECODE
49 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
50 SkImageDecoder* codec = gPairs[i].fProc(stream);
51 stream->rewind();
52 if (NULL != codec) {
53 return codec;
54 }
55 }
56 #endif
57 return NULL;
58 }
59
60 bool SkImageDecoder::SupportsFormat(Format format) {
61 #ifdef SK_SUPPORT_IMAGE_DECODE
62 for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) {
63 if (gPairs[i].fFormat == format) {
64 return true;
65 }
66 }
67 #endif
68 return false;
69 }
70
71 /////////////////////////////////////////////////////////////////////////
72
73 // the movie may hold onto the stream (by calling ref())
74 typedef SkMovie* (*SkMovieStreamProc)(SkStream*);
75 // the movie may NOT hold onto the pointer
76 typedef SkMovie* (*SkMovieMemoryProc)(const void*, size_t);
77
78 extern SkMovie* SkMovie_GIF_StreamFactory(SkStream*);
79 extern SkMovie* SkMovie_GIF_MemoryFactory(const void*, size_t);
80
81 #ifdef SK_SUPPORT_IMAGE_DECODE
82 static const SkMovieStreamProc gStreamProc[] = {
83 SkMovie_GIF_StreamFactory
84 };
85
86 static const SkMovieMemoryProc gMemoryProc[] = {
87 SkMovie_GIF_MemoryFactory
88 };
89 #endif
90
91 SkMovie* SkMovie::DecodeStream(SkStream* stream) {
92 #ifdef SK_SUPPORT_IMAGE_DECODE
93 for (unsigned i = 0; i < SK_ARRAY_COUNT(gStreamProc); i++) {
94 SkMovie* movie = gStreamProc[i](stream);
95 if (NULL != movie) {
96 return movie;
97 }
98 stream->rewind();
99 }
100 #endif
101 return NULL;
102 }
103
104 SkMovie* SkMovie::DecodeMemory(const void* data, size_t length)
105 {
106 #ifdef SK_SUPPORT_IMAGE_DECODE
107 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMemoryProc); i++) {
108 SkMovie* movie = gMemoryProc[i](data, length);
109 if (NULL != movie) {
110 return movie;
111 }
112 }
113 #endif
114 return NULL;
115 }
116
117 /////////////////////////////////////////////////////////////////////////
118
119 #ifdef SK_SUPPORT_IMAGE_ENCODE
120
121 extern SkImageEncoder* SkImageEncoder_JPEG_Factory();
122 extern SkImageEncoder* SkImageEncoder_PNG_Factory();
123
124 SkImageEncoder* SkImageEncoder::Create(Type t) {
125 switch (t) {
126 case kJPEG_Type:
127 return SkImageEncoder_JPEG_Factory();
128 case kPNG_Type:
129 return SkImageEncoder_PNG_Factory();
130 default:
131 return NULL;
132 }
133 }
134
135 #endif
OLDNEW
« no previous file with comments | « skia/ports/SkGlobals_global.cpp ('k') | skia/ports/SkImageRef_ashmem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698