本文整理汇总了C++中GLContext::fPixelStorei方法的典型用法代码示例。如果您正苦于以下问题:C++ GLContext::fPixelStorei方法的具体用法?C++ GLContext::fPixelStorei怎么用?C++ GLContext::fPixelStorei使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLContext
的用法示例。
在下文中一共展示了GLContext::fPixelStorei方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
bool
ReadbackSharedSurface(SharedSurface* src, gfx::DrawTarget* dst)
{
AutoLockBits lock(dst);
uint8_t* dstBytes;
gfx::IntSize dstSize;
int32_t dstStride;
gfx::SurfaceFormat dstFormat;
if (!lock.Lock(&dstBytes, &dstSize, &dstStride, &dstFormat))
return false;
const bool isDstRGBA = (dstFormat == gfx::SurfaceFormat::R8G8B8A8 ||
dstFormat == gfx::SurfaceFormat::R8G8B8X8);
MOZ_ASSERT_IF(!isDstRGBA, dstFormat == gfx::SurfaceFormat::B8G8R8A8 ||
dstFormat == gfx::SurfaceFormat::B8G8R8X8);
size_t width = src->mSize.width;
size_t height = src->mSize.height;
MOZ_ASSERT(width == (size_t)dstSize.width);
MOZ_ASSERT(height == (size_t)dstSize.height);
GLenum readGLFormat;
GLenum readType;
{
ScopedReadbackFB autoReadback(src);
// We have a source FB, now we need a format.
GLenum dstGLFormat = isDstRGBA ? LOCAL_GL_BGRA : LOCAL_GL_RGBA;
GLenum dstType = LOCAL_GL_UNSIGNED_BYTE;
// We actually don't care if they match, since we can handle
// any read{Format,Type} we get.
GLContext* gl = src->mGL;
GetActualReadFormats(gl, dstGLFormat, dstType, &readGLFormat,
&readType);
MOZ_ASSERT(readGLFormat == LOCAL_GL_RGBA ||
readGLFormat == LOCAL_GL_BGRA);
MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_BYTE);
// ReadPixels from the current FB into lockedBits.
{
size_t alignment = 8;
if (dstStride % 4 == 0)
alignment = 4;
ScopedPackState scopedPackState(gl);
if (alignment != 4) {
gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, alignment);
}
gl->raw_fReadPixels(0, 0, width, height, readGLFormat, readType,
dstBytes);
}
}
const bool isReadRGBA = readGLFormat == LOCAL_GL_RGBA;
if (isReadRGBA != isDstRGBA) {
for (size_t j = 0; j < height; ++j) {
uint8_t* rowItr = dstBytes + j*dstStride;
uint8_t* rowEnd = rowItr + 4*width;
while (rowItr != rowEnd) {
Swap(rowItr[0], rowItr[2]);
rowItr += 4;
}
}
}
return true;
}