示例#1
0
static cg_pipeline_t *
create_texture_pipeline(TestState *state)
{
    cg_pipeline_t *pipeline;
    cg_texture_t *tex;
    static const uint8_t tex_data[] = {
        0xff, 0x00, 0x00, 0xff, /* red */  0x00, 0xff, 0x00, 0xff, /* green */
        0x00, 0x00, 0xff, 0xff, /* blue */ 0xff, 0xff, 0x00, 0xff, /* yellow */
    };

    tex = test_cg_texture_new_from_data(test_dev,
                                        2, 2, /* width/height */
                                        TEST_CG_TEXTURE_NO_ATLAS,
                                        CG_PIXEL_FORMAT_RGBA_8888_PRE,
                                        8, /* rowstride */
                                        tex_data);

    pipeline = cg_pipeline_new(test_dev);

    cg_pipeline_set_layer_texture(pipeline, 0, tex);

    cg_pipeline_set_layer_filters(pipeline, 0,
                                  CG_PIPELINE_FILTER_NEAREST,
                                  CG_PIPELINE_FILTER_NEAREST);

    cg_object_unref(tex);

    return pipeline;
}
示例#2
0
static void
paint (cg_texture_t *texture)
{
  cg_pipeline_t *pipeline = cg_pipeline_new (test_dev);
  int x = 0, y = 0, size = TEXTURE_SIZE;

  cg_pipeline_set_layer_texture (pipeline, 0, texture);
  cg_pipeline_set_layer_filters (pipeline, 0,
                                   CG_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST,
                                   CG_PIPELINE_FILTER_NEAREST);

  cg_framebuffer_draw_rectangle (test_fb,
                                   pipeline,
                                   x, y,
                                   x + size,
                                   y + size);

  x += size;
  size /= 2;
  cg_framebuffer_draw_rectangle (test_fb,
                                   pipeline,
                                   x, y,
                                   x + size,
                                   y + size);

  x += size;
  size /= 2;
  cg_framebuffer_draw_rectangle (test_fb,
                                   pipeline,
                                   x, y,
                                   x + size,
                                   y + size);

  cg_object_unref (pipeline);
  cg_object_unref (texture);
}