本文整理汇总了C++中WebGLRenderingContext::graphicsContext3D方法的典型用法代码示例。如果您正苦于以下问题:C++ WebGLRenderingContext::graphicsContext3D方法的具体用法?C++ WebGLRenderingContext::graphicsContext3D怎么用?C++ WebGLRenderingContext::graphicsContext3D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLRenderingContext
的用法示例。
在下文中一共展示了WebGLRenderingContext::graphicsContext3D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bitmapLock
void GraphicsContext3DInternal::paintRenderingResultsToCanvas(CanvasRenderingContext* context)
{
HTMLCanvasElement* canvas = context->canvas();
ImageBuffer* imageBuffer = canvas->buffer();
unsigned char* pixels = 0;
#if PLATFORM(SKIA)
const SkBitmap* canvasBitmap = imageBuffer->context()->platformContext()->bitmap();
const SkBitmap* readbackBitmap = 0;
ASSERT(canvasBitmap->config() == SkBitmap::kARGB_8888_Config);
if (canvasBitmap->width() == m_impl->width() && canvasBitmap->height() == m_impl->height()) {
// This is the fastest and most common case. We read back
// directly into the canvas's backing store.
readbackBitmap = canvasBitmap;
m_resizingBitmap.reset();
} else {
// We need to allocate a temporary bitmap for reading back the
// pixel data. We will then use Skia to rescale this bitmap to
// the size of the canvas's backing store.
if (m_resizingBitmap.width() != m_impl->width() || m_resizingBitmap.height() != m_impl->height()) {
m_resizingBitmap.setConfig(SkBitmap::kARGB_8888_Config,
m_impl->width(),
m_impl->height());
if (!m_resizingBitmap.allocPixels())
return;
}
readbackBitmap = &m_resizingBitmap;
}
// Read back the frame buffer.
SkAutoLockPixels bitmapLock(*readbackBitmap);
pixels = static_cast<unsigned char*>(readbackBitmap->getPixels());
#elif PLATFORM(CG)
if (m_renderOutput)
pixels = m_renderOutput;
#else
#error Must port to your platform
#endif
m_impl->readBackFramebuffer(pixels, 4 * m_impl->width() * m_impl->height());
#if PLATFORM(SKIA)
if (m_resizingBitmap.readyToDraw()) {
// We need to draw the resizing bitmap into the canvas's backing store.
SkCanvas canvas(*canvasBitmap);
SkRect dst;
dst.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(canvasBitmap->width()), SkIntToScalar(canvasBitmap->height()));
canvas.drawBitmapRect(m_resizingBitmap, 0, dst);
}
#elif PLATFORM(CG)
if (m_renderOutput && context->is3d()) {
WebGLRenderingContext* webGLContext = static_cast<WebGLRenderingContext*>(context);
webGLContext->graphicsContext3D()->paintToCanvas(m_renderOutput, m_impl->width(), m_impl->height(), canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
}
#else
#error Must port to your platform
#endif
}