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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 namespace blink { | 100 namespace blink { |
| 103 | 101 |
| 104 namespace { | 102 namespace { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe ssage); | 493 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe ssage); |
| 496 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag e); | 494 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag e); |
| 497 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no", statusMessage); | 495 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no", statusMessage); |
| 498 formatWebGLStatusString("Reset notification strategy", String::format("0x%04 x", info.resetNotificationStrategy).utf8().data(), statusMessage); | 496 formatWebGLStatusString("Reset notification strategy", String::format("0x%04 x", info.resetNotificationStrategy).utf8().data(), statusMessage); |
| 499 formatWebGLStatusString("GPU process crash count", String::number(info.proce ssCrashCount).utf8().data(), statusMessage); | 497 formatWebGLStatusString("GPU process crash count", String::number(info.proce ssCrashCount).utf8().data(), statusMessage); |
| 500 formatWebGLStatusString("ErrorMessage", info.errorMessage.utf8().data(), sta tusMessage); | 498 formatWebGLStatusString("ErrorMessage", info.errorMessage.utf8().data(), sta tusMessage); |
| 501 statusMessage.append("."); | 499 statusMessage.append("."); |
| 502 return statusMessage; | 500 return statusMessage; |
| 503 } | 501 } |
| 504 | 502 |
| 505 static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DProvid erInternal(HTMLCanvasElement* canvas, ScriptState* scriptState, WebGLContextAttr ibutes attributes, unsigned webGLVersion) | 503 void WebGLRenderingContextBase::createWebGraphicsContext3DProviderMainThread(Web GLRenderingContextBase::createWebGraphicsContext3DProviderUtils* createUtils, Wa itableEvent* waitableEvent) |
|
Justin Novosad
2016/05/04 18:34:03
"OnMainThread"
| |
| 504 { | |
| 505 ASSERT(isMainThread()); | |
| 506 Platform::GraphicsInfo glInfo = createUtils->glInfo(); | |
| 507 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current() ->createOffscreenGraphicsContext3DProvider( | |
| 508 createUtils->contextAttributes(), createUtils->scriptState()->getExecuti onContext()->url(), 0, &glInfo)); | |
| 509 createUtils->setContextProvider(provider.release()); | |
| 510 waitableEvent->signal(); | |
| 511 } | |
| 512 | |
| 513 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProviderInternal(HTMLCanvasElement* canvas, ScriptState* scriptSta te, WebGLContextAttributes attributes, unsigned webGLVersion) | |
| 506 { | 514 { |
| 507 Platform::ContextAttributes contextAttributes = toPlatformContextAttributes( attributes, webGLVersion); | 515 Platform::ContextAttributes contextAttributes = toPlatformContextAttributes( attributes, webGLVersion); |
| 508 Platform::GraphicsInfo glInfo; | 516 Platform::GraphicsInfo glInfo; |
| 509 OwnPtr<WebGraphicsContext3DProvider> contextProvider; | 517 OwnPtr<WebGraphicsContext3DProvider> contextProvider; |
| 510 if (canvas) { | 518 if (canvas) { |
| 511 contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsC ontext3DProvider( | 519 contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsC ontext3DProvider( |
| 512 contextAttributes, canvas->document().topDocument().url(), 0, &glInf o)); | 520 contextAttributes, canvas->document().topDocument().url(), 0, &glInf o)); |
| 513 } else { | 521 } else { |
| 514 contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsC ontext3DProvider( | 522 if (isMainThread()) { |
| 515 contextAttributes, scriptState->getExecutionContext()->url(), 0, &gl Info)); | 523 contextProvider = adoptPtr(Platform::current()->createOffscreenGraph icsContext3DProvider( |
| 524 contextAttributes, scriptState->getExecutionContext()->url(), 0, &glInfo)); | |
| 525 } else { | |
| 526 WaitableEvent waitableEvent; | |
| 527 WebTaskRunner* taskRunner = Platform::current()->mainThread()->getWe bTaskRunner(); | |
| 528 OwnPtr<WebGLRenderingContextBase::createWebGraphicsContext3DProvider Utils> createUtils = adoptPtr(new WebGLRenderingContextBase::createWebGraphicsCo ntext3DProviderUtils(contextAttributes, glInfo, scriptState)); | |
| 529 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&createWebGraph icsContext3DProviderMainThread, AllowCrossThreadAccess(createUtils.get()), Allow CrossThreadAccess(&waitableEvent))); | |
| 530 waitableEvent.wait(); | |
| 531 contextProvider = createUtils->releaseContextProvider(); | |
| 532 contextProvider->DetachFromThread(); | |
| 533 } | |
| 516 } | 534 } |
| 517 if (!contextProvider || shouldFailContextCreationForTesting) { | 535 if (!contextProvider || shouldFailContextCreationForTesting) { |
| 518 shouldFailContextCreationForTesting = false; | 536 shouldFailContextCreationForTesting = false; |
| 519 if (canvas) | 537 if (canvas) |
| 520 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo))); | 538 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo))); |
| 521 return nullptr; | 539 return nullptr; |
| 522 } | 540 } |
| 523 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 541 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
| 524 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten cil")) { | 542 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten cil")) { |
| 525 if (canvas) | 543 if (canvas) |
| 526 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, "OES_packed_depth_stencil support is require d.")); | 544 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webg lcontextcreationerror, false, true, "OES_packed_depth_stencil support is require d.")); |
| 527 return nullptr; | 545 return nullptr; |
| 528 } | 546 } |
| 529 | |
| 530 return contextProvider.release(); | 547 return contextProvider.release(); |
| 531 } | 548 } |
| 532 | 549 |
| 533 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attribu tes, unsigned webGLVersion) | 550 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attribu tes, unsigned webGLVersion) |
| 534 { | 551 { |
| 535 Document& document = canvas->document(); | 552 Document& document = canvas->document(); |
| 536 LocalFrame* frame = document.frame(); | 553 LocalFrame* frame = document.frame(); |
| 537 if (!frame) { | 554 if (!frame) { |
| 538 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); | 555 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); |
| 539 return nullptr; | 556 return nullptr; |
| (...skipping 5730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6270 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6287 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6271 } | 6288 } |
| 6272 | 6289 |
| 6273 void WebGLRenderingContextBase::restoreUnpackParameters() | 6290 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6274 { | 6291 { |
| 6275 if (m_unpackAlignment != 1) | 6292 if (m_unpackAlignment != 1) |
| 6276 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6293 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6277 } | 6294 } |
| 6278 | 6295 |
| 6279 } // namespace blink | 6296 } // namespace blink |
| OLD | NEW |