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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp

Issue 1814263004: Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: complex-create: rebase Created 4 years, 9 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return; 94 return;
95 } 95 }
96 } 96 }
97 scoped.context()->m_framebufferBinding->drawBuffers(buffers); 97 scoped.context()->m_framebufferBinding->drawBuffers(buffers);
98 } 98 }
99 } 99 }
100 100
101 // static 101 // static
102 bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web glContext) 102 bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web glContext)
103 { 103 {
104 WebGraphicsContext3D* context = webglContext->webContext();
105 gpu::gles2::GLES2Interface* gl = webglContext->contextGL(); 104 gpu::gles2::GLES2Interface* gl = webglContext->contextGL();
106 Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil(); 105 Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil();
107 106
108 // This is called after we make sure GL_EXT_draw_buffers is supported. 107 // This is called after we make sure GL_EXT_draw_buffers is supported.
109 GLint maxDrawBuffers = 0; 108 GLint maxDrawBuffers = 0;
110 GLint maxColorAttachments = 0; 109 GLint maxColorAttachments = 0;
111 gl->GetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &maxDrawBuffers); 110 gl->GetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &maxDrawBuffers);
112 gl->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachments); 111 gl->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachments);
113 if (maxDrawBuffers < 4 || maxColorAttachments < 4) 112 if (maxDrawBuffers < 4 || maxColorAttachments < 4)
114 return false; 113 return false;
115 114
116 Platform3DObject fbo = context->createFramebuffer(); 115 GLuint fbo;
116 gl->GenFramebuffers(1, &fbo);
117 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); 117 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
118 118
119 const unsigned char* buffer = 0; // Chromium doesn't allow init data for dep th/stencil tetxures. 119 const unsigned char* buffer = 0; // Chromium doesn't allow init data for dep th/stencil tetxures.
120 bool supportsDepth = (extensionsUtil->supportsExtension("GL_CHROMIUM_depth_t exture") 120 bool supportsDepth = (extensionsUtil->supportsExtension("GL_CHROMIUM_depth_t exture")
121 || extensionsUtil->supportsExtension("GL_OES_depth_texture") 121 || extensionsUtil->supportsExtension("GL_OES_depth_texture")
122 || extensionsUtil->supportsExtension("GL_ARB_depth_texture")); 122 || extensionsUtil->supportsExtension("GL_ARB_depth_texture"));
123 bool supportsDepthStencil = (extensionsUtil->supportsExtension("GL_EXT_packe d_depth_stencil") 123 bool supportsDepthStencil = (extensionsUtil->supportsExtension("GL_EXT_packe d_depth_stencil")
124 || extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); 124 || extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"));
125 Platform3DObject depthStencil = 0; 125 GLuint depthStencil = 0;
126 if (supportsDepthStencil) { 126 if (supportsDepthStencil) {
127 depthStencil = context->createTexture(); 127 gl->GenTextures(1, &depthStencil);
128 gl->BindTexture(GL_TEXTURE_2D, depthStencil); 128 gl->BindTexture(GL_TEXTURE_2D, depthStencil);
129 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, 1, 1, 0, GL_DEPTH _STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, buffer); 129 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, 1, 1, 0, GL_DEPTH _STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, buffer);
130 } 130 }
131 Platform3DObject depth = 0; 131 GLuint depth = 0;
132 if (supportsDepth) { 132 if (supportsDepth) {
133 depth = context->createTexture(); 133 gl->GenTextures(1, &depth);
134 gl->BindTexture(GL_TEXTURE_2D, depth); 134 gl->BindTexture(GL_TEXTURE_2D, depth);
135 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C OMPONENT, GL_UNSIGNED_INT, buffer); 135 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C OMPONENT, GL_UNSIGNED_INT, buffer);
136 } 136 }
137 137
138 Vector<Platform3DObject> colors; 138 Vector<Platform3DObject> colors;
139 bool ok = true; 139 bool ok = true;
140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); 140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments);
141 for (GLint i = 0; i < maxAllowedBuffers; ++i) { 141 for (GLint i = 0; i < maxAllowedBuffers; ++i) {
142 Platform3DObject color = context->createTexture(); 142 GLuint color;
143 gl->GenTextures(1, &color);
143 colors.append(color); 144 colors.append(color);
144 gl->BindTexture(GL_TEXTURE_2D, color); 145 gl->BindTexture(GL_TEXTURE_2D, color);
145 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_ BYTE, buffer); 146 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_ BYTE, buffer);
146 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE XTURE_2D, color, 0); 147 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE XTURE_2D, color, 0);
147 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET E) { 148 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET E) {
148 ok = false; 149 ok = false;
149 break; 150 break;
150 } 151 }
151 if (supportsDepth) { 152 if (supportsDepth) {
152 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depth, 0); 153 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depth, 0);
153 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { 154 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) {
154 ok = false; 155 ok = false;
155 break; 156 break;
156 } 157 }
157 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); 158 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0);
158 } 159 }
159 if (supportsDepthStencil) { 160 if (supportsDepthStencil) {
160 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depthStencil, 0); 161 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depthStencil, 0);
161 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, depthStencil, 0); 162 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, depthStencil, 0);
162 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { 163 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) {
163 ok = false; 164 ok = false;
164 break; 165 break;
165 } 166 }
166 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); 167 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0);
167 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, 0, 0); 168 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, 0, 0);
168 } 169 }
169 } 170 }
170 171
171 webglContext->restoreCurrentFramebuffer(); 172 webglContext->restoreCurrentFramebuffer();
172 context->deleteFramebuffer(fbo); 173 gl->DeleteFramebuffers(1, &fbo);
173 webglContext->restoreCurrentTexture2D(); 174 webglContext->restoreCurrentTexture2D();
174 if (supportsDepth) 175 if (supportsDepth)
175 context->deleteTexture(depth); 176 gl->DeleteTextures(1, &depth);
176 if (supportsDepthStencil) 177 if (supportsDepthStencil)
177 context->deleteTexture(depthStencil); 178 gl->DeleteTextures(1, &depthStencil);
178 for (size_t i = 0; i < colors.size(); ++i) 179 gl->DeleteTextures(colors.size(), colors.data());
179 context->deleteTexture(colors[i]);
180 return ok; 180 return ok;
181 } 181 }
182 182
183 } // namespace blink 183 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLBuffer.cpp ('k') | third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698