本文整理汇总了C++中Extensions3D类的典型用法代码示例。如果您正苦于以下问题:C++ Extensions3D类的具体用法?C++ Extensions3D怎么用?C++ Extensions3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Extensions3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UNUSED_PARAM
void OESVertexArrayObject::bindVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (m_context->isContextLost())
return;
if (arrayObject && arrayObject->context() != m_context) {
m_context->graphicsContext3D()->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
if (arrayObject && !arrayObject->isDefaultObject() && arrayObject->object()) {
extensions->bindVertexArrayOES(arrayObject->object());
arrayObject->setHasEverBeenBound();
m_context->setBoundVertexArrayObject(arrayObject);
} else {
extensions->bindVertexArrayOES(0);
m_context->setBoundVertexArrayObject(0);
}
m_context->cleanupAfterGraphicsCall(false);
}
示例2: ShInitBuiltInResources
void GraphicsContext3DPrivate::initializeANGLE()
{
ShBuiltInResources ANGLEResources;
ShInitBuiltInResources(&ANGLEResources);
m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.MaxVertexAttribs);
m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.MaxVertexUniformVectors);
m_context->getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.MaxVaryingVectors);
m_context->getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxVertexTextureImageUnits);
m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxCombinedTextureImageUnits);
m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
m_context->getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
// Always set to 1 for OpenGL ES.
ANGLEResources.MaxDrawBuffers = 1;
Extensions3D* extensions = m_context->getExtensions();
if (extensions->supports("GL_ARB_texture_rectangle"))
ANGLEResources.ARB_texture_rectangle = 1;
GC3Dint range[2], precision;
m_context->getShaderPrecisionFormat(GraphicsContext3D::FRAGMENT_SHADER, GraphicsContext3D::HIGH_FLOAT, range, &precision);
ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
m_context->m_compiler.setResources(ANGLEResources);
}
示例3: getExtensions
void GraphicsContext3D::validateAttributes()
{
Extensions3D* extensions = getExtensions();
if (m_attrs.stencil) {
const char* packedDepthStencilExtension = isGLES2Compliant() ? "GL_OES_packed_depth_stencil" : "GL_EXT_packed_depth_stencil";
if (extensions->supports(packedDepthStencilExtension)) {
extensions->ensureEnabled(packedDepthStencilExtension);
// Force depth if stencil is true.
m_attrs.depth = true;
} else
m_attrs.stencil = false;
}
if (m_attrs.antialias) {
bool isValidVendor = true;
// Currently in Mac we only turn on antialias if vendor is NVIDIA,
// or if ATI and on 10.7.2 and above.
const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
if (!std::strstr(vendor, "NVIDIA") && !(std::strstr(vendor, "ATI") && systemAllowsMultisamplingOnATICards()))
isValidVendor = false;
if (!isValidVendor || !extensions->supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant())
m_attrs.antialias = false;
else
extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
}
}
示例4: supported
bool WebGLDepthTexture::supported(GraphicsContext3D* context)
{
Extensions3D* extensions = context->getExtensions();
return extensions->supports("GL_CHROMIUM_depth_texture")
|| extensions->supports("GL_OES_depth_texture")
|| extensions->supports("GL_ARB_depth_texture");
}
示例5: paintOnAndroid
void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context, WebCore::GraphicsContext3D* context3D, const IntRect& rect, uint8_t alpha)
{
if (!context || !context3D || !m_webMediaPlayer || context->paintingDisabled())
return;
Extensions3D* extensions = context3D->extensions();
if (!extensions || !extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy")
|| !context3D->makeContextCurrent())
return;
// Copy video texture into a RGBA texture based bitmap first as video texture on Android is GL_TEXTURE_EXTERNAL_OES
// which is not supported by Skia yet. The bitmap's size needs to be the same as the video and use naturalSize() here.
// Check if we could reuse existing texture based bitmap.
// Otherwise, release existing texture based bitmap and allocate a new one based on video size.
if (!ensureTextureBackedSkBitmap(context3D->grContext(), m_bitmap, naturalSize(), kTopLeft_GrSurfaceOrigin, kSkia8888_GrPixelConfig))
return;
// Copy video texture to bitmap texture.
WebGraphicsContext3D* webGraphicsContext3D = context3D->webContext();
WebCanvas* canvas = context->canvas();
unsigned textureId = static_cast<unsigned>((m_bitmap.getTexture())->getTextureHandle());
if (!m_webMediaPlayer->copyVideoTextureToPlatformTexture(webGraphicsContext3D, textureId, 0, GL_RGBA, GL_UNSIGNED_BYTE, true, false))
return;
// Draw the texture based bitmap onto the Canvas. If the canvas is hardware based, this will do a GPU-GPU texture copy. If the canvas is software based,
// the texture based bitmap will be readbacked to system memory then draw onto the canvas.
SkRect dest;
dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());
SkPaint paint;
paint.setAlpha(alpha);
// It is not necessary to pass the dest into the drawBitmap call since all the context have been set up before calling paintCurrentFrameInContext.
canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint);
}
示例6: copyToPlatformTexture
bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D& context, Platform3DObject texture, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
{
if (!m_data.m_layerBridge || !platformLayer())
return false;
Platform3DObject sourceTexture = m_data.m_layerBridge->backBufferTexture();
if (!context.makeContextCurrent())
return false;
Extensions3D* extensions = context.getExtensions();
if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy"))
return false;
// The canvas is stored in a premultiplied format, so unpremultiply if necessary.
context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyAlpha);
// The canvas is stored in an inverted position, so the flip semantics are reversed.
context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY);
extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, sourceTexture, texture, 0, internalFormat);
context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false);
context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false);
context.flush();
return true;
}
示例7: paintCompositedResultsToCanvas
void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer)
{
if (!m_context || !m_context->makeContextCurrent() || m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR)
return;
Extensions3D* extensions = m_context->getExtensions();
#if ENABLE(CANVAS_USES_MAILBOX)
// Since the m_frontColorBuffer was produced and sent to the compositor, it cannot be bound to an fbo.
// We have to make a copy of it here and bind that copy instead.
unsigned sourceTexture = createColorTexture(m_size);
extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, m_frontColorBuffer, sourceTexture, 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE);
#else
// FIXME: Re-examine general correctness of this code beacause m_colorBuffer may contain a stale copy of the data
// that was sent to the compositor at some point in the past.
unsigned sourceTexture = frontColorBuffer();
#endif // ENABLE(CANVAS_USES_MAILBOX)
// Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding).
// FIXME: The WebGLRenderingContext tracks the current framebuffer binding, it would be slightly more efficient to use this value
// rather than querying it off of the context.
GC3Dint previousFramebuffer = 0;
m_context->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &previousFramebuffer);
Platform3DObject framebuffer = m_context->createFramebuffer();
m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, framebuffer);
m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, sourceTexture, 0);
extensions->paintFramebufferToCanvas(framebuffer, size().width(), size().height(), !m_attributes.premultipliedAlpha, imageBuffer);
m_context->deleteFramebuffer(framebuffer);
#if ENABLE(CANVAS_USES_MAILBOX)
m_context->deleteTexture(sourceTexture);
#endif // ENABLE(CANVAS_USES_MAILBOX)
m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, previousFramebuffer);
}
示例8:
bool WebGLCompressedTextureS3TC::supported(WebGLRenderingContextBase* context)
{
Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
return extensions->supports("GL_EXT_texture_compression_s3tc")
|| (extensions->supports("GL_EXT_texture_compression_dxt1")
&& extensions->supports("GL_CHROMIUM_texture_compression_dxt3")
&& extensions->supports("GL_CHROMIUM_texture_compression_dxt5"));
}
示例9: commit
bool DrawingBuffer::prepareMailbox(WebKit::WebExternalTextureMailbox* outMailbox)
{
if (!m_context || !m_contentsChanged || !m_lastColorBuffer)
return false;
m_context->makeContextCurrent();
// Resolve the multisampled buffer into the texture referenced by m_lastColorBuffer mailbox.
if (multisample())
commit();
// We must restore the texture binding since creating new textures,
// consuming and producing mailboxes changes it.
ScopedTextureUnit0BindingRestorer restorer(m_context.get(), m_activeTextureUnit, m_texture2DBinding);
// First try to recycle an old buffer.
RefPtr<MailboxInfo> nextFrontColorBuffer = getRecycledMailbox();
// No buffer available to recycle, create a new one.
if (!nextFrontColorBuffer) {
unsigned newColorBuffer = createColorTexture(m_size);
// Bad things happened, abandon ship.
if (!newColorBuffer)
return false;
nextFrontColorBuffer = createNewMailbox(newColorBuffer);
}
if (m_preserveDrawingBuffer == Discard) {
m_colorBuffer = nextFrontColorBuffer->textureId;
swap(nextFrontColorBuffer, m_lastColorBuffer);
// It appears safe to overwrite the context's framebuffer binding in the Discard case since there will always be a
// WebGLRenderingContext::clearIfComposited() call made before the next draw call which restores the framebuffer binding.
// If this stops being true at some point, we should track the current framebuffer binding in the DrawingBuffer and restore
// it after attaching the new back buffer here.
m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
} else {
Extensions3D* extensions = m_context->getExtensions();
extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, m_colorBuffer, nextFrontColorBuffer->textureId, 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE);
}
if (multisample() && !m_framebufferBinding)
bind();
else
restoreFramebufferBinding();
m_contentsChanged = false;
context()->bindTexture(GraphicsContext3D::TEXTURE_2D, nextFrontColorBuffer->textureId);
context()->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, nextFrontColorBuffer->mailbox.name);
context()->flush();
m_context->markLayerComposited();
*outMailbox = nextFrontColorBuffer->mailbox;
m_frontColorBuffer = nextFrontColorBuffer->textureId;
return true;
}
示例10: OS
// static
bool EXTDrawBuffers::supported(WebGLRenderingContext* context)
{
#if OS(DARWIN)
// https://bugs.webkit.org/show_bug.cgi?id=112486
return false;
#endif
Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
return extensions->supports("GL_EXT_draw_buffers");
}
示例11: m_currentWidth
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool renderDirectlyToHostWindow)
: m_currentWidth(0)
, m_currentHeight(0)
, m_hostWindow(hostWindow)
, m_context(BlackBerry::Platform::Graphics::createWebGLContext())
, m_extensions(adoptPtr(new Extensions3DOpenGL(this)))
, m_attrs(attrs)
, m_texture(0)
, m_fbo(0)
, m_depthStencilBuffer(0)
, m_boundFBO(0)
, m_activeTexture(GL_TEXTURE0)
, m_boundTexture0(0)
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
{
if (!renderDirectlyToHostWindow) {
#if USE(ACCELERATED_COMPOSITING)
m_compositingLayer = WebGLLayerWebKitThread::create();
#endif
makeContextCurrent();
Extensions3D* extensions = getExtensions();
if (!extensions->supports("GL_IMG_multisampled_render_to_texture"))
m_attrs.antialias = false;
// Create a texture to render into.
::glGenTextures(1, &m_texture);
::glBindTexture(GL_TEXTURE_2D, m_texture);
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
::glBindTexture(GL_TEXTURE_2D, 0);
// Create an FBO.
::glGenFramebuffers(1, &m_fbo);
::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
if (m_attrs.stencil || m_attrs.depth)
::glGenRenderbuffers(1, &m_depthStencilBuffer);
m_boundFBO = m_fbo;
#if USE(ACCELERATED_COMPOSITING)
static_cast<WebGLLayerWebKitThread*>(m_compositingLayer.get())->setWebGLContext(this);
#endif
}
// FIXME: If GraphicsContext3D is created with renderDirectlyToHostWindow == true,
// makeContextCurrent() will make the shared context current.
makeContextCurrent();
// FIXME: Do we need to enable GL_VERTEX_PROGRAM_POINT_SIZE with GL ES2? See PR #120141.
::glClearColor(0, 0, 0, 0);
}
示例12: copyVideoTextureToPlatformTexture
bool WebMediaPlayerClientImpl::copyVideoTextureToPlatformTexture(WebCore::GraphicsContext3D* context, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
{
if (!context || !m_webMediaPlayer)
return false;
Extensions3D* extensions = context->getExtensions();
if (!extensions || !extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy") || !context->makeContextCurrent())
return false;
WebGraphicsContext3D* webGraphicsContext3D = GraphicsContext3DPrivate::extractWebGraphicsContext3D(context);
return m_webMediaPlayer->copyVideoTextureToPlatformTexture(webGraphicsContext3D, texture, level, internalFormat, premultiplyAlpha, flipY);
}
示例13: validateDepthStencil
void GraphicsContext3D::validateAttributes()
{
validateDepthStencil("GL_OES_packed_depth_stencil");
if (m_attrs.antialias) {
Extensions3D* extensions = getExtensions();
if (!extensions->supports("GL_IMG_multisampled_render_to_texture"))
m_attrs.antialias = false;
}
}
示例14: ASSERT
bool LayerTextureUpdaterSkPicture::createFrameBuffer()
{
ASSERT(!m_fbo);
ASSERT(!m_bufferSize.isEmpty());
// SKIA only needs color and stencil buffers, not depth buffer.
// But it is very uncommon for cards to support color + stencil FBO config.
// The most common config is color + packed-depth-stencil.
// Instead of iterating through all possible FBO configs, we only try the
// most common one here.
// FIXME: Delegate the task of creating frame-buffer to SKIA.
// It has all necessary code to iterate through all possible configs
// and choose the one most suitable for its purposes.
Extensions3D* extensions = context()->getExtensions();
if (!extensions->supports("GL_OES_packed_depth_stencil"))
return false;
extensions->ensureEnabled("GL_OES_packed_depth_stencil");
// Create and bind a frame-buffer-object.
m_fbo = context()->createFramebuffer();
if (!m_fbo)
return false;
context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
// We just need to create a stencil buffer for FBO.
// The color buffer (texture) will be provided by tiles.
// SKIA does not need depth buffer.
m_depthStencilBuffer = context()->createRenderbuffer();
if (!m_depthStencilBuffer) {
deleteFrameBuffer();
return false;
}
context()->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer);
context()->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, Extensions3D::DEPTH24_STENCIL8, m_bufferSize.width(), m_bufferSize.height());
context()->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer);
context()->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthStencilBuffer);
// Create a skia gpu canvas.
GrContext* skiaContext = m_context->grContext();
GrPlatformSurfaceDesc targetDesc;
targetDesc.reset();
targetDesc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType;
targetDesc.fRenderTargetFlags = kNone_GrPlatformRenderTargetFlagBit;
targetDesc.fWidth = m_bufferSize.width();
targetDesc.fHeight = m_bufferSize.height();
targetDesc.fConfig = kRGBA_8888_GrPixelConfig;
targetDesc.fStencilBits = 8;
targetDesc.fPlatformRenderTarget = m_fbo;
SkAutoTUnref<GrRenderTarget> target(static_cast<GrRenderTarget*>(skiaContext->createPlatformSurface(targetDesc)));
SkAutoTUnref<SkDevice> device(new SkGpuDevice(skiaContext, target.get()));
m_canvas = adoptPtr(new SkCanvas(device.get()));
context()->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0);
return true;
}
示例15: isVertexArrayOES
GC3Dboolean OESVertexArrayObject::isVertexArrayOES(WebGLVertexArrayObjectOES* arrayObject)
{
if (!arrayObject || m_context->isContextLost())
return 0;
if (!arrayObject->hasEverBeenBound())
return 0;
Extensions3D* extensions = m_context->graphicsContext3D()->getExtensions();
return extensions->isVertexArrayOES(arrayObject->object());
}