~ubuntu-branches/ubuntu/vivid/clutter-1.0/vivid-proposed

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl/cogl-texture-private.h

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-07-18 17:21:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20100718172149-j6s9u4chocaoykme
Tags: 1.2.12-1
* New upstream release.
* debian/libclutter-1.0-0.symbols,
  debian/rules:
  - Add a symbols file.
* debian/rules,
  debian/source/format:
  - Switch to source format 3.0 (quilt).
* debian/control.in:
  - Standards-Version is 3.9.0, no changes needed.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * An object oriented GL/GLES Abstraction/Utility Layer
 
5
 *
 
6
 * Copyright (C) 2007,2008,2009 Intel Corporation.
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 *
 
22
 */
 
23
 
 
24
#ifndef __COGL_TEXTURE_PRIVATE_H
 
25
#define __COGL_TEXTURE_PRIVATE_H
 
26
 
 
27
#include "cogl-bitmap-private.h"
 
28
#include "cogl-handle.h"
 
29
#include "cogl-material-private.h"
 
30
 
 
31
#define COGL_TEXTURE(tex) ((CoglTexture *)(tex))
 
32
 
 
33
typedef struct _CoglTexture           CoglTexture;
 
34
typedef struct _CoglTextureVtable     CoglTextureVtable;
 
35
 
 
36
typedef void (*CoglTextureSliceCallback) (CoglHandle handle,
 
37
                                          GLuint gl_handle,
 
38
                                          GLenum gl_target,
 
39
                                          const float *slice_coords,
 
40
                                          const float *virtual_coords,
 
41
                                          void *user_data);
 
42
 
 
43
typedef void (* CoglTextureManualRepeatCallback) (const float *coords,
 
44
                                                  void *user_data);
 
45
 
 
46
/* Encodes three possibiloities result of transforming a quad */
 
47
typedef enum {
 
48
  /* quad doesn't cross the boundaries of a texture */
 
49
  COGL_TRANSFORM_NO_REPEAT,
 
50
  /* quad crosses boundaries, hardware wrap mode can handle */
 
51
  COGL_TRANSFORM_HARDWARE_REPEAT,
 
52
  /* quad crosses boundaries, needs software fallback;
 
53
   * for a sliced texture, this might not actually involve
 
54
   * repeating, just a quad crossing multiple slices */
 
55
  COGL_TRANSFORM_SOFTWARE_REPEAT,
 
56
} CoglTransformResult;
 
57
 
 
58
struct _CoglTextureVtable
 
59
{
 
60
  /* Virtual functions that must be implemented for a texture
 
61
     backend */
 
62
 
 
63
  gboolean (* set_region) (CoglTexture    *tex,
 
64
                           int             src_x,
 
65
                           int             src_y,
 
66
                           int             dst_x,
 
67
                           int             dst_y,
 
68
                           unsigned int    dst_width,
 
69
                           unsigned int    dst_height,
 
70
                           int             width,
 
71
                           int             height,
 
72
                           CoglPixelFormat format,
 
73
                           unsigned int    rowstride,
 
74
                           const guint8   *data);
 
75
 
 
76
  int (* get_data) (CoglTexture     *tex,
 
77
                    CoglPixelFormat  format,
 
78
                    unsigned int     rowstride,
 
79
                    guint8          *data);
 
80
 
 
81
  void (* foreach_sub_texture_in_region) (CoglTexture *tex,
 
82
                                          float virtual_tx_1,
 
83
                                          float virtual_ty_1,
 
84
                                          float virtual_tx_2,
 
85
                                          float virtual_ty_2,
 
86
                                          CoglTextureSliceCallback callback,
 
87
                                          void *user_data);
 
88
 
 
89
  int (* get_max_waste) (CoglTexture *tex);
 
90
 
 
91
  gboolean (* is_sliced) (CoglTexture *tex);
 
92
 
 
93
  gboolean (* can_hardware_repeat) (CoglTexture *tex);
 
94
 
 
95
  void (* transform_coords_to_gl) (CoglTexture *tex,
 
96
                                   float *s,
 
97
                                   float *t);
 
98
  CoglTransformResult (* transform_quad_coords_to_gl) (CoglTexture *tex,
 
99
                                                       float *coords);
 
100
 
 
101
  gboolean (* get_gl_texture) (CoglTexture *tex,
 
102
                               GLuint *out_gl_handle,
 
103
                               GLenum *out_gl_target);
 
104
 
 
105
  void (* set_filters) (CoglTexture *tex,
 
106
                        GLenum min_filter,
 
107
                        GLenum mag_filter);
 
108
 
 
109
  void (* ensure_mipmaps) (CoglTexture *tex);
 
110
  void (* ensure_non_quad_rendering) (CoglTexture *tex);
 
111
 
 
112
  void (* set_wrap_mode_parameter) (CoglTexture *tex,
 
113
                                    GLenum wrap_mode);
 
114
 
 
115
  CoglPixelFormat (* get_format) (CoglTexture *tex);
 
116
  GLenum (* get_gl_format) (CoglTexture *tex);
 
117
  int (* get_width) (CoglTexture *tex);
 
118
  int (* get_height) (CoglTexture *tex);
 
119
};
 
120
 
 
121
struct _CoglTexture
 
122
{
 
123
  CoglHandleObject         _parent;
 
124
  const CoglTextureVtable *vtable;
 
125
};
 
126
 
 
127
void
 
128
_cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
 
129
                                             float virtual_tx_1,
 
130
                                             float virtual_ty_1,
 
131
                                             float virtual_tx_2,
 
132
                                             float virtual_ty_2,
 
133
                                             CoglTextureSliceCallback callback,
 
134
                                             void *user_data);
 
135
 
 
136
gboolean
 
137
_cogl_texture_can_hardware_repeat (CoglHandle handle);
 
138
 
 
139
void
 
140
_cogl_texture_transform_coords_to_gl (CoglHandle handle,
 
141
                                      float *s,
 
142
                                      float *t);
 
143
CoglTransformResult
 
144
_cogl_texture_transform_quad_coords_to_gl (CoglHandle handle,
 
145
                                           float *coords);
 
146
 
 
147
GLenum
 
148
_cogl_texture_get_gl_format (CoglHandle handle);
 
149
 
 
150
void
 
151
_cogl_texture_set_wrap_mode_parameter (CoglHandle handle,
 
152
                                       GLenum wrap_mode);
 
153
 
 
154
void
 
155
_cogl_texture_set_filters (CoglHandle handle,
 
156
                           GLenum min_filter,
 
157
                           GLenum mag_filter);
 
158
 
 
159
void
 
160
_cogl_texture_ensure_mipmaps (CoglHandle handle);
 
161
 
 
162
void
 
163
_cogl_texture_ensure_non_quad_rendering (CoglHandle handle);
 
164
 
 
165
/* Utility function to determine which pixel format to use when
 
166
   dst_format is COGL_PIXEL_FORMAT_ANY. If dst_format is not ANY then
 
167
   it will just be returned directly */
 
168
CoglPixelFormat
 
169
_cogl_texture_determine_internal_format (CoglPixelFormat src_format,
 
170
                                         CoglPixelFormat dst_format);
 
171
 
 
172
/* Utility function to help uploading a bitmap. If the bitmap needs
 
173
   premult conversion then it will be copied and *copied_bitmap will
 
174
   be set to TRUE. Otherwise dst_bmp will be set to a shallow copy of
 
175
   src_bmp. The GLenums needed for uploading are returned */
 
176
 
 
177
gboolean
 
178
_cogl_texture_prepare_for_upload (CoglBitmap      *src_bmp,
 
179
                                  CoglPixelFormat  dst_format,
 
180
                                  CoglPixelFormat *dst_format_out,
 
181
                                  CoglBitmap      *dst_bmp,
 
182
                                  gboolean        *copied_bitmap,
 
183
                                  GLenum          *out_glintformat,
 
184
                                  GLenum          *out_glformat,
 
185
                                  GLenum          *out_gltype);
 
186
 
 
187
void
 
188
_cogl_texture_prep_gl_alignment_for_pixels_upload (int pixels_rowstride);
 
189
 
 
190
void
 
191
_cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride);
 
192
 
 
193
/* Utility function for implementing manual repeating. Even texture
 
194
   backends that always support hardware repeating need this because
 
195
   when foreach_sub_texture_in_region is invoked Cogl will set the
 
196
   wrap mode to GL_CLAMP_TO_EDGE so hardware repeating can't be
 
197
   done */
 
198
void
 
199
_cogl_texture_iterate_manual_repeats (CoglTextureManualRepeatCallback callback,
 
200
                                      float tx_1, float ty_1,
 
201
                                      float tx_2, float ty_2,
 
202
                                      void *user_data);
 
203
 
 
204
/* Utility function to use as a fallback for getting the data of any
 
205
   texture via the framebuffer */
 
206
 
 
207
gboolean
 
208
_cogl_texture_draw_and_read (CoglHandle   handle,
 
209
                             CoglBitmap  *target_bmp,
 
210
                             GLuint       target_gl_format,
 
211
                             GLuint       target_gl_type);
 
212
 
 
213
#endif /* __COGL_TEXTURE_PRIVATE_H */