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 | * Copyright 2013 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef SkBitmapScaler_DEFINED |
michael@0 | 9 | #define SkBitmapScaler_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkBitmap.h" |
michael@0 | 12 | #include "SkConvolver.h" |
michael@0 | 13 | |
michael@0 | 14 | /** \class SkBitmapScaler |
michael@0 | 15 | |
michael@0 | 16 | Provides the interface for high quality image resampling. |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | class SK_API SkBitmapScaler { |
michael@0 | 20 | public: |
michael@0 | 21 | enum ResizeMethod { |
michael@0 | 22 | // Quality Methods |
michael@0 | 23 | // |
michael@0 | 24 | // Those enumeration values express a desired quality/speed tradeoff. |
michael@0 | 25 | // They are translated into an algorithm-specific method that depends |
michael@0 | 26 | // on the capabilities (CPU, GPU) of the underlying platform. |
michael@0 | 27 | // It is possible for all three methods to be mapped to the same |
michael@0 | 28 | // algorithm on a given platform. |
michael@0 | 29 | |
michael@0 | 30 | // Good quality resizing. Fastest resizing with acceptable visual quality. |
michael@0 | 31 | // This is typically intended for use during interactive layouts |
michael@0 | 32 | // where slower platforms may want to trade image quality for large |
michael@0 | 33 | // increase in resizing performance. |
michael@0 | 34 | // |
michael@0 | 35 | // For example the resizing implementation may devolve to linear |
michael@0 | 36 | // filtering if this enables GPU acceleration to be used. |
michael@0 | 37 | // |
michael@0 | 38 | // Note that the underlying resizing method may be determined |
michael@0 | 39 | // on the fly based on the parameters for a given resize call. |
michael@0 | 40 | // For example an implementation using a GPU-based linear filter |
michael@0 | 41 | // in the common case may still use a higher-quality software-based |
michael@0 | 42 | // filter in cases where using the GPU would actually be slower - due |
michael@0 | 43 | // to too much latency - or impossible - due to image format or size |
michael@0 | 44 | // constraints. |
michael@0 | 45 | RESIZE_GOOD, |
michael@0 | 46 | |
michael@0 | 47 | // Medium quality resizing. Close to high quality resizing (better |
michael@0 | 48 | // than linear interpolation) with potentially some quality being |
michael@0 | 49 | // traded-off for additional speed compared to RESIZE_BEST. |
michael@0 | 50 | // |
michael@0 | 51 | // This is intended, for example, for generation of large thumbnails |
michael@0 | 52 | // (hundreds of pixels in each dimension) from large sources, where |
michael@0 | 53 | // a linear filter would produce too many artifacts but where |
michael@0 | 54 | // a RESIZE_HIGH might be too costly time-wise. |
michael@0 | 55 | RESIZE_BETTER, |
michael@0 | 56 | |
michael@0 | 57 | // High quality resizing. The algorithm is picked to favor image quality. |
michael@0 | 58 | RESIZE_BEST, |
michael@0 | 59 | |
michael@0 | 60 | // |
michael@0 | 61 | // Algorithm-specific enumerations |
michael@0 | 62 | // |
michael@0 | 63 | |
michael@0 | 64 | // Box filter. This is a weighted average of all of the pixels touching |
michael@0 | 65 | // the destination pixel. For enlargement, this is nearest neighbor. |
michael@0 | 66 | // |
michael@0 | 67 | // You probably don't want this, it is here for testing since it is easy to |
michael@0 | 68 | // compute. Use RESIZE_LANCZOS3 instead. |
michael@0 | 69 | RESIZE_BOX, |
michael@0 | 70 | RESIZE_TRIANGLE, |
michael@0 | 71 | RESIZE_LANCZOS3, |
michael@0 | 72 | RESIZE_HAMMING, |
michael@0 | 73 | RESIZE_MITCHELL, |
michael@0 | 74 | |
michael@0 | 75 | // enum aliases for first and last methods by algorithm or by quality. |
michael@0 | 76 | RESIZE_FIRST_QUALITY_METHOD = RESIZE_GOOD, |
michael@0 | 77 | RESIZE_LAST_QUALITY_METHOD = RESIZE_BEST, |
michael@0 | 78 | RESIZE_FIRST_ALGORITHM_METHOD = RESIZE_BOX, |
michael@0 | 79 | RESIZE_LAST_ALGORITHM_METHOD = RESIZE_MITCHELL, |
michael@0 | 80 | }; |
michael@0 | 81 | |
michael@0 | 82 | // Resizes the given source bitmap using the specified resize method, so that |
michael@0 | 83 | // the entire image is (dest_size) big. The dest_subset is the rectangle in |
michael@0 | 84 | // this destination image that should actually be returned. |
michael@0 | 85 | // |
michael@0 | 86 | // The output image will be (dest_subset.width(), dest_subset.height()). This |
michael@0 | 87 | // will save work if you do not need the entire bitmap. |
michael@0 | 88 | // |
michael@0 | 89 | // The destination subset must be smaller than the destination image. |
michael@0 | 90 | static bool Resize(SkBitmap* result, |
michael@0 | 91 | const SkBitmap& source, |
michael@0 | 92 | ResizeMethod method, |
michael@0 | 93 | int dest_width, int dest_height, |
michael@0 | 94 | const SkIRect& dest_subset, |
michael@0 | 95 | const SkConvolutionProcs&, |
michael@0 | 96 | SkBitmap::Allocator* allocator = NULL); |
michael@0 | 97 | |
michael@0 | 98 | // Alternate version for resizing and returning the entire bitmap rather than |
michael@0 | 99 | // a subset. |
michael@0 | 100 | static bool Resize(SkBitmap* result, |
michael@0 | 101 | const SkBitmap& source, |
michael@0 | 102 | ResizeMethod method, |
michael@0 | 103 | int dest_width, int dest_height, |
michael@0 | 104 | const SkConvolutionProcs&, |
michael@0 | 105 | SkBitmap::Allocator* allocator = NULL); |
michael@0 | 106 | }; |
michael@0 | 107 | |
michael@0 | 108 | #endif |