| 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 #ifndef SkBmpCodec_DEFINED | 7 #ifndef SkBmpCodec_DEFINED |
| 8 #define SkBmpCodec_DEFINED | 8 #define SkBmpCodec_DEFINED |
| 9 | 9 |
| 10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 /* | 83 /* |
| 84 * Compute the number of colors in the color table | 84 * Compute the number of colors in the color table |
| 85 */ | 85 */ |
| 86 uint32_t computeNumColors(uint32_t numColors); | 86 uint32_t computeNumColors(uint32_t numColors); |
| 87 | 87 |
| 88 /* | 88 /* |
| 89 * Accessors used by subclasses | 89 * Accessors used by subclasses |
| 90 */ | 90 */ |
| 91 uint16_t bitsPerPixel() const { return fBitsPerPixel; } | 91 uint16_t bitsPerPixel() const { return fBitsPerPixel; } |
| 92 |
| 93 int subsetLeft() const { return fSubsetLeft; } |
| 94 int subsetWidth() const {return fSubsetWidth; } |
| 95 |
| 96 private: |
| 97 |
| 92 SkScanlineOrder onGetScanlineOrder() const override { return fRowOrder; } | 98 SkScanlineOrder onGetScanlineOrder() const override { return fRowOrder; } |
| 93 | 99 |
| 94 /* | 100 /* |
| 95 * To be overriden by bmp subclasses, which provide unique implementations. | 101 * To be overriden by bmp subclasses, which provide unique implementations. |
| 96 * Performs subclass specific setup. | 102 * Performs subclass specific setup. |
| 97 * | 103 * |
| 98 * @param dstInfo Contains output information. Height specifies | 104 * @param dstInfo Contains output information. Height specifies |
| 99 * the total number of rows that will be decoded. | 105 * the total number of rows that will be decoded. |
| 100 * @param options Additonal options to pass to the decoder. | 106 * @param options Additonal options to pass to the decoder. |
| 101 * @param inputColorPtr Client-provided memory for a color table. Must | 107 * @param inputColorPtr Client-provided memory for a color table. Must |
| 102 * be enough for 256 colors. This will be | 108 * be enough for 256 colors. This will be |
| 103 * populated with colors if the encoded image uses | 109 * populated with colors if the encoded image uses |
| 104 * a color table. | 110 * a color table. |
| 105 * @param inputColorCount If the encoded image uses a color table, this | 111 * @param inputColorCount If the encoded image uses a color table, this |
| 106 * will be set to the number of colors in the | 112 * will be set to the number of colors in the |
| 107 * color table. | 113 * color table. |
| 108 */ | 114 */ |
| 109 virtual SkCodec::Result prepareToDecode(const SkImageInfo& dstInfo, | 115 virtual SkCodec::Result prepareToDecode(const SkImageInfo& dstInfo, |
| 110 const SkCodec::Options& options, SkPMColor inputColorPtr[], | 116 const SkCodec::Options& options, SkPMColor inputColorPtr[], |
| 111 int* inputColorCount) = 0; | 117 int* inputColorCount) = 0; |
| 112 | 118 |
| 113 private: | |
| 114 | |
| 115 /* | 119 /* |
| 116 * Creates a bmp decoder | 120 * Creates a bmp decoder |
| 117 * Reads enough of the stream to determine the image format | 121 * Reads enough of the stream to determine the image format |
| 118 */ | 122 */ |
| 119 static SkCodec* NewFromStream(SkStream*, bool inIco); | 123 static SkCodec* NewFromStream(SkStream*, bool inIco); |
| 120 | 124 |
| 121 /* | 125 /* |
| 122 * Decodes the next dstInfo.height() lines. | 126 * Decodes the next dstInfo.height() lines. |
| 123 * | 127 * |
| 124 * onGetPixels() uses this for full image decodes. | 128 * onGetPixels() uses this for full image decodes. |
| 125 * SkScaledCodec::onGetPixels() uses the scanline decoder to call this with | 129 * SkScaledCodec::onGetPixels() uses the scanline decoder to call this with |
| 126 * dstInfo.height() = 1, in order to implement sampling. | 130 * dstInfo.height() = 1, in order to implement sampling. |
| 127 * A potential future use is to allow the caller to decode a subset of the | 131 * A potential future use is to allow the caller to decode a subset of the |
| 128 * lines in the image. | 132 * lines in the image. |
| 129 * | 133 * |
| 130 * @param dstInfo Contains output information. Height specifies the | 134 * @param dstInfo Contains output information. Height specifies the |
| 131 * number of rows to decode at this time. | 135 * number of rows to decode at this time. |
| 132 * @param dst Memory location to store output pixels | 136 * @param dst Memory location to store output pixels |
| 133 * @param dstRowBytes Bytes in a row of the destination | 137 * @param dstRowBytes Bytes in a row of the destination |
| 134 * @return Number of rows successfully decoded | 138 * @return Number of rows successfully decoded |
| 135 */ | 139 */ |
| 136 virtual int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowB
ytes, | 140 virtual int decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstRowB
ytes, |
| 137 const Options& opts) = 0; | 141 const Options& opts) = 0; |
| 138 | 142 |
| 139 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const SkCodec::Opti
ons&, | 143 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const SkCodec::Opti
ons&, |
| 140 SkPMColor inputColorPtr[], int* inputColorCount) override; | 144 SkPMColor inputColorPtr[], int* inputColorCount, int subsetLeft, int
subsetWidth) |
| 145 override; |
| 141 | 146 |
| 142 int onGetScanlines(void* dst, int count, size_t rowBytes) override; | 147 int onGetScanlines(void* dst, int count, size_t rowBytes) override; |
| 143 | 148 |
| 144 // TODO(msarett): Override default skipping with something more clever. | 149 // TODO(msarett): Override default skipping with something more clever. |
| 145 | 150 |
| 146 const uint16_t fBitsPerPixel; | 151 const uint16_t fBitsPerPixel; |
| 152 int fSubsetLeft; |
| 153 int fSubsetWidth; |
| 147 const SkScanlineOrder fRowOrder; | 154 const SkScanlineOrder fRowOrder; |
| 148 | 155 |
| 149 typedef SkCodec INHERITED; | 156 typedef SkCodec INHERITED; |
| 150 }; | 157 }; |
| 151 | 158 |
| 152 #endif | 159 #endif |
| OLD | NEW |