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

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

Issue 1914233006: Implement offscreenCanvas.getContext('webgl') on a worker thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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) 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "modules/webgl/OESTextureHalfFloatLinear.h" 59 #include "modules/webgl/OESTextureHalfFloatLinear.h"
60 #include "modules/webgl/OESVertexArrayObject.h" 60 #include "modules/webgl/OESVertexArrayObject.h"
61 #include "modules/webgl/WebGLActiveInfo.h" 61 #include "modules/webgl/WebGLActiveInfo.h"
62 #include "modules/webgl/WebGLBuffer.h" 62 #include "modules/webgl/WebGLBuffer.h"
63 #include "modules/webgl/WebGLCompressedTextureASTC.h" 63 #include "modules/webgl/WebGLCompressedTextureASTC.h"
64 #include "modules/webgl/WebGLCompressedTextureATC.h" 64 #include "modules/webgl/WebGLCompressedTextureATC.h"
65 #include "modules/webgl/WebGLCompressedTextureETC1.h" 65 #include "modules/webgl/WebGLCompressedTextureETC1.h"
66 #include "modules/webgl/WebGLCompressedTexturePVRTC.h" 66 #include "modules/webgl/WebGLCompressedTexturePVRTC.h"
67 #include "modules/webgl/WebGLCompressedTextureS3TC.h" 67 #include "modules/webgl/WebGLCompressedTextureS3TC.h"
68 #include "modules/webgl/WebGLContextAttributeHelpers.h" 68 #include "modules/webgl/WebGLContextAttributeHelpers.h"
69 #include "modules/webgl/WebGLContextAttributes.h"
70 #include "modules/webgl/WebGLContextEvent.h" 69 #include "modules/webgl/WebGLContextEvent.h"
71 #include "modules/webgl/WebGLContextGroup.h" 70 #include "modules/webgl/WebGLContextGroup.h"
72 #include "modules/webgl/WebGLDebugRendererInfo.h" 71 #include "modules/webgl/WebGLDebugRendererInfo.h"
73 #include "modules/webgl/WebGLDebugShaders.h" 72 #include "modules/webgl/WebGLDebugShaders.h"
74 #include "modules/webgl/WebGLDepthTexture.h" 73 #include "modules/webgl/WebGLDepthTexture.h"
75 #include "modules/webgl/WebGLDrawBuffers.h" 74 #include "modules/webgl/WebGLDrawBuffers.h"
76 #include "modules/webgl/WebGLFramebuffer.h" 75 #include "modules/webgl/WebGLFramebuffer.h"
77 #include "modules/webgl/WebGLLoseContext.h" 76 #include "modules/webgl/WebGLLoseContext.h"
78 #include "modules/webgl/WebGLProgram.h" 77 #include "modules/webgl/WebGLProgram.h"
79 #include "modules/webgl/WebGLRenderbuffer.h" 78 #include "modules/webgl/WebGLRenderbuffer.h"
80 #include "modules/webgl/WebGLShader.h" 79 #include "modules/webgl/WebGLShader.h"
81 #include "modules/webgl/WebGLShaderPrecisionFormat.h" 80 #include "modules/webgl/WebGLShaderPrecisionFormat.h"
82 #include "modules/webgl/WebGLTexture.h"
83 #include "modules/webgl/WebGLUniformLocation.h" 81 #include "modules/webgl/WebGLUniformLocation.h"
84 #include "modules/webgl/WebGLVertexArrayObject.h" 82 #include "modules/webgl/WebGLVertexArrayObject.h"
85 #include "modules/webgl/WebGLVertexArrayObjectOES.h" 83 #include "modules/webgl/WebGLVertexArrayObjectOES.h"
86 #include "platform/CheckedInt.h" 84 #include "platform/CheckedInt.h"
87 #include "platform/RuntimeEnabledFeatures.h" 85 #include "platform/RuntimeEnabledFeatures.h"
86 #include "platform/ThreadSafeFunctional.h"
87 #include "platform/WaitableEvent.h"
88 #include "platform/geometry/IntSize.h" 88 #include "platform/geometry/IntSize.h"
89 #include "platform/graphics/GraphicsContext.h" 89 #include "platform/graphics/GraphicsContext.h"
90 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 90 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
91 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" 91 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
92 #include "platform/graphics/gpu/DrawingBuffer.h"
93 #include "public/platform/Platform.h" 92 #include "public/platform/Platform.h"
94 #include "public/platform/WebGraphicsContext3DProvider.h"
95 #include "public/platform/functional/WebFunction.h" 93 #include "public/platform/functional/WebFunction.h"
96 #include "wtf/Functional.h" 94 #include "wtf/Functional.h"
97 #include "wtf/PassOwnPtr.h" 95 #include "wtf/PassOwnPtr.h"
98 #include "wtf/text/StringBuilder.h" 96 #include "wtf/text/StringBuilder.h"
99 #include "wtf/text/StringUTF8Adaptor.h" 97 #include "wtf/text/StringUTF8Adaptor.h"
100 #include "wtf/typed_arrays/ArrayBufferContents.h" 98 #include "wtf/typed_arrays/ArrayBufferContents.h"
101 99
102 #include <memory> 100 #include <memory>
103 101
104 namespace blink { 102 namespace blink {
105 103
106 namespace { 104 namespace {
107 105
108 const double secondsBetweenRestoreAttempts = 1.0; 106 const double secondsBetweenRestoreAttempts = 1.0;
109 const int maxGLErrorsAllowedToConsole = 256; 107 const int maxGLErrorsAllowedToConsole = 256;
110 const unsigned maxGLActiveContexts = 16; 108 const unsigned maxGLActiveContexts = 16;
109 const unsigned maxGLActiveContextsOnWorker = 4;
110
111 unsigned currentMaxGLContexts()
112 {
113 return isMainThread() ? maxGLActiveContexts : maxGLActiveContextsOnWorker;
114 }
111 115
112 using WebGLRenderingContextBaseSet = PersistentHeapHashSet<WeakMember<WebGLRende ringContextBase>>; 116 using WebGLRenderingContextBaseSet = PersistentHeapHashSet<WeakMember<WebGLRende ringContextBase>>;
113 WebGLRenderingContextBaseSet& activeContexts() 117 WebGLRenderingContextBaseSet& activeContexts()
114 { 118 {
115 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseSet, activeContexts, ()); 119 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<WebGLRenderingContextBaseSet> , activeContexts, new ThreadSpecific<WebGLRenderingContextBaseSet>());
116 return activeContexts; 120 if (!activeContexts.isSet())
121 activeContexts->registerAsStaticReference();
122 return *activeContexts;
117 } 123 }
118 124
119 using WebGLRenderingContextBaseMap = PersistentHeapHashMap<WeakMember<WebGLRende ringContextBase>, int>; 125 using WebGLRenderingContextBaseMap = PersistentHeapHashMap<WeakMember<WebGLRende ringContextBase>, int>;
120 WebGLRenderingContextBaseMap& forciblyEvictedContexts() 126 WebGLRenderingContextBaseMap& forciblyEvictedContexts()
121 { 127 {
122 DEFINE_STATIC_LOCAL(WebGLRenderingContextBaseMap, forciblyEvictedContexts, ( )); 128 DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<WebGLRenderingContextBaseMap> , forciblyEvictedContexts, new ThreadSpecific<WebGLRenderingContextBaseMap>());
123 return forciblyEvictedContexts; 129 if (!forciblyEvictedContexts.isSet())
130 forciblyEvictedContexts->registerAsStaticReference();
131 return *forciblyEvictedContexts;
124 } 132 }
125 133
126 } // namespace 134 } // namespace
127 135
128 ScopedRGBEmulationColorMask::ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interf ace* contextGL, GLboolean* colorMask, DrawingBuffer* drawingBuffer) 136 ScopedRGBEmulationColorMask::ScopedRGBEmulationColorMask(gpu::gles2::GLES2Interf ace* contextGL, GLboolean* colorMask, DrawingBuffer* drawingBuffer)
129 : m_contextGL(contextGL) 137 : m_contextGL(contextGL)
130 , m_requiresEmulation(drawingBuffer->requiresAlphaChannelToBePreserved()) 138 , m_requiresEmulation(drawingBuffer->requiresAlphaChannelToBePreserved())
131 { 139 {
132 if (m_requiresEmulation) { 140 if (m_requiresEmulation) {
133 memcpy(m_colorMask, colorMask, 4 * sizeof(GLboolean)); 141 memcpy(m_colorMask, colorMask, 4 * sizeof(GLboolean));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 candidate = context; 191 candidate = context;
184 generation = forciblyEvictedContexts().get(context); 192 generation = forciblyEvictedContexts().get(context);
185 } 193 }
186 } 194 }
187 195
188 return candidate; 196 return candidate;
189 } 197 }
190 198
191 void WebGLRenderingContextBase::activateContext(WebGLRenderingContextBase* conte xt) 199 void WebGLRenderingContextBase::activateContext(WebGLRenderingContextBase* conte xt)
192 { 200 {
201 unsigned maxGLContexts = currentMaxGLContexts();
193 unsigned removedContexts = 0; 202 unsigned removedContexts = 0;
194 while (activeContexts().size() >= maxGLActiveContexts && removedContexts < m axGLActiveContexts) { 203 while (activeContexts().size() >= maxGLContexts && removedContexts < maxGLCo ntexts) {
195 forciblyLoseOldestContext("WARNING: Too many active WebGL contexts. Olde st context will be lost."); 204 forciblyLoseOldestContext("WARNING: Too many active WebGL contexts. Olde st context will be lost.");
196 removedContexts++; 205 removedContexts++;
197 } 206 }
198 207
199 ASSERT(!context->isContextLost()); 208 ASSERT(!context->isContextLost());
200 activeContexts().add(context); 209 activeContexts().add(context);
201 } 210 }
202 211
203 void WebGLRenderingContextBase::deactivateContext(WebGLRenderingContextBase* con text) 212 void WebGLRenderingContextBase::deactivateContext(WebGLRenderingContextBase* con text)
204 { 213 {
(...skipping 11 matching lines...) Expand all
216 forciblyEvictedContexts().remove(context); 225 forciblyEvictedContexts().remove(context);
217 } 226 }
218 227
219 void WebGLRenderingContextBase::willDestroyContext(WebGLRenderingContextBase* co ntext) 228 void WebGLRenderingContextBase::willDestroyContext(WebGLRenderingContextBase* co ntext)
220 { 229 {
221 // These two sets keep weak references to their contexts; 230 // These two sets keep weak references to their contexts;
222 // verify that the GC already removed the |context| entries. 231 // verify that the GC already removed the |context| entries.
223 ASSERT(!forciblyEvictedContexts().contains(context)); 232 ASSERT(!forciblyEvictedContexts().contains(context));
224 ASSERT(!activeContexts().contains(context)); 233 ASSERT(!activeContexts().contains(context));
225 234
235 unsigned maxGLContexts = currentMaxGLContexts();
226 // Try to re-enable the oldest inactive contexts. 236 // Try to re-enable the oldest inactive contexts.
227 while (activeContexts().size() < maxGLActiveContexts && forciblyEvictedConte xts().size()) { 237 while (activeContexts().size() < maxGLContexts && forciblyEvictedContexts(). size()) {
228 WebGLRenderingContextBase* evictedContext = oldestEvictedContext(); 238 WebGLRenderingContextBase* evictedContext = oldestEvictedContext();
229 if (!evictedContext->m_restoreAllowed) { 239 if (!evictedContext->m_restoreAllowed) {
230 forciblyEvictedContexts().remove(evictedContext); 240 forciblyEvictedContexts().remove(evictedContext);
231 continue; 241 continue;
232 } 242 }
233 243
234 IntSize desiredSize = DrawingBuffer::adjustSize(evictedContext->clampedC anvasSize(), IntSize(), evictedContext->m_maxTextureSize); 244 IntSize desiredSize = DrawingBuffer::adjustSize(evictedContext->clampedC anvasSize(), IntSize(), evictedContext->m_maxTextureSize);
235 245
236 // If there's room in the pixel budget for this context, restore it. 246 // If there's room in the pixel budget for this context, restore it.
237 if (!desiredSize.isEmpty()) { 247 if (!desiredSize.isEmpty()) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe ssage); 523 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe ssage);
514 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag e); 524 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag e);
515 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no", statusMessage); 525 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no", statusMessage);
516 formatWebGLStatusString("Reset notification strategy", String::format("0x%04 x", info.resetNotificationStrategy).utf8().data(), statusMessage); 526 formatWebGLStatusString("Reset notification strategy", String::format("0x%04 x", info.resetNotificationStrategy).utf8().data(), statusMessage);
517 formatWebGLStatusString("GPU process crash count", String::number(info.proce ssCrashCount).utf8().data(), statusMessage); 527 formatWebGLStatusString("GPU process crash count", String::number(info.proce ssCrashCount).utf8().data(), statusMessage);
518 formatWebGLStatusString("ErrorMessage", info.errorMessage.utf8().data(), sta tusMessage); 528 formatWebGLStatusString("ErrorMessage", info.errorMessage.utf8().data(), sta tusMessage);
519 statusMessage.append("."); 529 statusMessage.append(".");
520 return statusMessage; 530 return statusMessage;
521 } 531 }
522 532
523 static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DProvid erInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLContextAttr ibutes attributes, unsigned webGLVersion) 533 void WebGLRenderingContextBase::createContextProviderOnMainThread(WebGLContextPr oviderCreationInfo* creationInfo, WaitableEvent* waitableEvent)
534 {
535 ASSERT(isMainThread());
536 Platform::GraphicsInfo glInfo = creationInfo->glInfo();
537 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current() ->createOffscreenGraphicsContext3DProvider(
538 creationInfo->contextAttributes(), creationInfo->scriptState()->getExecu tionContext()->url(), 0, &glInfo, Platform::DoNotBindToCurrentThread));
539 creationInfo->setContextProvider(provider.release());
540 waitableEvent->signal();
541 }
542
543 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createContex tProviderOnWorkerThread(Platform::ContextAttributes contextAttributes, Platform: :GraphicsInfo glInfo, ScriptState* scriptState)
544 {
545 // TODO(xidachen): make this context creation asynchronous.
546 WaitableEvent waitableEvent;
547 OwnPtr<WebGLContextProviderCreationInfo> creationInfo = adoptPtr(new WebGLCo ntextProviderCreationInfo(contextAttributes, glInfo, scriptState));
548 WebTaskRunner* taskRunner = Platform::current()->mainThread()->getWebTaskRun ner();
549 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&createContextProviderO nMainThread, AllowCrossThreadAccess(creationInfo.get()), AllowCrossThreadAccess( &waitableEvent)));
550 waitableEvent.wait();
551 return creationInfo->releaseContextProvider();
552 }
553
554 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createContex tProviderInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLCont extAttributes attributes, unsigned webGLVersion)
524 { 555 {
525 Platform::ContextAttributes contextAttributes = toPlatformContextAttributes( attributes, webGLVersion); 556 Platform::ContextAttributes contextAttributes = toPlatformContextAttributes( attributes, webGLVersion);
526 Platform::GraphicsInfo glInfo; 557 Platform::GraphicsInfo glInfo;
527 OwnPtr<WebGraphicsContext3DProvider> contextProvider; 558 OwnPtr<WebGraphicsContext3DProvider> contextProvider;
528 if (canvas) { 559 if (canvas) {
529 contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsC ontext3DProvider( 560 contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsC ontext3DProvider(
530 contextAttributes, canvas->document().topDocument().url(), 0, &glInf o)); 561 contextAttributes, canvas->document().topDocument().url(), 0, &glInf o, Platform::BindToCurrentThread));
531 } else { 562 } else {
532 contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsC ontext3DProvider( 563 if (isMainThread()) {
533 contextAttributes, scriptState->getExecutionContext()->url(), 0, &gl Info)); 564 contextProvider = adoptPtr(Platform::current()->createOffscreenGraph icsContext3DProvider(
565 contextAttributes, scriptState->getExecutionContext()->url(), 0, &glInfo, Platform::BindToCurrentThread));
566 } else {
567 contextProvider = createContextProviderOnWorkerThread(contextAttribu tes, glInfo, scriptState);
568 if (!contextProvider->bindToCurrentThread())
569 return nullptr;
570 }
534 } 571 }
535 if (!contextProvider || shouldFailContextCreationForTesting) { 572 if (!contextProvider || shouldFailContextCreationForTesting) {
536 shouldFailContextCreationForTesting = false; 573 shouldFailContextCreationForTesting = false;
537 if (canvas) 574 if (canvas)
538 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo))); 575 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo)));
539 return nullptr; 576 return nullptr;
540 } 577 }
541 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); 578 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL();
542 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten cil")) { 579 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten cil")) {
543 if (canvas) 580 if (canvas)
544 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, "OES_packed_depth_stencil support is require d.")); 581 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, "OES_packed_depth_stencil support is require d."));
545 return nullptr; 582 return nullptr;
546 } 583 }
547
548 return contextProvider.release(); 584 return contextProvider.release();
549 } 585 }
550 586
551 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attribu tes, unsigned webGLVersion) 587 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attribu tes, unsigned webGLVersion)
552 { 588 {
553 Document& document = canvas->document(); 589 Document& document = canvas->document();
554 LocalFrame* frame = document.frame(); 590 LocalFrame* frame = document.frame();
555 if (!frame) { 591 if (!frame) {
556 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); 592 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
557 return nullptr; 593 return nullptr;
558 } 594 }
559 Settings* settings = frame->settings(); 595 Settings* settings = frame->settings();
560 596
561 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in 597 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
562 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension. 598 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension.
563 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) { 599 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) {
564 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); 600 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
565 return nullptr; 601 return nullptr;
566 } 602 }
567 603
568 return createWebGraphicsContext3DProviderInternal(canvas, nullptr, attribute s, webGLVersion); 604 return createContextProviderInternal(canvas, nullptr, attributes, webGLVersi on);
569 } 605 }
570 606
571 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attribut es, unsigned webGLVersion) 607 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attribut es, unsigned webGLVersion)
572 { 608 {
573 return createWebGraphicsContext3DProviderInternal(nullptr, scriptState, attr ibutes, webGLVersion); 609 return createContextProviderInternal(nullptr, scriptState, attributes, webGL Version);
574 } 610 }
575 611
576 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() 612 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail()
577 { 613 {
578 shouldFailContextCreationForTesting = true; 614 shouldFailContextCreationForTesting = true;
579 } 615 }
580 616
581 namespace { 617 namespace {
582 618
583 // ES2 enums 619 // ES2 enums
(...skipping 5377 matching lines...) Expand 10 before | Expand all | Expand 10 after
5961 5997
5962 // If the context was lost due to RealLostContext, we need to destroy the ol d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou gh. 5998 // If the context was lost due to RealLostContext, we need to destroy the ol d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou gh.
5963 if (drawingBuffer()) { 5999 if (drawingBuffer()) {
5964 m_drawingBuffer->beginDestruction(); 6000 m_drawingBuffer->beginDestruction();
5965 m_drawingBuffer.clear(); 6001 m_drawingBuffer.clear();
5966 } 6002 }
5967 6003
5968 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque stedAttributes, version()); 6004 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque stedAttributes, version());
5969 Platform::GraphicsInfo glInfo; 6005 Platform::GraphicsInfo glInfo;
5970 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu rrent()->createOffscreenGraphicsContext3DProvider( 6006 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu rrent()->createOffscreenGraphicsContext3DProvider(
5971 attributes, canvas()->document().topDocument().url(), 0, &glInfo)); 6007 attributes, canvas()->document().topDocument().url(), 0, &glInfo, Platfo rm::BindToCurrentThread));
5972 RefPtr<DrawingBuffer> buffer; 6008 RefPtr<DrawingBuffer> buffer;
5973 if (contextProvider) { 6009 if (contextProvider) {
5974 // Construct a new drawing buffer with the new GL context. 6010 // Construct a new drawing buffer with the new GL context.
5975 buffer = createDrawingBuffer(contextProvider.release()); 6011 buffer = createDrawingBuffer(contextProvider.release());
5976 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i s set to null. 6012 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i s set to null.
5977 } 6013 }
5978 if (!buffer) { 6014 if (!buffer) {
5979 if (m_contextLostMode == RealLostContext) { 6015 if (m_contextLostMode == RealLostContext) {
5980 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO M_HERE); 6016 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO M_HERE);
5981 } else { 6017 } else {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
6306 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6342 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6307 } 6343 }
6308 6344
6309 void WebGLRenderingContextBase::restoreUnpackParameters() 6345 void WebGLRenderingContextBase::restoreUnpackParameters()
6310 { 6346 {
6311 if (m_unpackAlignment != 1) 6347 if (m_unpackAlignment != 1)
6312 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6348 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6313 } 6349 }
6314 6350
6315 } // namespace blink 6351 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698