michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsIconDecoder_h__ michael@0: #define nsIconDecoder_h__ michael@0: michael@0: #include "Decoder.h" michael@0: michael@0: #include "nsCOMPtr.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: class RasterImage; michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////////////////////// michael@0: // The icon decoder is a decoder specifically tailored for loading icons michael@0: // from the OS. We've defined our own little format to represent these icons michael@0: // and this decoder takes that format and converts it into 24-bit RGB with alpha channel michael@0: // support. It was modeled a bit off the PPM decoder. michael@0: // michael@0: // Assumptions about the decoder: michael@0: // (1) We receive ALL of the data from the icon channel in one OnDataAvailable call. We don't michael@0: // support multiple ODA calls yet. michael@0: // (2) the format of the incoming data is as follows: michael@0: // The first two bytes contain the width and the height of the icon. michael@0: // The remaining bytes contain the icon data, 4 bytes per pixel, in michael@0: // ARGB order (platform endianness, A in highest bits, B in lowest michael@0: // bits), row-primary, top-to-bottom, left-to-right, with michael@0: // premultiplied alpha. michael@0: // michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: class nsIconDecoder : public Decoder michael@0: { michael@0: public: michael@0: michael@0: nsIconDecoder(RasterImage &aImage); michael@0: virtual ~nsIconDecoder(); michael@0: michael@0: virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy); michael@0: michael@0: uint8_t mWidth; michael@0: uint8_t mHeight; michael@0: uint32_t mPixBytesRead; michael@0: uint32_t mState; michael@0: }; michael@0: michael@0: enum { michael@0: iconStateStart = 0, michael@0: iconStateHaveHeight = 1, michael@0: iconStateReadPixels = 2, michael@0: iconStateFinished = 3 michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif // nsIconDecoder_h__