rsdShader.cpp revision d32b7491f2f3ad65fc274e92c16f8e2213861d7a
1/* 2 * Copyright (C) 2011 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 <GLES2/gl2.h> 18#include <GLES2/gl2ext.h> 19 20#include <rs_hal.h> 21#include <rsContext.h> 22#include <rsProgram.h> 23 24#include "rsdCore.h" 25#include "rsdAllocation.h" 26#include "rsdShader.h" 27#include "rsdShaderCache.h" 28 29using namespace android; 30using namespace android::renderscript; 31 32RsdShader::RsdShader(const Program *p, uint32_t type, 33 const char * shaderText, uint32_t shaderLength) { 34 35 mUserShader.setTo(shaderText, shaderLength); 36 mRSProgram = p; 37 mType = type; 38 initMemberVars(); 39 initAttribAndUniformArray(); 40 init(); 41} 42 43RsdShader::~RsdShader() { 44 if (mShaderID) { 45 glDeleteShader(mShaderID); 46 } 47 48 delete[] mAttribNames; 49 delete[] mUniformNames; 50 delete[] mUniformArraySizes; 51 delete[] mTextureTargets; 52} 53 54void RsdShader::initMemberVars() { 55 mDirty = true; 56 mShaderID = 0; 57 mAttribCount = 0; 58 mUniformCount = 0; 59 60 mAttribNames = NULL; 61 mUniformNames = NULL; 62 mUniformArraySizes = NULL; 63 mTextureTargets = NULL; 64 65 mIsValid = false; 66} 67 68void RsdShader::init() { 69 uint32_t attribCount = 0; 70 uint32_t uniformCount = 0; 71 for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) { 72 initAddUserElement(mRSProgram->mHal.state.inputElements[ct], mAttribNames, NULL, &attribCount, RS_SHADER_ATTR); 73 } 74 for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) { 75 initAddUserElement(mRSProgram->mHal.state.constantTypes[ct]->getElement(), mUniformNames, mUniformArraySizes, &uniformCount, RS_SHADER_UNI); 76 } 77 78 mTextureUniformIndexStart = uniformCount; 79 char buf[256]; 80 for (uint32_t ct=0; ct < mRSProgram->mHal.state.texturesCount; ct++) { 81 snprintf(buf, sizeof(buf), "UNI_Tex%i", ct); 82 mUniformNames[uniformCount].setTo(buf); 83 mUniformArraySizes[uniformCount] = 1; 84 uniformCount++; 85 } 86 87} 88 89String8 RsdShader::getGLSLInputString() const { 90 String8 s; 91 for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) { 92 const Element *e = mRSProgram->mHal.state.inputElements[ct]; 93 for (uint32_t field=0; field < e->getFieldCount(); field++) { 94 const Element *f = e->getField(field); 95 96 // Cannot be complex 97 rsAssert(!f->getFieldCount()); 98 switch (f->getComponent().getVectorSize()) { 99 case 1: s.append("attribute float ATTRIB_"); break; 100 case 2: s.append("attribute vec2 ATTRIB_"); break; 101 case 3: s.append("attribute vec3 ATTRIB_"); break; 102 case 4: s.append("attribute vec4 ATTRIB_"); break; 103 default: 104 rsAssert(0); 105 } 106 107 s.append(e->getFieldName(field)); 108 s.append(";\n"); 109 } 110 } 111 return s; 112} 113 114void RsdShader::appendAttributes() { 115 for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) { 116 const Element *e = mRSProgram->mHal.state.inputElements[ct]; 117 for (uint32_t field=0; field < e->getFieldCount(); field++) { 118 const Element *f = e->getField(field); 119 const char *fn = e->getFieldName(field); 120 121 if (fn[0] == '#') { 122 continue; 123 } 124 125 // Cannot be complex 126 rsAssert(!f->getFieldCount()); 127 switch (f->getComponent().getVectorSize()) { 128 case 1: mShader.append("attribute float ATTRIB_"); break; 129 case 2: mShader.append("attribute vec2 ATTRIB_"); break; 130 case 3: mShader.append("attribute vec3 ATTRIB_"); break; 131 case 4: mShader.append("attribute vec4 ATTRIB_"); break; 132 default: 133 rsAssert(0); 134 } 135 136 mShader.append(fn); 137 mShader.append(";\n"); 138 } 139 } 140} 141 142void RsdShader::appendTextures() { 143 char buf[256]; 144 for (uint32_t ct=0; ct < mRSProgram->mHal.state.texturesCount; ct++) { 145 if (mRSProgram->mHal.state.textureTargets[ct] == RS_TEXTURE_2D) { 146 Allocation *a = mRSProgram->mHal.state.textures[ct]; 147 if (a && a->mHal.state.surfaceTextureID) { 148 snprintf(buf, sizeof(buf), "uniform samplerExternalOES UNI_Tex%i;\n", ct); 149 } else { 150 snprintf(buf, sizeof(buf), "uniform sampler2D UNI_Tex%i;\n", ct); 151 } 152 mTextureTargets[ct] = GL_TEXTURE_2D; 153 } else { 154 snprintf(buf, sizeof(buf), "uniform samplerCube UNI_Tex%i;\n", ct); 155 mTextureTargets[ct] = GL_TEXTURE_CUBE_MAP; 156 } 157 mShader.append(buf); 158 } 159} 160 161bool RsdShader::createShader() { 162 163 if (mType == GL_FRAGMENT_SHADER) { 164 mShader.append("precision mediump float;\n"); 165 } 166 appendUserConstants(); 167 appendAttributes(); 168 appendTextures(); 169 170 mShader.append(mUserShader); 171 172 return true; 173} 174 175bool RsdShader::loadShader(const Context *rsc) { 176 mShaderID = glCreateShader(mType); 177 rsAssert(mShaderID); 178 179 if (rsc->props.mLogShaders) { 180 ALOGV("Loading shader type %x, ID %i", mType, mShaderID); 181 ALOGV("%s", mShader.string()); 182 } 183 184 if (mShaderID) { 185 const char * ss = mShader.string(); 186 RSD_CALL_GL(glShaderSource, mShaderID, 1, &ss, NULL); 187 RSD_CALL_GL(glCompileShader, mShaderID); 188 189 GLint compiled = 0; 190 RSD_CALL_GL(glGetShaderiv, mShaderID, GL_COMPILE_STATUS, &compiled); 191 if (!compiled) { 192 GLint infoLen = 0; 193 RSD_CALL_GL(glGetShaderiv, mShaderID, GL_INFO_LOG_LENGTH, &infoLen); 194 if (infoLen) { 195 char* buf = (char*) malloc(infoLen); 196 if (buf) { 197 RSD_CALL_GL(glGetShaderInfoLog, mShaderID, infoLen, NULL, buf); 198 rsc->setError(RS_ERROR_FATAL_PROGRAM_LINK, buf); 199 free(buf); 200 } 201 RSD_CALL_GL(glDeleteShader, mShaderID); 202 mShaderID = 0; 203 return false; 204 } 205 } 206 } 207 208 if (rsc->props.mLogShaders) { 209 ALOGV("--Shader load result %x ", glGetError()); 210 } 211 mIsValid = true; 212 return true; 213} 214 215void RsdShader::appendUserConstants() { 216 for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) { 217 const Element *e = mRSProgram->mHal.state.constantTypes[ct]->getElement(); 218 for (uint32_t field=0; field < e->getFieldCount(); field++) { 219 const Element *f = e->getField(field); 220 const char *fn = e->getFieldName(field); 221 222 if (fn[0] == '#') { 223 continue; 224 } 225 226 // Cannot be complex 227 rsAssert(!f->getFieldCount()); 228 if (f->getType() == RS_TYPE_MATRIX_4X4) { 229 mShader.append("uniform mat4 UNI_"); 230 } else if (f->getType() == RS_TYPE_MATRIX_3X3) { 231 mShader.append("uniform mat3 UNI_"); 232 } else if (f->getType() == RS_TYPE_MATRIX_2X2) { 233 mShader.append("uniform mat2 UNI_"); 234 } else { 235 switch (f->getComponent().getVectorSize()) { 236 case 1: mShader.append("uniform float UNI_"); break; 237 case 2: mShader.append("uniform vec2 UNI_"); break; 238 case 3: mShader.append("uniform vec3 UNI_"); break; 239 case 4: mShader.append("uniform vec4 UNI_"); break; 240 default: 241 rsAssert(0); 242 } 243 } 244 245 mShader.append(fn); 246 if (e->getFieldArraySize(field) > 1) { 247 mShader.appendFormat("[%d]", e->getFieldArraySize(field)); 248 } 249 mShader.append(";\n"); 250 } 251 } 252} 253 254void RsdShader::logUniform(const Element *field, const float *fd, uint32_t arraySize ) { 255 RsDataType dataType = field->getType(); 256 uint32_t elementSize = field->getSizeBytes() / sizeof(float); 257 for (uint32_t i = 0; i < arraySize; i ++) { 258 if (arraySize > 1) { 259 ALOGV("Array Element [%u]", i); 260 } 261 if (dataType == RS_TYPE_MATRIX_4X4) { 262 ALOGV("Matrix4x4"); 263 ALOGV("{%f, %f, %f, %f", fd[0], fd[4], fd[8], fd[12]); 264 ALOGV(" %f, %f, %f, %f", fd[1], fd[5], fd[9], fd[13]); 265 ALOGV(" %f, %f, %f, %f", fd[2], fd[6], fd[10], fd[14]); 266 ALOGV(" %f, %f, %f, %f}", fd[3], fd[7], fd[11], fd[15]); 267 } else if (dataType == RS_TYPE_MATRIX_3X3) { 268 ALOGV("Matrix3x3"); 269 ALOGV("{%f, %f, %f", fd[0], fd[3], fd[6]); 270 ALOGV(" %f, %f, %f", fd[1], fd[4], fd[7]); 271 ALOGV(" %f, %f, %f}", fd[2], fd[5], fd[8]); 272 } else if (dataType == RS_TYPE_MATRIX_2X2) { 273 ALOGV("Matrix2x2"); 274 ALOGV("{%f, %f", fd[0], fd[2]); 275 ALOGV(" %f, %f}", fd[1], fd[3]); 276 } else { 277 switch (field->getComponent().getVectorSize()) { 278 case 1: 279 ALOGV("Uniform 1 = %f", fd[0]); 280 break; 281 case 2: 282 ALOGV("Uniform 2 = %f %f", fd[0], fd[1]); 283 break; 284 case 3: 285 ALOGV("Uniform 3 = %f %f %f", fd[0], fd[1], fd[2]); 286 break; 287 case 4: 288 ALOGV("Uniform 4 = %f %f %f %f", fd[0], fd[1], fd[2], fd[3]); 289 break; 290 default: 291 rsAssert(0); 292 } 293 } 294 ALOGE("Element size %u data=%p", elementSize, fd); 295 fd += elementSize; 296 ALOGE("New data=%p", fd); 297 } 298} 299 300void RsdShader::setUniform(const Context *rsc, const Element *field, const float *fd, 301 int32_t slot, uint32_t arraySize ) { 302 RsDataType dataType = field->getType(); 303 if (dataType == RS_TYPE_MATRIX_4X4) { 304 RSD_CALL_GL(glUniformMatrix4fv, slot, arraySize, GL_FALSE, fd); 305 } else if (dataType == RS_TYPE_MATRIX_3X3) { 306 RSD_CALL_GL(glUniformMatrix3fv, slot, arraySize, GL_FALSE, fd); 307 } else if (dataType == RS_TYPE_MATRIX_2X2) { 308 RSD_CALL_GL(glUniformMatrix2fv, slot, arraySize, GL_FALSE, fd); 309 } else { 310 switch (field->getComponent().getVectorSize()) { 311 case 1: 312 RSD_CALL_GL(glUniform1fv, slot, arraySize, fd); 313 break; 314 case 2: 315 RSD_CALL_GL(glUniform2fv, slot, arraySize, fd); 316 break; 317 case 3: 318 RSD_CALL_GL(glUniform3fv, slot, arraySize, fd); 319 break; 320 case 4: 321 RSD_CALL_GL(glUniform4fv, slot, arraySize, fd); 322 break; 323 default: 324 rsAssert(0); 325 } 326 } 327} 328 329void RsdShader::setupSampler(const Context *rsc, const Sampler *s, const Allocation *tex) { 330 RsdHal *dc = (RsdHal *)rsc->mHal.drv; 331 332 GLenum trans[] = { 333 GL_NEAREST, //RS_SAMPLER_NEAREST, 334 GL_LINEAR, //RS_SAMPLER_LINEAR, 335 GL_LINEAR_MIPMAP_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR, 336 GL_REPEAT, //RS_SAMPLER_WRAP, 337 GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP 338 GL_LINEAR_MIPMAP_NEAREST, //RS_SAMPLER_LINEAR_MIP_NEAREST 339 }; 340 341 GLenum transNP[] = { 342 GL_NEAREST, //RS_SAMPLER_NEAREST, 343 GL_LINEAR, //RS_SAMPLER_LINEAR, 344 GL_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR, 345 GL_CLAMP_TO_EDGE, //RS_SAMPLER_WRAP, 346 GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP 347 GL_LINEAR, //RS_SAMPLER_LINEAR_MIP_NEAREST, 348 }; 349 350 // This tells us the correct texture type 351 DrvAllocation *drvTex = (DrvAllocation *)tex->mHal.drv; 352 const GLenum target = drvTex->glTarget; 353 354 if (!dc->gl.gl.OES_texture_npot && tex->getType()->getIsNp2()) { 355 if (tex->getHasGraphicsMipmaps() && 356 (dc->gl.gl.NV_texture_npot_2D_mipmap || dc->gl.gl.IMG_texture_npot)) { 357 if (dc->gl.gl.NV_texture_npot_2D_mipmap) { 358 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER, 359 trans[s->mHal.state.minFilter]); 360 } else { 361 switch (trans[s->mHal.state.minFilter]) { 362 case GL_LINEAR_MIPMAP_LINEAR: 363 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER, 364 GL_LINEAR_MIPMAP_NEAREST); 365 break; 366 default: 367 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER, 368 trans[s->mHal.state.minFilter]); 369 break; 370 } 371 } 372 } else { 373 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER, 374 transNP[s->mHal.state.minFilter]); 375 } 376 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MAG_FILTER, 377 transNP[s->mHal.state.magFilter]); 378 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_S, transNP[s->mHal.state.wrapS]); 379 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_T, transNP[s->mHal.state.wrapT]); 380 } else { 381 if (tex->getHasGraphicsMipmaps()) { 382 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER, 383 trans[s->mHal.state.minFilter]); 384 } else { 385 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MIN_FILTER, 386 transNP[s->mHal.state.minFilter]); 387 } 388 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_MAG_FILTER, trans[s->mHal.state.magFilter]); 389 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_S, trans[s->mHal.state.wrapS]); 390 RSD_CALL_GL(glTexParameteri, target, GL_TEXTURE_WRAP_T, trans[s->mHal.state.wrapT]); 391 } 392 393 float anisoValue = rsMin(dc->gl.gl.EXT_texture_max_aniso, s->mHal.state.aniso); 394 if (dc->gl.gl.EXT_texture_max_aniso > 1.0f) { 395 RSD_CALL_GL(glTexParameterf, target, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisoValue); 396 } 397 398 rsdGLCheckError(rsc, "Sampler::setup tex env"); 399} 400 401void RsdShader::setupTextures(const Context *rsc, RsdShaderCache *sc) { 402 if (mRSProgram->mHal.state.texturesCount == 0) { 403 return; 404 } 405 406 RsdHal *dc = (RsdHal *)rsc->mHal.drv; 407 408 uint32_t numTexturesToBind = mRSProgram->mHal.state.texturesCount; 409 uint32_t numTexturesAvailable = dc->gl.gl.maxFragmentTextureImageUnits; 410 if (numTexturesToBind >= numTexturesAvailable) { 411 ALOGE("Attempting to bind %u textures on shader id %u, but only %u are available", 412 mRSProgram->mHal.state.texturesCount, (uint32_t)this, numTexturesAvailable); 413 rsc->setError(RS_ERROR_BAD_SHADER, "Cannot bind more textuers than available"); 414 numTexturesToBind = numTexturesAvailable; 415 } 416 417 for (uint32_t ct=0; ct < numTexturesToBind; ct++) { 418 RSD_CALL_GL(glActiveTexture, GL_TEXTURE0 + ct); 419 RSD_CALL_GL(glUniform1i, sc->fragUniformSlot(mTextureUniformIndexStart + ct), ct); 420 421 if (!mRSProgram->mHal.state.textures[ct]) { 422 // if nothing is bound, reset to default GL texture 423 RSD_CALL_GL(glBindTexture, mTextureTargets[ct], 0); 424 continue; 425 } 426 427 DrvAllocation *drvTex = (DrvAllocation *)mRSProgram->mHal.state.textures[ct]->mHal.drv; 428 if (drvTex->glTarget != GL_TEXTURE_2D && drvTex->glTarget != GL_TEXTURE_CUBE_MAP) { 429 ALOGE("Attempting to bind unknown texture to shader id %u, texture unit %u", (uint)this, ct); 430 rsc->setError(RS_ERROR_BAD_SHADER, "Non-texture allocation bound to a shader"); 431 } 432 RSD_CALL_GL(glBindTexture, drvTex->glTarget, drvTex->textureID); 433 rsdGLCheckError(rsc, "ProgramFragment::setup tex bind"); 434 if (mRSProgram->mHal.state.samplers[ct]) { 435 setupSampler(rsc, mRSProgram->mHal.state.samplers[ct], 436 mRSProgram->mHal.state.textures[ct]); 437 } else { 438 RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 439 RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 440 RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 441 RSD_CALL_GL(glTexParameteri, drvTex->glTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 442 rsdGLCheckError(rsc, "ProgramFragment::setup tex env"); 443 } 444 rsdGLCheckError(rsc, "ProgramFragment::setup uniforms"); 445 } 446 447 RSD_CALL_GL(glActiveTexture, GL_TEXTURE0); 448 mDirty = false; 449 rsdGLCheckError(rsc, "ProgramFragment::setup"); 450} 451 452void RsdShader::setupUserConstants(const Context *rsc, RsdShaderCache *sc, bool isFragment) { 453 uint32_t uidx = 0; 454 for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) { 455 Allocation *alloc = mRSProgram->mHal.state.constants[ct]; 456 if (!alloc) { 457 ALOGE("Attempting to set constants on shader id %u, but alloc at slot %u is not set", 458 (uint32_t)this, ct); 459 rsc->setError(RS_ERROR_BAD_SHADER, "No constant allocation bound"); 460 continue; 461 } 462 463 const uint8_t *data = static_cast<const uint8_t *>(alloc->getPtr()); 464 const Element *e = mRSProgram->mHal.state.constantTypes[ct]->getElement(); 465 for (uint32_t field=0; field < e->getFieldCount(); field++) { 466 const Element *f = e->getField(field); 467 const char *fieldName = e->getFieldName(field); 468 // If this field is padding, skip it 469 if (fieldName[0] == '#') { 470 continue; 471 } 472 473 uint32_t offset = e->getFieldOffsetBytes(field); 474 const float *fd = reinterpret_cast<const float *>(&data[offset]); 475 476 int32_t slot = -1; 477 uint32_t arraySize = 1; 478 if (!isFragment) { 479 slot = sc->vtxUniformSlot(uidx); 480 arraySize = sc->vtxUniformSize(uidx); 481 } else { 482 slot = sc->fragUniformSlot(uidx); 483 arraySize = sc->fragUniformSize(uidx); 484 } 485 if (rsc->props.mLogShadersUniforms) { 486 ALOGV("Uniform slot=%i, offset=%i, constant=%i, field=%i, uidx=%i, name=%s", 487 slot, offset, ct, field, uidx, fieldName); 488 } 489 uidx ++; 490 if (slot < 0) { 491 continue; 492 } 493 494 if (rsc->props.mLogShadersUniforms) { 495 logUniform(f, fd, arraySize); 496 } 497 setUniform(rsc, f, fd, slot, arraySize); 498 } 499 } 500} 501 502void RsdShader::setup(const android::renderscript::Context *rsc, RsdShaderCache *sc) { 503 504 setupUserConstants(rsc, sc, mType == GL_FRAGMENT_SHADER); 505 setupTextures(rsc, sc); 506} 507 508void RsdShader::initAttribAndUniformArray() { 509 mAttribCount = 0; 510 for (uint32_t ct=0; ct < mRSProgram->mHal.state.inputElementsCount; ct++) { 511 const Element *elem = mRSProgram->mHal.state.inputElements[ct]; 512 for (uint32_t field=0; field < elem->getFieldCount(); field++) { 513 if (elem->getFieldName(field)[0] != '#') { 514 mAttribCount ++; 515 } 516 } 517 } 518 519 mUniformCount = 0; 520 for (uint32_t ct=0; ct < mRSProgram->mHal.state.constantsCount; ct++) { 521 const Element *elem = mRSProgram->mHal.state.constantTypes[ct]->getElement(); 522 523 for (uint32_t field=0; field < elem->getFieldCount(); field++) { 524 if (elem->getFieldName(field)[0] != '#') { 525 mUniformCount ++; 526 } 527 } 528 } 529 mUniformCount += mRSProgram->mHal.state.texturesCount; 530 531 if (mAttribCount) { 532 mAttribNames = new String8[mAttribCount]; 533 } 534 if (mUniformCount) { 535 mUniformNames = new String8[mUniformCount]; 536 mUniformArraySizes = new uint32_t[mUniformCount]; 537 } 538 539 mTextureCount = mRSProgram->mHal.state.texturesCount; 540 if (mTextureCount) { 541 mTextureTargets = new uint32_t[mTextureCount]; 542 } 543} 544 545void RsdShader::initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths, 546 uint32_t *count, const char *prefix) { 547 rsAssert(e->getFieldCount()); 548 for (uint32_t ct=0; ct < e->getFieldCount(); ct++) { 549 const Element *ce = e->getField(ct); 550 if (ce->getFieldCount()) { 551 initAddUserElement(ce, names, arrayLengths, count, prefix); 552 } else if (e->getFieldName(ct)[0] != '#') { 553 String8 tmp(prefix); 554 tmp.append(e->getFieldName(ct)); 555 names[*count].setTo(tmp.string()); 556 if (arrayLengths) { 557 arrayLengths[*count] = e->getFieldArraySize(ct); 558 } 559 (*count)++; 560 } 561 } 562} 563