Chromium Code Reviews| 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 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Return a size that approximately supports the desired scale factor. | 43 * Return a size that approximately supports the desired scale factor. |
| 44 * The codec may not be able to scale efficiently to the exact scale | 44 * The codec may not be able to scale efficiently to the exact scale |
| 45 * factor requested, so return a size that approximates that scale. | 45 * factor requested, so return a size that approximates that scale. |
| 46 * | 46 * |
| 47 * FIXME: Move to SkImageGenerator? | 47 * FIXME: Move to SkImageGenerator? |
| 48 */ | 48 */ |
| 49 SkISize getScaledDimensions(float desiredScale) const; | 49 SkISize getScaledDimensions(float desiredScale) const; |
| 50 | 50 |
| 51 /** | |
| 52 * Whether or not the memory passed to getPixels is zero initialized. | |
| 53 */ | |
| 54 enum ZeroInitialized { | |
|
scroggo
2015/03/05 16:12:23
I decided to go with ZeroInitialized instead of Sk
| |
| 55 /** | |
| 56 * The memory passed to getPixels is zero initialized. The SkCodec | |
| 57 * may take advantage of this by skipping writing zeroes. | |
| 58 */ | |
| 59 kYes_ZeroInitialized, | |
| 60 /** | |
| 61 * The memory passed to getPixels has not been initialized to zero, | |
| 62 * so the SkCodec must write all zeroes to memory. | |
| 63 * | |
| 64 * This is the default. | |
| 65 */ | |
| 66 kNo_ZeroInitialized, | |
| 67 }; | |
| 68 | |
| 69 /** | |
| 70 * Specify whether this SkCodec should treat the memory passed to | |
| 71 * getPixels as zero initialized. | |
| 72 * | |
| 73 * The default is No. | |
| 74 */ | |
| 75 void setZeroInitialized(ZeroInitialized zero) { fZeroInitialized = zero; } | |
|
scroggo
2015/03/05 16:12:23
It probably makes sense to include this as part of
| |
| 76 | |
| 77 /** | |
| 78 * Return whether this SkCodec considers memory passed to getPixels as | |
| 79 * zero initialized. | |
| 80 */ | |
| 81 ZeroInitialized getZeroInitialized() const { return fZeroInitialized; } | |
| 82 | |
| 51 protected: | 83 protected: |
| 52 SkCodec(const SkImageInfo&, SkStream*); | 84 SkCodec(const SkImageInfo&, SkStream*); |
| 53 | 85 |
| 54 /** | 86 /** |
| 55 * The SkAlphaType is a conservative answer. i.e. it is possible that it | 87 * The SkAlphaType is a conservative answer. i.e. it is possible that it |
| 56 * initially returns a non-opaque answer, but completing the decode | 88 * initially returns a non-opaque answer, but completing the decode |
| 57 * reveals that the image is actually opaque. | 89 * reveals that the image is actually opaque. |
| 58 */ | 90 */ |
| 59 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { | 91 bool onGetInfo(SkImageInfo* info) SK_OVERRIDE { |
| 60 *info = fInfo; | 92 *info = fInfo; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 78 * - if the stream did not need to be rewound. | 110 * - if the stream did not need to be rewound. |
| 79 * false | 111 * false |
| 80 * - if the stream needed to be rewound, and rewind failed. | 112 * - if the stream needed to be rewound, and rewind failed. |
| 81 * Subclasses MUST call this function before reading the stream (e.g. in | 113 * Subclasses MUST call this function before reading the stream (e.g. in |
| 82 * onGetPixels). If it returns false, onGetPixels should return | 114 * onGetPixels). If it returns false, onGetPixels should return |
| 83 * kCouldNotRewind. | 115 * kCouldNotRewind. |
| 84 */ | 116 */ |
| 85 bool SK_WARN_UNUSED_RESULT rewindIfNeeded(); | 117 bool SK_WARN_UNUSED_RESULT rewindIfNeeded(); |
| 86 | 118 |
| 87 private: | 119 private: |
| 88 const SkImageInfo fInfo; | 120 const SkImageInfo fInfo; |
| 89 SkAutoTDelete<SkStream> fStream; | 121 SkAutoTDelete<SkStream> fStream; |
| 90 bool fNeedsRewind; | 122 bool fNeedsRewind; |
| 123 ZeroInitialized fZeroInitialized; | |
| 91 }; | 124 }; |
| 92 #endif // SkCodec_DEFINED | 125 #endif // SkCodec_DEFINED |
| OLD | NEW |