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 2011 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 | #include "GrGLSL.h" |
michael@0 | 9 | #include "GrGLShaderVar.h" |
michael@0 | 10 | #include "SkString.h" |
michael@0 | 11 | |
michael@0 | 12 | GrGLSLGeneration GrGetGLSLGeneration(const GrGLInterface* gl) { |
michael@0 | 13 | GrGLSLVersion ver = GrGLGetGLSLVersion(gl); |
michael@0 | 14 | switch (gl->fStandard) { |
michael@0 | 15 | case kGL_GrGLStandard: |
michael@0 | 16 | SkASSERT(ver >= GR_GLSL_VER(1,10)); |
michael@0 | 17 | if (ver >= GR_GLSL_VER(1,50)) { |
michael@0 | 18 | return k150_GrGLSLGeneration; |
michael@0 | 19 | } else if (ver >= GR_GLSL_VER(1,40)) { |
michael@0 | 20 | return k140_GrGLSLGeneration; |
michael@0 | 21 | } else if (ver >= GR_GLSL_VER(1,30)) { |
michael@0 | 22 | return k130_GrGLSLGeneration; |
michael@0 | 23 | } else { |
michael@0 | 24 | return k110_GrGLSLGeneration; |
michael@0 | 25 | } |
michael@0 | 26 | case kGLES_GrGLStandard: |
michael@0 | 27 | // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL |
michael@0 | 28 | SkASSERT(ver >= GR_GL_VER(1,00)); |
michael@0 | 29 | return k110_GrGLSLGeneration; |
michael@0 | 30 | default: |
michael@0 | 31 | GrCrash("Unknown GL Standard"); |
michael@0 | 32 | return k110_GrGLSLGeneration; // suppress warning |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { |
michael@0 | 37 | switch (info.glslGeneration()) { |
michael@0 | 38 | case k110_GrGLSLGeneration: |
michael@0 | 39 | if (kGLES_GrGLStandard == info.standard()) { |
michael@0 | 40 | // ES2s shader language is based on version 1.20 but is version |
michael@0 | 41 | // 1.00 of the ES language. |
michael@0 | 42 | return "#version 100\n"; |
michael@0 | 43 | } else { |
michael@0 | 44 | SkASSERT(kGL_GrGLStandard == info.standard()); |
michael@0 | 45 | return "#version 110\n"; |
michael@0 | 46 | } |
michael@0 | 47 | case k130_GrGLSLGeneration: |
michael@0 | 48 | SkASSERT(kGL_GrGLStandard == info.standard()); |
michael@0 | 49 | return "#version 130\n"; |
michael@0 | 50 | case k140_GrGLSLGeneration: |
michael@0 | 51 | SkASSERT(kGL_GrGLStandard == info.standard()); |
michael@0 | 52 | return "#version 140\n"; |
michael@0 | 53 | case k150_GrGLSLGeneration: |
michael@0 | 54 | SkASSERT(kGL_GrGLStandard == info.standard()); |
michael@0 | 55 | if (info.caps()->isCoreProfile()) { |
michael@0 | 56 | return "#version 150\n"; |
michael@0 | 57 | } else { |
michael@0 | 58 | return "#version 150 compatibility\n"; |
michael@0 | 59 | } |
michael@0 | 60 | default: |
michael@0 | 61 | GrCrash("Unknown GL version."); |
michael@0 | 62 | return ""; // suppress warning |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | namespace { |
michael@0 | 67 | void append_tabs(SkString* outAppend, int tabCnt) { |
michael@0 | 68 | static const char kTabs[] = "\t\t\t\t\t\t\t\t"; |
michael@0 | 69 | while (tabCnt) { |
michael@0 | 70 | int cnt = GrMin((int)GR_ARRAY_COUNT(kTabs), tabCnt); |
michael@0 | 71 | outAppend->append(kTabs, cnt); |
michael@0 | 72 | tabCnt -= cnt; |
michael@0 | 73 | } |
michael@0 | 74 | } |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | void GrGLSLMulVarBy4f(SkString* outAppend, |
michael@0 | 78 | unsigned tabCnt, |
michael@0 | 79 | const char* vec4VarName, |
michael@0 | 80 | const GrGLSLExpr4& mulFactor) { |
michael@0 | 81 | if (mulFactor.isOnes()) { |
michael@0 | 82 | *outAppend = SkString(); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | append_tabs(outAppend, tabCnt); |
michael@0 | 86 | |
michael@0 | 87 | if (mulFactor.isZeros()) { |
michael@0 | 88 | outAppend->appendf("%s = vec4(0);\n", vec4VarName); |
michael@0 | 89 | } else { |
michael@0 | 90 | outAppend->appendf("%s *= %s;\n", vec4VarName, mulFactor.c_str()); |
michael@0 | 91 | } |
michael@0 | 92 | } |