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

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

Issue 189423003: WebGL: Restore atomically both WebGraphicsContext3D and DrawingBuffer together. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 | « no previous file | 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) 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 4114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 for (size_t i = 0; i < m_extensions.size(); ++i) { 4125 for (size_t i = 0; i < m_extensions.size(); ++i) {
4126 ExtensionTracker* tracker = m_extensions[i]; 4126 ExtensionTracker* tracker = m_extensions[i];
4127 tracker->loseExtension(); 4127 tracker->loseExtension();
4128 } 4128 }
4129 4129
4130 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) 4130 for (size_t i = 0; i < WebGLExtensionNameCount; ++i)
4131 m_extensionEnabled[i] = false; 4131 m_extensionEnabled[i] = false;
4132 4132
4133 removeAllCompressedTextureFormats(); 4133 removeAllCompressedTextureFormats();
4134 4134
4135 if (mode != RealLostContext) 4135 destroyContext();
4136 destroyContext();
4137 4136
4138 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole; 4137 ConsoleDisplayPreference display = (mode == RealLostContext) ? DisplayInCons ole: DontDisplayInConsole;
4139 synthesizeGLError(GC3D_CONTEXT_LOST_WEBGL, "loseContext", "context lost", di splay); 4138 synthesizeGLError(GC3D_CONTEXT_LOST_WEBGL, "loseContext", "context lost", di splay);
4140 4139
4141 // Don't allow restoration unless the context lost event has both been 4140 // Don't allow restoration unless the context lost event has both been
4142 // dispatched and its default behavior prevented. 4141 // dispatched and its default behavior prevented.
4143 m_restoreAllowed = false; 4142 m_restoreAllowed = false;
4144 4143
4145 // Always defer the dispatch of the context lost event, to implement 4144 // Always defer the dispatch of the context lost event, to implement
4146 // the spec behavior of queueing a task. 4145 // the spec behavior of queueing a task.
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
5329 if (!frame) 5328 if (!frame)
5330 return; 5329 return;
5331 5330
5332 Settings* settings = frame->settings(); 5331 Settings* settings = frame->settings();
5333 5332
5334 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) 5333 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ()))
5335 return; 5334 return;
5336 5335
5337 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings); 5336 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings);
5338 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes)); 5337 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes));
5338
5339 if (context) {
5340 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad optRef(new WebGLRenderingContextEvictionManager());
5341
5342 // Construct a new drawing buffer with the new WebGraphicsContext3D.
5343 m_drawingBuffer->releaseResources();
5344 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
5345 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize (), preserve, contextEvictionManager.release());
5346
5347 if (m_drawingBuffer->isZeroSized()) {
5348 m_drawingBuffer->releaseResources();
5349 context.clear();
5350 }
5351 }
5339 if (!context) { 5352 if (!context) {
5340 if (m_contextLostMode == RealLostContext) { 5353 if (m_contextLostMode == RealLostContext) {
5341 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); 5354 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts);
5342 } else { 5355 } else {
5343 // This likely shouldn't happen but is the best way to report it to the WebGL app. 5356 // This likely shouldn't happen but is the best way to report it to the WebGL app.
5344 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); 5357 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context ");
5345 } 5358 }
5346 return; 5359 return;
5347 } 5360 }
5348 5361
5349 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR ef(new WebGLRenderingContextEvictionManager());
5350
5351 // Construct a new drawing buffer with the new WebGraphicsContext3D.
5352 m_drawingBuffer->releaseResources();
5353 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->prese rveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
5354 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(), preserve, contextEvictionManager.release());
5355
5356 if (m_drawingBuffer->isZeroSized())
5357 return;
dshwang 2014/03/10 18:23:31 Currently, when failing to create fbo, return here
5358
5359 m_drawingBuffer->bind(); 5362 m_drawingBuffer->bind();
5360 5363
5361 m_lostContextErrors.clear(); 5364 m_lostContextErrors.clear();
5362 5365
5363 m_context = context.release(); 5366 m_context = context.release();
5364 m_contextLost = false; 5367 m_contextLost = false;
5365 5368
5366 setupFlags(); 5369 setupFlags();
5367 initializeNewContext(); 5370 initializeNewContext();
5368 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); 5371 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, ""));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
5555 if (m_textureUnits[i].m_texture2DBinding 5558 if (m_textureUnits[i].m_texture2DBinding
5556 || m_textureUnits[i].m_textureCubeMapBinding) { 5559 || m_textureUnits[i].m_textureCubeMapBinding) {
5557 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5560 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5558 return; 5561 return;
5559 } 5562 }
5560 } 5563 }
5561 m_onePlusMaxNonDefaultTextureUnit = 0; 5564 m_onePlusMaxNonDefaultTextureUnit = 0;
5562 } 5565 }
5563 5566
5564 } // namespace WebCore 5567 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698