gfx/skia/trunk/src/gpu/gl/GrGLSL.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial