Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Sign In

uber / deck.gl / 13127

29 Aug 2019 - 17:33 coverage increased (+2.5%) to 83.552%
13127

Pull #3507

travis-ci-com

9181eb84f9c35729a3bad740fb7f9d93?size=18&default=identiconweb-flow
update the component-wrapping-rfc.md
Pull Request #3507: update the component-wrapping-rfc.md

3393 of 4570 branches covered (74.25%)

Branch coverage included in aggregate %.

7066 of 7948 relevant lines covered (88.9%)

3403.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.87
/modules/core/src/effects/post-process-effect.js
1
import Effect from '../lib/effect';
2
import ScreenPass from '../passes/screen-pass';
3
/* eslint-disable import/no-extraneous-dependencies */
4
import {normalizeShaderModule} from '@luma.gl/shadertools';
5

6
export default class PostProcessEffect extends Effect {
7
  constructor(module, props = {}) {
8
    super(props);
1×
9
    this.id = `${module.name}-pass`;
1×
10
    normalizeShaderModule(module);
14×
11
    this.module = module;
1×
12
  }
13

14
  prepare(gl) {
15
    if (!this.passes) {
Branches [[1, 1]] missed. 1×
16
      this.passes = createPasses(gl, this.module, this.id, this.props);
1×
17
    }
18
  }
19

20
  render(params) {
21
    const {target = null} = params;
3×
22
    let switchBuffer = false;
1×
23
    for (let index = 0; index < this.passes.length; index++) {
5×
24
      const inputBuffer = switchBuffer ? params.outputBuffer : params.inputBuffer;
Branches [[3, 0]] missed. 5×
25
      let outputBuffer = switchBuffer ? params.inputBuffer : params.outputBuffer;
Branches [[4, 0]] missed. 5×
26
      if (target && index === this.passes.length - 1) {
5×
27
        outputBuffer = target;
4×
28
      }
29
      this.passes[index].render({inputBuffer, outputBuffer});
4×
30
      switchBuffer = !switchBuffer;
2×
31
    }
32
    return {
2×
33
      inputBuffer: switchBuffer ? params.outputBuffer : params.inputBuffer,
Branches [[7, 1]] missed.
34
      outputBuffer: switchBuffer ? params.inputBuffer : params.outputBuffer
Branches [[8, 1]] missed.
35
    };
36
  }
37

38
  cleanup() {
39
    if (this.passes) {
2×
40
      for (const pass of this.passes) {
2×
41
        pass.delete();
2×
42
      }
43
      this.passes = null;
2×
44
    }
45
  }
46
}
47

48
function createPasses(gl, module, id, moduleProps) {
49
  if (module.filter || module.sampler) {
Branches [[10, 0]] missed. 2×
50
    const fs = getFragmentShaderForRenderPass(module);
1×
51
    const pass = new ScreenPass(gl, {
2×
52
      id,
53
      module,
54
      fs,
55
      moduleProps
56
    });
57
    return [pass];
2×
58
  }
59

60
  const passes = module.passes || [];
Branches [[12, 1]] missed. 2×
61
  return passes.map((pass, index) => {
6×
62
    const fs = getFragmentShaderForRenderPass(module, pass);
4×
63
    const idn = `${id}-${index}`;
4×
64

65
    return new ScreenPass(gl, {
4×
66
      id: idn,
67
      module,
68
      fs,
69
      moduleProps
70
    });
71
  });
72
}
73

74
const FILTER_FS_TEMPLATE = func => `\
4×
75
uniform sampler2D texture;
76
uniform vec2 texSize;
77

78
varying vec2 position;
79
varying vec2 coordinate;
80
varying vec2 uv;
81

82
void main() {
83
  vec2 texCoord = coordinate;
84

85
  gl_FragColor = texture2D(texture, texCoord);
86
  gl_FragColor = ${func}(gl_FragColor, texSize, texCoord);
87
}
88
`;
89

UNCOV
90
const SAMPLER_FS_TEMPLATE = func => `\
!
91
uniform sampler2D texture;
92
uniform vec2 texSize;
93

94
varying vec2 position;
95
varying vec2 coordinate;
96
varying vec2 uv;
97

98
void main() {
99
  vec2 texCoord = coordinate;
100

101
  gl_FragColor = ${func}(texture, texSize, texCoord);
102
}
103
`;
104

105
function getFragmentShaderForRenderPass(module, pass = module) {
Branches [[13, 0]] missed.
106
  if (pass.filter) {
Branches [[14, 0]] missed. 4×
107
    const func = typeof pass.filter === 'string' ? pass.filter : `${module.name}_filterColor`;
Branches [[15, 0], [15, 1]] missed. 4×
108
    return FILTER_FS_TEMPLATE(func);
4×
109
  }
110

111
  if (pass.sampler) {
Branches [[16, 1]] missed. 4×
112
    const func = typeof pass.sampler === 'string' ? pass.sampler : `${module.name}_sampleColor`;
Branches [[17, 0]] missed. 4×
113
    return SAMPLER_FS_TEMPLATE(func);
1×
114
  }
115

116
  // console.error(`${module.name} no fragment shader generated`);
117
  return null;
!
118
}
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
BLOG · TWITTER · Legal & Privacy · Supported CI Services · What's a CI service? · Automated Testing

© 2019 Coveralls, LLC