Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | #ifndef SkScaledBitmapSampler_DEFINED |
michael@0 | 9 | #define SkScaledBitmapSampler_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkTypes.h" |
michael@0 | 12 | #include "SkColor.h" |
michael@0 | 13 | #include "SkImageDecoder.h" |
michael@0 | 14 | |
michael@0 | 15 | class SkBitmap; |
michael@0 | 16 | |
michael@0 | 17 | class SkScaledBitmapSampler { |
michael@0 | 18 | public: |
michael@0 | 19 | SkScaledBitmapSampler(int origWidth, int origHeight, int cellSize); |
michael@0 | 20 | |
michael@0 | 21 | int scaledWidth() const { return fScaledWidth; } |
michael@0 | 22 | int scaledHeight() const { return fScaledHeight; } |
michael@0 | 23 | |
michael@0 | 24 | int srcY0() const { return fY0; } |
michael@0 | 25 | int srcDX() const { return fDX; } |
michael@0 | 26 | int srcDY() const { return fDY; } |
michael@0 | 27 | |
michael@0 | 28 | enum SrcConfig { |
michael@0 | 29 | kGray, // 1 byte per pixel |
michael@0 | 30 | kIndex, // 1 byte per pixel |
michael@0 | 31 | kRGB, // 3 bytes per pixel |
michael@0 | 32 | kRGBX, // 4 byes per pixel (ignore 4th) |
michael@0 | 33 | kRGBA, // 4 bytes per pixel |
michael@0 | 34 | kRGB_565 // 2 bytes per pixel |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | // Given a dst bitmap (with pixels already allocated) and a src-config, |
michael@0 | 38 | // prepares iterator to process the src colors and write them into dst. |
michael@0 | 39 | // Returns false if the request cannot be fulfulled. |
michael@0 | 40 | bool begin(SkBitmap* dst, SrcConfig sc, const SkImageDecoder& decoder, |
michael@0 | 41 | const SkPMColor* = NULL); |
michael@0 | 42 | // call with row of src pixels, for y = 0...scaledHeight-1. |
michael@0 | 43 | // returns true if the row had non-opaque alpha in it |
michael@0 | 44 | bool next(const uint8_t* SK_RESTRICT src); |
michael@0 | 45 | |
michael@0 | 46 | // Like next(), but specifies the y value of the source row, so the |
michael@0 | 47 | // rows can come in any order. If the row is not part of the output |
michael@0 | 48 | // sample, it will be skipped. Only sampleInterlaced OR next should |
michael@0 | 49 | // be called for one SkScaledBitmapSampler. |
michael@0 | 50 | bool sampleInterlaced(const uint8_t* SK_RESTRICT src, int srcY); |
michael@0 | 51 | |
michael@0 | 52 | typedef bool (*RowProc)(void* SK_RESTRICT dstRow, |
michael@0 | 53 | const uint8_t* SK_RESTRICT src, |
michael@0 | 54 | int width, int deltaSrc, int y, |
michael@0 | 55 | const SkPMColor[]); |
michael@0 | 56 | |
michael@0 | 57 | private: |
michael@0 | 58 | int fScaledWidth; |
michael@0 | 59 | int fScaledHeight; |
michael@0 | 60 | |
michael@0 | 61 | int fX0; // first X coord to sample |
michael@0 | 62 | int fY0; // first Y coord (scanline) to sample |
michael@0 | 63 | int fDX; // step between X samples |
michael@0 | 64 | int fDY; // step between Y samples |
michael@0 | 65 | |
michael@0 | 66 | #ifdef SK_DEBUG |
michael@0 | 67 | // Keep track of whether the caller is using next or sampleInterlaced. |
michael@0 | 68 | // Only one can be used per sampler. |
michael@0 | 69 | enum SampleMode { |
michael@0 | 70 | kUninitialized_SampleMode, |
michael@0 | 71 | kConsecutive_SampleMode, |
michael@0 | 72 | kInterlaced_SampleMode, |
michael@0 | 73 | }; |
michael@0 | 74 | |
michael@0 | 75 | SampleMode fSampleMode; |
michael@0 | 76 | #endif |
michael@0 | 77 | |
michael@0 | 78 | // setup state |
michael@0 | 79 | char* fDstRow; // points into bitmap's pixels |
michael@0 | 80 | size_t fDstRowBytes; |
michael@0 | 81 | int fCurrY; // used for dithering |
michael@0 | 82 | int fSrcPixelSize; // 1, 3, 4 |
michael@0 | 83 | RowProc fRowProc; |
michael@0 | 84 | |
michael@0 | 85 | // optional reference to the src colors if the src is a palette model |
michael@0 | 86 | const SkPMColor* fCTable; |
michael@0 | 87 | |
michael@0 | 88 | #ifdef SK_DEBUG |
michael@0 | 89 | // Helper class allowing a test to have access to fRowProc. |
michael@0 | 90 | friend class RowProcTester; |
michael@0 | 91 | #endif |
michael@0 | 92 | }; |
michael@0 | 93 | |
michael@0 | 94 | #endif |