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 5353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5364 if (!frame) | 5364 if (!frame) |
5365 return; | 5365 return; |
5366 | 5366 |
5367 Settings* settings = frame->settings(); | 5367 Settings* settings = frame->settings(); |
5368 | 5368 |
5369 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 5369 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
5370 return; | 5370 return; |
5371 | 5371 |
5372 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings); | 5372 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings); |
5373 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes, 0)); | 5373 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes, 0)); |
| 5374 RefPtr<DrawingBuffer> drawingBuffer; |
| 5375 if (context) { |
| 5376 // If the context was lost due to RealLostContext, we need to release FB
Os before creating new DrawingBuffer to ensure resource budget enough. |
| 5377 m_drawingBuffer->releaseResources(); |
| 5378 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad
optRef(new WebGLRenderingContextEvictionManager()); |
| 5379 |
| 5380 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
| 5381 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p
reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 5382 drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize()
, preserve, contextEvictionManager.release()); |
| 5383 |
| 5384 if (drawingBuffer->isZeroSized()) { |
| 5385 drawingBuffer.clear(); |
| 5386 context.clear(); |
| 5387 } |
| 5388 } |
5374 if (!context) { | 5389 if (!context) { |
5375 if (m_contextLostMode == RealLostContext) { | 5390 if (m_contextLostMode == RealLostContext) { |
5376 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE
); | 5391 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE
); |
5377 } else { | 5392 } else { |
5378 // This likely shouldn't happen but is the best way to report it to
the WebGL app. | 5393 // This likely shouldn't happen but is the best way to report it to
the WebGL app. |
5379 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); | 5394 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); |
5380 } | 5395 } |
5381 return; | 5396 return; |
5382 } | 5397 } |
5383 | 5398 |
5384 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 5399 m_drawingBuffer = drawingBuffer.release(); |
5385 | |
5386 // Construct a new drawing buffer with the new WebGraphicsContext3D. | |
5387 m_drawingBuffer->releaseResources(); | |
5388 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->prese
rveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | |
5389 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(),
preserve, contextEvictionManager.release()); | |
5390 | |
5391 if (m_drawingBuffer->isZeroSized()) | |
5392 return; | |
5393 | |
5394 m_drawingBuffer->bind(); | 5400 m_drawingBuffer->bind(); |
5395 | 5401 |
5396 m_lostContextErrors.clear(); | 5402 m_lostContextErrors.clear(); |
5397 | 5403 |
5398 m_context = context.release(); | 5404 m_context = context.release(); |
5399 m_contextLost = false; | 5405 m_contextLost = false; |
5400 | 5406 |
5401 setupFlags(); | 5407 setupFlags(); |
5402 initializeNewContext(); | 5408 initializeNewContext(); |
5403 markContextChanged(CanvasContextChanged); | 5409 markContextChanged(CanvasContextChanged); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5591 if (m_textureUnits[i].m_texture2DBinding | 5597 if (m_textureUnits[i].m_texture2DBinding |
5592 || m_textureUnits[i].m_textureCubeMapBinding) { | 5598 || m_textureUnits[i].m_textureCubeMapBinding) { |
5593 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5599 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
5594 return; | 5600 return; |
5595 } | 5601 } |
5596 } | 5602 } |
5597 m_onePlusMaxNonDefaultTextureUnit = 0; | 5603 m_onePlusMaxNonDefaultTextureUnit = 0; |
5598 } | 5604 } |
5599 | 5605 |
5600 } // namespace WebCore | 5606 } // namespace WebCore |
OLD | NEW |