~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to clutter/fruity/clutter-stage-fruity.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
  EGLConfig            configs[2];
64
64
  EGLint               config_count;
65
65
  EGLBoolean           status;
66
 
  gboolean             is_offscreen;
 
66
  EGLint               cfg_attribs[] = {
 
67
      EGL_BUFFER_SIZE,    EGL_DONT_CARE,
 
68
      EGL_RED_SIZE,       5,
 
69
      EGL_GREEN_SIZE,     6,
 
70
      EGL_BLUE_SIZE,      5,
 
71
      EGL_DEPTH_SIZE,     16,
 
72
      EGL_ALPHA_SIZE,     EGL_DONT_CARE,
 
73
      EGL_STENCIL_SIZE,   2,
 
74
      EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
 
75
      EGL_NONE };
67
76
 
68
77
  CLUTTER_NOTE (BACKEND, "Realizing main stage");
69
78
 
70
 
  g_object_get (stage_egl->wrapper, "offscreen", &is_offscreen, NULL);
71
 
 
72
79
  backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ());
73
80
 
74
 
  if (G_LIKELY (!is_offscreen))
75
 
    {
76
 
      EGLint cfg_attribs[] = { EGL_BUFFER_SIZE,    EGL_DONT_CARE,
77
 
                               EGL_RED_SIZE,       5,
78
 
                               EGL_GREEN_SIZE,     6,
79
 
                               EGL_BLUE_SIZE,      5,
80
 
                               EGL_DEPTH_SIZE,     16,
81
 
                               EGL_ALPHA_SIZE,     EGL_DONT_CARE,
82
 
                               EGL_STENCIL_SIZE,   2,
83
 
                               EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
84
 
                               EGL_NONE };
85
 
 
86
 
      status = eglGetConfigs (backend_egl->edpy,
87
 
                              configs, 
88
 
                              2, 
89
 
                              &config_count);
90
 
 
91
 
      if (status != EGL_TRUE)
92
 
        g_warning ("eglGetConfigs failed");
93
 
 
94
 
      status = eglChooseConfig (backend_egl->edpy,
95
 
                                cfg_attribs,
96
 
                                configs,
97
 
                                G_N_ELEMENTS (configs),
98
 
                                &config_count);
99
 
 
100
 
      if (status != EGL_TRUE)
101
 
        {
102
 
          g_critical ("eglChooseConfig failed");
103
 
          CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
104
 
          return;
105
 
        }
106
 
 
107
 
      if (stage_egl->egl_surface != EGL_NO_SURFACE)
108
 
        {
109
 
          eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface);
110
 
          stage_egl->egl_surface = EGL_NO_SURFACE;
111
 
        }
112
 
 
113
 
       if (backend_egl->egl_context)
114
 
         {
115
 
            eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
116
 
            backend_egl->egl_context = NULL;
117
 
         }
118
 
 
119
 
      stage_egl->egl_surface =
120
 
        eglCreateWindowSurface (backend_egl->edpy,
121
 
                                configs[0],
122
 
                                NULL,
123
 
                                NULL);
124
 
 
125
 
 
126
 
 
127
 
      if (stage_egl->egl_surface == EGL_NO_SURFACE)
128
 
        {
129
 
          g_critical ("Unable to create an EGL surface");
130
 
          CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
131
 
          return;
132
 
        }
133
 
 
134
 
      eglQuerySurface (backend_egl->edpy,
135
 
                       stage_egl->egl_surface,
136
 
                       EGL_WIDTH,
137
 
                       &stage_egl->surface_width);
138
 
 
139
 
      eglQuerySurface (backend_egl->edpy,
140
 
                       stage_egl->egl_surface,
141
 
                       EGL_HEIGHT,
142
 
                       &stage_egl->surface_height);
143
 
 
144
 
      CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i", 
145
 
                    stage_egl->surface_width,
146
 
                    stage_egl->surface_height);
147
 
 
148
 
 
149
 
      if (G_UNLIKELY (backend_egl->egl_context == NULL))
150
 
        {
151
 
          CLUTTER_NOTE (GL, "Creating EGL Context");
152
 
 
153
 
          backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
154
 
                                                       configs[0],
155
 
                                                       EGL_NO_CONTEXT,
156
 
                                                       NULL);
157
 
 
158
 
          if (backend_egl->egl_context == EGL_NO_CONTEXT)
159
 
            {
160
 
              g_critical ("Unable to create a suitable EGL context");
161
 
 
162
 
              CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
163
 
              return;
164
 
            }
165
 
        }
166
 
 
167
 
      /* this will make sure to set the current context */
168
 
      CLUTTER_NOTE (BACKEND, "Setting context");
169
 
 
170
 
      /* this should be done in ClutterBackend::ensure_context */
171
 
      status = eglMakeCurrent (backend_egl->edpy,
172
 
                               stage_egl->egl_surface,
173
 
                               stage_egl->egl_surface,
174
 
                               backend_egl->egl_context);
175
 
 
176
 
      if (status != EGL_TRUE)
177
 
        {
178
 
          g_critical ("eglMakeCurrent failed");
179
 
          CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
180
 
          return;
181
 
        }
182
 
    }
183
 
  else
184
 
    {
185
 
      g_warning("EGL Backend does not yet support offscreen rendering\n");
186
 
      CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
 
81
  status = eglGetConfigs (backend_egl->edpy,
 
82
                          configs,
 
83
                          2,
 
84
                          &config_count);
 
85
 
 
86
  if (status != EGL_TRUE)
 
87
    g_warning ("eglGetConfigs failed");
 
88
 
 
89
  status = eglChooseConfig (backend_egl->edpy,
 
90
                            cfg_attribs,
 
91
                            configs,
 
92
                            G_N_ELEMENTS (configs),
 
93
                            &config_count);
 
94
 
 
95
  if (status != EGL_TRUE)
 
96
    {
 
97
      g_critical ("eglChooseConfig failed");
 
98
      CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
 
99
      return;
 
100
    }
 
101
 
 
102
  if (stage_egl->egl_surface != EGL_NO_SURFACE)
 
103
    {
 
104
      eglDestroySurface (backend_egl->edpy, stage_egl->egl_surface);
 
105
      stage_egl->egl_surface = EGL_NO_SURFACE;
 
106
    }
 
107
 
 
108
   if (backend_egl->egl_context)
 
109
     {
 
110
        eglDestroyContext (backend_egl->edpy, backend_egl->egl_context);
 
111
        backend_egl->egl_context = NULL;
 
112
     }
 
113
 
 
114
  stage_egl->egl_surface =
 
115
    eglCreateWindowSurface (backend_egl->edpy,
 
116
                            configs[0],
 
117
                            NULL,
 
118
                            NULL);
 
119
 
 
120
 
 
121
 
 
122
  if (stage_egl->egl_surface == EGL_NO_SURFACE)
 
123
    {
 
124
      g_critical ("Unable to create an EGL surface");
 
125
      CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
 
126
      return;
 
127
    }
 
128
 
 
129
  eglQuerySurface (backend_egl->edpy,
 
130
                   stage_egl->egl_surface,
 
131
                   EGL_WIDTH,
 
132
                   &stage_egl->surface_width);
 
133
 
 
134
  eglQuerySurface (backend_egl->edpy,
 
135
                   stage_egl->egl_surface,
 
136
                   EGL_HEIGHT,
 
137
                   &stage_egl->surface_height);
 
138
 
 
139
  CLUTTER_NOTE (BACKEND, "EGL surface is %ix%i",
 
140
                stage_egl->surface_width,
 
141
                stage_egl->surface_height);
 
142
 
 
143
 
 
144
  if (G_UNLIKELY (backend_egl->egl_context == NULL))
 
145
    {
 
146
      CLUTTER_NOTE (GL, "Creating EGL Context");
 
147
 
 
148
      backend_egl->egl_context = eglCreateContext (backend_egl->edpy,
 
149
                                                   configs[0],
 
150
                                                   EGL_NO_CONTEXT,
 
151
                                                   NULL);
 
152
 
 
153
      if (backend_egl->egl_context == EGL_NO_CONTEXT)
 
154
        {
 
155
          g_critical ("Unable to create a suitable EGL context");
 
156
 
 
157
          CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
 
158
          return;
 
159
        }
 
160
    }
 
161
 
 
162
  /* this will make sure to set the current context */
 
163
  CLUTTER_NOTE (BACKEND, "Setting context");
 
164
 
 
165
  /* this should be done in ClutterBackend::ensure_context */
 
166
  status = eglMakeCurrent (backend_egl->edpy,
 
167
                           stage_egl->egl_surface,
 
168
                           stage_egl->egl_surface,
 
169
                           backend_egl->egl_context);
 
170
 
 
171
  if (status != EGL_TRUE)
 
172
    {
 
173
      g_critical ("eglMakeCurrent failed");
 
174
      CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
 
175
      return;
187
176
    }
188
177
}
189
178