Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp

Issue 2711783003: Move the WebGL DrawBuffers support check to the command buffer service. (Closed)
Patch Set: Fix typo Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp b/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp
index dd5047330e1f78625ce29b75a3d7a95f2df2d702..07eff8406447621cab9180a7c125a5b2061023eb 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp
@@ -45,8 +45,7 @@ WebGLDrawBuffers* WebGLDrawBuffers::create(WebGLRenderingContextBase* context) {
// static
bool WebGLDrawBuffers::supported(WebGLRenderingContextBase* context) {
- return (context->extensionsUtil()->supportsExtension("GL_EXT_draw_buffers") &&
- satisfiesWebGLRequirements(context));
+ return context->extensionsUtil()->supportsExtension("GL_EXT_draw_buffers");
}
// static
@@ -96,101 +95,4 @@ void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GLenum>& buffers) {
}
}
-// static
-bool WebGLDrawBuffers::satisfiesWebGLRequirements(
- WebGLRenderingContextBase* webglContext) {
- gpu::gles2::GLES2Interface* gl = webglContext->contextGL();
- Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil();
-
- // This is called after we make sure GL_EXT_draw_buffers is supported.
- GLint maxDrawBuffers = 0;
- GLint maxColorAttachments = 0;
- gl->GetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &maxDrawBuffers);
- gl->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachments);
- if (maxDrawBuffers < 4 || maxColorAttachments < 4)
- return false;
-
- GLuint fbo;
- gl->GenFramebuffers(1, &fbo);
- gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
-
- const unsigned char* buffer =
- 0; // Chromium doesn't allow init data for depth/stencil tetxures.
- bool supportsDepth =
- (extensionsUtil->supportsExtension("GL_CHROMIUM_depth_texture") ||
- extensionsUtil->supportsExtension("GL_OES_depth_texture") ||
- extensionsUtil->supportsExtension("GL_ARB_depth_texture"));
- bool supportsDepthStencil =
- (extensionsUtil->supportsExtension("GL_EXT_packed_depth_stencil") ||
- extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"));
- GLuint depthStencil = 0;
- if (supportsDepthStencil) {
- gl->GenTextures(1, &depthStencil);
- gl->BindTexture(GL_TEXTURE_2D, depthStencil);
- gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, 1, 1, 0,
- GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, buffer);
- }
- GLuint depth = 0;
- if (supportsDepth) {
- gl->GenTextures(1, &depth);
- gl->BindTexture(GL_TEXTURE_2D, depth);
- gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0,
- GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buffer);
- }
-
- Vector<GLuint> colors;
- bool ok = true;
- GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments);
- for (GLint i = 0; i < maxAllowedBuffers; ++i) {
- GLuint color;
-
- gl->GenTextures(1, &color);
- colors.push_back(color);
- gl->BindTexture(GL_TEXTURE_2D, color);
- gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, buffer);
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
- GL_TEXTURE_2D, color, 0);
- if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
- ok = false;
- break;
- }
- if (supportsDepth) {
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_TEXTURE_2D, depth, 0);
- if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) !=
- GL_FRAMEBUFFER_COMPLETE) {
- ok = false;
- break;
- }
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_TEXTURE_2D, 0, 0);
- }
- if (supportsDepthStencil) {
- // For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we
- // emulate it at the command buffer level for WebGL contexts.
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
- GL_TEXTURE_2D, depthStencil, 0);
- if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) !=
- GL_FRAMEBUFFER_COMPLETE) {
- ok = false;
- break;
- }
- gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
- GL_TEXTURE_2D, 0, 0);
- }
- }
-
- webglContext->restoreCurrentFramebuffer();
- gl->DeleteFramebuffers(1, &fbo);
- webglContext->restoreCurrentTexture2D();
- if (supportsDepth)
- gl->DeleteTextures(1, &depth);
- if (supportsDepthStencil)
- gl->DeleteTextures(1, &depthStencil);
- gl->DeleteTextures(colors.size(), colors.data());
-
- return ok;
-}
-
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698