Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "rsContext.h" |
| 18 | #include "rsScriptC.h" |
| 19 | #include "rsMatrix.h" |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 20 | |
| 21 | #include "acc/acc.h" |
| 22 | #include "utils/Timers.h" |
| 23 | |
| 24 | #define GL_GLEXT_PROTOTYPES |
| 25 | |
| 26 | #include <GLES/gl.h> |
| 27 | #include <GLES/glext.h> |
| 28 | #include <GLES2/gl2.h> |
| 29 | #include <GLES2/gl2ext.h> |
| 30 | |
| 31 | #include <time.h> |
| 32 | |
| 33 | using namespace android; |
| 34 | using namespace android::renderscript; |
| 35 | |
| 36 | #define GET_TLS() Context::ScriptTLSStruct * tls = \ |
| 37 | (Context::ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); \ |
| 38 | Context * rsc = tls->mContext; \ |
| 39 | ScriptC * sc = (ScriptC *) tls->mScript |
| 40 | |
| 41 | |
| 42 | ////////////////////////////////////////////////////////////////////////////// |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 43 | // Context |
| 44 | ////////////////////////////////////////////////////////////////////////////// |
| 45 | |
| 46 | static void SC_bindTexture(RsProgramFragment vpf, uint32_t slot, RsAllocation va) |
| 47 | { |
| 48 | GET_TLS(); |
| 49 | rsi_ProgramBindTexture(rsc, |
| 50 | static_cast<ProgramFragment *>(vpf), |
| 51 | slot, |
| 52 | static_cast<Allocation *>(va)); |
| 53 | |
| 54 | } |
| 55 | |
| 56 | static void SC_bindSampler(RsProgramFragment vpf, uint32_t slot, RsSampler vs) |
| 57 | { |
| 58 | GET_TLS(); |
| 59 | rsi_ProgramBindSampler(rsc, |
| 60 | static_cast<ProgramFragment *>(vpf), |
| 61 | slot, |
| 62 | static_cast<Sampler *>(vs)); |
| 63 | |
| 64 | } |
| 65 | |
| 66 | static void SC_bindProgramStore(RsProgramStore pfs) |
| 67 | { |
| 68 | GET_TLS(); |
| 69 | rsi_ContextBindProgramStore(rsc, pfs); |
| 70 | } |
| 71 | |
| 72 | static void SC_bindProgramFragment(RsProgramFragment pf) |
| 73 | { |
| 74 | GET_TLS(); |
| 75 | rsi_ContextBindProgramFragment(rsc, pf); |
| 76 | } |
| 77 | |
| 78 | static void SC_bindProgramVertex(RsProgramVertex pv) |
| 79 | { |
| 80 | GET_TLS(); |
| 81 | rsi_ContextBindProgramVertex(rsc, pv); |
| 82 | } |
| 83 | |
| 84 | static void SC_bindProgramRaster(RsProgramRaster pv) |
| 85 | { |
| 86 | GET_TLS(); |
| 87 | rsi_ContextBindProgramRaster(rsc, pv); |
| 88 | } |
| 89 | |
| 90 | ////////////////////////////////////////////////////////////////////////////// |
| 91 | // VP |
| 92 | ////////////////////////////////////////////////////////////////////////////// |
| 93 | |
Jim Miller | d8e7620 | 2010-07-28 14:46:22 -0700 | [diff] [blame] | 94 | static void SC_vpLoadProjectionMatrix(const rsc_Matrix *m) |
| 95 | { |
| 96 | GET_TLS(); |
| 97 | rsc->getVertex()->setProjectionMatrix(m); |
| 98 | } |
| 99 | |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 100 | static void SC_vpLoadModelMatrix(const rsc_Matrix *m) |
| 101 | { |
| 102 | GET_TLS(); |
| 103 | rsc->getVertex()->setModelviewMatrix(m); |
| 104 | } |
| 105 | |
| 106 | static void SC_vpLoadTextureMatrix(const rsc_Matrix *m) |
| 107 | { |
| 108 | GET_TLS(); |
| 109 | rsc->getVertex()->setTextureMatrix(m); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | |
| 114 | ////////////////////////////////////////////////////////////////////////////// |
| 115 | // Drawing |
| 116 | ////////////////////////////////////////////////////////////////////////////// |
| 117 | |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 118 | static void SC_drawQuadTexCoords(float x1, float y1, float z1, |
| 119 | float u1, float v1, |
| 120 | float x2, float y2, float z2, |
| 121 | float u2, float v2, |
| 122 | float x3, float y3, float z3, |
| 123 | float u3, float v3, |
| 124 | float x4, float y4, float z4, |
| 125 | float u4, float v4) |
| 126 | { |
| 127 | GET_TLS(); |
| 128 | if (!rsc->setupCheck()) { |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | //LOGE("Quad"); |
| 133 | //LOGE("%4.2f, %4.2f, %4.2f", x1, y1, z1); |
| 134 | //LOGE("%4.2f, %4.2f, %4.2f", x2, y2, z2); |
| 135 | //LOGE("%4.2f, %4.2f, %4.2f", x3, y3, z3); |
| 136 | //LOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4); |
| 137 | |
| 138 | float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4}; |
| 139 | const float tex[] = {u1,v1, u2,v2, u3,v3, u4,v4}; |
| 140 | |
| 141 | VertexArray va; |
Jason Sams | 8cb39de | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 142 | va.add(GL_FLOAT, 3, 12, false, (uint32_t)vtx, "position"); |
| 143 | va.add(GL_FLOAT, 2, 8, false, (uint32_t)tex, "texture0"); |
| 144 | va.setupGL2(rsc, &rsc->mStateVertexArray, &rsc->mShaderCache); |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 145 | |
| 146 | glDrawArrays(GL_TRIANGLE_FAN, 0, 4); |
| 147 | } |
| 148 | |
| 149 | static void SC_drawQuad(float x1, float y1, float z1, |
| 150 | float x2, float y2, float z2, |
| 151 | float x3, float y3, float z3, |
| 152 | float x4, float y4, float z4) |
| 153 | { |
| 154 | SC_drawQuadTexCoords(x1, y1, z1, 0, 1, |
| 155 | x2, y2, z2, 1, 1, |
| 156 | x3, y3, z3, 1, 0, |
| 157 | x4, y4, z4, 0, 0); |
| 158 | } |
| 159 | |
| 160 | static void SC_drawSpriteScreenspace(float x, float y, float z, float w, float h) |
| 161 | { |
| 162 | GET_TLS(); |
| 163 | ObjectBaseRef<const ProgramVertex> tmp(rsc->getVertex()); |
| 164 | rsc->setVertex(rsc->getDefaultProgramVertex()); |
| 165 | //rsc->setupCheck(); |
| 166 | |
| 167 | //GLint crop[4] = {0, h, w, -h}; |
| 168 | |
| 169 | float sh = rsc->getHeight(); |
| 170 | |
| 171 | SC_drawQuad(x, sh - y, z, |
| 172 | x+w, sh - y, z, |
| 173 | x+w, sh - (y+h), z, |
| 174 | x, sh - (y+h), z); |
| 175 | rsc->setVertex((ProgramVertex *)tmp.get()); |
| 176 | } |
Jason Sams | 6d1cf41 | 2010-06-17 18:05:38 -0700 | [diff] [blame] | 177 | /* |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 178 | static void SC_drawSprite(float x, float y, float z, float w, float h) |
| 179 | { |
| 180 | GET_TLS(); |
| 181 | float vin[3] = {x, y, z}; |
| 182 | float vout[4]; |
| 183 | |
| 184 | //LOGE("ds in %f %f %f", x, y, z); |
| 185 | rsc->getVertex()->transformToScreen(rsc, vout, vin); |
| 186 | //LOGE("ds out %f %f %f %f", vout[0], vout[1], vout[2], vout[3]); |
| 187 | vout[0] /= vout[3]; |
| 188 | vout[1] /= vout[3]; |
| 189 | vout[2] /= vout[3]; |
| 190 | |
| 191 | vout[0] *= rsc->getWidth() / 2; |
| 192 | vout[1] *= rsc->getHeight() / 2; |
| 193 | vout[0] += rsc->getWidth() / 2; |
| 194 | vout[1] += rsc->getHeight() / 2; |
| 195 | |
| 196 | vout[0] -= w/2; |
| 197 | vout[1] -= h/2; |
| 198 | |
| 199 | //LOGE("ds out2 %f %f %f", vout[0], vout[1], vout[2]); |
| 200 | |
| 201 | // U, V, W, H |
| 202 | SC_drawSpriteScreenspace(vout[0], vout[1], z, h, w); |
| 203 | //rsc->setupCheck(); |
| 204 | } |
Jason Sams | 6d1cf41 | 2010-06-17 18:05:38 -0700 | [diff] [blame] | 205 | */ |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 206 | |
| 207 | static void SC_drawRect(float x1, float y1, |
| 208 | float x2, float y2, float z) |
| 209 | { |
| 210 | //LOGE("SC_drawRect %f,%f %f,%f %f", x1, y1, x2, y2, z); |
| 211 | SC_drawQuad(x1, y2, z, |
| 212 | x2, y2, z, |
| 213 | x2, y1, z, |
| 214 | x1, y1, z); |
| 215 | } |
| 216 | |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 217 | static void SC_drawMesh(RsMesh vsm) |
| 218 | { |
| 219 | GET_TLS(); |
| 220 | Mesh *sm = static_cast<Mesh *>(vsm); |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 221 | if (!rsc->setupCheck()) { |
| 222 | return; |
| 223 | } |
| 224 | sm->render(rsc); |
| 225 | } |
| 226 | |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 227 | static void SC_drawMeshPrimitive(RsMesh vsm, uint32_t primIndex) |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 228 | { |
| 229 | GET_TLS(); |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 230 | Mesh *sm = static_cast<Mesh *>(vsm); |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 231 | if (!rsc->setupCheck()) { |
| 232 | return; |
| 233 | } |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 234 | sm->renderPrimitive(rsc, primIndex); |
| 235 | } |
| 236 | |
| 237 | static void SC_drawMeshPrimitiveRange(RsMesh vsm, uint32_t primIndex, uint32_t start, uint32_t len) |
| 238 | { |
| 239 | GET_TLS(); |
| 240 | Mesh *sm = static_cast<Mesh *>(vsm); |
| 241 | if (!rsc->setupCheck()) { |
| 242 | return; |
| 243 | } |
| 244 | sm->renderPrimitiveRange(rsc, primIndex, start, len); |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | |
| 248 | ////////////////////////////////////////////////////////////////////////////// |
| 249 | // |
| 250 | ////////////////////////////////////////////////////////////////////////////// |
| 251 | |
| 252 | |
| 253 | static void SC_color(float r, float g, float b, float a) |
| 254 | { |
| 255 | GET_TLS(); |
| 256 | rsc->mStateVertex.color[0] = r; |
| 257 | rsc->mStateVertex.color[1] = g; |
| 258 | rsc->mStateVertex.color[2] = b; |
| 259 | rsc->mStateVertex.color[3] = a; |
| 260 | if (!rsc->checkVersion2_0()) { |
| 261 | glColor4f(r, g, b, a); |
| 262 | } |
| 263 | } |
| 264 | |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 265 | static void SC_uploadToTexture2(RsAllocation va, uint32_t baseMipLevel) |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 266 | { |
| 267 | GET_TLS(); |
| 268 | rsi_AllocationUploadToTexture(rsc, va, false, baseMipLevel); |
| 269 | } |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 270 | static void SC_uploadToTexture(RsAllocation va) |
| 271 | { |
| 272 | GET_TLS(); |
| 273 | rsi_AllocationUploadToTexture(rsc, va, false, 0); |
| 274 | } |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 275 | |
| 276 | static void SC_uploadToBufferObject(RsAllocation va) |
| 277 | { |
| 278 | GET_TLS(); |
| 279 | rsi_AllocationUploadToBufferObject(rsc, va); |
| 280 | } |
| 281 | |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 282 | static void SC_ClearColor(float r, float g, float b, float a) |
| 283 | { |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 284 | GET_TLS(); |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 285 | if (!rsc->setupCheck()) { |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | glClearColor(r, g, b, a); |
| 290 | glClear(GL_COLOR_BUFFER_BIT); |
| 291 | } |
| 292 | |
| 293 | static void SC_ClearDepth(float v) |
| 294 | { |
| 295 | GET_TLS(); |
| 296 | if (!rsc->setupCheck()) { |
| 297 | return; |
| 298 | } |
| 299 | |
| 300 | glClearDepthf(v); |
| 301 | glClear(GL_DEPTH_BUFFER_BIT); |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static uint32_t SC_getWidth() |
| 305 | { |
| 306 | GET_TLS(); |
| 307 | return rsc->getWidth(); |
| 308 | } |
| 309 | |
| 310 | static uint32_t SC_getHeight() |
| 311 | { |
| 312 | GET_TLS(); |
| 313 | return rsc->getHeight(); |
| 314 | } |
| 315 | |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 316 | static void SC_DrawTextAlloc(RsAllocation va, int x, int y) |
| 317 | { |
| 318 | GET_TLS(); |
| 319 | Allocation *alloc = static_cast<Allocation *>(va); |
| 320 | rsc->mStateFont.renderText(alloc, x, y); |
| 321 | } |
| 322 | |
| 323 | static void SC_DrawText(const char *text, int x, int y) |
| 324 | { |
| 325 | GET_TLS(); |
| 326 | rsc->mStateFont.renderText(text, x, y); |
| 327 | } |
| 328 | |
| 329 | static void SC_BindFont(RsFont font) |
| 330 | { |
| 331 | GET_TLS(); |
| 332 | rsi_ContextBindFont(rsc, font); |
| 333 | } |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 334 | |
| 335 | ////////////////////////////////////////////////////////////////////////////// |
| 336 | // Class implementation |
| 337 | ////////////////////////////////////////////////////////////////////////////// |
| 338 | |
| 339 | // llvm name mangling ref |
| 340 | // <builtin-type> ::= v # void |
| 341 | // ::= b # bool |
| 342 | // ::= c # char |
| 343 | // ::= a # signed char |
| 344 | // ::= h # unsigned char |
| 345 | // ::= s # short |
| 346 | // ::= t # unsigned short |
| 347 | // ::= i # int |
| 348 | // ::= j # unsigned int |
| 349 | // ::= l # long |
| 350 | // ::= m # unsigned long |
| 351 | // ::= x # long long, __int64 |
| 352 | // ::= y # unsigned long long, __int64 |
| 353 | // ::= f # float |
| 354 | // ::= d # double |
| 355 | |
| 356 | static ScriptCState::SymbolTable_t gSyms[] = { |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 357 | { "_Z22rsgBindProgramFragment19rs_program_fragment", (void *)&SC_bindProgramFragment }, |
| 358 | { "_Z19rsgBindProgramStore16rs_program_store", (void *)&SC_bindProgramStore }, |
| 359 | { "_Z20rsgBindProgramVertex17rs_program_vertex", (void *)&SC_bindProgramVertex }, |
| 360 | { "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_bindProgramRaster }, |
| 361 | { "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_bindSampler }, |
| 362 | { "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_bindTexture }, |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 363 | |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 364 | { "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_vpLoadProjectionMatrix }, |
| 365 | { "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_vpLoadModelMatrix }, |
| 366 | { "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", (void *)&SC_vpLoadTextureMatrix }, |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 367 | |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 368 | { "_Z11rsgGetWidthv", (void *)&SC_getWidth }, |
| 369 | { "_Z12rsgGetHeightv", (void *)&SC_getHeight }, |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 370 | |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 371 | { "_Z18rsgUploadToTexture13rs_allocationj", (void *)&SC_uploadToTexture2 }, |
Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 372 | { "_Z18rsgUploadToTexture13rs_allocation", (void *)&SC_uploadToTexture }, |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 373 | { "_Z23rsgUploadToBufferObject13rs_allocation", (void *)&SC_uploadToBufferObject }, |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 374 | |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 375 | { "_Z11rsgDrawRectfffff", (void *)&SC_drawRect }, |
| 376 | { "_Z11rsgDrawQuadffffffffffff", (void *)&SC_drawQuad }, |
| 377 | { "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", (void *)&SC_drawQuadTexCoords }, |
| 378 | { "_Z24rsgDrawSpriteScreenspacefffff", (void *)&SC_drawSpriteScreenspace }, |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 379 | |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 380 | { "_Z11rsgDrawMesh7rs_mesh", (void *)&SC_drawMesh }, |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 381 | { "_Z11rsgDrawMesh7rs_meshj", (void *)&SC_drawMeshPrimitive }, |
| 382 | { "_Z11rsgDrawMesh7rs_meshjjj", (void *)&SC_drawMeshPrimitiveRange }, |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 383 | |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 384 | { "_Z13rsgClearColorffff", (void *)&SC_ClearColor }, |
| 385 | { "_Z13rsgClearDepthf", (void *)&SC_ClearDepth }, |
Jason Sams | d79b2e9 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 386 | |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 387 | { "_Z11rsgDrawTextPKcii", (void *)&SC_DrawText }, |
| 388 | { "_Z11rsgDrawText13rs_allocationii", (void *)&SC_DrawTextAlloc }, |
| 389 | |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 390 | { "_Z11rsgBindFont7rs_font", (void *)&SC_BindFont }, |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 391 | |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 392 | // misc |
Jason Sams | f0690c4 | 2010-07-29 17:31:14 -0700 | [diff] [blame^] | 393 | { "_Z5colorffff", (void *)&SC_color }, |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 394 | |
Jason Sams | 536923d | 2010-05-18 13:35:45 -0700 | [diff] [blame] | 395 | { NULL, NULL } |
| 396 | }; |
| 397 | |
| 398 | const ScriptCState::SymbolTable_t * ScriptCState::lookupSymbolGL(const char *sym) |
| 399 | { |
| 400 | ScriptCState::SymbolTable_t *syms = gSyms; |
| 401 | |
| 402 | while (syms->mPtr) { |
| 403 | if (!strcmp(syms->mName, sym)) { |
| 404 | return syms; |
| 405 | } |
| 406 | syms++; |
| 407 | } |
| 408 | return NULL; |
| 409 | } |
| 410 | |