~gnome3-team/mutter/trunk

« back to all changes in this revision

Viewing changes to cogl/cogl/driver/gl/cogl-pipeline-vertend-fixed.c

  • Committer: Rui Matos
  • Date: 2016-04-27 16:36:25 UTC
  • mfrom: (0.87.3184)
  • Revision ID: git-v1:3fcbe1d3ec5c9208dde080f7e9dac24e4c379bc0
Merge cogl's cogl-1.22 branch into mutter

https://bugzilla.gnome.org/show_bug.cgi?id=760439

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * A Low Level GPU Graphics and Utilities API
 
5
 *
 
6
 * Copyright (C) 2008,2009,2010 Intel Corporation.
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person
 
9
 * obtaining a copy of this software and associated documentation
 
10
 * files (the "Software"), to deal in the Software without
 
11
 * restriction, including without limitation the rights to use, copy,
 
12
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 
13
 * of the Software, and to permit persons to whom the Software is
 
14
 * furnished to do so, subject to the following conditions:
 
15
 *
 
16
 * The above copyright notice and this permission notice shall be
 
17
 * included in all copies or substantial portions of the Software.
 
18
 *
 
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
20
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
22
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 
23
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 
24
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
25
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
26
 * SOFTWARE.
 
27
 *
 
28
 *
 
29
 *
 
30
 * Authors:
 
31
 *   Neil Roberts <neil@linux.intel.com>
 
32
 */
 
33
 
 
34
#ifdef HAVE_CONFIG_H
 
35
#include "config.h"
 
36
#endif
 
37
 
 
38
#include "cogl-context-private.h"
 
39
#include "cogl-util-gl-private.h"
 
40
#include "cogl-pipeline-private.h"
 
41
#include "cogl-pipeline-state-private.h"
 
42
#include "cogl-pipeline-opengl-private.h"
 
43
#include "cogl-framebuffer-private.h"
 
44
 
 
45
#ifdef COGL_PIPELINE_VERTEND_FIXED
 
46
 
 
47
#include "cogl-context-private.h"
 
48
#include "cogl-object-private.h"
 
49
#include "cogl-program-private.h"
 
50
 
 
51
const CoglPipelineVertend _cogl_pipeline_fixed_vertend;
 
52
 
 
53
static void
 
54
_cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
 
55
                                    int n_layers,
 
56
                                    unsigned long pipelines_difference)
 
57
{
 
58
  _cogl_use_vertex_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED);
 
59
}
 
60
 
 
61
static CoglBool
 
62
_cogl_pipeline_vertend_fixed_add_layer (CoglPipeline *pipeline,
 
63
                                        CoglPipelineLayer *layer,
 
64
                                        unsigned long layers_difference,
 
65
                                        CoglFramebuffer *framebuffer)
 
66
{
 
67
  CoglContext *ctx = framebuffer->context;
 
68
  int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
 
69
  CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index);
 
70
 
 
71
  if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX)
 
72
    {
 
73
      CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
 
74
      CoglPipelineLayer *authority =
 
75
        _cogl_pipeline_layer_get_authority (layer, state);
 
76
      CoglMatrixEntry *matrix_entry;
 
77
 
 
78
      cogl_matrix_stack_set (unit->matrix_stack,
 
79
                             &authority->big_state->matrix);
 
80
 
 
81
      _cogl_set_active_texture_unit (unit_index);
 
82
 
 
83
      matrix_entry = unit->matrix_stack->last_entry;
 
84
      _cogl_matrix_entry_flush_to_gl_builtins (ctx, matrix_entry,
 
85
                                               COGL_MATRIX_TEXTURE,
 
86
                                               framebuffer,
 
87
                                               FALSE /* enable flip */);
 
88
    }
 
89
 
 
90
  return TRUE;
 
91
}
 
92
 
 
93
static CoglBool
 
94
_cogl_pipeline_vertend_fixed_end (CoglPipeline *pipeline,
 
95
                                  unsigned long pipelines_difference)
 
96
{
 
97
  _COGL_GET_CONTEXT (ctx, FALSE);
 
98
 
 
99
  if (pipelines_difference & COGL_PIPELINE_STATE_POINT_SIZE)
 
100
    {
 
101
      CoglPipeline *authority =
 
102
        _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_POINT_SIZE);
 
103
 
 
104
      if (authority->big_state->point_size > 0.0f)
 
105
        GE( ctx, glPointSize (authority->big_state->point_size) );
 
106
    }
 
107
 
 
108
  return TRUE;
 
109
}
 
110
 
 
111
const CoglPipelineVertend _cogl_pipeline_fixed_vertend =
 
112
{
 
113
  _cogl_pipeline_vertend_fixed_start,
 
114
  _cogl_pipeline_vertend_fixed_add_layer,
 
115
  _cogl_pipeline_vertend_fixed_end,
 
116
  NULL, /* pipeline_change_notify */
 
117
  NULL /* layer_change_notify */
 
118
};
 
119
 
 
120
#endif /* COGL_PIPELINE_VERTEND_FIXED */
 
121