diff --git a/packages/tests/all.test.js b/packages/tests/all.test.js
index bde6bc6..9260d9e 100755
--- a/packages/tests/all.test.js
+++ b/packages/tests/all.test.js
@@ -1687,6 +1687,85 @@ test("Node `backbuffering` in `sync`", () => {
inst.unmount();
});
+test("Node `backbuffering` with Uniform.backbufferFrom", () => {
+ const shaders = Shaders.create({
+ colorShift: {
+ frag: GLSL`
+ precision highp float;
+ varying vec2 uv;
+ uniform sampler2D t;
+ void main() {
+ vec4 c = texture2D(t, uv);
+ gl_FragColor = vec4(c.b, c.r, c.g, c.a); // shifting the rgb components
+ }`
+ },
+ darken: {
+ frag: GLSL`
+ precision highp float;
+ varying vec2 uv;
+ uniform sampler2D t;
+ uniform float m;
+ void main() {
+ gl_FragColor = m * texture2D(t, uv);
+ }`
+ }
+ });
+ class Darken extends React.Component {
+ render() {
+ const { children: t } = this.props;
+ return ;
+ }
+ }
+ class Effect extends React.Component {
+ getMainBuffer = () => {
+ const { main } = this.refs;
+ return main ? Uniform.backbufferFrom(main.getNodeRef()) : null;
+ };
+ render() {
+ const { initWithImage } = this.props;
+ return (
+
+
+
+
+
+
+
+
+
+ );
+ }
+ }
+
+ const inst = create();
+ const surface = inst.getInstance().refs.surface;
+
+ for (let i = 1; i <= 6; i++) {
+ const val = Math.round(255 * Math.pow(0.8, i)); // Darken effect will multiply the color by 0.8 each draw time
+ const expected = [0, 0, 0, val];
+ expected[i % 3] = val; // the colorShift will shift the r,g,b components with the color val
+ expectToBeCloseToColorArray(
+ surface.capture(0, 0, 1, 1).data,
+ new Uint8Array(expected)
+ );
+ inst.update();
+ surface.flush();
+ }
+
+ surface.glView.simulateContextLost();
+ inst.unmount();
+});
+
test("texture can be null", () => {
const shaders = Shaders.create({
helloTexture: {
diff --git a/packages/tests/flow/snapshot.txt b/packages/tests/flow/snapshot.txt
index 96c9a3c..a15dbcb 100644
--- a/packages/tests/flow/snapshot.txt
+++ b/packages/tests/flow/snapshot.txt
@@ -1,25 +1,25 @@
-../all.test.js:2572
+../all.test.js:2651
v----
-2572: }}
-2576: />
+2651: }}
+2655: />
-^ props of React element `Node`
-2574: uniformsOptions={{ t: { interpolation: "nope" } }}
+2653: uniformsOptions={{ t: { interpolation: "nope" } }}
^^^^^^ string. This type is incompatible with
65: interpolation: Interpolation,
^^^^^^^^^^^^^ string enum. See: ../node_modules/gl-react/lib/Node.js.flow:65
-../all.test.js:2584
+../all.test.js:2663
v----
-2584: }}
-2588: />
+2663: }}
+2667: />
-^ props of React element `Node`
-2586: uniformsOptions={{ t: { wrap: "nope" } }}
+2665: uniformsOptions={{ t: { wrap: "nope" } }}
^^^^^^ string. This type is incompatible with
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ union: tuple type | WrapMode. See: ../node_modules/gl-react/lib/Node.js.flow:66
@@ -27,7 +27,7 @@
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^^^^^^^^^^^^^ tuple type. See: ../node_modules/gl-react/lib/Node.js.flow:66
Error:
- 2586: uniformsOptions={{ t: { wrap: "nope" } }}
+ 2665: uniformsOptions={{ t: { wrap: "nope" } }}
^^^^^^ string. This type is incompatible with
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^^^^^^^^^^^^^ tuple type. See: ../node_modules/gl-react/lib/Node.js.flow:66
@@ -35,20 +35,20 @@
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^ WrapMode. See: ../node_modules/gl-react/lib/Node.js.flow:66
Error:
- 2586: uniformsOptions={{ t: { wrap: "nope" } }}
+ 2665: uniformsOptions={{ t: { wrap: "nope" } }}
^^^^^^ string. This type is incompatible with
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^ string enum. See: ../node_modules/gl-react/lib/Node.js.flow:66
-../all.test.js:2596
+../all.test.js:2675
v----
-2596: }}
-2600: />
+2675: }}
+2679: />
-^ props of React element `Node`
-2598: uniformsOptions={{ t: { wrap: ["nope", "nope"] } }}
+2677: uniformsOptions={{ t: { wrap: ["nope", "nope"] } }}
^^^^^^^^^^^^^^^^ array literal. This type is incompatible with
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ union: tuple type | WrapMode. See: ../node_modules/gl-react/lib/Node.js.flow:66
@@ -56,7 +56,7 @@
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^^^^^^^^^^^^^ tuple type. See: ../node_modules/gl-react/lib/Node.js.flow:66
Error:
- 2598: uniformsOptions={{ t: { wrap: ["nope", "nope"] } }}
+ 2677: uniformsOptions={{ t: { wrap: ["nope", "nope"] } }}
^^^^^^ string. This type is incompatible with
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^ string enum. See: ../node_modules/gl-react/lib/Node.js.flow:66
@@ -64,20 +64,20 @@
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^ WrapMode. See: ../node_modules/gl-react/lib/Node.js.flow:66
Error:
- 2598: uniformsOptions={{ t: { wrap: ["nope", "nope"] } }}
+ 2677: uniformsOptions={{ t: { wrap: ["nope", "nope"] } }}
^^^^^^^^^^^^^^^^ array literal. This type is incompatible with
66: wrap: [WrapMode, WrapMode] | WrapMode
^^^^^^^^ string enum. See: ../node_modules/gl-react/lib/Node.js.flow:66
-../all.test.js:2608
+../all.test.js:2687
v----
-2608: }}
-2612: />
+2687: }}
+2691: />
-^ props of React element `Node`
-2609: blendFunc="nope"
+2688: blendFunc="nope"
^^^^^^ string. Inexact type is incompatible with exact type
177: blendFunc: BlendFuncSrcDst,
^^^^^^^^^^^^^^^ exact type: object type. See: ../node_modules/gl-react/lib/Node.js.flow:177