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 | float4x4 mLayerTransform; |
michael@0 | 2 | float4 vRenderTargetOffset; |
michael@0 | 3 | float4x4 mProjection; |
michael@0 | 4 | |
michael@0 | 5 | typedef float4 rect; |
michael@0 | 6 | rect vTextureCoords; |
michael@0 | 7 | rect vLayerQuad; |
michael@0 | 8 | rect vMaskQuad; |
michael@0 | 9 | |
michael@0 | 10 | texture tex0; |
michael@0 | 11 | sampler s2D; |
michael@0 | 12 | sampler s2DWhite; |
michael@0 | 13 | sampler s2DY; |
michael@0 | 14 | sampler s2DCb; |
michael@0 | 15 | sampler s2DCr; |
michael@0 | 16 | sampler s2DMask; |
michael@0 | 17 | |
michael@0 | 18 | |
michael@0 | 19 | float fLayerOpacity; |
michael@0 | 20 | float4 fLayerColor; |
michael@0 | 21 | |
michael@0 | 22 | struct VS_INPUT { |
michael@0 | 23 | float4 vPosition : POSITION; |
michael@0 | 24 | }; |
michael@0 | 25 | |
michael@0 | 26 | struct VS_OUTPUT { |
michael@0 | 27 | float4 vPosition : POSITION; |
michael@0 | 28 | float2 vTexCoords : TEXCOORD0; |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | struct VS_OUTPUT_MASK { |
michael@0 | 32 | float4 vPosition : POSITION; |
michael@0 | 33 | float2 vTexCoords : TEXCOORD0; |
michael@0 | 34 | float2 vMaskCoords : TEXCOORD1; |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | struct VS_OUTPUT_MASK_3D { |
michael@0 | 38 | float4 vPosition : POSITION; |
michael@0 | 39 | float2 vTexCoords : TEXCOORD0; |
michael@0 | 40 | float3 vMaskCoords : TEXCOORD1; |
michael@0 | 41 | }; |
michael@0 | 42 | |
michael@0 | 43 | VS_OUTPUT LayerQuadVS(const VS_INPUT aVertex) |
michael@0 | 44 | { |
michael@0 | 45 | VS_OUTPUT outp; |
michael@0 | 46 | outp.vPosition = aVertex.vPosition; |
michael@0 | 47 | |
michael@0 | 48 | // We use 4 component floats to uniquely describe a rectangle, by the structure |
michael@0 | 49 | // of x, y, width, height. This allows us to easily generate the 4 corners |
michael@0 | 50 | // of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the |
michael@0 | 51 | // stream source for our LayerQuad vertex shader. We do this by doing: |
michael@0 | 52 | // Xout = x + Xin * width |
michael@0 | 53 | // Yout = y + Yin * height |
michael@0 | 54 | float2 position = vLayerQuad.xy; |
michael@0 | 55 | float2 size = vLayerQuad.zw; |
michael@0 | 56 | outp.vPosition.x = position.x + outp.vPosition.x * size.x; |
michael@0 | 57 | outp.vPosition.y = position.y + outp.vPosition.y * size.y; |
michael@0 | 58 | |
michael@0 | 59 | outp.vPosition = mul(mLayerTransform, outp.vPosition); |
michael@0 | 60 | outp.vPosition.xyz /= outp.vPosition.w; |
michael@0 | 61 | outp.vPosition = outp.vPosition - vRenderTargetOffset; |
michael@0 | 62 | outp.vPosition.xyz *= outp.vPosition.w; |
michael@0 | 63 | |
michael@0 | 64 | // adjust our vertices to match d3d9's pixel coordinate system |
michael@0 | 65 | // which has pixel centers at integer locations |
michael@0 | 66 | outp.vPosition.xy -= 0.5; |
michael@0 | 67 | |
michael@0 | 68 | outp.vPosition = mul(mProjection, outp.vPosition); |
michael@0 | 69 | |
michael@0 | 70 | position = vTextureCoords.xy; |
michael@0 | 71 | size = vTextureCoords.zw; |
michael@0 | 72 | outp.vTexCoords.x = position.x + aVertex.vPosition.x * size.x; |
michael@0 | 73 | outp.vTexCoords.y = position.y + aVertex.vPosition.y * size.y; |
michael@0 | 74 | |
michael@0 | 75 | return outp; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | VS_OUTPUT_MASK LayerQuadVSMask(const VS_INPUT aVertex) |
michael@0 | 79 | { |
michael@0 | 80 | VS_OUTPUT_MASK outp; |
michael@0 | 81 | float4 position = float4(0, 0, 0, 1); |
michael@0 | 82 | |
michael@0 | 83 | // We use 4 component floats to uniquely describe a rectangle, by the structure |
michael@0 | 84 | // of x, y, width, height. This allows us to easily generate the 4 corners |
michael@0 | 85 | // of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the |
michael@0 | 86 | // stream source for our LayerQuad vertex shader. We do this by doing: |
michael@0 | 87 | // Xout = x + Xin * width |
michael@0 | 88 | // Yout = y + Yin * height |
michael@0 | 89 | float2 size = vLayerQuad.zw; |
michael@0 | 90 | position.x = vLayerQuad.x + aVertex.vPosition.x * size.x; |
michael@0 | 91 | position.y = vLayerQuad.y + aVertex.vPosition.y * size.y; |
michael@0 | 92 | |
michael@0 | 93 | position = mul(mLayerTransform, position); |
michael@0 | 94 | outp.vPosition.w = position.w; |
michael@0 | 95 | outp.vPosition.xyz = position.xyz / position.w; |
michael@0 | 96 | outp.vPosition = outp.vPosition - vRenderTargetOffset; |
michael@0 | 97 | outp.vPosition.xyz *= outp.vPosition.w; |
michael@0 | 98 | |
michael@0 | 99 | // adjust our vertices to match d3d9's pixel coordinate system |
michael@0 | 100 | // which has pixel centers at integer locations |
michael@0 | 101 | outp.vPosition.xy -= 0.5; |
michael@0 | 102 | |
michael@0 | 103 | outp.vPosition = mul(mProjection, outp.vPosition); |
michael@0 | 104 | |
michael@0 | 105 | // calculate the position on the mask texture |
michael@0 | 106 | outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z; |
michael@0 | 107 | outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w; |
michael@0 | 108 | |
michael@0 | 109 | size = vTextureCoords.zw; |
michael@0 | 110 | outp.vTexCoords.x = vTextureCoords.x + aVertex.vPosition.x * size.x; |
michael@0 | 111 | outp.vTexCoords.y = vTextureCoords.y + aVertex.vPosition.y * size.y; |
michael@0 | 112 | |
michael@0 | 113 | return outp; |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | VS_OUTPUT_MASK_3D LayerQuadVSMask3D(const VS_INPUT aVertex) |
michael@0 | 117 | { |
michael@0 | 118 | VS_OUTPUT_MASK_3D outp; |
michael@0 | 119 | float4 position = float4(0, 0, 0, 1); |
michael@0 | 120 | |
michael@0 | 121 | // We use 4 component floats to uniquely describe a rectangle, by the structure |
michael@0 | 122 | // of x, y, width, height. This allows us to easily generate the 4 corners |
michael@0 | 123 | // of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the |
michael@0 | 124 | // stream source for our LayerQuad vertex shader. We do this by doing: |
michael@0 | 125 | // Xout = x + Xin * width |
michael@0 | 126 | // Yout = y + Yin * height |
michael@0 | 127 | float2 size = vLayerQuad.zw; |
michael@0 | 128 | position.x = vLayerQuad.x + aVertex.vPosition.x * size.x; |
michael@0 | 129 | position.y = vLayerQuad.y + aVertex.vPosition.y * size.y; |
michael@0 | 130 | |
michael@0 | 131 | position = mul(mLayerTransform, position); |
michael@0 | 132 | outp.vPosition.w = position.w; |
michael@0 | 133 | outp.vPosition.xyz = position.xyz / position.w; |
michael@0 | 134 | outp.vPosition = outp.vPosition - vRenderTargetOffset; |
michael@0 | 135 | outp.vPosition.xyz *= outp.vPosition.w; |
michael@0 | 136 | |
michael@0 | 137 | // adjust our vertices to match d3d9's pixel coordinate system |
michael@0 | 138 | // which has pixel centers at integer locations |
michael@0 | 139 | outp.vPosition.xy -= 0.5; |
michael@0 | 140 | |
michael@0 | 141 | outp.vPosition = mul(mProjection, outp.vPosition); |
michael@0 | 142 | |
michael@0 | 143 | // calculate the position on the mask texture |
michael@0 | 144 | position.xyz /= position.w; |
michael@0 | 145 | outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z; |
michael@0 | 146 | outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w; |
michael@0 | 147 | // correct for perspective correct interpolation, see comment in D3D10 shader |
michael@0 | 148 | outp.vMaskCoords.z = 1; |
michael@0 | 149 | outp.vMaskCoords *= position.w; |
michael@0 | 150 | |
michael@0 | 151 | size = vTextureCoords.zw; |
michael@0 | 152 | outp.vTexCoords.x = vTextureCoords.x + aVertex.vPosition.x * size.x; |
michael@0 | 153 | outp.vTexCoords.y = vTextureCoords.y + aVertex.vPosition.y * size.y; |
michael@0 | 154 | |
michael@0 | 155 | return outp; |
michael@0 | 156 | } |
michael@0 | 157 | |
michael@0 | 158 | float4 ComponentPass1Shader(const VS_OUTPUT aVertex) : COLOR |
michael@0 | 159 | { |
michael@0 | 160 | float4 src = tex2D(s2D, aVertex.vTexCoords); |
michael@0 | 161 | float4 alphas = 1.0 - tex2D(s2DWhite, aVertex.vTexCoords) + src; |
michael@0 | 162 | alphas.a = alphas.g; |
michael@0 | 163 | return alphas * fLayerOpacity; |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | float4 ComponentPass2Shader(const VS_OUTPUT aVertex) : COLOR |
michael@0 | 167 | { |
michael@0 | 168 | float4 src = tex2D(s2D, aVertex.vTexCoords); |
michael@0 | 169 | float4 alphas = 1.0 - tex2D(s2DWhite, aVertex.vTexCoords) + src; |
michael@0 | 170 | src.a = alphas.g; |
michael@0 | 171 | return src * fLayerOpacity; |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | float4 RGBAShader(const VS_OUTPUT aVertex) : COLOR |
michael@0 | 175 | { |
michael@0 | 176 | return tex2D(s2D, aVertex.vTexCoords) * fLayerOpacity; |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | float4 RGBShader(const VS_OUTPUT aVertex) : COLOR |
michael@0 | 180 | { |
michael@0 | 181 | float4 result; |
michael@0 | 182 | result = tex2D(s2D, aVertex.vTexCoords); |
michael@0 | 183 | result.a = 1.0; |
michael@0 | 184 | return result * fLayerOpacity; |
michael@0 | 185 | } |
michael@0 | 186 | |
michael@0 | 187 | float4 YCbCrShader(const VS_OUTPUT aVertex) : COLOR |
michael@0 | 188 | { |
michael@0 | 189 | float4 yuv; |
michael@0 | 190 | float4 color; |
michael@0 | 191 | |
michael@0 | 192 | yuv.r = tex2D(s2DCr, aVertex.vTexCoords).a - 0.5; |
michael@0 | 193 | yuv.g = tex2D(s2DY, aVertex.vTexCoords).a - 0.0625; |
michael@0 | 194 | yuv.b = tex2D(s2DCb, aVertex.vTexCoords).a - 0.5; |
michael@0 | 195 | |
michael@0 | 196 | color.r = yuv.g * 1.164 + yuv.r * 1.596; |
michael@0 | 197 | color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b; |
michael@0 | 198 | color.b = yuv.g * 1.164 + yuv.b * 2.018; |
michael@0 | 199 | color.a = 1.0f; |
michael@0 | 200 | |
michael@0 | 201 | return color * fLayerOpacity; |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | float4 SolidColorShader(const VS_OUTPUT aVertex) : COLOR |
michael@0 | 205 | { |
michael@0 | 206 | return fLayerColor; |
michael@0 | 207 | } |
michael@0 | 208 | |
michael@0 | 209 | float4 ComponentPass1ShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR |
michael@0 | 210 | { |
michael@0 | 211 | float4 src = tex2D(s2D, aVertex.vTexCoords); |
michael@0 | 212 | float4 alphas = 1.0 - tex2D(s2DWhite, aVertex.vTexCoords) + src; |
michael@0 | 213 | alphas.a = alphas.g; |
michael@0 | 214 | float2 maskCoords = aVertex.vMaskCoords; |
michael@0 | 215 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 216 | return alphas * fLayerOpacity * mask; |
michael@0 | 217 | } |
michael@0 | 218 | |
michael@0 | 219 | float4 ComponentPass2ShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR |
michael@0 | 220 | { |
michael@0 | 221 | float4 src = tex2D(s2D, aVertex.vTexCoords); |
michael@0 | 222 | float4 alphas = 1.0 - tex2D(s2DWhite, aVertex.vTexCoords) + src; |
michael@0 | 223 | src.a = alphas.g; |
michael@0 | 224 | float2 maskCoords = aVertex.vMaskCoords; |
michael@0 | 225 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 226 | return src * fLayerOpacity * mask; |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 | float4 RGBAShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR |
michael@0 | 230 | { |
michael@0 | 231 | float2 maskCoords = aVertex.vMaskCoords; |
michael@0 | 232 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 233 | return tex2D(s2D, aVertex.vTexCoords) * fLayerOpacity * mask; |
michael@0 | 234 | } |
michael@0 | 235 | |
michael@0 | 236 | float4 RGBAShaderMask3D(const VS_OUTPUT_MASK_3D aVertex) : COLOR |
michael@0 | 237 | { |
michael@0 | 238 | float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z; |
michael@0 | 239 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 240 | return tex2D(s2D, aVertex.vTexCoords) * fLayerOpacity * mask; |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | float4 RGBShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR |
michael@0 | 244 | { |
michael@0 | 245 | float4 result; |
michael@0 | 246 | result = tex2D(s2D, aVertex.vTexCoords); |
michael@0 | 247 | result.a = 1.0; |
michael@0 | 248 | float2 maskCoords = aVertex.vMaskCoords; |
michael@0 | 249 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 250 | return result * fLayerOpacity * mask; |
michael@0 | 251 | } |
michael@0 | 252 | |
michael@0 | 253 | float4 YCbCrShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR |
michael@0 | 254 | { |
michael@0 | 255 | float4 yuv; |
michael@0 | 256 | float4 color; |
michael@0 | 257 | |
michael@0 | 258 | yuv.r = tex2D(s2DCr, aVertex.vTexCoords).a - 0.5; |
michael@0 | 259 | yuv.g = tex2D(s2DY, aVertex.vTexCoords).a - 0.0625; |
michael@0 | 260 | yuv.b = tex2D(s2DCb, aVertex.vTexCoords).a - 0.5; |
michael@0 | 261 | |
michael@0 | 262 | color.r = yuv.g * 1.164 + yuv.r * 1.596; |
michael@0 | 263 | color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b; |
michael@0 | 264 | color.b = yuv.g * 1.164 + yuv.b * 2.018; |
michael@0 | 265 | color.a = 1.0f; |
michael@0 | 266 | |
michael@0 | 267 | float2 maskCoords = aVertex.vMaskCoords; |
michael@0 | 268 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 269 | return color * fLayerOpacity * mask; |
michael@0 | 270 | } |
michael@0 | 271 | |
michael@0 | 272 | float4 SolidColorShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR |
michael@0 | 273 | { |
michael@0 | 274 | float2 maskCoords = aVertex.vMaskCoords; |
michael@0 | 275 | float mask = tex2D(s2DMask, maskCoords).a; |
michael@0 | 276 | return fLayerColor * mask; |
michael@0 | 277 | } |