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

Side by Side Diff: Source/core/html/canvas/WebGLDrawBuffers.cpp

Issue 223223003: Re-land "WebGL: Transfer ownership of WebGraphicsContext3D to DrawingBuffer" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix errata on comment Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (n != 1) { 72 if (n != 1) {
73 m_context->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", " more than one buffer"); 73 m_context->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", " more than one buffer");
74 return; 74 return;
75 } 75 }
76 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) { 76 if (bufs[0] != GL_BACK && bufs[0] != GL_NONE) {
77 m_context->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersWEBGL ", "BACK or NONE"); 77 m_context->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersWEBGL ", "BACK or NONE");
78 return; 78 return;
79 } 79 }
80 // Because the backbuffer is simulated on all current WebKit ports, we n eed to change BACK to COLOR_ATTACHMENT0. 80 // Because the backbuffer is simulated on all current WebKit ports, we n eed to change BACK to COLOR_ATTACHMENT0.
81 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE; 81 GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE;
82 m_context->webGraphicsContext3D()->drawBuffersEXT(1, &value); 82 m_context->webContext()->drawBuffersEXT(1, &value);
83 m_context->setBackDrawBuffer(bufs[0]); 83 m_context->setBackDrawBuffer(bufs[0]);
84 } else { 84 } else {
85 if (n > m_context->maxDrawBuffers()) { 85 if (n > m_context->maxDrawBuffers()) {
86 m_context->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", " more than max draw buffers"); 86 m_context->synthesizeGLError(GL_INVALID_VALUE, "drawBuffersWEBGL", " more than max draw buffers");
87 return; 87 return;
88 } 88 }
89 for (GLsizei i = 0; i < n; ++i) { 89 for (GLsizei i = 0; i < n; ++i) {
90 if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_AT TACHMENT0_EXT + i)) { 90 if (bufs[i] != GL_NONE && bufs[i] != static_cast<GLenum>(GL_COLOR_AT TACHMENT0_EXT + i)) {
91 m_context->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersW EBGL", "COLOR_ATTACHMENTi_EXT or NONE"); 91 m_context->synthesizeGLError(GL_INVALID_OPERATION, "drawBuffersW EBGL", "COLOR_ATTACHMENTi_EXT or NONE");
92 return; 92 return;
93 } 93 }
94 } 94 }
95 m_context->m_framebufferBinding->drawBuffers(buffers); 95 m_context->m_framebufferBinding->drawBuffers(buffers);
96 } 96 }
97 } 97 }
98 98
99 // static 99 // static
100 bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web glContext) 100 bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web glContext)
101 { 101 {
102 blink::WebGraphicsContext3D* context = webglContext->webGraphicsContext3D(); 102 blink::WebGraphicsContext3D* context = webglContext->webContext();
103 Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil(); 103 Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil();
104 104
105 // This is called after we make sure GL_EXT_draw_buffers is supported. 105 // This is called after we make sure GL_EXT_draw_buffers is supported.
106 GLint maxDrawBuffers = 0; 106 GLint maxDrawBuffers = 0;
107 GLint maxColorAttachments = 0; 107 GLint maxColorAttachments = 0;
108 context->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &maxDrawBuffers); 108 context->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &maxDrawBuffers);
109 context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachments); 109 context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachments);
110 if (maxDrawBuffers < 4 || maxColorAttachments < 4) 110 if (maxDrawBuffers < 4 || maxColorAttachments < 4)
111 return false; 111 return false;
112 112
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (supportsDepth) 171 if (supportsDepth)
172 context->deleteTexture(depth); 172 context->deleteTexture(depth);
173 if (supportsDepthStencil) 173 if (supportsDepthStencil)
174 context->deleteTexture(depthStencil); 174 context->deleteTexture(depthStencil);
175 for (size_t i = 0; i < colors.size(); ++i) 175 for (size_t i = 0; i < colors.size(); ++i)
176 context->deleteTexture(colors[i]); 176 context->deleteTexture(colors[i]);
177 return ok; 177 return ok;
178 } 178 }
179 179
180 } // namespace WebCore 180 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLDebugShaders.cpp ('k') | Source/core/html/canvas/WebGLFramebuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698