# all files / ol/render/webgl/circlereplay/ defaultshader.js

100% Statements 31/31
50% Branches 14/28
100% Functions 3/3
100% Lines 31/31

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163

    1×

    1×
    1×
    1×

    1×
    1×

    1×

    1×

    1×

    1×

    1×

    1×
    1×

    1×

    1×

    1×

    1×

    1×

    1×

    4×

    4×

    4×

    4×

    4×

    4×

    4×

    4×

    4×

    4×

    4×

    4×

     // This file is automatically generated, do not edit
    /* eslint openlayers-internal/no-missing-requires: 0 */
    goog.provide('ol.render.webgl.circlereplay.defaultshader');

    goog.require('ol');
    goog.require('ol.webgl.Fragment');
    goog.require('ol.webgl.Vertex');

    /**
     * @constructor
     * @extends {ol.webgl.Fragment}
     * @struct
     */
    ol.render.webgl.circlereplay.defaultshader.Fragment = function() {
      ol.webgl.Fragment.call(this, ol.render.webgl.circlereplay.defaultshader.Fragment.SOURCE);
    };
    ol.inherits(ol.render.webgl.circlereplay.defaultshader.Fragment, ol.webgl.Fragment);

    /**
     * @const
     * @type {string}
     */
    ol.render.webgl.circlereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_fillColor;\nuniform vec4 u_strokeColor;\nuniform vec2 u_size;\n\nvoid main(void) {\n  vec2 windowCenter = vec2((v_center.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n      (v_center.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n  vec2 windowOffset = vec2((v_offset.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n      (v_offset.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n  float radius = length(windowCenter - windowOffset);\n  float dist = length(windowCenter - gl_FragCoord.xy);\n  if (dist > radius + v_halfWidth) {\n    if (u_strokeColor.a == 0.0) {\n      gl_FragColor = u_fillColor;\n    } else {\n      gl_FragColor = u_strokeColor;\n    }\n    gl_FragColor.a = gl_FragColor.a - (dist - (radius + v_halfWidth));\n  } else if (u_fillColor.a == 0.0) {\n    // Hooray, no fill, just stroke. We can use real antialiasing.\n    gl_FragColor = u_strokeColor;\n    if (dist < radius - v_halfWidth) {\n      gl_FragColor.a = gl_FragColor.a - (radius - v_halfWidth - dist);\n    }\n  } else {\n    gl_FragColor = u_fillColor;\n    float strokeDist = radius - v_halfWidth;\n    float antialias = 2.0 * v_pixelRatio;\n    if (dist > strokeDist) {\n      gl_FragColor = u_strokeColor;\n    } else if (dist >= strokeDist - antialias) {\n      float step = smoothstep(strokeDist - antialias, strokeDist, dist);\n      gl_FragColor = mix(u_fillColor, u_strokeColor, step);\n    }\n  }\n  gl_FragColor.a = gl_FragColor.a * u_opacity;\n  if (gl_FragColor.a <= 0.0) {\n    discard;\n  }\n}\n';

    /**
     * @const
     * @type {string}
     */
    ol.render.webgl.circlereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying vec2 b;varying float c;varying float d;uniform float m;uniform vec4 n;uniform vec4 o;uniform vec2 p;void main(void){vec2 windowCenter=vec2((a.x+1.0)/2.0*p.x*d,(a.y+1.0)/2.0*p.y*d);vec2 windowOffset=vec2((b.x+1.0)/2.0*p.x*d,(b.y+1.0)/2.0*p.y*d);float radius=length(windowCenter-windowOffset);float dist=length(windowCenter-gl_FragCoord.xy);if(dist>radius+c){if(o.a==0.0){gl_FragColor=n;}else{gl_FragColor=o;}gl_FragColor.a=gl_FragColor.a-(dist-(radius+c));}else if(n.a==0.0){gl_FragColor=o;if(dist<radius-c){gl_FragColor.a=gl_FragColor.a-(radius-c-dist);}} else{gl_FragColor=n;float strokeDist=radius-c;float antialias=2.0*d;if(dist>strokeDist){gl_FragColor=o;}else if(dist>=strokeDist-antialias){float step=smoothstep(strokeDist-antialias,strokeDist,dist);gl_FragColor=mix(n,o,step);}} gl_FragColor.a=gl_FragColor.a*m;if(gl_FragColor.a<=0.0){discard;}}';

    /**
     * @const
     * @type {string}
     */
    ol.render.webgl.circlereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
      ol.render.webgl.circlereplay.defaultshader.Fragment.DEBUG_SOURCE :
      ol.render.webgl.circlereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;

    ol.render.webgl.circlereplay.defaultshader.fragment = new ol.render.webgl.circlereplay.defaultshader.Fragment();

    /**
     * @constructor
     * @extends {ol.webgl.Vertex}
     * @struct
     */
    ol.render.webgl.circlereplay.defaultshader.Vertex = function() {
      ol.webgl.Vertex.call(this, ol.render.webgl.circlereplay.defaultshader.Vertex.SOURCE);
    };
    ol.inherits(ol.render.webgl.circlereplay.defaultshader.Vertex, ol.webgl.Vertex);

    /**
     * @const
     * @type {string}
     */
    ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n  mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n  v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n  v_pixelRatio = u_pixelRatio;\n  float lineWidth = u_lineWidth * u_pixelRatio;\n  v_halfWidth = lineWidth / 2.0;\n  if (lineWidth == 0.0) {\n    lineWidth = 2.0 * u_pixelRatio;\n  }\n  vec2 offset;\n  // Radius with anitaliasing (roughly).\n  float radius = a_radius + 3.0 * u_pixelRatio;\n  // Until we get gl_VertexID in WebGL, we store an instruction.\n  if (a_instruction == 0.0) {\n    // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n    // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n    offset = vec2(-1.0, 1.0);\n  } else if (a_instruction == 1.0) {\n    offset = vec2(-1.0, -1.0);\n  } else if (a_instruction == 2.0) {\n    offset = vec2(1.0, -1.0);\n  } else {\n    offset = vec2(1.0, 1.0);\n  }\n\n  gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n      offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n  v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n      0.0, 1.0)).xy;\n\n  if (distance(v_center, v_offset) > 20000.0) {\n    gl_Position = vec4(v_center, 0.0, 1.0);\n  }\n}\n\n\n';

    /**
     * @const
     * @type {string}
     */
    ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;if(f==0.0){offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}';

    /**
     * @const
     * @type {string}
     */
    ol.render.webgl.circlereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
      ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE :
      ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;

    ol.render.webgl.circlereplay.defaultshader.vertex = new ol.render.webgl.circlereplay.defaultshader.Vertex();

    /**
     * @constructor
     * @param {WebGLRenderingContext} gl GL.
     * @param {WebGLProgram} program Program.
     * @struct
     */
    ol.render.webgl.circlereplay.defaultshader.Locations = function(gl, program) {

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_fillColor = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_fillColor' : 'n');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_lineWidth = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_lineWidth' : 'k');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_offsetRotateMatrix = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_offsetScaleMatrix = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_opacity = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_opacity' : 'm');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_pixelRatio = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_pixelRatio' : 'l');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_projectionMatrix = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_size = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_size' : 'p');

      /**
       * @type {WebGLUniformLocation}
       */
      this.u_strokeColor = gl.getUniformLocation(
          program, ol.DEBUG_WEBGL ? 'u_strokeColor' : 'o');

      /**
       * @type {number}
       */
      this.a_instruction = gl.getAttribLocation(
          program, ol.DEBUG_WEBGL ? 'a_instruction' : 'f');

      /**
       * @type {number}
       */
      this.a_position = gl.getAttribLocation(
          program, ol.DEBUG_WEBGL ? 'a_position' : 'e');

      /**
       * @type {number}
       */
      this.a_radius = gl.getAttribLocation(
          program, ol.DEBUG_WEBGL ? 'a_radius' : 'g');
    };