本文整理汇总了C++中dom::Sequence::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::Length方法的具体用法?C++ Sequence::Length怎么用?C++ Sequence::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dom::Sequence
的用法示例。
在下文中一共展示了Sequence::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
void
WebGL2Context::GetUniformIndices(WebGLProgram* program,
const dom::Sequence<nsString>& uniformNames,
dom::Nullable< nsTArray<GLuint> >& retval)
{
retval.SetNull();
if (IsContextLost())
return;
if (!ValidateObject("getUniformIndices: program", program))
return;
if (!uniformNames.Length())
return;
GLuint progname = program->mGLName;
size_t count = uniformNames.Length();
nsTArray<GLuint>& arr = retval.SetValue();
MakeContextCurrent();
for (size_t n = 0; n < count; n++) {
NS_LossyConvertUTF16toASCII name(uniformNames[n]);
// const GLchar* glname = name.get();
const GLchar* glname = nullptr;
name.BeginReading(glname);
GLuint index = 0;
gl->fGetUniformIndices(progname, 1, &glname, &index);
arr.AppendElement(index);
}
}
示例2: MakeContextCurrent
void
WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
GLint x, GLint y, GLsizei width, GLsizei height,
ErrorResult& rv)
{
if (IsContextLost())
return;
MakeContextCurrent();
if (!ValidateFramebufferTarget(target, "framebufferRenderbuffer"))
return;
const WebGLFramebuffer* fb;
bool isDefaultFB;
switch (target) {
case LOCAL_GL_FRAMEBUFFER:
case LOCAL_GL_DRAW_FRAMEBUFFER:
fb = mBoundDrawFramebuffer;
isDefaultFB = gl->Screen()->IsDrawFramebufferDefault();
break;
case LOCAL_GL_READ_FRAMEBUFFER:
fb = mBoundReadFramebuffer;
isDefaultFB = gl->Screen()->IsReadFramebufferDefault();
break;
default:
MOZ_CRASH("Bad target.");
}
for (size_t i = 0; i < attachments.Length(); i++) {
if (!ValidateFramebufferAttachment(fb, attachments[i],
"invalidateSubFramebuffer"))
{
return;
}
}
// InvalidateFramebuffer is a hint to the driver. Should be OK to
// skip calls if not supported, for example by OSX 10.9 GL
// drivers.
static bool invalidateFBSupported = gl->IsSupported(gl::GLFeature::invalidate_framebuffer);
if (!invalidateFBSupported)
return;
if (!fb && !isDefaultFB) {
dom::Sequence<GLenum> tmpAttachments;
if (!TranslateDefaultAttachments(attachments, &tmpAttachments)) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
gl->fInvalidateSubFramebuffer(target, tmpAttachments.Length(), tmpAttachments.Elements(),
x, y, width, height);
} else {
gl->fInvalidateSubFramebuffer(target, attachments.Length(), attachments.Elements(),
x, y, width, height);
}
}
示例3: MakeContextCurrent
void
WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
GLint x, GLint y, GLsizei width, GLsizei height)
{
if (IsContextLost())
return;
MakeContextCurrent();
if (!ValidateFramebufferTarget(target, "framebufferRenderbuffer"))
return;
const WebGLFramebuffer* fb;
bool isDefaultFB;
switch (target) {
case LOCAL_GL_FRAMEBUFFER:
case LOCAL_GL_DRAW_FRAMEBUFFER:
fb = mBoundDrawFramebuffer;
isDefaultFB = gl->Screen()->IsDrawFramebufferDefault();
break;
case LOCAL_GL_READ_FRAMEBUFFER:
fb = mBoundReadFramebuffer;
isDefaultFB = gl->Screen()->IsReadFramebufferDefault();
break;
default:
MOZ_CRASH("Bad target.");
}
for (size_t i = 0; i < attachments.Length(); i++) {
if (!ValidateFramebufferAttachment(fb, attachments[i],
"invalidateSubFramebuffer"))
{
return;
}
}
if (!fb && !isDefaultFB) {
dom::Sequence<GLenum> tmpAttachments;
TranslateDefaultAttachments(attachments, &tmpAttachments);
gl->fInvalidateSubFramebuffer(target, tmpAttachments.Length(), tmpAttachments.Elements(),
x, y, width, height);
} else {
gl->fInvalidateSubFramebuffer(target, attachments.Length(), attachments.Elements(),
x, y, width, height);
}
}
示例4: switch
// Map attachments intended for the default buffer, to attachments for a non-
// default buffer.
static bool
TranslateDefaultAttachments(const dom::Sequence<GLenum>& in, dom::Sequence<GLenum>* out)
{
for (size_t i = 0; i < in.Length(); i++) {
switch (in[i]) {
case LOCAL_GL_COLOR:
if (!out->AppendElement(LOCAL_GL_COLOR_ATTACHMENT0, fallible)) {
return false;
}
break;
case LOCAL_GL_DEPTH:
if (!out->AppendElement(LOCAL_GL_DEPTH_ATTACHMENT, fallible)) {
return false;
}
break;
case LOCAL_GL_STENCIL:
if (!out->AppendElement(LOCAL_GL_STENCIL_ATTACHMENT, fallible)) {
return false;
}
break;
}
}
return true;
}
示例5: ErrorInvalidEnumInfo
void
WebGL2Context::GetActiveUniforms(WebGLProgram* program,
const dom::Sequence<GLuint>& uniformIndices,
GLenum pname,
dom::Nullable< nsTArray<GLint> >& retval)
{
retval.SetNull();
if (IsContextLost())
return;
if (pname == LOCAL_GL_UNIFORM_NAME_LENGTH) {
ErrorInvalidEnumInfo("getActiveUniforms: pname", pname);
return;
}
if (!ValidateObject("getActiveUniforms: program", program))
return;
size_t count = uniformIndices.Length();
if (!count)
return;
GLuint progname = program->mGLName;
nsTArray<GLint>& arr = retval.SetValue();
arr.SetLength(count);
MakeContextCurrent();
gl->fGetActiveUniformsiv(progname, count, uniformIndices.Elements(), pname,
arr.Elements());
}
示例6: funcScope
void WebGL2Context::GetUniformIndices(
const WebGLProgram& program, const dom::Sequence<nsString>& uniformNames,
dom::Nullable<nsTArray<GLuint> >& retval) {
const FuncScope funcScope(*this, "getUniformIndices");
retval.SetNull();
if (IsContextLost()) return;
if (!ValidateObject("program", program)) return;
if (!uniformNames.Length()) return;
program.GetUniformIndices(uniformNames, retval);
}
示例7:
void
WebGL2Context::ClearBufferfv(GLenum buffer, GLint drawbuffer, const dom::Sequence<GLfloat>& value)
{
if (IsContextLost()) {
return;
}
if (!ValidateClearBuffer("clearBufferfv", buffer, drawbuffer, value.Length())) {
return;
}
ClearBufferfv_base(buffer, drawbuffer, value.Elements());
}
示例8: switch
void
WebGLProgram::TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
GLenum bufferMode)
{
const char funcName[] = "transformFeedbackVaryings";
const auto& gl = mContext->gl;
gl->MakeCurrent();
switch (bufferMode) {
case LOCAL_GL_INTERLEAVED_ATTRIBS:
break;
case LOCAL_GL_SEPARATE_ATTRIBS:
{
GLuint maxAttribs = 0;
gl->GetUIntegerv(LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
&maxAttribs);
if (varyings.Length() > maxAttribs) {
mContext->ErrorInvalidValue("%s: Length of `varyings` exceeds %s.",
funcName,
"TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");
return;
}
}
break;
default:
mContext->ErrorInvalidEnum("%s: Bad `bufferMode`: 0x%04x.", funcName, bufferMode);
return;
}
////
mNextLink_TransformFeedbackVaryings.assign(varyings.Elements(),
varyings.Elements() + varyings.Length());
mNextLink_TransformFeedbackBufferMode = bufferMode;
}
示例9: mappedName
void
WebGLProgram::GetUniformIndices(const dom::Sequence<nsString>& uniformNames,
dom::Nullable< nsTArray<GLuint> >& retval) const
{
const char funcName[] = "getUniformIndices";
if (!IsLinked()) {
mContext->ErrorInvalidOperation("%s: `program` must be linked.", funcName);
return;
}
size_t count = uniformNames.Length();
nsTArray<GLuint>& arr = retval.SetValue();
gl::GLContext* gl = mContext->GL();
gl->MakeCurrent();
for (size_t i = 0; i < count; i++) {
const NS_LossyConvertUTF16toASCII userName(uniformNames[i]);
nsDependentCString baseUserName;
bool isArray;
size_t arrayIndex;
if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex)) {
arr.AppendElement(LOCAL_GL_INVALID_INDEX);
continue;
}
webgl::UniformInfo* info;
if (!LinkInfo()->FindUniform(baseUserName, &info)) {
arr.AppendElement(LOCAL_GL_INVALID_INDEX);
continue;
}
nsAutoCString mappedName(info->mActiveInfo->mBaseMappedName);
if (isArray) {
mappedName.AppendLiteral("[");
mappedName.AppendInt(uint32_t(arrayIndex));
mappedName.AppendLiteral("]");
}
const GLchar* mappedNameBytes = mappedName.BeginReading();
GLuint index = 0;
gl->fGetUniformIndices(mGLName, 1, &mappedNameBytes, &index);
arr.AppendElement(index);
}
}
示例10: switch
// Map attachments intended for the default buffer, to attachments for a non-
// default buffer.
static void
TranslateDefaultAttachments(const dom::Sequence<GLenum>& in, dom::Sequence<GLenum>* out)
{
for (size_t i = 0; i < in.Length(); i++) {
switch (in[i]) {
case LOCAL_GL_COLOR:
out->AppendElement(LOCAL_GL_COLOR_ATTACHMENT0);
break;
case LOCAL_GL_DEPTH:
out->AppendElement(LOCAL_GL_DEPTH_ATTACHMENT);
break;
case LOCAL_GL_STENCIL:
out->AppendElement(LOCAL_GL_STENCIL_ATTACHMENT);
break;
}
}
}
示例11:
void
WebGL2Context::GetUniformIndices(WebGLProgram* program,
const dom::Sequence<nsString>& uniformNames,
dom::Nullable< nsTArray<GLuint> >& retval)
{
retval.SetNull();
if (IsContextLost())
return;
if (!ValidateObject("getUniformIndices: program", program))
return;
if (!uniformNames.Length())
return;
program->GetUniformIndices(uniformNames, retval);
}
示例12: ErrorInvalidOperation
void
WebGL2Context::SamplerParameterfv(WebGLSampler* sampler, GLenum pname, const dom::Sequence<GLfloat>& param)
{
if (IsContextLost())
return;
if (!sampler || sampler->IsDeleted())
return ErrorInvalidOperation("samplerParameterfv: invalid sampler");
if (param.Length() < 1)
return /* TODO(djg): Error message */;
/* TODO(djg): All of these calls in ES3 only take 1 param */
if (!ValidateSamplerParameterParams(pname, WebGLIntOrFloat(param[0]), "samplerParameterfv"))
return;
WebGLContextUnchecked::SamplerParameterfv(sampler, pname, param.Elements());
}
示例13: ErrorInvalidOperation
void
WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
{
const char funcName[] = "drawBuffers";
if (IsContextLost())
return;
if (mBoundDrawFramebuffer) {
mBoundDrawFramebuffer->DrawBuffers(funcName, buffers);
return;
}
// GLES 3.0.4 p186:
// "If the GL is bound to the default framebuffer, then `n` must be 1 and the
// constant must be BACK or NONE. [...] If DrawBuffers is supplied with a
// constant other than BACK and NONE, or with a value of `n` other than 1, the
// error INVALID_OPERATION is generated."
if (buffers.Length() != 1) {
ErrorInvalidOperation("%s: For the default framebuffer, `buffers` must have a"
" length of 1.",
funcName);
return;
}
switch (buffers[0]) {
case LOCAL_GL_NONE:
case LOCAL_GL_BACK:
break;
default:
ErrorInvalidOperation("%s: For the default framebuffer, `buffers[0]` must be"
" BACK or NONE.",
funcName);
return;
}
mDefaultFB_DrawBuffer0 = buffers[0];
gl->Screen()->SetDrawBuffer(buffers[0]);
}
示例14: asciiName
void
WebGLProgram::TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
GLenum bufferMode)
{
if (bufferMode != LOCAL_GL_INTERLEAVED_ATTRIBS &&
bufferMode != LOCAL_GL_SEPARATE_ATTRIBS)
{
mContext->ErrorInvalidEnum("transformFeedbackVaryings: `bufferMode` %s is "
"invalid. Must be one of gl.INTERLEAVED_ATTRIBS or "
"gl.SEPARATE_ATTRIBS.",
mContext->EnumName(bufferMode));
return;
}
size_t varyingsCount = varyings.Length();
if (bufferMode == LOCAL_GL_SEPARATE_ATTRIBS &&
varyingsCount >= mContext->mGLMaxTransformFeedbackSeparateAttribs)
{
mContext->ErrorInvalidValue("transformFeedbackVaryings: Number of `varyings` exc"
"eeds gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
return;
}
std::vector<nsCString> asciiVaryings;
for (size_t i = 0; i < varyingsCount; i++) {
if (!ValidateGLSLVariableName(varyings[i], mContext, "transformFeedbackVaryings"))
return;
NS_LossyConvertUTF16toASCII asciiName(varyings[i]);
asciiVaryings.push_back(asciiName);
}
// All validated. Translate the strings and store them until
// program linking.
mTransformFeedbackBufferMode = bufferMode;
mTransformFeedbackVaryings.swap(asciiVaryings);
}
示例15: sizeof
void
WebGL2Context::TransformFeedbackVaryings(WebGLProgram* program,
const dom::Sequence<nsString>& varyings,
GLenum bufferMode)
{
if (IsContextLost())
return;
if (!ValidateObject("transformFeedbackVaryings: program", program))
return;
GLsizei count = varyings.Length();
GLchar** tmpVaryings = (GLchar**) nsMemory::Alloc(count * sizeof(GLchar*));
for (GLsizei n = 0; n < count; n++) {
tmpVaryings[n] = (GLchar*) ToNewCString(varyings[n]);
}
GLuint progname = program->GLName();
MakeContextCurrent();
gl->fTransformFeedbackVaryings(progname, count, tmpVaryings, bufferMode);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, tmpVaryings);
}