当前位置: 首页>>代码示例>>C++>>正文


C++ AttributeMap::begin方法代码示例

本文整理汇总了C++中AttributeMap::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeMap::begin方法的具体用法?C++ AttributeMap::begin怎么用?C++ AttributeMap::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AttributeMap的用法示例。


在下文中一共展示了AttributeMap::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onObserve

void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber)
{
	std::cout << "onObserve" << std::endl;
//    if(eCode == SUCCESS_RESPONSE)
	if(eCode <= OC_STACK_RESOURCE_DELETED)
    {

        AttributeMap attributeMap = rep.getAttributeMap();

        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            if(attributeMap.find(it->first) == attributeMap.end())
            {
                return;
            }
        }

        if(rep.getUri().empty())
        {
        	cout << "uri is null\n";
            return;
        }

        std::cout << std::endl;
        std::cout << "========================================================" << std::endl;
        std::cout << "Receive OBSERVE RESULT:" << std::endl;
        std::cout << "\tSequenceNumber: " << sequenceNumber << std::endl;
        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            std::cout << "\tAttribute name: " << it->first << " value: ";
            for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
            {
                std::cout << "\t" << *valueItr << " ";
            }

            std::cout << std::endl;
        }

        if(observe_count() > 30)
        {
            std::cout << "Cancelling Observe..." << std::endl;
            OCStackResult result = g_curResource->cancelObserve();

            std::cout << "Cancel result: " << result << std::endl;
            sleep(10);
            std::cout << "DONE" << std::endl;
            std::exit(0);
        }
    }
    else
    {
        std::cout << "onObserve Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
开发者ID:tizenorg,项目名称:platform.upstream.iotivity,代码行数:55,代码来源:SampleConsumer.cpp

示例2: onPut

void onPut(const OCRepresentation& rep , const int eCode)
{
    if(eCode == SUCCESS_RESPONSE)
    {
        std::cout << "PUT request was successful" << std::endl;

        AttributeMap attributeMap = rep.getAttributeMap();

        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            std::cout << "\tAttribute name: " << it->first << " value: ";
            for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
            {
                std::cout << "\t" << *valueItr << " ";
            }

            std::cout << std::endl;
        }

        std::vector< OCRepresentation > children = rep.getChildren();

        for(auto oit = children.begin() ; oit != children.end() ; ++oit)
        {
            attributeMap = oit->getAttributeMap();

            for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
            {
                std::cout << "\tAttribute name: " << it->first << " value: ";
                for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
                {
                    std::cout << "\t" << *valueItr << " ";
                }

                std::cout << std::endl;
            }
        }

        if(OBSERVE_TYPE_TO_USE == ObserveType::Observe)
            std::cout << std::endl << "Observe is used." << std::endl << std::endl;
        else if(OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
            std::cout << std::endl << "ObserveAll is used." << std::endl << std::endl;

        QueryParamsMap test;

        g_curResource->observe(ObserveType::Observe , test , &onObserve);

    }
    else
    {
        std::cout << "onPut Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
开发者ID:tizenorg,项目名称:platform.upstream.iotivity,代码行数:53,代码来源:SampleConsumer.cpp

示例3: onobserve

void onobserve()
{

    oicappData *ad = g_oicObserveAd;

    AttributeMap attributeMap = g_curAttributeMap;

    std::string tmpStr[2];
    int index = 0;
    for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
    {
        tmpStr[index] = it->first;
        tmpStr[index].append(" : ");
        for(auto value = it->second.begin() ; value != it->second.end() ; ++value)
        {
            tmpStr[index].append(*value);
        }
        index++;
    }

    DBG("%s" , tmpStr[0].c_str());
    DBG("%s" , tmpStr[1].c_str());
    _gl_update_item(ad , strdup(tmpStr[0].c_str()) , ad->itemConsumerTemp);
    _gl_update_item(ad , strdup(tmpStr[1].c_str()) , ad->itemConsumerHumid);
}
开发者ID:tizenorg,项目名称:platform.upstream.iotivity,代码行数:25,代码来源:oicapp-client.cpp

示例4: onGet

// callback handler on GET request
void onGet(const HeaderOptions &headerOption , const OCRepresentation& rep , const int eCode)
{
    if(eCode == SUCCESS_RESPONSE)
    {
        std::cout << "GET request was successful" << std::endl;

        AttributeMap attributeMap = rep.getAttributeMap();

        std::cout << "Resource URI: " << rep.getUri() << std::endl;

        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            std::cout << "\tAttribute name: " << it->first << " value: ";
            for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
            {
                std::cout << "\t" << *valueItr << " ";
            }

            std::cout << std::endl;
        }

        std::vector< OCRepresentation > children = rep.getChildren();

        for(auto oit = children.begin() ; oit != children.end() ; ++oit)
        {
            std::cout << "Child Resource URI: " << oit->getUri() << std::endl;

            attributeMap = oit->getAttributeMap();

            for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
            {
                std::cout << "\tAttribute name: " << it->first << " value: ";
                for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
                {
                    std::cout << "\t" << *valueItr << " ";
                }

                std::cout << std::endl;
            }
        }
    }
    else
    {
        std::cout << "onGET Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
开发者ID:tizenorg,项目名称:platform.upstream.iotivity,代码行数:48,代码来源:SampleConsumer.cpp

示例5: printAttributeMap

void printAttributeMap(const AttributeMap attributeMap)
{
    for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
    {
        DBG("\tAttribute name: %s" , it->first.c_str());
        for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
        {
            DBG("\t\tAttribute value: %s" , (*valueItr).c_str());
        }
    }
}
开发者ID:tizenorg,项目名称:platform.upstream.iotivity,代码行数:11,代码来源:oicapp-client.cpp

示例6: handleStartElement

void SerializingParser::handleStartElement(const std::string& tag, const std::string&  ns, const AttributeMap& attributes) {
	boost::shared_ptr<XMLElement> element(new XMLElement(tag, ns));
	for (AttributeMap::const_iterator i = attributes.begin(); i != attributes.end(); ++i) {
		element->setAttribute((*i).first, (*i).second);
	}

	if (elementStack_.empty()) {
		rootElement_ = element;
	}
	else {
		(*(elementStack_.end() - 1))->addNode(element);
	}
	elementStack_.push_back(element);
}
开发者ID:bessey,项目名称:picnic-doc-server,代码行数:14,代码来源:SerializingParser.cpp

示例7: writeSparse

	void writeSparse(QFile& file, const AttributeMap& data)
	{
		FNTRACE("ini", "", "writeSparse", QString("file %1, %2 rows of data").arg(file.fileName()).arg(data.size()));

		if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
			ETHROW(Exception(QString("Unable to open %1 for writing.").arg(file.fileName())));

		file.resize(0);
		QTextStream fout(&file);

		int max_key_length = 0;
		for (AttributeMap::const_iterator iter = data.begin(); iter != data.end(); ++iter)
		{
			if (iter.key().length() > max_key_length)
				max_key_length = iter.key().length();
		}
		for (AttributeMap::const_iterator iter = data.begin(); iter != data.end(); ++iter)
		{
			fout << iter.key();
			for (int i = iter.key().length(); i < max_key_length; ++i)
				fout << ' ';
			fout << " = " << iter.value() << "\n";
		}
	}
开发者ID:devnev,项目名称:ds1edit-loader,代码行数:24,代码来源:iniparser.cpp

示例8: scanForWantedComponents

 void scanForWantedComponents(const AttributeMap &attributeMap)
 {
     // [EGL 1.5] section 3.4.1.2 page 30
     // Sorting rule #3: by larger total number of color bits, not considering
     // components that are 0 or don't-care.
     for (auto attribIter = attributeMap.begin(); attribIter != attributeMap.end(); attribIter++)
     {
         EGLint attributeKey = attribIter->first;
         EGLint attributeValue = attribIter->second;
         if (attributeKey != 0 && attributeValue != EGL_DONT_CARE)
         {
             switch (attributeKey)
             {
             case EGL_RED_SIZE:       mWantRed = true; break;
             case EGL_GREEN_SIZE:     mWantGreen = true; break;
             case EGL_BLUE_SIZE:      mWantBlue = true; break;
             case EGL_ALPHA_SIZE:     mWantAlpha = true; break;
             case EGL_LUMINANCE_SIZE: mWantLuminance = true; break;
             }
         }
     }
 }
开发者ID:ppy,项目名称:angle,代码行数:22,代码来源:Config.cpp

示例9: writeAttributes

void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
{
	for (AttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it)
	{
		if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES))
		{
			writeNewLine();
			writeIndent(_depth + 1);
		}
		else
		{
			writeMarkup(MARKUP_SPACE);
		}
		writeXML(it->first);
		writeMarkup(MARKUP_EQQUOT);
		for (XMLString::const_iterator itc = it->second.begin(); itc != it->second.end(); ++itc)
		{
			XMLChar c = *itc;
			switch (c)
			{
			case '"':  writeMarkup(MARKUP_QUOTENC); break;
			case '\'': writeMarkup(MARKUP_APOSENC); break;
			case '&':  writeMarkup(MARKUP_AMPENC); break;
			case '<':  writeMarkup(MARKUP_LTENC); break;
			case '>':  writeMarkup(MARKUP_GTENC); break;
			case '\t': writeMarkup(MARKUP_TABENC); break;
			case '\r': writeMarkup(MARKUP_CRENC); break;
			case '\n': writeMarkup(MARKUP_LFENC); break;
			default:
				if (c >= 0 && c < 32)
					throw XMLException("Invalid character token.");
				else 
					writeXML(c);
			}
		}
		writeMarkup(MARKUP_QUOT);
	}
}
开发者ID:BrianHoldsworth,项目名称:Poco,代码行数:38,代码来源:XMLWriter.cpp

示例10: ValidateCreateImageKHR

Error ValidateCreateImageKHR(const Display *display,
                             gl::Context *context,
                             EGLenum target,
                             EGLClientBuffer buffer,
                             const AttributeMap &attributes)
{
    Error error = ValidateContext(display, context);
    if (error.isError())
    {
        return error;
    }

    const DisplayExtensions &displayExtensions = display->getExtensions();

    if (!displayExtensions.imageBase && !displayExtensions.image)
    {
        // It is out of spec what happens when calling an extension function when the extension is
        // not available.
        // EGL_BAD_DISPLAY seems like a reasonable error.
        return Error(EGL_BAD_DISPLAY, "EGL_KHR_image not supported.");
    }

    // TODO(geofflang): Complete validation from EGL_KHR_image_base:
    // If the resource specified by <dpy>, <ctx>, <target>, <buffer> and <attrib_list> is itself an
    // EGLImage sibling, the error EGL_BAD_ACCESS is generated.

    for (AttributeMap::const_iterator attributeIter = attributes.begin();
         attributeIter != attributes.end(); attributeIter++)
    {
        EGLint attribute = attributeIter->first;
        EGLint value     = attributeIter->second;

        switch (attribute)
        {
            case EGL_IMAGE_PRESERVED_KHR:
                switch (value)
                {
                    case EGL_TRUE:
                    case EGL_FALSE:
                        break;

                    default:
                        return Error(EGL_BAD_PARAMETER,
                                     "EGL_IMAGE_PRESERVED_KHR must be EGL_TRUE or EGL_FALSE.");
                }
                break;

            case EGL_GL_TEXTURE_LEVEL_KHR:
                if (!displayExtensions.glTexture2DImage &&
                    !displayExtensions.glTextureCubemapImage && !displayExtensions.glTexture3DImage)
                {
                    return Error(EGL_BAD_PARAMETER,
                                 "EGL_GL_TEXTURE_LEVEL_KHR cannot be used without "
                                 "KHR_gl_texture_*_image support.");
                }

                if (value < 0)
                {
                    return Error(EGL_BAD_PARAMETER, "EGL_GL_TEXTURE_LEVEL_KHR cannot be negative.");
                }
                break;

            case EGL_GL_TEXTURE_ZOFFSET_KHR:
                if (!displayExtensions.glTexture3DImage)
                {
                    return Error(EGL_BAD_PARAMETER,
                                 "EGL_GL_TEXTURE_ZOFFSET_KHR cannot be used without "
                                 "KHR_gl_texture_3D_image support.");
                }
                break;

            default:
                return Error(EGL_BAD_PARAMETER, "invalid attribute: 0x%X", attribute);
        }
    }

    switch (target)
    {
        case EGL_GL_TEXTURE_2D_KHR:
        {
            if (!displayExtensions.glTexture2DImage)
            {
                return Error(EGL_BAD_PARAMETER, "KHR_gl_texture_2D_image not supported.");
            }

            if (buffer == 0)
            {
                return Error(EGL_BAD_PARAMETER,
                             "buffer cannot reference a 2D texture with the name 0.");
            }

            const gl::Texture *texture =
                context->getTexture(egl_gl::EGLClientBufferToGLObjectHandle(buffer));
            if (texture == nullptr || texture->getTarget() != GL_TEXTURE_2D)
            {
                return Error(EGL_BAD_PARAMETER, "target is not a 2D texture.");
            }

            if (texture->getBoundSurface() != nullptr)
            {
//.........这里部分代码省略.........
开发者ID:bsergean,项目名称:angle,代码行数:101,代码来源:validationEGL.cpp

示例11: ValidateCreatePbufferFromClientBuffer

Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, EGLClientBuffer buffer,
                                            Config *config, const AttributeMap& attributes)
{
    Error error = ValidateConfig(display, config);
    if (error.isError())
    {
        return error;
    }

    const DisplayExtensions &displayExtensions = display->getExtensions();

    switch (buftype)
    {
      case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
        if (!displayExtensions.d3dShareHandleClientBuffer)
        {
            return Error(EGL_BAD_PARAMETER);
        }
        if (buffer == nullptr)
        {
            return Error(EGL_BAD_PARAMETER);
        }
        break;

      default:
        return Error(EGL_BAD_PARAMETER);
    }

    for (AttributeMap::const_iterator attributeIter = attributes.begin(); attributeIter != attributes.end(); attributeIter++)
    {
        EGLint attribute = attributeIter->first;
        EGLint value = attributeIter->second;

        switch (attribute)
        {
          case EGL_WIDTH:
          case EGL_HEIGHT:
            if (!displayExtensions.d3dShareHandleClientBuffer)
            {
                return Error(EGL_BAD_PARAMETER);
            }
            if (value < 0)
            {
                return Error(EGL_BAD_PARAMETER);
            }
            break;

          case EGL_TEXTURE_FORMAT:
            switch (value)
            {
              case EGL_NO_TEXTURE:
              case EGL_TEXTURE_RGB:
              case EGL_TEXTURE_RGBA:
                break;
              default:
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_TEXTURE_TARGET:
            switch (value)
            {
              case EGL_NO_TEXTURE:
              case EGL_TEXTURE_2D:
                break;
              default:
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_MIPMAP_TEXTURE:
            break;

          default:
            return Error(EGL_BAD_ATTRIBUTE);
        }
    }

    if (!(config->surfaceType & EGL_PBUFFER_BIT))
    {
        return Error(EGL_BAD_MATCH);
    }

    EGLenum textureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
    EGLenum textureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);
    if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) ||
        (textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE))
    {
        return Error(EGL_BAD_MATCH);
    }

    if ((textureFormat == EGL_TEXTURE_RGB  && config->bindToTextureRGB  != EGL_TRUE) ||
        (textureFormat == EGL_TEXTURE_RGBA && config->bindToTextureRGBA != EGL_TRUE))
    {
        return Error(EGL_BAD_ATTRIBUTE);
    }

    if (buftype == EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE)
    {
        EGLint width = attributes.get(EGL_WIDTH, 0);
//.........这里部分代码省略.........
开发者ID:bsergean,项目名称:angle,代码行数:101,代码来源:validationEGL.cpp

示例12: ValidateCreatePbufferSurface

Error ValidateCreatePbufferSurface(Display *display, Config *config, const AttributeMap& attributes)
{
    Error error = ValidateConfig(display, config);
    if (error.isError())
    {
        return error;
    }

    for (AttributeMap::const_iterator attributeIter = attributes.begin(); attributeIter != attributes.end(); attributeIter++)
    {
        EGLint attribute = attributeIter->first;
        EGLint value = attributeIter->second;

        switch (attribute)
        {
          case EGL_WIDTH:
          case EGL_HEIGHT:
            if (value < 0)
            {
                return Error(EGL_BAD_PARAMETER);
            }
            break;

          case EGL_LARGEST_PBUFFER:
            break;

          case EGL_TEXTURE_FORMAT:
            switch (value)
            {
              case EGL_NO_TEXTURE:
              case EGL_TEXTURE_RGB:
              case EGL_TEXTURE_RGBA:
                break;
              default:
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_TEXTURE_TARGET:
            switch (value)
            {
              case EGL_NO_TEXTURE:
              case EGL_TEXTURE_2D:
                break;
              default:
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_MIPMAP_TEXTURE:
            break;

          case EGL_VG_COLORSPACE:
            break;

          case EGL_VG_ALPHA_FORMAT:
            break;

          default:
            return Error(EGL_BAD_ATTRIBUTE);
        }
    }

    if (!(config->surfaceType & EGL_PBUFFER_BIT))
    {
        return Error(EGL_BAD_MATCH);
    }

    const Caps &caps = display->getCaps();

    EGLenum textureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
    EGLenum textureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE);

    if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) ||
        (textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE))
    {
        return Error(EGL_BAD_MATCH);
    }

    if ((textureFormat == EGL_TEXTURE_RGB  && config->bindToTextureRGB != EGL_TRUE) ||
        (textureFormat == EGL_TEXTURE_RGBA && config->bindToTextureRGBA != EGL_TRUE))
    {
        return Error(EGL_BAD_ATTRIBUTE);
    }

    EGLint width = attributes.get(EGL_WIDTH, 0);
    EGLint height = attributes.get(EGL_HEIGHT, 0);
    if (textureFormat != EGL_NO_TEXTURE && !caps.textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height)))
    {
        return Error(EGL_BAD_MATCH);
    }

    return Error(EGL_SUCCESS);
}
开发者ID:bsergean,项目名称:angle,代码行数:94,代码来源:validationEGL.cpp

示例13: ValidateCreateWindowSurface

Error ValidateCreateWindowSurface(Display *display, Config *config, EGLNativeWindowType window,
                                  const AttributeMap& attributes)
{
    Error error = ValidateConfig(display, config);
    if (error.isError())
    {
        return error;
    }

    if (!display->isValidNativeWindow(window))
    {
        return Error(EGL_BAD_NATIVE_WINDOW);
    }

    const DisplayExtensions &displayExtensions = display->getExtensions();

    for (AttributeMap::const_iterator attributeIter = attributes.begin(); attributeIter != attributes.end(); attributeIter++)
    {
        EGLint attribute = attributeIter->first;
        EGLint value = attributeIter->second;

        switch (attribute)
        {
          case EGL_RENDER_BUFFER:
            switch (value)
            {
              case EGL_BACK_BUFFER:
                break;
              case EGL_SINGLE_BUFFER:
                return Error(EGL_BAD_MATCH);   // Rendering directly to front buffer not supported
              default:
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
            if (!displayExtensions.postSubBuffer)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_WIDTH:
          case EGL_HEIGHT:
            if (!displayExtensions.windowFixedSize)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            if (value < 0)
            {
                return Error(EGL_BAD_PARAMETER);
            }
            break;

          case EGL_FIXED_SIZE_ANGLE:
            if (!displayExtensions.windowFixedSize)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          case EGL_VG_COLORSPACE:
            return Error(EGL_BAD_MATCH);

          case EGL_VG_ALPHA_FORMAT:
            return Error(EGL_BAD_MATCH);

          default:
            return Error(EGL_BAD_ATTRIBUTE);
        }
    }

    if (Display::hasExistingWindowSurface(window))
    {
        return Error(EGL_BAD_ALLOC);
    }

    return Error(EGL_SUCCESS);
}
开发者ID:bsergean,项目名称:angle,代码行数:79,代码来源:validationEGL.cpp

示例14: ValidateCreateContext

Error ValidateCreateContext(Display *display, Config *configuration, gl::Context *shareContext,
                            const AttributeMap& attributes)
{
    Error error = ValidateConfig(display, configuration);
    if (error.isError())
    {
        return error;
    }

    // Get the requested client version (default is 1) and check it is 2 or 3.
    EGLint clientMajorVersion = 1;
    EGLint clientMinorVersion = 0;
    EGLint contextFlags = 0;
    bool resetNotification = false;
    bool robustAccess = false;
    for (AttributeMap::const_iterator attributeIter = attributes.begin(); attributeIter != attributes.end(); attributeIter++)
    {
        EGLint attribute = attributeIter->first;
        EGLint value = attributeIter->second;

        switch (attribute)
        {
          case EGL_CONTEXT_CLIENT_VERSION:
            clientMajorVersion = value;
            break;

          case EGL_CONTEXT_MINOR_VERSION:
            clientMinorVersion = value;
            break;

          case EGL_CONTEXT_FLAGS_KHR:
            contextFlags = value;
            break;

          case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
            // Only valid for OpenGL (non-ES) contexts
            return Error(EGL_BAD_ATTRIBUTE);

          case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
            if (!display->getExtensions().createContextRobustness)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            if (value != EGL_TRUE && value != EGL_FALSE)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            robustAccess = (value == EGL_TRUE);
            break;

          case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
            static_assert(EGL_LOSE_CONTEXT_ON_RESET_EXT == EGL_LOSE_CONTEXT_ON_RESET_KHR, "EGL extension enums not equal.");
            static_assert(EGL_NO_RESET_NOTIFICATION_EXT == EGL_NO_RESET_NOTIFICATION_KHR, "EGL extension enums not equal.");
            // same as EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, fall through
          case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
            if (!display->getExtensions().createContextRobustness)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            if (value == EGL_LOSE_CONTEXT_ON_RESET_EXT)
            {
                resetNotification = true;
            }
            else if (value != EGL_NO_RESET_NOTIFICATION_EXT)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

          default:
            return Error(EGL_BAD_ATTRIBUTE);
        }
    }

    if ((clientMajorVersion != 2 && clientMajorVersion != 3) || clientMinorVersion != 0)
    {
        return Error(EGL_BAD_CONFIG);
    }

    if (clientMajorVersion == 3 && !(configuration->conformant & EGL_OPENGL_ES3_BIT_KHR))
    {
        return Error(EGL_BAD_CONFIG);
    }

    // Note: EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR does not apply to ES
    const EGLint validContextFlags = (EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR |
                                      EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR);
    if ((contextFlags & ~validContextFlags) != 0)
    {
        return Error(EGL_BAD_ATTRIBUTE);
    }

    if ((contextFlags & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) > 0)
    {
        robustAccess = true;
    }

    if (robustAccess)
    {
        // Unimplemented
//.........这里部分代码省略.........
开发者ID:bsergean,项目名称:angle,代码行数:101,代码来源:validationEGL.cpp

示例15: ValidateCreateContext

Error ValidateCreateContext(Display *display, Config *configuration, gl::Context *shareContext,
                            const AttributeMap& attributes)
{
    ANGLE_TRY(ValidateConfig(display, configuration));

    // Get the requested client version (default is 1) and check it is 2 or 3.
    EGLAttrib clientMajorVersion = 1;
    EGLAttrib clientMinorVersion = 0;
    EGLAttrib contextFlags       = 0;
    bool resetNotification = false;
    bool robustAccess = false;
    for (AttributeMap::const_iterator attributeIter = attributes.begin(); attributeIter != attributes.end(); attributeIter++)
    {
        EGLAttrib attribute = attributeIter->first;
        EGLAttrib value     = attributeIter->second;

        switch (attribute)
        {
        case EGL_CONTEXT_CLIENT_VERSION:
            clientMajorVersion = value;
            break;

        case EGL_CONTEXT_MINOR_VERSION:
            clientMinorVersion = value;
            break;

        case EGL_CONTEXT_FLAGS_KHR:
            contextFlags = value;
            break;

        case EGL_CONTEXT_OPENGL_DEBUG:
            break;

        case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
            // Only valid for OpenGL (non-ES) contexts
            return Error(EGL_BAD_ATTRIBUTE);

        case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
            if (!display->getExtensions().createContextRobustness)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            if (value != EGL_TRUE && value != EGL_FALSE)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            robustAccess = (value == EGL_TRUE);
            break;

        case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
            static_assert(EGL_LOSE_CONTEXT_ON_RESET_EXT == EGL_LOSE_CONTEXT_ON_RESET_KHR, "EGL extension enums not equal.");
            static_assert(EGL_NO_RESET_NOTIFICATION_EXT == EGL_NO_RESET_NOTIFICATION_KHR, "EGL extension enums not equal.");
        // same as EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, fall through
        case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
            if (!display->getExtensions().createContextRobustness)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            if (value == EGL_LOSE_CONTEXT_ON_RESET_EXT)
            {
                resetNotification = true;
            }
            else if (value != EGL_NO_RESET_NOTIFICATION_EXT)
            {
                return Error(EGL_BAD_ATTRIBUTE);
            }
            break;

        case EGL_CONTEXT_OPENGL_NO_ERROR_KHR:
            if (!display->getExtensions().createContextNoError)
            {
                return Error(EGL_BAD_ATTRIBUTE, "Invalid Context attribute.");
            }
            if (value != EGL_TRUE && value != EGL_FALSE)
            {
                return Error(EGL_BAD_ATTRIBUTE, "Attribute must be EGL_TRUE or EGL_FALSE.");
            }
            break;

        case EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE:
            if (!display->getExtensions().createContextWebGLCompatibility)
            {
                return Error(EGL_BAD_ATTRIBUTE,
                             "Attribute EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE requires "
                             "EGL_ANGLE_create_context_webgl_compatibility.");
            }
            if (value != EGL_TRUE && value != EGL_FALSE)
            {
                return Error(
                           EGL_BAD_ATTRIBUTE,
                           "EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE must be EGL_TRUE or EGL_FALSE.");
            }
            break;

        default:
            return Error(EGL_BAD_ATTRIBUTE);
        }
    }

    switch (clientMajorVersion)
//.........这里部分代码省略.........
开发者ID:servo,项目名称:angle,代码行数:101,代码来源:validationEGL.cpp


注:本文中的AttributeMap::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。