~elementary-os/elementaryos/os-patch-mutter-bionic

« back to all changes in this revision

Viewing changes to cogl/tests/conform/test-blend.c

  • Committer: RabbitBot
  • Date: 2018-04-11 14:49:36 UTC
  • Revision ID: rabbitbot@elementary.io-20180411144936-hgymqa9d8d1xfpbh
Initial import, version 3.28.0-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cogl/cogl.h>
 
2
 
 
3
#include <string.h>
 
4
 
 
5
#include "test-utils.h"
 
6
 
 
7
static void
 
8
paint (void)
 
9
{
 
10
  CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
 
11
  int width = cogl_framebuffer_get_width (test_fb);
 
12
  int half_width = width / 2;
 
13
  int height = cogl_framebuffer_get_height (test_fb);
 
14
  CoglVertexP2 tri0_vertices[] = {
 
15
        { 0, 0 },
 
16
        { 0, height },
 
17
        { half_width, height },
 
18
  };
 
19
  CoglVertexP2C4 tri1_vertices[] = {
 
20
        { half_width, 0, 0x80, 0x80, 0x80, 0x80 },
 
21
        { half_width, height, 0x80, 0x80, 0x80, 0x80 },
 
22
        { width, height, 0x80, 0x80, 0x80, 0x80 },
 
23
  };
 
24
  CoglPrimitive *tri0;
 
25
  CoglPrimitive *tri1;
 
26
 
 
27
  cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0);
 
28
 
 
29
  tri0 = cogl_primitive_new_p2 (test_ctx, COGL_VERTICES_MODE_TRIANGLES,
 
30
                                3, tri0_vertices);
 
31
  tri1 = cogl_primitive_new_p2c4 (test_ctx, COGL_VERTICES_MODE_TRIANGLES,
 
32
                                  3, tri1_vertices);
 
33
 
 
34
  /* Check that cogl correctly handles the case where we draw
 
35
   * different primitives same pipeline and switch from using the
 
36
   * opaque color associated with the pipeline and using a colour
 
37
   * attribute with an alpha component which implies blending is
 
38
   * required.
 
39
   *
 
40
   * If Cogl gets this wrong then then in all likelyhood the second
 
41
   * primitive will be drawn with blending still disabled.
 
42
   */
 
43
 
 
44
  cogl_primitive_draw (tri0, test_fb, pipeline);
 
45
  cogl_primitive_draw (tri1, test_fb, pipeline);
 
46
 
 
47
  test_utils_check_pixel_and_alpha (test_fb,
 
48
                                    half_width + 5,
 
49
                                    height - 5,
 
50
                                    0x80808080);
 
51
}
 
52
 
 
53
void
 
54
test_blend (void)
 
55
{
 
56
  cogl_framebuffer_orthographic (test_fb, 0, 0,
 
57
                                 cogl_framebuffer_get_width (test_fb),
 
58
                                 cogl_framebuffer_get_height (test_fb),
 
59
                                 -1,
 
60
                                 100);
 
61
 
 
62
  paint ();
 
63
}
 
64