本文整理汇总了C++中WebGLContext::ErrorInvalidOperation方法的典型用法代码示例。如果您正苦于以下问题:C++ WebGLContext::ErrorInvalidOperation方法的具体用法?C++ WebGLContext::ErrorInvalidOperation怎么用?C++ WebGLContext::ErrorInvalidOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLContext
的用法示例。
在下文中一共展示了WebGLContext::ErrorInvalidOperation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scopedFB
//.........这里部分代码省略.........
fallbackReason = "non-zero UNPACK_SKIP_* not yet supported";
break;
}
const auto fnHasPremultMismatch = [&]() {
if (mSrcAlphaType == gfxAlphaType::Opaque)
return false;
const bool srcIsPremult = (mSrcAlphaType == gfxAlphaType::Premult);
const auto& dstIsPremult = webgl->mPixelStore_PremultiplyAlpha;
if (srcIsPremult == dstIsPremult)
return false;
if (dstIsPremult) {
fallbackReason = "UNPACK_PREMULTIPLY_ALPHA_WEBGL is not true";
} else {
fallbackReason = "UNPACK_PREMULTIPLY_ALPHA_WEBGL is not false";
}
return true;
};
if (fnHasPremultMismatch())
break;
if (dui->unpackFormat != LOCAL_GL_RGB && dui->unpackFormat != LOCAL_GL_RGBA) {
fallbackReason = "`format` is not RGB or RGBA";
break;
}
if (dui->unpackType != LOCAL_GL_UNSIGNED_BYTE) {
fallbackReason = "`type` is not UNSIGNED_BYTE";
break;
}
gl::ScopedFramebuffer scopedFB(gl);
gl::ScopedBindFramebuffer bindFB(gl, scopedFB.FB());
{
gl::GLContext::LocalErrorScope errorScope(*gl);
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
target.get(), tex->mGLName, level);
if (errorScope.GetError()) {
fallbackReason = "bug: failed to attach to FB for blit";
break;
}
}
const GLenum status = gl->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
fallbackReason = "bug: failed to confirm FB for blit";
break;
}
const gfx::IntSize destSize(mWidth, mHeight);
const auto dstOrigin = (webgl->mPixelStore_FlipY ? gl::OriginPos::TopLeft
: gl::OriginPos::BottomLeft);
if (!gl->BlitHelper()->BlitImageToFramebuffer(mImage, destSize, scopedFB.FB(),
dstOrigin))
{
fallbackReason = "likely bug: failed to blit";
break;
}
// Blitting was successful, so we're done!
*out_error = 0;
return true;
} while (false);
const nsPrintfCString perfMsg("%s: Failed to hit GPU-copy fast-path: %s (src type %u)",
funcName, fallbackReason, uint32_t(mImage->GetFormat()));
if (webgl->mPixelStore_RequireFastPath) {
webgl->ErrorInvalidOperation("%s", perfMsg.BeginReading());
return false;
}
webgl->GeneratePerfWarning("%s Falling back to CPU upload.",
perfMsg.BeginReading());
const RefPtr<gfx::SourceSurface> surf = mImage->GetAsSourceSurface();
RefPtr<gfx::DataSourceSurface> dataSurf;
if (surf) {
// WARNING: OSX can lose our MakeCurrent here.
dataSurf = surf->GetDataSurface();
}
if (!dataSurf) {
webgl->ErrorOutOfMemory("%s: GetAsSourceSurface or GetDataSurface failed after"
" blit failed for TexUnpackImage.",
funcName);
return false;
}
const TexUnpackSurface surfBlob(webgl, target, mWidth, mHeight, mDepth, dataSurf,
mSrcAlphaType);
return surfBlob.TexOrSubImage(isSubImage, needsRespec, funcName, tex, target, level,
dui, xOffset, yOffset, zOffset, pi, out_error);
}
示例2: bindPBO
bool
TexUnpackBytes::TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
WebGLTexture* tex, TexImageTarget target, GLint level,
const webgl::DriverUnpackInfo* dui, GLint xOffset,
GLint yOffset, GLint zOffset, const webgl::PackingInfo& pi,
GLenum* const out_error) const
{
WebGLContext* webgl = tex->mContext;
const auto format = FormatForPackingInfo(pi);
const auto bytesPerPixel = webgl::BytesPerPixel(pi);
const uint8_t* uploadPtr = mPtr;
UniqueBuffer tempBuffer;
do {
if (!mIsClientData || !mPtr)
break;
if (!webgl->mPixelStore_FlipY &&
!webgl->mPixelStore_PremultiplyAlpha)
{
break;
}
if (webgl->mPixelStore_UnpackImageHeight ||
webgl->mPixelStore_UnpackSkipImages ||
webgl->mPixelStore_UnpackRowLength ||
webgl->mPixelStore_UnpackSkipRows ||
webgl->mPixelStore_UnpackSkipPixels)
{
webgl->ErrorInvalidOperation("%s: Non-DOM-Element uploads with alpha-premult"
" or y-flip do not support subrect selection.",
funcName);
return false;
}
webgl->GenerateWarning("%s: Alpha-premult and y-flip are deprecated for"
" non-DOM-Element uploads.",
funcName);
const uint32_t rowLength = mWidth;
const uint32_t rowCount = mHeight * mDepth;
const auto stride = RoundUpToMultipleOf(rowLength * bytesPerPixel, mAlignment);
if (!ConvertIfNeeded(webgl, funcName, rowLength, rowCount, format, mPtr, stride,
format, stride, &uploadPtr, &tempBuffer))
{
return false;
}
} while (false);
//////
const auto& gl = webgl->gl;
bool useParanoidHandling = false;
if (mNeedsExactUpload && webgl->mBoundPixelUnpackBuffer) {
webgl->GenerateWarning("%s: Uploads from a buffer with a final row with a byte"
" count smaller than the row stride can incur extra"
" overhead.",
funcName);
if (gl->WorkAroundDriverBugs()) {
useParanoidHandling |= (gl->Vendor() == gl::GLVendor::NVIDIA);
}
}
if (!useParanoidHandling) {
if (webgl->mBoundPixelUnpackBuffer) {
gl->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER,
webgl->mBoundPixelUnpackBuffer->mGLName);
}
*out_error = DoTexOrSubImage(isSubImage, gl, target, level, dui, xOffset, yOffset,
zOffset, mWidth, mHeight, mDepth, uploadPtr);
if (webgl->mBoundPixelUnpackBuffer) {
gl->fBindBuffer(LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
}
return true;
}
//////
MOZ_ASSERT(webgl->mBoundPixelUnpackBuffer);
if (!isSubImage) {
// Alloc first to catch OOMs.
AssertUintParamCorrect(gl, LOCAL_GL_PIXEL_UNPACK_BUFFER, 0);
*out_error = DoTexOrSubImage(false, gl, target, level, dui, xOffset, yOffset,
zOffset, mWidth, mHeight, mDepth, nullptr);
if (*out_error)
return true;
}
const ScopedLazyBind bindPBO(gl, LOCAL_GL_PIXEL_UNPACK_BUFFER,
webgl->mBoundPixelUnpackBuffer);
//////
//.........这里部分代码省略.........