Commit 0b584162 authored by Gaëtan Renaudeau's avatar Gaëtan Renaudeau

Merge branch '2.18.0'

parents 5669c7e1 5a5fccf5
...@@ -11,23 +11,20 @@ uniform vec2 direction; ...@@ -11,23 +11,20 @@ uniform vec2 direction;
uniform vec2 resolution; uniform vec2 resolution;
// from https://github.com/Jam3/glsl-fast-gaussian-blur // from https://github.com/Jam3/glsl-fast-gaussian-blur
vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) { vec4 blur9(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
vec2 off1 = vec2(1.411764705882353) * direction; vec2 off1 = vec2(1.3846153846) * direction;
vec2 off2 = vec2(3.2941176470588234) * direction; vec2 off2 = vec2(3.2307692308) * direction;
vec2 off3 = vec2(5.176470588235294) * direction; color += texture2D(image, uv) * 0.2270270270;
color += texture2D(image, uv) * 0.1964825501511404; color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344; color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344; color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732; color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;
color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;
color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;
return color; return color;
} }
void main () { void main () {
gl_FragColor = blur13(t, uv, resolution, direction); gl_FragColor = blur9(t, uv, resolution, direction);
} }
` `
} }
......
...@@ -256,25 +256,20 @@ class Simple extends Component { ...@@ -256,25 +256,20 @@ class Simple extends Component {
width={256} width={256}
height={160} height={160}
factor={factor}> factor={factor}>
<Blur <View style={{ width: 256, height: 160, padding: 10, backgroundColor: "#f9f9f9" }}>
width={256} <Slider
height={160} style={{ height: 80 }}
factor={factor/2}> max={1}
<View style={{ width: 256, height: 160, padding: 10, backgroundColor: "#f9f9f9" }}> onChange={factor => this.setState({ factor })}
<Slider />
style={{ height: 80 }} <View style={{ height: 60, flexDirection: "row", alignItems: "center" }}>
max={2} <Switch style={{flex:1}} checked={switch1} onCheckedChange={({checked:switch1}) => this.setState({ switch1 })} />
onChange={factor => this.setState({ factor })} <Switch style={{flex:1}} checked={switch2} onCheckedChange={({checked:switch2}) => this.setState({ switch2 })} />
/> <Switch style={{flex:1}} checked={switch3} onCheckedChange={({checked:switch3}) => this.setState({ switch3 })} />
<View style={{ height: 60, flexDirection: "row", alignItems: "center" }}> </View>
<Switch style={{flex:1}} checked={switch1} onCheckedChange={({checked:switch1}) => this.setState({ switch1 })} /> <Progress progress={factor} style={{height: 10, marginTop: 8, flex:1}} />
<Switch style={{flex:1}} checked={switch2} onCheckedChange={({checked:switch2}) => this.setState({ switch2 })} />
<Switch style={{flex:1}} checked={switch3} onCheckedChange={({checked:switch3}) => this.setState({ switch3 })} />
</View>
<Progress progress={factor} style={{height: 10, marginTop: 8, flex:1}} />
</View> </View>
</Blur>
</Blur> </Blur>
</HueRotate> </HueRotate>
</Surface> </Surface>
......
#import "RCTBridge.h" #import "RCTBridge.h"
#import "RCTUtils.h" #import "RCTUtils.h"
#import "RCTConvert.h" #import "RCTConvert.h"
...@@ -492,6 +491,9 @@ RCT_NOT_IMPLEMENTED(-init) ...@@ -492,6 +491,9 @@ RCT_NOT_IMPLEMENTED(-init)
for (GLRenderData *child in renderData.children) for (GLRenderData *child in renderData.children)
weak_recDraw(child); weak_recDraw(child);
RCT_PROFILE_BEGIN_EVENT(0, @"node", nil);
RCT_PROFILE_BEGIN_EVENT(0, @"bind fbo", nil);
if (renderData.fboId == -1) { if (renderData.fboId == -1) {
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport(0, 0, w, h); glViewport(0, 0, w, h);
...@@ -501,23 +503,34 @@ RCT_NOT_IMPLEMENTED(-init) ...@@ -501,23 +503,34 @@ RCT_NOT_IMPLEMENTED(-init)
[fbo setShapeWithWidth:w withHeight:h]; [fbo setShapeWithWidth:w withHeight:h];
[fbo bind]; [fbo bind];
} }
RCT_PROFILE_END_EVENT(0, @"gl", nil);
RCT_PROFILE_BEGIN_EVENT(0, @"bind shader", nil);
[renderData.shader bind]; [renderData.shader bind];
RCT_PROFILE_END_EVENT(0, @"gl", nil);
RCT_PROFILE_BEGIN_EVENT(0, @"bind textures", nil);
for (NSString *uniformName in renderData.textures) { for (NSString *uniformName in renderData.textures) {
GLTexture *texture = renderData.textures[uniformName]; GLTexture *texture = renderData.textures[uniformName];
int unit = [((NSNumber *)renderData.uniforms[uniformName]) intValue]; int unit = [((NSNumber *)renderData.uniforms[uniformName]) intValue];
[texture bind:unit]; [texture bind:unit];
} }
RCT_PROFILE_END_EVENT(0, @"gl", nil);
RCT_PROFILE_BEGIN_EVENT(0, @"bind set uniforms", nil);
for (NSString *uniformName in renderData.uniforms) { for (NSString *uniformName in renderData.uniforms) {
[renderData.shader setUniform:uniformName withValue:renderData.uniforms[uniformName]]; [renderData.shader setUniform:uniformName withValue:renderData.uniforms[uniformName]];
} }
RCT_PROFILE_END_EVENT(0, @"gl", nil);
RCT_PROFILE_BEGIN_EVENT(0, @"draw", nil);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_TRIANGLES, 0, 6); glDrawArrays(GL_TRIANGLES, 0, 6);
RCT_PROFILE_END_EVENT(0, @"gl", nil);
RCT_PROFILE_END_EVENT(0, @"gl", nil);
}; };
// DRAWING THE SCENE // DRAWING THE SCENE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment