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

Side by Side Diff: src/codec/SkCodec.cpp

Issue 1956573002: Compile SkForceLinking on CMake (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Refactoring Created 4 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
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/images/SkForceLinking.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 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkCodec.h" 9 #include "SkCodec.h"
10 #include "SkCodecPriv.h" 10 #include "SkCodecPriv.h"
11 #include "SkColorSpace.h" 11 #include "SkColorSpace.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkGifCodec.h" 13 #include "SkGifCodec.h"
14 #include "SkIcoCodec.h" 14 #include "SkIcoCodec.h"
15 #include "SkJpegCodec.h" 15 #include "SkJpegCodec.h"
16 #ifdef SK_CODEC_DECODES_PNG 16 #ifdef SK_HAS_PNG_LIBRARY
17 #include "SkPngCodec.h" 17 #include "SkPngCodec.h"
18 #endif 18 #endif
19 #include "SkRawCodec.h" 19 #include "SkRawCodec.h"
20 #include "SkStream.h" 20 #include "SkStream.h"
21 #include "SkWbmpCodec.h" 21 #include "SkWbmpCodec.h"
22 #include "SkWebpCodec.h" 22 #include "SkWebpCodec.h"
23 23
24 struct DecoderProc { 24 struct DecoderProc {
25 bool (*IsFormat)(const void*, size_t); 25 bool (*IsFormat)(const void*, size_t);
26 SkCodec* (*NewFromStream)(SkStream*); 26 SkCodec* (*NewFromStream)(SkStream*);
27 }; 27 };
28 28
29 static const DecoderProc gDecoderProcs[] = { 29 static const DecoderProc gDecoderProcs[] = {
30 #ifdef SK_CODEC_DECODES_JPEG 30 #ifdef SK_HAS_JPEG_LIBRARY
31 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream }, 31 { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream },
32 #endif 32 #endif
33 #ifdef SK_CODEC_DECODES_WEBP 33 #ifdef SK_HAS_WEBP_LIBRARY
34 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream }, 34 { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream },
35 #endif 35 #endif
36 #ifdef SK_CODEC_DECODES_GIF 36 #ifdef SK_HAS_GIF_LIBRARY
37 { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, 37 { SkGifCodec::IsGif, SkGifCodec::NewFromStream },
38 #endif 38 #endif
39 #ifdef SK_CODEC_DECODES_PNG 39 #ifdef SK_HAS_PNG_LIBRARY
40 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, 40 { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream },
41 #endif 41 #endif
42 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, 42 { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream },
43 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream } 43 { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream }
44 }; 44 };
45 45
46 size_t SkCodec::MinBufferedBytesNeeded() { 46 size_t SkCodec::MinBufferedBytesNeeded() {
47 return WEBP_VP8_HEADER_SIZE; 47 return WEBP_VP8_HEADER_SIZE;
48 } 48 }
49 49
(...skipping 29 matching lines...) Expand all
79 // Attempt to read() and pass the actual amount read to the decoder. 79 // Attempt to read() and pass the actual amount read to the decoder.
80 bytesRead = stream->read(buffer, bytesToRead); 80 bytesRead = stream->read(buffer, bytesToRead);
81 if (!stream->rewind()) { 81 if (!stream->rewind()) {
82 SkCodecPrintf("Encoded image data could not peek or rewind to determ ine format!\n"); 82 SkCodecPrintf("Encoded image data could not peek or rewind to determ ine format!\n");
83 return nullptr; 83 return nullptr;
84 } 84 }
85 } 85 }
86 86
87 // PNG is special, since we want to be able to supply an SkPngChunkReader. 87 // PNG is special, since we want to be able to supply an SkPngChunkReader.
88 // But this code follows the same pattern as the loop. 88 // But this code follows the same pattern as the loop.
89 #ifdef SK_CODEC_DECODES_PNG 89 #ifdef SK_HAS_PNG_LIBRARY
90 if (SkPngCodec::IsPng(buffer, bytesRead)) { 90 if (SkPngCodec::IsPng(buffer, bytesRead)) {
91 return SkPngCodec::NewFromStream(streamDeleter.release(), chunkReader); 91 return SkPngCodec::NewFromStream(streamDeleter.release(), chunkReader);
92 } else 92 } else
93 #endif 93 #endif
94 { 94 {
95 for (DecoderProc proc : gDecoderProcs) { 95 for (DecoderProc proc : gDecoderProcs) {
96 if (proc.IsFormat(buffer, bytesRead)) { 96 if (proc.IsFormat(buffer, bytesRead)) {
97 return proc.NewFromStream(streamDeleter.release()); 97 return proc.NewFromStream(streamDeleter.release());
98 } 98 }
99 } 99 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested); 382 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq uested);
383 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1); 383 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1);
384 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { 384 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) {
385 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes); 385 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r owBytes);
386 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler); 386 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp ler);
387 } 387 }
388 break; 388 break;
389 } 389 }
390 } 390 }
391 } 391 }
OLDNEW
« no previous file with comments | « src/codec/SkAndroidCodec.cpp ('k') | src/images/SkForceLinking.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698