// Export: void AboutOpera::generateData( URL& url ) { writePreamble( url ); // <html><body> surplus // <require> each of these should close exactly the HTML tags it opens: writeVersion( url ); writeUA( url ); writeRegInfo( url ); writePaths( url ); writeSound( url ); writeCredits( url ); // </require> url.WriteDocumentData(UNI_L("\n\n <address>")); #ifdef GEIR_MEMORIAL OP_STATUS rc; OpString span; TRAP(rc, g_languageManager->GetStringL(Str::S_DEDICATED_TO, span)); if (OpStatus::IsSuccess(rc)) { url.WriteDocumentData(UNI_L("<span>")); // In memory of Geir Ivarsøy. url.WriteDocumentData(span); url.WriteDocumentData(UNI_L("</span> ")); } #endif outASCII(url, "Copyright © 1995-"); outASCII(url, __DATE__ + 7); // "Mmm dd Year" + 7 == "Year" outASCII(url, " Opera Software ASA.\n" "All rights reserved.</address>\n" "</body>\n</html>\n"); url.WriteDocumentDataFinished(); }
void TranslatorGLSL::translate(TIntermNode *root, int) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(root); writePragma(); // Write extension behaviour as needed writeExtensionBehavior(); bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; if (precisionEmulation) { EmulatePrecision emulatePrecision; root->traverse(&emulatePrecision); emulatePrecision.updateTree(); emulatePrecision.writeEmulationHelpers(sink, getOutputType()); } // Write emulated built-in functions if needed. if (!getBuiltInFunctionEmulator().IsOutputEmpty()) { sink << "// BEGIN: Generated code for built-in function emulation\n\n"; sink << "#define webgl_emu_precision\n\n"; getBuiltInFunctionEmulator().OutputEmulatedFunctions(sink); sink << "// END: Generated code for built-in function emulation\n\n"; } // Write array bounds clamping emulation if needed. getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); // Declare gl_FragColor and glFragData as webgl_FragColor and webgl_FragData // if it's core profile shaders and they are used. if (getShaderType() == GL_FRAGMENT_SHADER && IsGLSL130OrNewer(getOutputType())) { TFragmentOutSearcher searcher; root->traverse(&searcher); ASSERT(!(searcher.usesGlFragData() && searcher.usesGlFragColor())); if (searcher.usesGlFragColor()) { sink << "out vec4 webgl_FragColor;\n"; } if (searcher.usesGlFragData()) { sink << "out vec4 webgl_FragData[gl_MaxDrawBuffers];\n"; } } // Write translated shader. TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion(), getOutputType()); root->traverse(&outputGLSL); }
/** serialize the data to the Serializer * * serializes the frame, the info about colums and rows to the serializer. * * @param out the serializer object that the data will be serialzed to */ void serialize(SerializerBackend &out)const { writeVersion(out); /** write the columns rows and then the frame */ out.add(_columns); out.add(_rows); for (frame_t::const_iterator it=_frame.begin();it!=_frame.end();++it) out.add(*it); }
void TranslatorGLSL::translate(TIntermNode* root) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(getShaderType(), root, sink); // Write translated shader. TOutputGLSL outputGLSL(sink); root->traverse(&outputGLSL); }
/** serialize the data to the Serializer * * serializes the key within the map and then the detector to the serializer. * * @param out the serializer object that the data will be serialzed to */ void serialize(SerializerBackend &out)const { writeVersion(out); /** write how many items in the container there are */ out.add(static_cast<size_t>(_detectors.size())); /** write the keys of the detector and the detector itself */ detectors_t::const_iterator it(_detectors.begin()); for(; it != _detectors.end(); ++it) { out.add(it->first); it->second.serialize(out); } }
/************************************* MapLayer File layout { VERSION PVRTBoundingBox2D boundingbox; CHECKPOINT PVRTCoordinateVector coordinates; CHECKPOINT PVRTIndexSet indexset CHECKPOINT }; *************************************/ bool writeMapLayer(const char *pszFilename, const PVRTMapLayer &layer) { ofstream file(pszFilename, ios::binary); if (!file.is_open()) return false; writeVersion(file); writeBoundingBox(file, layer.boundingbox); writeSecurityCheckpoint(file); writeVector<PVRTVertex>(file, layer.coordinates); writeSecurityCheckpoint(file); writeIndexSet(file, layer.indexset); writeSecurityCheckpoint(file); file.close(); return true; }
/************************************* BucketMapLayer File layout { VERSION PVRTBoundingBox2D boundingbox; CHECKPOINT PVRTCoordinateBucketVector coordinatebuckets; CHECKPOINT PVRTBucketIndexSetVector bucketindexsets; CHECKPOINT }; *************************************/ bool writeBucketMapLayer(const char *pszFilename, const PVRTBucketMapLayer &layer) { ofstream file(pszFilename, ios::binary); if (!file.is_open()) return false; writeVersion(file); writeBoundingBox(file, layer.boundingbox); writeSecurityCheckpoint(file); if (!writeCoordinateBucketVector(file, layer.coordinatebuckets)) return false; writeSecurityCheckpoint(file); writeBucketIndexSetVector(file, layer.bucketindexsets); writeSecurityCheckpoint(file); file.close(); return true; }
void TranslatorGLSL::translate(TIntermNode* root) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(getShaderType(), root, sink); // Write extension behaviour as needed writeExtensionBehavior(); // Write emulated built-in functions if needed. getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( sink, false); // Write array bounds clamping emulation if needed. getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); // Write translated shader. TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion()); root->traverse(&outputGLSL); }
void TranslatorGLSL::translate(TIntermNode *root, int) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(root); writePragma(); // Write extension behaviour as needed writeExtensionBehavior(); bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; if (precisionEmulation) { EmulatePrecision emulatePrecision(getSymbolTable(), getShaderVersion()); root->traverse(&emulatePrecision); emulatePrecision.updateTree(); emulatePrecision.writeEmulationHelpers(sink, getOutputType()); } // Write emulated built-in functions if needed. if (!getBuiltInFunctionEmulator().IsOutputEmpty()) { sink << "// BEGIN: Generated code for built-in function emulation\n\n"; sink << "#define webgl_emu_precision\n\n"; getBuiltInFunctionEmulator().OutputEmulatedFunctions(sink); sink << "// END: Generated code for built-in function emulation\n\n"; } // Write translated shader. TOutputGLSL outputGLSL(sink, getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion(), getOutputType()); root->traverse(&outputGLSL); }
void TranslatorGLSL::translate(TIntermNode *root, int compileOptions) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(root); writePragma(); // Write extension behaviour as needed writeExtensionBehavior(root); bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; if (precisionEmulation) { EmulatePrecision emulatePrecision(getSymbolTable(), getShaderVersion()); root->traverse(&emulatePrecision); emulatePrecision.updateTree(); emulatePrecision.writeEmulationHelpers(sink, getOutputType()); } // Write emulated built-in functions if needed. if (!getBuiltInFunctionEmulator().IsOutputEmpty()) { sink << "// BEGIN: Generated code for built-in function emulation\n\n"; sink << "#define webgl_emu_precision\n\n"; getBuiltInFunctionEmulator().OutputEmulatedFunctions(sink); sink << "// END: Generated code for built-in function emulation\n\n"; } // Write array bounds clamping emulation if needed. getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); // Declare gl_FragColor and glFragData as webgl_FragColor and webgl_FragData // if it's core profile shaders and they are used. if (getShaderType() == GL_FRAGMENT_SHADER) { const bool mayHaveESSL1SecondaryOutputs = IsExtensionEnabled(getExtensionBehavior(), "GL_EXT_blend_func_extended") && getShaderVersion() == 100; const bool declareGLFragmentOutputs = IsGLSL130OrNewer(getOutputType()); bool hasGLFragColor = false; bool hasGLFragData = false; bool hasGLSecondaryFragColor = false; bool hasGLSecondaryFragData = false; for (const auto &outputVar : outputVariables) { if (declareGLFragmentOutputs) { if (outputVar.name == "gl_FragColor") { ASSERT(!hasGLFragColor); hasGLFragColor = true; continue; } else if (outputVar.name == "gl_FragData") { ASSERT(!hasGLFragData); hasGLFragData = true; continue; } } if (mayHaveESSL1SecondaryOutputs) { if (outputVar.name == "gl_SecondaryFragColorEXT") { ASSERT(!hasGLSecondaryFragColor); hasGLSecondaryFragColor = true; continue; } else if (outputVar.name == "gl_SecondaryFragDataEXT") { ASSERT(!hasGLSecondaryFragData); hasGLSecondaryFragData = true; continue; } } } ASSERT(!((hasGLFragColor || hasGLSecondaryFragColor) && (hasGLFragData || hasGLSecondaryFragData))); if (hasGLFragColor) { sink << "out vec4 webgl_FragColor;\n"; } if (hasGLFragData) { sink << "out vec4 webgl_FragData[gl_MaxDrawBuffers];\n"; } if (hasGLSecondaryFragColor) { sink << "out vec4 angle_SecondaryFragColor;\n"; } if (hasGLSecondaryFragData) { sink << "out vec4 angle_SecondaryFragData[" << getResources().MaxDualSourceDrawBuffers << "];\n"; } } // Write translated shader. TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderVersion(), getOutputType()); root->traverse(&outputGLSL); }
void TranslatorGLSL::translate(TIntermNode *root, ShCompileOptions compileOptions) { TInfoSinkBase& sink = getInfoSink().obj; // Write GLSL version. writeVersion(root); // Write extension behaviour as needed writeExtensionBehavior(root); // Write pragmas after extensions because some drivers consider pragmas // like non-preprocessor tokens. writePragma(compileOptions); // If flattening the global invariant pragma, write invariant declarations for built-in // variables. It should be harmless to do this twice in the case that the shader also explicitly // did this. However, it's important to emit invariant qualifiers only for those built-in // variables that are actually used, to avoid affecting the behavior of the shader. if ((compileOptions & SH_FLATTEN_PRAGMA_STDGL_INVARIANT_ALL) && getPragma().stdgl.invariantAll) { ASSERT(wereVariablesCollected()); switch (getShaderType()) { case GL_VERTEX_SHADER: sink << "invariant gl_Position;\n"; // gl_PointSize should be declared invariant in both ESSL 1.00 and 3.00 fragment // shaders if it's statically referenced. conditionallyOutputInvariantDeclaration("gl_PointSize"); break; case GL_FRAGMENT_SHADER: // The preprocessor will reject this pragma if it's used in ESSL 3.00 fragment // shaders, so we can use simple logic to determine whether to declare these // variables invariant. conditionallyOutputInvariantDeclaration("gl_FragCoord"); conditionallyOutputInvariantDeclaration("gl_PointCoord"); break; default: // Currently not reached, but leave this in for future expansion. ASSERT(false); break; } } if ((compileOptions & SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH) != 0) { sh::RewriteTexelFetchOffset(root, getSymbolTable(), getShaderVersion()); } bool precisionEmulation = getResources().WEBGL_debug_shader_precision && getPragma().debugShaderPrecision; if (precisionEmulation) { EmulatePrecision emulatePrecision(getSymbolTable(), getShaderVersion()); root->traverse(&emulatePrecision); emulatePrecision.updateTree(); emulatePrecision.writeEmulationHelpers(sink, getShaderVersion(), getOutputType()); } // Write emulated built-in functions if needed. if (!getBuiltInFunctionEmulator().IsOutputEmpty()) { sink << "// BEGIN: Generated code for built-in function emulation\n\n"; sink << "#define webgl_emu_precision\n\n"; getBuiltInFunctionEmulator().OutputEmulatedFunctions(sink); sink << "// END: Generated code for built-in function emulation\n\n"; } // Write array bounds clamping emulation if needed. getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); // Declare gl_FragColor and glFragData as webgl_FragColor and webgl_FragData // if it's core profile shaders and they are used. if (getShaderType() == GL_FRAGMENT_SHADER) { const bool mayHaveESSL1SecondaryOutputs = IsExtensionEnabled(getExtensionBehavior(), "GL_EXT_blend_func_extended") && getShaderVersion() == 100; const bool declareGLFragmentOutputs = IsGLSL130OrNewer(getOutputType()); bool hasGLFragColor = false; bool hasGLFragData = false; bool hasGLSecondaryFragColor = false; bool hasGLSecondaryFragData = false; for (const auto &outputVar : outputVariables) { if (declareGLFragmentOutputs) { if (outputVar.name == "gl_FragColor") { ASSERT(!hasGLFragColor); hasGLFragColor = true; continue; } else if (outputVar.name == "gl_FragData") { ASSERT(!hasGLFragData); hasGLFragData = true; continue; } } if (mayHaveESSL1SecondaryOutputs) { if (outputVar.name == "gl_SecondaryFragColorEXT") { ASSERT(!hasGLSecondaryFragColor); hasGLSecondaryFragColor = true; continue; } else if (outputVar.name == "gl_SecondaryFragDataEXT") { ASSERT(!hasGLSecondaryFragData); hasGLSecondaryFragData = true; continue; } } } ASSERT(!((hasGLFragColor || hasGLSecondaryFragColor) && (hasGLFragData || hasGLSecondaryFragData))); if (hasGLFragColor) { sink << "out vec4 webgl_FragColor;\n"; } if (hasGLFragData) { sink << "out vec4 webgl_FragData[gl_MaxDrawBuffers];\n"; } if (hasGLSecondaryFragColor) { sink << "out vec4 angle_SecondaryFragColor;\n"; } if (hasGLSecondaryFragData) { sink << "out vec4 angle_SecondaryFragData[" << getResources().MaxDualSourceDrawBuffers << "];\n"; } } if (getShaderType() == GL_COMPUTE_SHADER && isComputeShaderLocalSizeDeclared()) { const sh::WorkGroupSize &localSize = getComputeShaderLocalSize(); sink << "layout (local_size_x=" << localSize[0] << ", local_size_y=" << localSize[1] << ", local_size_z=" << localSize[2] << ") in;\n"; } // Write translated shader. TOutputGLSL outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable(), getShaderType(), getShaderVersion(), getOutputType(), compileOptions); root->traverse(&outputGLSL); }
bool SeekThermal::Command::Application::parseArguments(size_t argc, char** argv) { std::string argument = argv[0]; size_t i = argument.rfind('/'); if (i != std::string::npos) executable = argument.substr(i+1); else executable = argument; int j = 0; for (int i = 1; i < argc; ++i) { argument = argv[i]; if ((argument[0] == '-') && (argument[1] == '-')) { std::string key = argument.substr(2); std::map<std::string, Argument>::iterator it = keyedArguments.find(key); if (it != keyedArguments.end()) { if (it->second.getFormat().empty()) { it->second.setValue<bool>(true); if ((*this)["help"].getValue<bool>()) { writeHelp(std::cerr); return false; } if ((*this)["version"].getValue<bool>()) { writeVersion(std::cout); return false; } } else if (i+1 < argc) { std::string value = argv[++i]; it->second.setValue(value); } else throw ArgumentFormatError(key, it->second.getFormat()); } else throw ArgumentKeyError(key); } else { if (j < arguments.size()) { if (arguments[j].getGreedy()) { std::string args; for ( ; i < argc; ++i) { args += argv[i]; if (i+1 < argc) args += " "; } arguments[j].setValue(args); } else { arguments[j].setValue(argument); ++j; } } else throw UnexpectedArgumentError(argument); } } for ( ; j < arguments.size(); ++j) if (arguments[j].getValue().empty()) throw MissingArgumentError(arguments[j].getFormat()); return true; }