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.

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

mercurial