GIntBig *OGRMIAttrIndex::GetAllMatches( OGRField *psKey, GIntBig* panFIDList, int* nFIDCount, int* nLength ) { GByte *pabyKey = BuildKey( psKey ); GIntBig nFID; if (panFIDList == NULL) { panFIDList = (GIntBig *) CPLMalloc(sizeof(GIntBig) * 2); *nFIDCount = 0; *nLength = 2; } nFID = poINDFile->FindFirst( iIndex, pabyKey ); while( nFID > 0 ) { if( *nFIDCount >= *nLength-1 ) { *nLength = (*nLength) * 2 + 10; panFIDList = (GIntBig *) CPLRealloc(panFIDList, sizeof(GIntBig)* (*nLength)); } panFIDList[(*nFIDCount)++] = nFID - 1; nFID = poINDFile->FindNext( iIndex, pabyKey ); } panFIDList[*nFIDCount] = OGRNullFID; return panFIDList; }
GIntBig OGRMIAttrIndex::GetFirstMatch( OGRField *psKey ) { GByte *pabyKey = BuildKey( psKey ); const GIntBig nFID = poINDFile->FindFirst( iIndex, pabyKey ); if( nFID < 1 ) return OGRNullFID; else return nFID - 1; }
bool psOptions::GetOption(const char * className, const char * name, bool defaultValue) { csString key; BuildKey(key, className, name); EnsureSubscription(key); if (configFile->KeyExists(key)) return configFile->GetBool(key); SetOption(className, name, defaultValue); return defaultValue; }
OGRErr OGRMIAttrIndex::AddEntry( OGRField *psKey, long nFID ) { GByte *pabyKey = BuildKey( psKey ); if( psKey == NULL ) return OGRERR_FAILURE; if( poINDFile->AddEntry( iIndex, pabyKey, nFID+1 ) != 0 ) return OGRERR_FAILURE; else return OGRERR_NONE; }
OGRErr OGRMIAttrIndex::AddEntry( OGRField *psKey, GIntBig nFID ) { if( psKey == nullptr ) return OGRERR_FAILURE; if( nFID >= INT_MAX ) return OGRERR_FAILURE; GByte *pabyKey = BuildKey( psKey ); if( pabyKey == nullptr ) return OGRERR_FAILURE; if( poINDFile->AddEntry( iIndex, pabyKey, static_cast<int>(nFID)+1 ) != 0 ) return OGRERR_FAILURE; else return OGRERR_NONE; }
OGRErr OGRMIAttrIndex::AddEntry( OGRField *psKey, GIntBig nFID ) { if( psKey == NULL ) return OGRERR_FAILURE; if( nFID >= INT_MAX ) return OGRERR_FAILURE; GByte *pabyKey = BuildKey( psKey ); if( pabyKey == NULL ) return OGRERR_FAILURE; if( poINDFile->AddEntry( iIndex, pabyKey, (int)nFID+1 ) != 0 ) return OGRERR_FAILURE; else return OGRERR_NONE; }
bool SetAttributes(HCOSE hHandle, const cn_cbor * pAttributes, int which, int msgType, bool fPublicKey) { const cn_cbor * pKey; const cn_cbor * pValue; int keyNew; cn_cbor * pValueNew; bool f = false; if (pAttributes == NULL) return true; if (pAttributes->type != CN_CBOR_MAP) return false; for (pKey = pAttributes->first_child; pKey != NULL; pKey = pKey->next->next) { pValue = pKey->next; if (pKey->type != CN_CBOR_TEXT) return false; if (strcmp(pKey->v.str, "alg") == 0) { keyNew = COSE_Header_Algorithm; pValueNew = cn_cbor_int_create(MapAlgorithmName(pValue), CBOR_CONTEXT_PARAM_COMMA NULL); } else if (strcmp(pKey->v.str, "ctyp") == 0) { keyNew = COSE_Header_Content_Type; pValueNew = cn_cbor_clone(pValue, CBOR_CONTEXT_PARAM_COMMA NULL); if (pValueNew == NULL) return false; } else if (strcmp(pKey->v.str, "IV_hex") == 0) { keyNew = COSE_Header_IV; pValueNew = cn_cbor_data_create(FromHex(pValue->v.str, (int) pValue->length), (int) pValue->length / 2, CBOR_CONTEXT_PARAM_COMMA NULL); } else if (strcmp(pKey->v.str, "apu_id") == 0) { keyNew = COSE_Header_KDF_U_name; pValueNew = cn_cbor_data_create(pValue->v.bytes, (int)pValue->length, CBOR_CONTEXT_PARAM_COMMA NULL); if (pValueNew == NULL) return false; } else if (strcmp(pKey->v.str, "apv_id") == 0) { keyNew = COSE_Header_KDF_V_name; pValueNew = cn_cbor_data_create(pValue->v.bytes, (int)pValue->length, CBOR_CONTEXT_PARAM_COMMA NULL); if (pValueNew == NULL) return false; } else if (strcmp(pKey->v.str, "pub_other") == 0) { keyNew = COSE_Header_KDF_PUB_other; pValueNew = cn_cbor_data_create(pValue->v.bytes, (int)pValue->length, CBOR_CONTEXT_PARAM_COMMA NULL); if (pValueNew == NULL) return false; } else if (strcmp(pKey->v.str, "priv_other") == 0) { keyNew = COSE_Header_KDF_PRIV; pValueNew = cn_cbor_data_create(pValue->v.bytes, (int)pValue->length, CBOR_CONTEXT_PARAM_COMMA NULL); if (pValueNew == NULL) return false; } else if (strcmp(pKey->v.str, "spk") == 0) { keyNew = COSE_Header_ECDH_STATIC; pValueNew = BuildKey(pValue, fPublicKey); if (pValueNew == NULL) return false; } else { continue; } switch (msgType) { #if INCLUDE_MAC case Attributes_MAC_protected: f = COSE_Mac_map_put_int((HCOSE_MAC)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_MAC0 case Attributes_MAC0_protected: f = COSE_Mac0_map_put_int((HCOSE_MAC0)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_ENCRYPT || INCLUDE_MAC case Attributes_Recipient_protected: f = COSE_Recipient_map_put_int((HCOSE_RECIPIENT)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_ENCRYPT case Attributes_Enveloped_protected: f = COSE_Enveloped_map_put_int((HCOSE_ENVELOPED)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_ENCRYPT0 case Attributes_Encrypt_protected: f = COSE_Encrypt_map_put_int((HCOSE_ENCRYPT)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_SIGN case Attributes_Sign_protected: f = COSE_Sign_map_put_int((HCOSE_SIGN)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_SIGN case Attributes_Signer_protected: f = COSE_Signer_map_put_int((HCOSE_SIGNER)hHandle, keyNew, pValueNew, which, NULL); break; #endif #if INCLUDE_SIGN0 case Attributes_Sign0_protected: f = COSE_Sign0_map_put_int((HCOSE_SIGN0)hHandle, keyNew, pValueNew, which, NULL); break; #endif } // assert(f); } return true; }
void GraphicsGL2::DrawScenePass( const GraphicsConfigPass & pass, std::map <std::string, PtrVector <Drawable> > & culled_static_drawlist, std::ostream & error_output) { // log failure here? if (!pass.conditions.Satisfied(conditions)) return; // setup shader shader_map_type::iterator si = shaders.find(pass.shader); if (si == shaders.end()) { ReportOnce(&pass, "Shader " + pass.shader + " couldn't be found", error_output); return; } renderscene.SetShader(&si->second); // setup textures std::vector <TextureInterface*> input_textures; GetScenePassInputTextures(pass.inputs, input_textures); renderscene.SetTextures(glstate, input_textures, error_output); // setup state renderscene.SetColorMask(glstate, pass.write_color, pass.write_alpha); renderscene.SetDepthMode(glstate, DepthModeFromString(pass.depthtest), pass.write_depth); renderscene.SetBlendMode(glstate, BlendModeFromString(pass.blendmode)); // setup output render_output_map_type::iterator oi = render_outputs.find(pass.output); if (oi == render_outputs.end()) { ReportOnce(&pass, "Render output " + pass.output + " couldn't be found", error_output); return; } RenderOutput & output = oi->second; // handle the cubemap case const bool cubemap = (output.IsFBO() && output.RenderToFBO().IsCubemap()); const int cubesides = cubemap ? 6 : 1; std::string cameraname = pass.camera; for (int cubeside = 0; cubeside < cubesides; cubeside++) { if (cubemap) { // build a name for the sub camera std::stringstream converter; converter << pass.camera << "_cubeside" << cubeside; cameraname = converter.str(); // attach the correct cube side on the render output AttachCubeSide(cubeside, output.RenderToFBO(), error_output); } // setup camera camera_map_type::iterator ci = cameras.find(cameraname); if (ci == cameras.end()) { ReportOnce(&pass, "Camera " + pass.camera + " couldn't be found", error_output); return; } renderscene.SetCamera(ci->second); // render pass draw layers output.Begin(glstate, error_output); renderscene.ClearOutput(glstate, pass.clear_color, pass.clear_depth); for (std::vector <std::string>::const_iterator d = pass.draw.begin(); d != pass.draw.end(); d++) { const std::string & layer = *d; // setup dynamic drawlist reseatable_reference <PtrVector <Drawable> > container_dynamic = dynamic_drawlist.GetByName(layer); if (!container_dynamic) { ReportOnce(&pass, "Drawable container " + layer + " couldn't be found", error_output); return; } // setup static drawlist const std::string drawlist_key = BuildKey(cameraname, layer); std::map <std::string, PtrVector <Drawable> >::const_iterator container_static = culled_static_drawlist.find(drawlist_key); if (container_static == culled_static_drawlist.end()) { ReportOnce(&pass, "Couldn't find culled static drawlist for camera/draw combination: " + drawlist_key, error_output); return; } if (!container_dynamic->empty() || !container_static->second.empty()) { renderscene.SetDrawLists(*container_dynamic, container_static->second); renderscene.Render(glstate, error_output); } } output.End(glstate, error_output); CheckForOpenGLErrors("render output end", error_output); } }
void GraphicsGL2::CullScenePass( const GraphicsConfigPass & pass, std::map <std::string, PtrVector <Drawable> > & culled_static_drawlist, std::ostream & error_output) { // for each pass, we have which camera and which draw layer to use // we want to do culling for each unique camera and draw layer combination // use camera/layer as the unique key assert(!pass.draw.empty()); if (pass.draw.back() == "postprocess" || !pass.conditions.Satisfied(conditions)) return; for (std::vector <std::string>::const_iterator d = pass.draw.begin(); d != pass.draw.end(); d++) { // determine if we're dealing with a cubemap render_output_map_type::iterator oi = render_outputs.find(pass.output); if (oi == render_outputs.end()) { ReportOnce(&pass, "Render output "+pass.output+" couldn't be found", error_output); return; } const bool cubemap = (oi->second.IsFBO() && oi->second.RenderToFBO().IsCubemap()); const int cubesides = cubemap ? 6 : 1; std::string cameraname = pass.camera; for (int cubeside = 0; cubeside < cubesides; cubeside++) { if (cubemap) { // build sub-camera // build a name for the sub camera { std::stringstream converter; converter << pass.camera << "_cubeside" << cubeside; cameraname = converter.str(); } // get the base camera camera_map_type::iterator bci = cameras.find(pass.camera); if (bci == cameras.end()) { ReportOnce(&pass, "Camera "+pass.camera+" couldn't be found", error_output); return; } // create our sub-camera GraphicsCamera & cam = cameras[cameraname]; cam = bci->second; // set the sub-camera's properties cam.rot = GetCubeSideOrientation(cubeside, cam.rot, error_output); cam.fov = 90; assert(oi->second.IsFBO()); const FrameBufferObject & fbo = oi->second.RenderToFBO(); cam.w = fbo.GetWidth(); cam.h = fbo.GetHeight(); } std::string key = BuildKey(cameraname, *d); if (pass.cull) { camera_map_type::iterator ci = cameras.find(cameraname); if (ci == cameras.end()) { ReportOnce(&pass, "Camera "+cameraname+" couldn't be found", error_output); return; } GraphicsCamera & cam = ci->second; if (culled_static_drawlist.find(key) == culled_static_drawlist.end()) { Frustum frustum; frustum.Extract(GetProjMatrix(cam).GetArray(), GetViewMatrix(cam).GetArray()); reseatable_reference <AabbTreeNodeAdapter <Drawable> > container = static_drawlist.GetDrawlist().GetByName(*d); if (!container) { ReportOnce(&pass, "Drawable container "+*d+" couldn't be found", error_output); return; } container->Query(frustum, culled_static_drawlist[key]); } } else { reseatable_reference <AabbTreeNodeAdapter <Drawable> > container = static_drawlist.GetDrawlist().GetByName(*d); if (!container) { ReportOnce(&pass, "Drawable container "+*d+" couldn't be found", error_output); return; } container->Query(Aabb<float>::IntersectAlways(), culled_static_drawlist[key]); } } } }
void GraphicsGL2::CullScenePass( const GraphicsConfigPass & pass, std::ostream & error_output) { // for each pass, we have which camera and which draw layer to use // we want to do culling for each unique camera and draw layer combination // use camera/layer as the unique key assert(!pass.draw.empty()); if (pass.draw.back() == "postprocess" || !pass.conditions.Satisfied(conditions)) return; for (std::vector <std::string>::const_iterator d = pass.draw.begin(); d != pass.draw.end(); d++) { // determine if we're dealing with a cubemap RenderOutputMap::iterator oi = render_outputs.find(pass.output); if (oi == render_outputs.end()) { ReportOnce(&pass, "Render output "+pass.output+" couldn't be found", error_output); return; } const bool cubemap = (oi->second.IsFBO() && oi->second.RenderToFBO().IsCubemap()); const int cubesides = cubemap ? 6 : 1; std::string cameraname = pass.camera; for (int cubeside = 0; cubeside < cubesides; cubeside++) { if (cubemap) { // build a name for the sub camera { std::ostringstream s; s << pass.camera << "_cubeside" << cubeside; cameraname = s.str(); } // get the base camera CameraMap::iterator bci = cameras.find(pass.camera); if (bci == cameras.end()) { ReportOnce(&pass, "Camera " + pass.camera + " couldn't be found", error_output); return; } // create our sub-camera GraphicsCamera & cam = cameras[cameraname]; cam = bci->second; // set the sub-camera's properties cam.rot = GetCubeSideOrientation(cubeside, cam.rot, error_output); cam.fov = 90; assert(oi->second.IsFBO()); const FrameBufferObject & fbo = oi->second.RenderToFBO(); cam.w = fbo.GetWidth(); cam.h = fbo.GetHeight(); } const std::string drawlist_name = BuildKey(cameraname, *d); CulledDrawList & drawlist = culled_drawlists[drawlist_name]; if (drawlist.valid) break; drawlist.valid = true; if (pass.cull) { // cull static drawlist reseatable_reference <AabbTreeNodeAdapter <Drawable> > container = static_drawlist.GetByName(*d); if (!container) { ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output); return; } CameraMap::iterator ci = cameras.find(cameraname); if (ci == cameras.end()) { ReportOnce(&pass, "Camera " + cameraname + " couldn't be found", error_output); return; } const GraphicsCamera & cam = ci->second; Frustum frustum; frustum.Extract(GetProjMatrix(cam).GetArray(), GetViewMatrix(cam).GetArray()); container->Query(frustum, drawlist.drawables); // cull dynamic drawlist reseatable_reference <PtrVector <Drawable> > container_dynamic = dynamic_drawlist.GetByName(*d); if (!container_dynamic) { ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output); return; } for (size_t i = 0; i < container_dynamic->size(); ++i) { if (!Cull(frustum, *(*container_dynamic)[i])) drawlist.drawables.push_back((*container_dynamic)[i]); } } else { // copy static drawlist reseatable_reference <AabbTreeNodeAdapter <Drawable> > container = static_drawlist.GetByName(*d); if (!container) { ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output); return; } container->Query(Aabb<float>::IntersectAlways(), drawlist.drawables); // copy dynamic drawlist reseatable_reference <PtrVector <Drawable> > container_dynamic = dynamic_drawlist.GetByName(*d); if (!container_dynamic) { ReportOnce(&pass, "Drawable container " + *d + " couldn't be found", error_output); return; } drawlist.drawables.insert( drawlist.drawables.end(), container_dynamic->begin(), container_dynamic->end()); } } } }