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

Side by Side Diff: Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

Issue 12843018: Merge 145856 "Check to ensure MultisampleRenderbuffer creation s..." (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 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
« no previous file with comments | « Source/WebCore/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 m_context->clear(clearMask); 182 m_context->clear(clearMask);
183 183
184 // The multisample fbo was just cleared, but we also need to clear the non-m ultisampled buffer too. 184 // The multisample fbo was just cleared, but we also need to clear the non-m ultisampled buffer too.
185 if (m_multisampleFBO) { 185 if (m_multisampleFBO) {
186 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 186 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
187 m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT); 187 m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
188 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisample FBO); 188 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisample FBO);
189 } 189 }
190 } 190 }
191 191
192 // Only way to ensure that we're not getting a bad framebuffer on some AMD/OSX d evices.
193 // FIXME: This can be removed once renderbufferStorageMultisample starts reporti ng GL_OUT_OF_MEMORY properly.
194 bool DrawingBuffer::checkBufferIntegrity()
195 {
196 if (!m_multisampleFBO)
197 return true;
198
199 if (m_scissorEnabled)
200 m_context->disable(GraphicsContext3D::SCISSOR_TEST);
201
202 m_context->colorMask(true, true, true, true);
203
204 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO) ;
205 m_context->clearColor(1.0f, 0.0f, 1.0f, 1.0f);
206 m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
207
208 commit(0, 0, 1, 1);
209
210 unsigned char pixel[4] = {0, 0, 0, 0};
211 m_context->readPixels(0, 0, 1, 1, GraphicsContext3D::RGBA, GraphicsContext3D ::UNSIGNED_BYTE, &pixel);
212
213 if (m_scissorEnabled)
214 m_context->enable(GraphicsContext3D::SCISSOR_TEST);
215
216 return (pixel[0] == 0xFF && pixel[1] == 0x00 && pixel[2] == 0xFF && pixel[3] == 0xFF);
217 }
218
192 bool DrawingBuffer::reset(const IntSize& newSize) 219 bool DrawingBuffer::reset(const IntSize& newSize)
193 { 220 {
194 if (!m_context) 221 if (!m_context)
195 return false; 222 return false;
196 223
197 m_context->makeContextCurrent(); 224 m_context->makeContextCurrent();
198 225
199 int maxTextureSize = 0; 226 int maxTextureSize = 0;
200 m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize) ; 227 m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize) ;
201 if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) { 228 if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) {
(...skipping 29 matching lines...) Expand all
231 if (attributes.alpha) { 258 if (attributes.alpha) {
232 internalColorFormat = GraphicsContext3D::RGBA; 259 internalColorFormat = GraphicsContext3D::RGBA;
233 colorFormat = GraphicsContext3D::RGBA; 260 colorFormat = GraphicsContext3D::RGBA;
234 internalRenderbufferFormat = Extensions3D::RGBA8_OES; 261 internalRenderbufferFormat = Extensions3D::RGBA8_OES;
235 } else { 262 } else {
236 internalColorFormat = GraphicsContext3D::RGB; 263 internalColorFormat = GraphicsContext3D::RGB;
237 colorFormat = GraphicsContext3D::RGB; 264 colorFormat = GraphicsContext3D::RGB;
238 internalRenderbufferFormat = Extensions3D::RGB8_OES; 265 internalRenderbufferFormat = Extensions3D::RGB8_OES;
239 } 266 }
240 267
241
242 do { 268 do {
243 m_size = adjustedSize; 269 m_size = adjustedSize;
244 // resize multisample FBO 270 // resize multisample FBO
245 if (multisample()) { 271 if (multisample()) {
246 int maxSampleCount = 0; 272 int maxSampleCount = 0;
247 273
248 m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCoun t); 274 m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCoun t);
249 int sampleCount = std::min(4, maxSampleCount); 275 int sampleCount = std::min(4, maxSampleCount);
250 276
251 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_mul tisampleFBO); 277 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_mul tisampleFBO);
252 278
253 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_m ultisampleColorBuffer); 279 m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_m ultisampleColorBuffer);
254 m_context->getExtensions()->renderbufferStorageMultisample(Graph icsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.widt h(), m_size.height()); 280 m_context->getExtensions()->renderbufferStorageMultisample(Graph icsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.widt h(), m_size.height());
281
282 if (m_context->getError() == GraphicsContext3D::OUT_OF_MEMORY) {
283 adjustedSize.scale(s_resourceAdjustedRatio);
284 continue;
285 }
286
255 m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFE R, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_mult isampleColorBuffer); 287 m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFE R, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_mult isampleColorBuffer);
256 resizeDepthStencil(sampleCount); 288 resizeDepthStencil(sampleCount);
257 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBU FFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { 289 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBU FFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
258 adjustedSize.scale(s_resourceAdjustedRatio); 290 adjustedSize.scale(s_resourceAdjustedRatio);
259 continue; 291 continue;
260 } 292 }
261 } 293 }
262 294
263 // resize regular FBO 295 // resize regular FBO
264 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); 296 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
265 297
266 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer) ; 298 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer) ;
267 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internalColo rFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNS IGNED_BYTE, 0); 299 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internalColo rFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNS IGNED_BYTE, 0);
268 300
269 m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, Grap hicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); 301 m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, Grap hicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
270 302
271 // resize the front color buffer 303 // resize the front color buffer
272 if (m_separateFrontTexture) { 304 if (m_separateFrontTexture) {
273 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_frontCol orBuffer); 305 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_frontCol orBuffer);
274 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internal ColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D: :UNSIGNED_BYTE, 0); 306 m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, internal ColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D: :UNSIGNED_BYTE, 0);
275 } 307 }
276 308
277 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); 309 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
278 310
279 if (!multisample()) 311 if (!multisample())
280 resizeDepthStencil(0); 312 resizeDepthStencil(0);
281 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER ) == GraphicsContext3D::FRAMEBUFFER_COMPLETE) 313 if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER ) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
282 break; 314 adjustedSize.scale(s_resourceAdjustedRatio);
283 adjustedSize.scale(s_resourceAdjustedRatio); 315 continue;
316 }
317
318 #if OS(DARWIN)
319 // FIXME: This can be removed once renderbufferStorageMultisample st arts reporting GL_OUT_OF_MEMORY properly on OSX.
320 if (!checkBufferIntegrity()) {
321 adjustedSize.scale(s_resourceAdjustedRatio);
322 continue;
323 }
324 #endif
325
326 break;
284 327
285 } while (!adjustedSize.isEmpty()); 328 } while (!adjustedSize.isEmpty());
286 329
287 pixelDelta = m_size.width() * m_size.height(); 330 pixelDelta = m_size.width() * m_size.height();
288 pixelDelta -= oldSize; 331 pixelDelta -= oldSize;
289 s_currentResourceUsePixels += pixelDelta; 332 s_currentResourceUsePixels += pixelDelta;
290 333
291 if (!newSize.isEmpty() && adjustedSize.isEmpty()) { 334 if (!newSize.isEmpty() && adjustedSize.isEmpty()) {
292 clear(); 335 clear();
293 return false; 336 return false;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 { 424 {
382 if (!m_context) 425 if (!m_context)
383 return; 426 return;
384 427
385 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); 428 m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo);
386 } 429 }
387 430
388 } // namespace WebCore 431 } // namespace WebCore
389 432
390 #endif 433 #endif
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698