image/decoders/nsIconDecoder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/decoders/nsIconDecoder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsIconDecoder_h__
    1.11 +#define nsIconDecoder_h__
    1.12 +
    1.13 +#include "Decoder.h"
    1.14 +
    1.15 +#include "nsCOMPtr.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace image {
    1.19 +class RasterImage;
    1.20 +
    1.21 +//////////////////////////////////////////////////////////////////////////////////////////////
    1.22 +// The icon decoder is a decoder specifically tailored for loading icons 
    1.23 +// from the OS. We've defined our own little format to represent these icons
    1.24 +// and this decoder takes that format and converts it into 24-bit RGB with alpha channel
    1.25 +// support. It was modeled a bit off the PPM decoder.
    1.26 +//
    1.27 +// Assumptions about the decoder:
    1.28 +// (1) We receive ALL of the data from the icon channel in one OnDataAvailable call. We don't
    1.29 +//     support multiple ODA calls yet.
    1.30 +// (2) the format of the incoming data is as follows:
    1.31 +//     The first two bytes contain the width and the height of the icon. 
    1.32 +//     The remaining bytes contain the icon data, 4 bytes per pixel, in
    1.33 +//       ARGB order (platform endianness, A in highest bits, B in lowest
    1.34 +//       bits), row-primary, top-to-bottom, left-to-right, with
    1.35 +//       premultiplied alpha.
    1.36 +//
    1.37 +//
    1.38 +//////////////////////////////////////////////////////////////////////////////////////////////
    1.39 +
    1.40 +class nsIconDecoder : public Decoder
    1.41 +{
    1.42 +public:
    1.43 +
    1.44 +  nsIconDecoder(RasterImage &aImage);
    1.45 +  virtual ~nsIconDecoder();
    1.46 +
    1.47 +  virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
    1.48 +
    1.49 +  uint8_t mWidth;
    1.50 +  uint8_t mHeight;
    1.51 +  uint32_t mPixBytesRead;
    1.52 +  uint32_t mState;
    1.53 +};
    1.54 +
    1.55 +enum {
    1.56 +  iconStateStart      = 0,
    1.57 +  iconStateHaveHeight = 1,
    1.58 +  iconStateReadPixels = 2,
    1.59 +  iconStateFinished   = 3
    1.60 +};
    1.61 +
    1.62 +} // namespace image
    1.63 +} // namespace mozilla
    1.64 +
    1.65 +#endif // nsIconDecoder_h__

mercurial