diff --git a/cogl/cogl/cogl-framebuffer-private.h b/cogl/cogl/cogl-framebuffer-private.h index 523647819..945af926d 100644 --- a/cogl/cogl/cogl-framebuffer-private.h +++ b/cogl/cogl/cogl-framebuffer-private.h @@ -196,7 +196,7 @@ void _cogl_framebuffer_add_dependency (CoglFramebuffer *framebuffer, CoglFramebuffer *dependency); -void +COGL_EXPORT_TEST void _cogl_framebuffer_flush_journal (CoglFramebuffer *framebuffer); void diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 9d487714b..8986e0466 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -45,8 +45,6 @@ #include "driver/gl/cogl-pipeline-progend-glsl-private.h" -#include - #include #include @@ -306,38 +304,6 @@ flush_depth_state (CoglContext *ctx, } } -UNIT_TEST (check_gl_blend_enable, - 0 /* no requirements */, - 0 /* no failure cases */) -{ - CoglPipeline *pipeline = cogl_pipeline_new (test_ctx); - - /* By default blending should be disabled */ - g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); - - cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); - _cogl_framebuffer_flush_journal (test_fb); - - /* After drawing an opaque rectangle blending should still be - * disabled */ - g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); - - cogl_pipeline_set_color4f (pipeline, 0, 0, 0, 0); - cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); - _cogl_framebuffer_flush_journal (test_fb); - - /* After drawing a transparent rectangle blending should be enabled */ - g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 1); - - cogl_pipeline_set_blend (pipeline, "RGBA=ADD(SRC_COLOR, 0)", NULL); - cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); - _cogl_framebuffer_flush_journal (test_fb); - - /* After setting a blend string that effectively disables blending - * then blending should be disabled */ - g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); -} - static void _cogl_pipeline_flush_color_blend_alpha_depth_state ( CoglPipeline *pipeline, diff --git a/src/tests/cogl/unit/meson.build b/src/tests/cogl/unit/meson.build index 4ee20bcc7..16a8169e9 100644 --- a/src/tests/cogl/unit/meson.build +++ b/src/tests/cogl/unit/meson.build @@ -3,6 +3,7 @@ cogl_unit_tests = [ ['test-pipeline-cache', true], ['test-pipeline-state-known-failure', false], ['test-pipeline-state', true], + ['test-pipeline-glsl', true], ] test_env = environment() diff --git a/src/tests/cogl/unit/test-pipeline-glsl.c b/src/tests/cogl/unit/test-pipeline-glsl.c new file mode 100644 index 000000000..6d2ac214f --- /dev/null +++ b/src/tests/cogl/unit/test-pipeline-glsl.c @@ -0,0 +1,44 @@ +#include "cogl-config.h" + +#include "cogl/cogl.h" +#include "tests/cogl-test-utils.h" + +static void +test_pipeline_opengl_blend_enable (void) +{ + CoglPipeline *pipeline; + + pipeline = cogl_pipeline_new (test_ctx); + + /* By default blending should be disabled */ + g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); + + cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); + _cogl_framebuffer_flush_journal (test_fb); + + /* After drawing an opaque rectangle blending should still be + * disabled */ + g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); + + cogl_pipeline_set_color4f (pipeline, 0, 0, 0, 0); + cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); + _cogl_framebuffer_flush_journal (test_fb); + + /* After drawing a transparent rectangle blending should be enabled */ + g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 1); + + cogl_pipeline_set_blend (pipeline, "RGBA=ADD(SRC_COLOR, 0)", NULL); + cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); + _cogl_framebuffer_flush_journal (test_fb); + + /* After setting a blend string that effectively disables blending + * then blending should be disabled */ + g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); + + cogl_object_unref (pipeline); +} + +COGL_TEST_SUITE ( + g_test_add_func ("/pipeline/opengl/blend-enable", + test_pipeline_opengl_blend_enable); +)