Thu, 15 Jan 2015 15:59:08 +0100
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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef MOZILLA_IMAGELIB_BMPHEADERS_H_ |
michael@0 | 6 | #define MOZILLA_IMAGELIB_BMPHEADERS_H_ |
michael@0 | 7 | |
michael@0 | 8 | namespace mozilla { |
michael@0 | 9 | namespace image { |
michael@0 | 10 | |
michael@0 | 11 | struct BMPFILEHEADER { |
michael@0 | 12 | char signature[2]; // String "BM" |
michael@0 | 13 | uint32_t filesize; |
michael@0 | 14 | int32_t reserved; // Zero |
michael@0 | 15 | uint32_t dataoffset; // Offset to raster data |
michael@0 | 16 | |
michael@0 | 17 | uint32_t bihsize; |
michael@0 | 18 | }; |
michael@0 | 19 | |
michael@0 | 20 | // The length of the bitmap file header as defined in the BMP spec. |
michael@0 | 21 | #define BFH_LENGTH 14 |
michael@0 | 22 | // Internally we store the bitmap file header with an additional 4 bytes which |
michael@0 | 23 | // is used to store the bitmap information header size. |
michael@0 | 24 | #define BFH_INTERNAL_LENGTH 18 |
michael@0 | 25 | |
michael@0 | 26 | #define OS2_INTERNAL_BIH_LENGTH 8 |
michael@0 | 27 | #define WIN_V3_INTERNAL_BIH_LENGTH 36 |
michael@0 | 28 | #define WIN_V5_INTERNAL_BIH_LENGTH 120 |
michael@0 | 29 | |
michael@0 | 30 | #define OS2_BIH_LENGTH 12 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER) |
michael@0 | 31 | #define WIN_V3_BIH_LENGTH 40 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER) |
michael@0 | 32 | #define WIN_V5_BIH_LENGTH 124 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER) |
michael@0 | 33 | |
michael@0 | 34 | #define OS2_HEADER_LENGTH (BFH_INTERNAL_LENGTH + OS2_INTERNAL_BIH_LENGTH) |
michael@0 | 35 | #define WIN_V3_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V3_INTERNAL_BIH_LENGTH) |
michael@0 | 36 | #define WIN_V5_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V5_INTERNAL_BIH_LENGTH) |
michael@0 | 37 | |
michael@0 | 38 | #ifndef LCS_sRGB |
michael@0 | 39 | #define LCS_sRGB 0x73524742 |
michael@0 | 40 | #endif |
michael@0 | 41 | |
michael@0 | 42 | struct xyz { |
michael@0 | 43 | int32_t x, y, z; |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | struct xyzTriple { |
michael@0 | 47 | xyz r, g, b; |
michael@0 | 48 | }; |
michael@0 | 49 | |
michael@0 | 50 | struct BITMAPV5HEADER { |
michael@0 | 51 | int32_t width; // Uint16 in OS/2 BMPs |
michael@0 | 52 | int32_t height; // Uint16 in OS/2 BMPs |
michael@0 | 53 | uint16_t planes; // =1 |
michael@0 | 54 | uint16_t bpp; // Bits per pixel. |
michael@0 | 55 | // The rest of the header is not available in OS/2 BMP Files |
michael@0 | 56 | uint32_t compression; // 0=no compression 1=8bit RLE 2=4bit RLE |
michael@0 | 57 | uint32_t image_size; // (compressed) image size. Can be 0 if compression==0 |
michael@0 | 58 | uint32_t xppm; // Pixels per meter, horizontal |
michael@0 | 59 | uint32_t yppm; // Pixels per meter, vertical |
michael@0 | 60 | uint32_t colors; // Used Colors |
michael@0 | 61 | uint32_t important_colors; // Number of important colors. 0=all |
michael@0 | 62 | uint32_t red_mask; // Bits used for red component |
michael@0 | 63 | uint32_t green_mask; // Bits used for green component |
michael@0 | 64 | uint32_t blue_mask; // Bits used for blue component |
michael@0 | 65 | uint32_t alpha_mask; // Bits used for alpha component |
michael@0 | 66 | uint32_t color_space; // 0x73524742=LCS_sRGB ... |
michael@0 | 67 | // These members are unused unless color_space == LCS_CALIBRATED_RGB |
michael@0 | 68 | xyzTriple white_point; // Logical white point |
michael@0 | 69 | uint32_t gamma_red; // Red gamma component |
michael@0 | 70 | uint32_t gamma_green; // Green gamma component |
michael@0 | 71 | uint32_t gamma_blue; // Blue gamma component |
michael@0 | 72 | uint32_t intent; // Rendering intent |
michael@0 | 73 | // These members are unused unless color_space == LCS_PROFILE_* |
michael@0 | 74 | uint32_t profile_offset; // Offset to profile data in bytes |
michael@0 | 75 | uint32_t profile_size; // Size of profile data in bytes |
michael@0 | 76 | uint32_t reserved; // =0 |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | struct colorTable { |
michael@0 | 80 | uint8_t red; |
michael@0 | 81 | uint8_t green; |
michael@0 | 82 | uint8_t blue; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | struct bitFields { |
michael@0 | 86 | uint32_t red; |
michael@0 | 87 | uint32_t green; |
michael@0 | 88 | uint32_t blue; |
michael@0 | 89 | uint8_t redLeftShift; |
michael@0 | 90 | uint8_t redRightShift; |
michael@0 | 91 | uint8_t greenLeftShift; |
michael@0 | 92 | uint8_t greenRightShift; |
michael@0 | 93 | uint8_t blueLeftShift; |
michael@0 | 94 | uint8_t blueRightShift; |
michael@0 | 95 | }; |
michael@0 | 96 | |
michael@0 | 97 | } // namespace image |
michael@0 | 98 | } // namespace mozilla |
michael@0 | 99 | |
michael@0 | 100 | #define BITFIELD_LENGTH 12 // Length of the bitfields structure in the bmp file |
michael@0 | 101 | #define USE_RGB |
michael@0 | 102 | |
michael@0 | 103 | // BMPINFOHEADER.compression defines |
michael@0 | 104 | #ifndef BI_RGB |
michael@0 | 105 | #define BI_RGB 0 |
michael@0 | 106 | #endif |
michael@0 | 107 | #ifndef BI_RLE8 |
michael@0 | 108 | #define BI_RLE8 1 |
michael@0 | 109 | #endif |
michael@0 | 110 | #ifndef BI_RLE4 |
michael@0 | 111 | #define BI_RLE4 2 |
michael@0 | 112 | #endif |
michael@0 | 113 | #ifndef BI_BITFIELDS |
michael@0 | 114 | #define BI_BITFIELDS 3 |
michael@0 | 115 | #endif |
michael@0 | 116 | // BI_ALPHABITFIELDS means no compression and specifies alpha bits |
michael@0 | 117 | // valid only for 32bpp and 16bpp |
michael@0 | 118 | #ifndef BI_ALPHABITFIELDS |
michael@0 | 119 | #define BI_ALPHABITFIELDS 4 |
michael@0 | 120 | #endif |
michael@0 | 121 | |
michael@0 | 122 | // RLE Escape codes |
michael@0 | 123 | #define RLE_ESCAPE 0 |
michael@0 | 124 | #define RLE_ESCAPE_EOL 0 |
michael@0 | 125 | #define RLE_ESCAPE_EOF 1 |
michael@0 | 126 | #define RLE_ESCAPE_DELTA 2 |
michael@0 | 127 | |
michael@0 | 128 | /// enums for mState |
michael@0 | 129 | enum ERLEState { |
michael@0 | 130 | eRLEStateInitial, |
michael@0 | 131 | eRLEStateNeedSecondEscapeByte, |
michael@0 | 132 | eRLEStateNeedXDelta, |
michael@0 | 133 | eRLEStateNeedYDelta, ///< mStateData will hold x delta |
michael@0 | 134 | eRLEStateAbsoluteMode, ///< mStateData will hold count of existing data to read |
michael@0 | 135 | eRLEStateAbsoluteModePadded ///< As above, but another byte of data has to be read as padding |
michael@0 | 136 | }; |
michael@0 | 137 | |
michael@0 | 138 | #endif |