1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/*
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include "main/mtypes.h"
#include "main/context.h"
#include "main/teximage.h"
#include "main/texstate.h"
#include "main/imports.h"
#include "glapi/dispatch.h"
#include "eglimage.h"
#if FEATURE_OES_EGL_image
void GLAPIENTRY
_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_renderbuffer *rb;
if (!ctx->Extensions.OES_EGL_image) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glEGLImageTargetRenderbufferStorageOES(unsupported)");
return;
}
if (target != GL_RENDERBUFFER) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glEGLImageTargetRenderbufferStorage(target=0x%x)", target);
return;
}
rb = ctx->CurrentRenderbuffer;
if (!rb) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glEGLImageTargetRenderbufferStorageOES(no bound rb)");
return;
}
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
ASSERT(ctx->Driver.EGLImageTargetRenderbufferStorage);
ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image);
/* invalidate fbo? */
}
void GLAPIENTRY _mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
if (!ctx->Extensions.OES_EGL_image) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glEGLImageTargetTexture2DOES(unsupported)");
return;
}
if (target != GL_TEXTURE_2D) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glEGLImageTargetTexture2D(target=0x%x)", target);
return;
}
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
texUnit = _mesa_get_current_tex_unit(ctx);
texObj = _mesa_select_tex_object(ctx, texUnit, target);
_mesa_lock_texture(ctx, texObj);
ASSERT(ctx->Driver.EGLImageTargetTexture2D);
ctx->Driver.EGLImageTargetTexture2D(ctx, texObj ,image);
/* invalidate state and fbo?*/
/* fbo? */
texObj->_Complete = GL_FALSE;
ctx->NewState |= _NEW_TEXTURE;
_mesa_unlock_texture(ctx, texObj);
}
void
_mesa_init_eglimage_dispatch(struct _glapi_table *disp)
{
SET_EGLImageTargetRenderbufferStorageOES(disp,
_mesa_EGLImageTargetRenderbufferStorageOES);
SET_EGLImageTargetTexture2DOES(disp, _mesa_EGLImageTargetTexture2DOES);
}
#endif /* FEATURE_OES_EGL_image */
|