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 (c) 2012 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | // Contains analysis utilities for dealing with HLSL's lack of support for |
michael@0 | 7 | // the use of intrinsic functions which (implicitly or explicitly) compute |
michael@0 | 8 | // gradients of functions with discontinuities. |
michael@0 | 9 | // |
michael@0 | 10 | |
michael@0 | 11 | #include "compiler/DetectDiscontinuity.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "compiler/ParseHelper.h" |
michael@0 | 14 | |
michael@0 | 15 | namespace sh |
michael@0 | 16 | { |
michael@0 | 17 | bool DetectLoopDiscontinuity::traverse(TIntermNode *node) |
michael@0 | 18 | { |
michael@0 | 19 | mLoopDepth = 0; |
michael@0 | 20 | mLoopDiscontinuity = false; |
michael@0 | 21 | node->traverse(this); |
michael@0 | 22 | return mLoopDiscontinuity; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | bool DetectLoopDiscontinuity::visitLoop(Visit visit, TIntermLoop *loop) |
michael@0 | 26 | { |
michael@0 | 27 | if (visit == PreVisit) |
michael@0 | 28 | { |
michael@0 | 29 | ++mLoopDepth; |
michael@0 | 30 | } |
michael@0 | 31 | else if (visit == PostVisit) |
michael@0 | 32 | { |
michael@0 | 33 | --mLoopDepth; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | return true; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | bool DetectLoopDiscontinuity::visitBranch(Visit visit, TIntermBranch *node) |
michael@0 | 40 | { |
michael@0 | 41 | if (mLoopDiscontinuity) |
michael@0 | 42 | { |
michael@0 | 43 | return false; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | if (!mLoopDepth) |
michael@0 | 47 | { |
michael@0 | 48 | return true; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | switch (node->getFlowOp()) |
michael@0 | 52 | { |
michael@0 | 53 | case EOpKill: |
michael@0 | 54 | break; |
michael@0 | 55 | case EOpBreak: |
michael@0 | 56 | case EOpContinue: |
michael@0 | 57 | case EOpReturn: |
michael@0 | 58 | mLoopDiscontinuity = true; |
michael@0 | 59 | break; |
michael@0 | 60 | default: UNREACHABLE(); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | return !mLoopDiscontinuity; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | bool DetectLoopDiscontinuity::visitAggregate(Visit visit, TIntermAggregate *node) |
michael@0 | 67 | { |
michael@0 | 68 | return !mLoopDiscontinuity; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | bool containsLoopDiscontinuity(TIntermNode *node) |
michael@0 | 72 | { |
michael@0 | 73 | DetectLoopDiscontinuity detectLoopDiscontinuity; |
michael@0 | 74 | return detectLoopDiscontinuity.traverse(node); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | bool DetectGradientOperation::traverse(TIntermNode *node) |
michael@0 | 78 | { |
michael@0 | 79 | mGradientOperation = false; |
michael@0 | 80 | node->traverse(this); |
michael@0 | 81 | return mGradientOperation; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | bool DetectGradientOperation::visitUnary(Visit visit, TIntermUnary *node) |
michael@0 | 85 | { |
michael@0 | 86 | if (mGradientOperation) |
michael@0 | 87 | { |
michael@0 | 88 | return false; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | switch (node->getOp()) |
michael@0 | 92 | { |
michael@0 | 93 | case EOpDFdx: |
michael@0 | 94 | case EOpDFdy: |
michael@0 | 95 | mGradientOperation = true; |
michael@0 | 96 | default: |
michael@0 | 97 | break; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | return !mGradientOperation; |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | bool DetectGradientOperation::visitAggregate(Visit visit, TIntermAggregate *node) |
michael@0 | 104 | { |
michael@0 | 105 | if (mGradientOperation) |
michael@0 | 106 | { |
michael@0 | 107 | return false; |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | if (node->getOp() == EOpFunctionCall) |
michael@0 | 111 | { |
michael@0 | 112 | if (!node->isUserDefined()) |
michael@0 | 113 | { |
michael@0 | 114 | TString name = TFunction::unmangleName(node->getName()); |
michael@0 | 115 | |
michael@0 | 116 | if (name == "texture2D" || |
michael@0 | 117 | name == "texture2DProj" || |
michael@0 | 118 | name == "textureCube") |
michael@0 | 119 | { |
michael@0 | 120 | mGradientOperation = true; |
michael@0 | 121 | } |
michael@0 | 122 | } |
michael@0 | 123 | else |
michael@0 | 124 | { |
michael@0 | 125 | // When a user defined function is called, we have to |
michael@0 | 126 | // conservatively assume it to contain gradient operations |
michael@0 | 127 | mGradientOperation = true; |
michael@0 | 128 | } |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | return !mGradientOperation; |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | bool containsGradientOperation(TIntermNode *node) |
michael@0 | 135 | { |
michael@0 | 136 | DetectGradientOperation detectGradientOperation; |
michael@0 | 137 | return detectGradientOperation.traverse(node); |
michael@0 | 138 | } |
michael@0 | 139 | } |