2001-04-02 08:56:18 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-04-02 08:56:18 +04:00
|
|
|
|
2015-04-06 02:22:00 +03:00
|
|
|
#ifndef mozilla_image_decoders_nsIconDecoder_h
|
|
|
|
#define mozilla_image_decoders_nsIconDecoder_h
|
2001-04-02 08:56:18 +04:00
|
|
|
|
2010-08-23 06:30:46 +04:00
|
|
|
#include "Decoder.h"
|
2001-04-02 08:56:18 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2010-08-14 08:09:49 +04:00
|
|
|
namespace mozilla {
|
2012-01-06 20:02:27 +04:00
|
|
|
namespace image {
|
2010-08-14 08:09:49 +04:00
|
|
|
class RasterImage;
|
2001-04-02 08:56:18 +04:00
|
|
|
|
2014-11-14 20:59:00 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// The icon decoder is a decoder specifically tailored for loading icons
|
2001-04-02 08:56:18 +04:00
|
|
|
// from the OS. We've defined our own little format to represent these icons
|
2014-11-14 20:59:00 +03:00
|
|
|
// and this decoder takes that format and converts it into 24-bit RGB with
|
|
|
|
// alpha channel support. It was modeled a bit off the PPM decoder.
|
2001-04-02 08:56:18 +04:00
|
|
|
//
|
|
|
|
// Assumptions about the decoder:
|
2014-11-14 20:59:00 +03:00
|
|
|
// (1) We receive ALL of the data from the icon channel in one OnDataAvailable
|
|
|
|
// call. We don't support multiple ODA calls yet.
|
2001-04-02 08:56:18 +04:00
|
|
|
// (2) the format of the incoming data is as follows:
|
2014-11-14 20:59:00 +03:00
|
|
|
// The first two bytes contain the width and the height of the icon.
|
2007-01-09 02:58:12 +03:00
|
|
|
// The remaining bytes contain the icon data, 4 bytes per pixel, in
|
|
|
|
// ARGB order (platform endianness, A in highest bits, B in lowest
|
|
|
|
// bits), row-primary, top-to-bottom, left-to-right, with
|
|
|
|
// premultiplied alpha.
|
2001-04-02 08:56:18 +04:00
|
|
|
//
|
|
|
|
//
|
2014-11-14 20:59:00 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-04-02 08:56:18 +04:00
|
|
|
|
2010-08-23 06:30:46 +04:00
|
|
|
class nsIconDecoder : public Decoder
|
2001-04-02 08:56:18 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-01-16 02:11:35 +03:00
|
|
|
explicit nsIconDecoder(RasterImage* aImage);
|
2001-04-02 08:56:18 +04:00
|
|
|
virtual ~nsIconDecoder();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
2010-08-23 06:30:46 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mWidth;
|
|
|
|
uint8_t mHeight;
|
|
|
|
uint32_t mPixBytesRead;
|
|
|
|
uint32_t mState;
|
2009-09-13 02:44:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
iconStateStart = 0,
|
|
|
|
iconStateHaveHeight = 1,
|
|
|
|
iconStateReadPixels = 2,
|
2010-09-12 19:22:27 +04:00
|
|
|
iconStateFinished = 3
|
2001-04-02 08:56:18 +04:00
|
|
|
};
|
|
|
|
|
2012-01-06 20:02:27 +04:00
|
|
|
} // namespace image
|
2010-08-23 06:30:46 +04:00
|
|
|
} // namespace mozilla
|
2009-09-13 02:44:18 +04:00
|
|
|
|
2015-04-06 02:22:00 +03:00
|
|
|
#endif // mozilla_image_decoders_nsIconDecoder_h
|