OLD | NEW |
---|---|
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 #ifndef SkCodec_DEFINED | 8 #ifndef SkCodec_DEFINED |
9 #define SkCodec_DEFINED | 9 #define SkCodec_DEFINED |
10 | 10 |
11 #include "../private/SkTemplates.h" | 11 #include "../private/SkTemplates.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkEncodedFormat.h" | 13 #include "SkEncodedFormat.h" |
14 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
15 #include "SkSize.h" | 15 #include "SkSize.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 #include "SkTypes.h" | 17 #include "SkTypes.h" |
18 | 18 |
19 class SkData; | 19 class SkData; |
20 class SkPngChunkReader; | 20 class SkPngChunkReader; |
21 class SkSampler; | 21 class SkSampler; |
22 | 22 |
23 /** | 23 /** |
24 * Abstraction layer directly on top of an image codec. | 24 * Abstraction layer directly on top of an image codec. |
25 */ | 25 */ |
26 class SkCodec : SkNoncopyable { | 26 class SkCodec : SkNoncopyable { |
27 public: | 27 public: |
28 /** | 28 /** |
29 * Number of bytes that must be buffered in SkStream input. | |
30 * | |
31 * An SkStream passed to NewFromStream must be able to use this many | |
32 * bytes to determine the image type. Then the same SkStream must be | |
33 * passed to the correct decoder to read from the beginning. | |
34 * | |
35 * This can be accomplished by implementing peek() to support peeking | |
36 * this many bytes, or by implementing rewind() to be able to rewind() | |
37 * after reading this many bytes. | |
38 */ | |
39 static size_t BufferedBytesNeeded(); | |
reed1
2015/12/08 15:04:57
MinBufferedBytesNeeded?
scroggo
2015/12/08 18:35:44
Done.
| |
40 | |
41 /** | |
29 * If this stream represents an encoded image that we know how to decode, | 42 * If this stream represents an encoded image that we know how to decode, |
30 * return an SkCodec that can decode it. Otherwise return NULL. | 43 * return an SkCodec that can decode it. Otherwise return NULL. |
31 * | 44 * |
45 * As stated above, this call must be able to peek or read | |
46 * BufferedBytesNeeded to determine the correct format, and then start | |
47 * reading from the beginning. First it will attempt to peek, and it | |
48 * assumes that if less than BufferedBytesNeeded bytes (but more than | |
49 * zero) are returned, this is because the stream is shorter than this, | |
50 * so falling back to reading would not provide more data. If peek() | |
51 * returns zero bytes, this call will instead attempt to read(). This | |
52 * will require that the stream can be rewind()ed. | |
53 * | |
32 * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if | 54 * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if |
33 * the image is a png. | 55 * the image is a png. |
34 * | 56 * |
35 * If NULL is returned, the stream is deleted immediately. Otherwise, the | 57 * If NULL is returned, the stream is deleted immediately. Otherwise, the |
36 * SkCodec takes ownership of it, and will delete it when done with it. | 58 * SkCodec takes ownership of it, and will delete it when done with it. |
37 */ | 59 */ |
38 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); | 60 static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); |
39 | 61 |
40 /** | 62 /** |
41 * If this data represents an encoded image that we know how to decode, | 63 * If this data represents an encoded image that we know how to decode, |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 * May create a sampler, if one is not currently being used. Otherwise, doe s | 609 * May create a sampler, if one is not currently being used. Otherwise, doe s |
588 * not affect ownership. | 610 * not affect ownership. |
589 * | 611 * |
590 * Only valid during scanline decoding. | 612 * Only valid during scanline decoding. |
591 */ | 613 */ |
592 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } | 614 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } |
593 | 615 |
594 friend class SkSampledCodec; | 616 friend class SkSampledCodec; |
595 }; | 617 }; |
596 #endif // SkCodec_DEFINED | 618 #endif // SkCodec_DEFINED |
OLD | NEW |