Skip to content

Commit 91b165e

Browse files
committed
remove useless imp
1 parent 9e3c9cd commit 91b165e

File tree

3 files changed

+43
-57
lines changed

3 files changed

+43
-57
lines changed

library/src/main/jni/cge/filters/cgeDataParsingEngine.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,8 @@ CGEImageFilterInterface* CGEDataParsingEngine::advancedStyleParser(const char* p
11151115

11161116
else if (strcmp(buffer, "waveform") == 0)
11171117
{
1118-
float x, y, value1, value2, r, g, b, a = 1.0f;
1119-
if (sscanf(pstr, "%f%*c%f%*c%f%*c%f%*c%f%*c%f%*c%f%*c%f", &x, &y, &value1, &value2, &r, &g, &b, &a) < 7)
1118+
float x, y, width, height;
1119+
if (sscanf(pstr, "%f%*c%f%*c%f%*c%f", &x, &y, &width, &height) < 4)
11201120
{
11211121
LOG_ERROR_PARAM(pstr);
11221122
return nullptr;
@@ -1127,8 +1127,7 @@ CGEImageFilterInterface* CGEDataParsingEngine::advancedStyleParser(const char* p
11271127
{
11281128
proc = filter;
11291129
filter->setFormPosition(x, y);
1130-
filter->setFormSize(value1, value2);
1131-
filter->setColor(r, g, b, a);
1130+
filter->setFormSize(width, height);
11321131
}
11331132
}
11341133
else if (strcmp(buffer, "edge") == 0)
Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
#include "cgeWaveformFilter.h"
22

3-
#include <EGL/egl.h>
4-
5-
static CGEConstString s_vshWaveform = "#version 310 es\n" CGE_SHADER_STRING_PRECISION_H(
6-
layout(location = 0) in vec2 position;
7-
layout(location = 0) out vec2 textureCoordinate;
8-
void main() {
9-
gl_Position = vec4(position, 0.0, 1.0);
10-
textureCoordinate = (position.xy + 1.0) / 2.0;
11-
});
12-
13-
static CGEConstString s_fshWaveform = "#version 310 es\n" CGE_SHADER_STRING(
14-
precision highp float;
15-
precision highp int;
16-
layout(location = 0) in vec2 textureCoordinate;
17-
layout(binding = 0) uniform sampler2D inputImageTexture;
18-
layout(rgba8ui, binding = 1) uniform writeonly highp uimage2D outputImage;
19-
layout(location = 0) out vec4 fragColor;
20-
21-
void main() {
22-
fragColor = vec4(1.0);
23-
vec4 color = texture(inputImageTexture, textureCoordinate);
24-
float lum = dot(color.rgb, vec3(0.299, 0.587, 0.114));
25-
ivec2 newLoc = ivec2(vec2(textureCoordinate.x, lum) * vec2(imageSize(outputImage)));
26-
// uint newLum = uint(lum * 255.0);
27-
imageStore(outputImage, newLoc, uvec4(255, 255, 255, 255));
28-
29-
// TODO: 直接使用 255 来描述最亮是没有问题的。 如果要实现颜色亮度叠加. 可以考虑使用 imageAtomicAdd.
30-
});
3+
#define USING_ALPHA 1 /// 视图增加一个 80% 的半透明
4+
5+
// static CGEConstString s_vshWaveform = "#version 310 es\n" CGE_SHADER_STRING_PRECISION_H(
6+
// layout(location = 0) in vec2 position;
7+
// layout(location = 0) out vec2 textureCoordinate;
8+
// void main() {
9+
// gl_Position = vec4(position, 0.0, 1.0);
10+
// textureCoordinate = (position.xy + 1.0) / 2.0;
11+
// });
12+
13+
// static CGEConstString s_fshWaveform = "#version 310 es\n" CGE_SHADER_STRING(
14+
// precision highp float;
15+
// precision highp int;
16+
// layout(location = 0) in vec2 textureCoordinate;
17+
// layout(binding = 0) uniform sampler2D inputImageTexture;
18+
// layout(rgba8ui, binding = 1) uniform writeonly highp uimage2D outputImage;
19+
// layout(location = 0) out vec4 fragColor;
20+
21+
// void main() {
22+
// fragColor = vec4(1.0);
23+
// vec4 color = texture(inputImageTexture, textureCoordinate);
24+
// float lum = dot(color.rgb, vec3(0.299, 0.587, 0.114));
25+
// ivec2 newLoc = ivec2(vec2(textureCoordinate.x, lum) * vec2(imageSize(outputImage)));
26+
// // uint newLum = uint(lum * 255.0);
27+
// imageStore(outputImage, newLoc, uvec4(255, 255, 255, 255));
28+
29+
// // TODO: 直接使用 255 来描述最亮是没有问题的。 如果要实现颜色亮度叠加. 可以考虑使用 imageAtomicAdd.
30+
// });
3131

3232
static CGEConstString s_cshWaveform = "#version 310 es\n" CGE_SHADER_STRING(
3333
precision highp float;
@@ -55,31 +55,17 @@ bool CGEWaveformFilter::init()
5555
m_program.bind();
5656
setFormPosition(0.1f, 0.1f);
5757
setFormSize(0.3f, 0.3f);
58-
setColor(0.0f, 0.0f, 0.0f, 0.5f);
5958
m_drawer.reset(TextureDrawer::create());
6059
m_drawer->setFlipScale(1.0f, -1.0f); // flip upside down, meet the gl coord.
6160
m_renderTarget = std::make_unique<FrameBufferWithTexture>();
6261
return true;
6362
}
6463

65-
// if (initShadersFromString(s_vshWaveform, s_fshWaveform))
66-
// {
67-
// m_program.bind();
68-
// setFormPosition(0.1f, 0.1f);
69-
// setFormSize(0.3f, 0.3f);
70-
// setColor(0.0f, 0.0f, 0.0f, 0.5f);
71-
// m_drawer.reset(TextureDrawer::create());
72-
// m_drawer->setFlipScale(1.0f, -1.0f); // flip upside down, meet the gl coord.
73-
// m_renderTarget = std::make_unique<FrameBufferWithTexture>();
74-
// return true;
75-
// }
76-
7764
CGE_LOG_ERROR(R"(CGEWaveformFilter::init failed. This filter needs GLES3.1 and later!
7865
Only GLES 3.1+ support image store.
7966
You need to imp a fallback version which reading pixels every frame like `cgeColorMappingFilter`
8067
)");
81-
CGE_LOG_ERROR("Failed Vertex Shader: %s\n", s_vshWaveform);
82-
CGE_LOG_ERROR("Failed Fragment Shader: %s\n", s_fshWaveform);
68+
CGE_LOG_ERROR("Failed Compute Shader: %s\n", s_cshWaveform);
8369
return false;
8470
}
8571

@@ -106,9 +92,20 @@ void CGEWaveformFilter::render2Texture(CGEImageHandlerInterface* handler, GLuint
10692

10793
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
10894

95+
#if USING_ALPHA
96+
glEnable(GL_BLEND);
97+
glBlendColor(1, 1, 1, 0.8);
98+
glBlendFunc(GL_ONE, GL_ONE_MINUS_CONSTANT_ALPHA);
99+
#endif
100+
109101
handler->setAsTarget();
110102
glViewport(m_position[0] * sz.width, m_position[1] * sz.height, m_size[0] * sz.width, m_size[1] * sz.height);
111103
m_drawer->drawTexture(m_renderTarget->texture());
104+
105+
#if USING_ALPHA
106+
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
107+
glDisable(GL_BLEND);
108+
#endif
112109
}
113110

114111
void CGEWaveformFilter::setFormPosition(float left, float top)
@@ -121,8 +118,4 @@ void CGEWaveformFilter::setFormSize(float width, float height)
121118
m_size = { width, height };
122119
}
123120

124-
void CGEWaveformFilter::setColor(float r, float g, float b, float a)
125-
{
126-
m_color = { r, g, b, a };
127-
}
128121
} // namespace CGE

library/src/main/jni/cge/filters/cgeWaveformFilter.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ class CGEWaveformFilter : public CGEImageFilterInterface
2121
*/
2222
void setFormSize(float width, float height);
2323

24-
/**
25-
* @brief 背景色
26-
*/
27-
void setColor(float r, float g, float b, float a);
28-
2924
bool init() override;
3025

3126
void render2Texture(CGEImageHandlerInterface* handler, GLuint srcTexture, GLuint vertexBufferID) override;
@@ -35,7 +30,6 @@ class CGEWaveformFilter : public CGEImageFilterInterface
3530
std::unique_ptr<FrameBufferWithTexture> m_renderTarget;
3631
Vec2f m_position;
3732
Vec2f m_size;
38-
Vec4f m_color;
3933
};
4034
} // namespace CGE
4135

0 commit comments

Comments
 (0)