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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF
inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D
::WebGraphicsErrorMessageCallback { | 497 class WebGLRenderingContextErrorMessageCallback final : public GarbageCollectedF
inalized<WebGLRenderingContextErrorMessageCallback>, public WebGraphicsContext3D
::WebGraphicsErrorMessageCallback { |
498 public: | 498 public: |
499 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte
xtBase* context) | 499 static WebGLRenderingContextErrorMessageCallback* create(WebGLRenderingConte
xtBase* context) |
500 { | 500 { |
501 return new WebGLRenderingContextErrorMessageCallback(context); | 501 return new WebGLRenderingContextErrorMessageCallback(context); |
502 } | 502 } |
503 | 503 |
504 ~WebGLRenderingContextErrorMessageCallback() override { } | 504 ~WebGLRenderingContextErrorMessageCallback() override { } |
505 | 505 |
506 virtual void onErrorMessage(const WebString& message, WGC3Dint) | 506 virtual void onErrorMessage(const WebString& message, GLint) |
507 { | 507 { |
508 if (m_context->m_synthesizedErrorsToConsole) | 508 if (m_context->m_synthesizedErrorsToConsole) |
509 m_context->printGLErrorToConsole(message); | 509 m_context->printGLErrorToConsole(message); |
510 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas()
, message); | 510 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas()
, message); |
511 } | 511 } |
512 | 512 |
513 DEFINE_INLINE_TRACE() | 513 DEFINE_INLINE_TRACE() |
514 { | 514 { |
515 visitor->trace(m_context); | 515 visitor->trace(m_context); |
516 } | 516 } |
517 | 517 |
518 private: | 518 private: |
519 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase
* context) | 519 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase
* context) |
520 : m_context(context) { } | 520 : m_context(context) { } |
521 | 521 |
522 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | 522 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
523 }; | 523 }; |
524 | 524 |
525 static void formatWebGLStatusString(const String& glInfo, const String& infostri
ng, String& statusMessage) | 525 static void formatWebGLStatusString(const String& glInfo, const String& infostri
ng, String& statusMessage) |
526 { | 526 { |
527 if (!infostring.isEmpty()) | 527 if (!infostring.isEmpty()) |
528 statusMessage.append(", " + glInfo + " = " + infostring); | 528 statusMessage.append(", " + glInfo + " = " + infostring); |
529 } | 529 } |
530 | 530 |
531 static String extractWebGLContextCreationError(const WebGraphicsContext3D::WebGr
aphicsInfo& info) | 531 static String extractWebGLContextCreationError(const Platform::GraphicsInfo& inf
o) |
532 { | 532 { |
533 String statusMessage("Could not create a WebGL context"); | 533 String statusMessage("Could not create a WebGL context"); |
534 formatWebGLStatusString("VENDOR", info.vendorId ? String::format("0x%04x", i
nfo.vendorId).utf8().data() : "0xffff", statusMessage); | 534 formatWebGLStatusString("VENDOR", info.vendorId ? String::format("0x%04x", i
nfo.vendorId).utf8().data() : "0xffff", statusMessage); |
535 formatWebGLStatusString("DEVICE", info.deviceId ? String::format("0x%04x", i
nfo.deviceId).utf8().data() : "0xffff", statusMessage); | 535 formatWebGLStatusString("DEVICE", info.deviceId ? String::format("0x%04x", i
nfo.deviceId).utf8().data() : "0xffff", statusMessage); |
536 formatWebGLStatusString("GL_VENDOR", info.vendorInfo.utf8().data(), statusMe
ssage); | 536 formatWebGLStatusString("GL_VENDOR", info.vendorInfo.utf8().data(), statusMe
ssage); |
537 formatWebGLStatusString("GL_RENDERER", info.rendererInfo.utf8().data(), stat
usMessage); | 537 formatWebGLStatusString("GL_RENDERER", info.rendererInfo.utf8().data(), stat
usMessage); |
538 formatWebGLStatusString("GL_VERSION", info.driverVersion.utf8().data(), stat
usMessage); | 538 formatWebGLStatusString("GL_VERSION", info.driverVersion.utf8().data(), stat
usMessage); |
539 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe
ssage); | 539 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe
ssage); |
540 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag
e); | 540 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag
e); |
541 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no",
statusMessage); | 541 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no",
statusMessage); |
(...skipping 15 matching lines...) Expand all Loading... |
557 Settings* settings = frame->settings(); | 557 Settings* settings = frame->settings(); |
558 | 558 |
559 // The FrameLoaderClient might block creation of a new WebGL context despite
the page settings; in | 559 // The FrameLoaderClient might block creation of a new WebGL context despite
the page settings; in |
560 // particular, if WebGL contexts were lost one or more times via the GL_ARB_
robustness extension. | 560 // particular, if WebGL contexts were lost one or more times via the GL_ARB_
robustness extension. |
561 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) { | 561 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) { |
562 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); | 562 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); |
563 return nullptr; | 563 return nullptr; |
564 } | 564 } |
565 | 565 |
566 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt
ributes(attributes, document.topDocument().url().getString(), settings, webGLVer
sion); | 566 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt
ributes(attributes, document.topDocument().url().getString(), settings, webGLVer
sion); |
567 WebGraphicsContext3D::WebGraphicsInfo glInfo; | 567 Platform::GraphicsInfo glInfo; |
568 glInfo.testFailContext = shouldFailContextCreationForTesting; | 568 glInfo.testFailContext = shouldFailContextCreationForTesting; |
569 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(wgc3dAttributes, 0, &glInfo)); | 569 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(wgc3dAttributes, 0, &glInfo)); |
570 if (!contextProvider || shouldFailContextCreationForTesting) { | 570 if (!contextProvider || shouldFailContextCreationForTesting) { |
571 shouldFailContextCreationForTesting = false; | 571 shouldFailContextCreationForTesting = false; |
572 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); | 572 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); |
573 return nullptr; | 573 return nullptr; |
574 } | 574 } |
575 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); | 575 gpu::gles2::GLES2Interface* gl = contextProvider->contextGL(); |
576 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten
cil")) { | 576 if (!String(gl->GetString(GL_EXTENSIONS)).contains("GL_OES_packed_depth_sten
cil")) { |
577 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "OES_packed_depth_stencil support is required.")
); | 577 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "OES_packed_depth_stencil support is required.")
); |
(...skipping 5411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5989 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 5989 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
5990 return; | 5990 return; |
5991 | 5991 |
5992 // 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. | 5992 // 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. |
5993 if (drawingBuffer()) { | 5993 if (drawingBuffer()) { |
5994 m_drawingBuffer->beginDestruction(); | 5994 m_drawingBuffer->beginDestruction(); |
5995 m_drawingBuffer.clear(); | 5995 m_drawingBuffer.clear(); |
5996 } | 5996 } |
5997 | 5997 |
5998 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, canvas()->document().topDocument().url().getString(),
settings, version()); | 5998 WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttribut
es(m_requestedAttributes, canvas()->document().topDocument().url().getString(),
settings, version()); |
5999 blink::WebGraphicsContext3D::WebGraphicsInfo glInfo; | 5999 Platform::GraphicsInfo glInfo; |
6000 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(attributes, 0, &glInfo)); | 6000 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider(attributes, 0, &glInfo)); |
6001 RefPtr<DrawingBuffer> buffer; | 6001 RefPtr<DrawingBuffer> buffer; |
6002 if (contextProvider) { | 6002 if (contextProvider) { |
6003 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 6003 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
6004 buffer = createDrawingBuffer(contextProvider.release()); | 6004 buffer = createDrawingBuffer(contextProvider.release()); |
6005 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. | 6005 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. |
6006 } | 6006 } |
6007 if (!buffer) { | 6007 if (!buffer) { |
6008 if (m_contextLostMode == RealLostContext) { | 6008 if (m_contextLostMode == RealLostContext) { |
6009 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); | 6009 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6339 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6339 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6340 } | 6340 } |
6341 | 6341 |
6342 void WebGLRenderingContextBase::restoreUnpackParameters() | 6342 void WebGLRenderingContextBase::restoreUnpackParameters() |
6343 { | 6343 { |
6344 if (m_unpackAlignment != 1) | 6344 if (m_unpackAlignment != 1) |
6345 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6345 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6346 } | 6346 } |
6347 | 6347 |
6348 } // namespace blink | 6348 } // namespace blink |
OLD | NEW |