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 2012 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 GrConvolutionEffect_DEFINED |
michael@0 | 9 | #define GrConvolutionEffect_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "Gr1DKernelEffect.h" |
michael@0 | 12 | |
michael@0 | 13 | class GrGLConvolutionEffect; |
michael@0 | 14 | |
michael@0 | 15 | /** |
michael@0 | 16 | * A convolution effect. The kernel is specified as an array of 2 * half-width |
michael@0 | 17 | * + 1 weights. Each texel is multiplied by it's weight and summed to determine |
michael@0 | 18 | * the output color. The output color is modulated by the input color. |
michael@0 | 19 | */ |
michael@0 | 20 | class GrConvolutionEffect : public Gr1DKernelEffect { |
michael@0 | 21 | |
michael@0 | 22 | public: |
michael@0 | 23 | |
michael@0 | 24 | /// Convolve with an arbitrary user-specified kernel |
michael@0 | 25 | static GrEffectRef* Create(GrTexture* tex, |
michael@0 | 26 | Direction dir, |
michael@0 | 27 | int halfWidth, |
michael@0 | 28 | const float* kernel, |
michael@0 | 29 | bool useBounds, |
michael@0 | 30 | float bounds[2]) { |
michael@0 | 31 | AutoEffectUnref effect(SkNEW_ARGS(GrConvolutionEffect, (tex, |
michael@0 | 32 | dir, |
michael@0 | 33 | halfWidth, |
michael@0 | 34 | kernel, |
michael@0 | 35 | useBounds, |
michael@0 | 36 | bounds))); |
michael@0 | 37 | return CreateEffectRef(effect); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | /// Convolve with a Gaussian kernel |
michael@0 | 41 | static GrEffectRef* CreateGaussian(GrTexture* tex, |
michael@0 | 42 | Direction dir, |
michael@0 | 43 | int halfWidth, |
michael@0 | 44 | float gaussianSigma, |
michael@0 | 45 | bool useBounds, |
michael@0 | 46 | float bounds[2]) { |
michael@0 | 47 | AutoEffectUnref effect(SkNEW_ARGS(GrConvolutionEffect, (tex, |
michael@0 | 48 | dir, |
michael@0 | 49 | halfWidth, |
michael@0 | 50 | gaussianSigma, |
michael@0 | 51 | useBounds, |
michael@0 | 52 | bounds))); |
michael@0 | 53 | return CreateEffectRef(effect); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | virtual ~GrConvolutionEffect(); |
michael@0 | 57 | |
michael@0 | 58 | const float* kernel() const { return fKernel; } |
michael@0 | 59 | |
michael@0 | 60 | const float* bounds() const { return fBounds; } |
michael@0 | 61 | bool useBounds() const { return fUseBounds; } |
michael@0 | 62 | |
michael@0 | 63 | static const char* Name() { return "Convolution"; } |
michael@0 | 64 | |
michael@0 | 65 | typedef GrGLConvolutionEffect GLEffect; |
michael@0 | 66 | |
michael@0 | 67 | virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
michael@0 | 68 | |
michael@0 | 69 | virtual void getConstantColorComponents(GrColor*, uint32_t* validFlags) const { |
michael@0 | 70 | // If the texture was opaque we could know that the output color if we knew the sum of the |
michael@0 | 71 | // kernel values. |
michael@0 | 72 | *validFlags = 0; |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | enum { |
michael@0 | 76 | // This was decided based on the min allowed value for the max texture |
michael@0 | 77 | // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 |
michael@0 | 78 | // on a blur filter gives a kernel width of 25 while a sigma of 5.0 |
michael@0 | 79 | // would exceed a 32 wide kernel. |
michael@0 | 80 | kMaxKernelRadius = 12, |
michael@0 | 81 | // With a C++11 we could have a constexpr version of WidthFromRadius() |
michael@0 | 82 | // and not have to duplicate this calculation. |
michael@0 | 83 | kMaxKernelWidth = 2 * kMaxKernelRadius + 1, |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | protected: |
michael@0 | 87 | |
michael@0 | 88 | float fKernel[kMaxKernelWidth]; |
michael@0 | 89 | bool fUseBounds; |
michael@0 | 90 | float fBounds[2]; |
michael@0 | 91 | |
michael@0 | 92 | private: |
michael@0 | 93 | GrConvolutionEffect(GrTexture*, Direction, |
michael@0 | 94 | int halfWidth, |
michael@0 | 95 | const float* kernel, |
michael@0 | 96 | bool useBounds, |
michael@0 | 97 | float bounds[2]); |
michael@0 | 98 | |
michael@0 | 99 | /// Convolve with a Gaussian kernel |
michael@0 | 100 | GrConvolutionEffect(GrTexture*, Direction, |
michael@0 | 101 | int halfWidth, |
michael@0 | 102 | float gaussianSigma, |
michael@0 | 103 | bool useBounds, |
michael@0 | 104 | float bounds[2]); |
michael@0 | 105 | |
michael@0 | 106 | virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; |
michael@0 | 107 | |
michael@0 | 108 | GR_DECLARE_EFFECT_TEST; |
michael@0 | 109 | |
michael@0 | 110 | typedef Gr1DKernelEffect INHERITED; |
michael@0 | 111 | }; |
michael@0 | 112 | |
michael@0 | 113 | #endif |