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 SkJpegCodec_DEFINED | 8 #ifndef SkJpegCodec_DEFINED |
9 #define SkJpegCodec_DEFINED | 9 #define SkJpegCodec_DEFINED |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes
, const Options&, | 52 Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes
, const Options&, |
53 SkPMColor*, int*) override; | 53 SkPMColor*, int*) override; |
54 | 54 |
55 SkEncodedFormat onGetEncodedFormat() const override { | 55 SkEncodedFormat onGetEncodedFormat() const override { |
56 return kJPEG_SkEncodedFormat; | 56 return kJPEG_SkEncodedFormat; |
57 } | 57 } |
58 | 58 |
59 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, const Op
tions& options, | 59 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, const Op
tions& options, |
60 SkPMColor ctable[], int* ctableCount) override; | 60 SkPMColor ctable[], int* ctableCount) override; |
61 | 61 |
| 62 /* |
| 63 * Checks if we can patially natively scale to the desiredScale, and partial
ly natively scales |
| 64 * the dimensions if possible. |
| 65 * Returns the new sampleSize, which is used to finish scaling to the desire
dScale |
| 66 * Ex: desiredScale = 1/6. Natively can scale by 1/2. New sampleSize = 3, as
there is still |
| 67 * 1/3 scaling left to do, which is done by sampling. |
| 68 * Returns -1 if partial native scaling is not supported. |
| 69 */ |
| 70 int onPartiallyNativelyScale(float desiredScale) override; |
| 71 |
62 private: | 72 private: |
| 73 SkAutoTDelete<SkSwizzler> fSwizzler; |
63 | 74 |
64 /* | 75 /* |
65 * Read enough of the stream to initialize the SkJpegCodec. | 76 * Read enough of the stream to initialize the SkJpegCodec. |
66 * Returns a bool representing success or failure. | 77 * Returns a bool representing success or failure. |
67 * | 78 * |
68 * @param codecOut | 79 * @param codecOut |
69 * If this returns true, and codecOut was not NULL, | 80 * If this returns true, and codecOut was not NULL, |
70 * codecOut will be set to a new SkJpegCodec. | 81 * codecOut will be set to a new SkJpegCodec. |
71 * | 82 * |
72 * @param decoderMgrOut | 83 * @param decoderMgrOut |
(...skipping 14 matching lines...) Expand all Loading... |
87 * Creates an instance of the decoder | 98 * Creates an instance of the decoder |
88 * Called only by NewFromStream | 99 * Called only by NewFromStream |
89 * | 100 * |
90 * @param srcInfo contains the source width and height | 101 * @param srcInfo contains the source width and height |
91 * @param stream the encoded image data | 102 * @param stream the encoded image data |
92 * @param decoderMgr holds decompress struct, src manager, and error manager | 103 * @param decoderMgr holds decompress struct, src manager, and error manager |
93 * takes ownership | 104 * takes ownership |
94 */ | 105 */ |
95 SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, JpegDecoderMgr* de
coderMgr); | 106 SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, JpegDecoderMgr* de
coderMgr); |
96 | 107 |
| 108 // Helper to set up swizzler. |
| 109 Result initializeSwizzler(const SkImageInfo& requestedInfo, void* dst, |
| 110 size_t rowBytes, const Options&, SkPMColor*, |
| 111 int* ctableCount, int dstWidth); |
| 112 |
97 /* | 113 /* |
98 * Handles rewinding the input stream if it is necessary | 114 * Handles rewinding the input stream if it is necessary |
99 */ | 115 */ |
100 bool handleRewind(); | 116 bool handleRewind(); |
101 | 117 |
102 /* | 118 /* |
103 * Checks if the conversion between the input image and the requested output | 119 * Checks if the conversion between the input image and the requested output |
104 * image has been implemented | 120 * image has been implemented |
105 * Sets the output color space | 121 * Sets the output color space |
106 */ | 122 */ |
107 bool setOutputColorSpace(const SkImageInfo& dst); | 123 bool setOutputColorSpace(const SkImageInfo& dst); |
108 | 124 |
109 /* | 125 /* |
110 * Checks if we can scale to the requested dimensions and scales the dimensi
ons | 126 * Checks if we can natively scale to the requested dimensions and natively
scales the |
111 * if possible | 127 * dimensions if possible |
112 */ | 128 */ |
113 bool scaleToDimensions(uint32_t width, uint32_t height); | 129 bool nativelyScaleToDimensions(uint32_t width, uint32_t height); |
114 | 130 |
115 /* | 131 /* |
116 * Create the swizzler based on the encoded format | 132 * Create the swizzler based on the encoded format |
117 */ | 133 */ |
118 void initializeSwizzler(const SkImageInfo& dstInfo, void* dst, size_t dstRow
Bytes, | 134 void initializeSwizzler(const SkImageInfo& dstInfo, void* dst, size_t dstRow
Bytes, |
119 const Options& options); | 135 const Options& options); |
120 | 136 |
121 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; | 137 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; |
122 | 138 int fPartialDenom; |
| 139 int fPartialNum; |
123 friend class SkJpegScanlineDecoder; | 140 friend class SkJpegScanlineDecoder; |
124 | 141 |
125 typedef SkCodec INHERITED; | 142 typedef SkCodec INHERITED; |
126 }; | 143 }; |
127 | 144 |
128 #endif | 145 #endif |
OLD | NEW |