Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 5321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5332 if (!frame) | 5332 if (!frame) |
| 5333 return; | 5333 return; |
| 5334 | 5334 |
| 5335 Settings* settings = frame->settings(); | 5335 Settings* settings = frame->settings(); |
| 5336 | 5336 |
| 5337 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) | 5337 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) |
| 5338 return; | 5338 return; |
| 5339 | 5339 |
| 5340 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings); | 5340 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings); |
| 5341 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes)); | 5341 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes)); |
| 5342 RefPtr<DrawingBuffer> drawingBuffer; | |
| 5343 if (context) { | |
| 5344 // If the context was lost due to RealLostContext, we need to release FB Os before creating new DrawingBuffer to ensure resource budget enough. | |
| 5345 m_drawingBuffer->releaseResources(); | |
| 5346 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad optRef(new WebGLRenderingContextEvictionManager()); | |
| 5347 | |
| 5348 // Construct a new drawing buffer with the new WebGraphicsContext3D. | |
| 5349 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | |
| 5350 drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize() , preserve, contextEvictionManager.release()); | |
| 5351 | |
| 5352 if (drawingBuffer->isZeroSized()) { | |
| 5353 drawingBuffer.clear(); | |
| 5354 context.clear(); | |
| 5355 } | |
| 5356 } | |
| 5342 if (!context) { | 5357 if (!context) { |
| 5343 if (m_contextLostMode == RealLostContext) { | 5358 if (m_contextLostMode == RealLostContext) { |
| 5344 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); | 5359 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); |
| 5345 } else { | 5360 } else { |
| 5346 // This likely shouldn't happen but is the best way to report it to the WebGL app. | 5361 // This likely shouldn't happen but is the best way to report it to the WebGL app. |
| 5347 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); | 5362 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); |
| 5348 } | 5363 } |
| 5349 return; | 5364 return; |
| 5350 } | 5365 } |
| 5351 | 5366 |
| 5352 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager()); | 5367 m_drawingBuffer = drawingBuffer.release(); |
| 5353 | |
| 5354 // Construct a new drawing buffer with the new WebGraphicsContext3D. | |
| 5355 m_drawingBuffer->releaseResources(); | |
| 5356 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->prese rveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | |
| 5357 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release()); | |
| 5358 | |
| 5359 if (m_drawingBuffer->isZeroSized()) | |
| 5360 return; | |
|
dshwang
2014/03/14 07:48:34
Unfortunately, this change is very hard to be cove
| |
| 5361 | |
| 5362 m_drawingBuffer->bind(); | 5368 m_drawingBuffer->bind(); |
|
Ken Russell (switch to Gerrit)
2014/03/14 01:49:19
If the code path "if (drawingBuffer->isZeroSized()
Ken Russell (switch to Gerrit)
2014/03/14 02:56:46
Never mind, I'm wrong.
| |
| 5363 | 5369 |
| 5364 m_lostContextErrors.clear(); | 5370 m_lostContextErrors.clear(); |
| 5365 | 5371 |
| 5366 m_context = context.release(); | 5372 m_context = context.release(); |
| 5367 m_contextLost = false; | 5373 m_contextLost = false; |
| 5368 | 5374 |
| 5369 setupFlags(); | 5375 setupFlags(); |
| 5370 initializeNewContext(); | 5376 initializeNewContext(); |
| 5371 markContextChanged(CanvasContextChanged); | 5377 markContextChanged(CanvasContextChanged); |
| 5372 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); | 5378 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5559 if (m_textureUnits[i].m_texture2DBinding | 5565 if (m_textureUnits[i].m_texture2DBinding |
| 5560 || m_textureUnits[i].m_textureCubeMapBinding) { | 5566 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5561 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5567 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5562 return; | 5568 return; |
| 5563 } | 5569 } |
| 5564 } | 5570 } |
| 5565 m_onePlusMaxNonDefaultTextureUnit = 0; | 5571 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5566 } | 5572 } |
| 5567 | 5573 |
| 5568 } // namespace WebCore | 5574 } // namespace WebCore |
| OLD | NEW |