image/decoders/nsIconDecoder.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:98b8c01593de
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef nsIconDecoder_h__
8 #define nsIconDecoder_h__
9
10 #include "Decoder.h"
11
12 #include "nsCOMPtr.h"
13
14 namespace mozilla {
15 namespace image {
16 class RasterImage;
17
18 //////////////////////////////////////////////////////////////////////////////////////////////
19 // The icon decoder is a decoder specifically tailored for loading icons
20 // from the OS. We've defined our own little format to represent these icons
21 // and this decoder takes that format and converts it into 24-bit RGB with alpha channel
22 // support. It was modeled a bit off the PPM decoder.
23 //
24 // Assumptions about the decoder:
25 // (1) We receive ALL of the data from the icon channel in one OnDataAvailable call. We don't
26 // support multiple ODA calls yet.
27 // (2) the format of the incoming data is as follows:
28 // The first two bytes contain the width and the height of the icon.
29 // The remaining bytes contain the icon data, 4 bytes per pixel, in
30 // ARGB order (platform endianness, A in highest bits, B in lowest
31 // bits), row-primary, top-to-bottom, left-to-right, with
32 // premultiplied alpha.
33 //
34 //
35 //////////////////////////////////////////////////////////////////////////////////////////////
36
37 class nsIconDecoder : public Decoder
38 {
39 public:
40
41 nsIconDecoder(RasterImage &aImage);
42 virtual ~nsIconDecoder();
43
44 virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
45
46 uint8_t mWidth;
47 uint8_t mHeight;
48 uint32_t mPixBytesRead;
49 uint32_t mState;
50 };
51
52 enum {
53 iconStateStart = 0,
54 iconStateHaveHeight = 1,
55 iconStateReadPixels = 2,
56 iconStateFinished = 3
57 };
58
59 } // namespace image
60 } // namespace mozilla
61
62 #endif // nsIconDecoder_h__

mercurial