image/decoders/nsIconDecoder.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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/. */
     7 #ifndef nsIconDecoder_h__
     8 #define nsIconDecoder_h__
    10 #include "Decoder.h"
    12 #include "nsCOMPtr.h"
    14 namespace mozilla {
    15 namespace image {
    16 class RasterImage;
    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 //////////////////////////////////////////////////////////////////////////////////////////////
    37 class nsIconDecoder : public Decoder
    38 {
    39 public:
    41   nsIconDecoder(RasterImage &aImage);
    42   virtual ~nsIconDecoder();
    44   virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
    46   uint8_t mWidth;
    47   uint8_t mHeight;
    48   uint32_t mPixBytesRead;
    49   uint32_t mState;
    50 };
    52 enum {
    53   iconStateStart      = 0,
    54   iconStateHaveHeight = 1,
    55   iconStateReadPixels = 2,
    56   iconStateFinished   = 3
    57 };
    59 } // namespace image
    60 } // namespace mozilla
    62 #endif // nsIconDecoder_h__

mercurial