| 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 visitor->trace(m_context); | 519 visitor->trace(m_context); |
| 520 } | 520 } |
| 521 | 521 |
| 522 private: | 522 private: |
| 523 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase
* context) | 523 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase
* context) |
| 524 : m_context(context) { } | 524 : m_context(context) { } |
| 525 | 525 |
| 526 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | 526 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
| 527 }; | 527 }; |
| 528 | 528 |
| 529 static void formatWebGLStatusString(const String& glInfo, const String& infostri
ng, String& statusMessage) |
| 530 { |
| 531 if (!infostring.isEmpty()) |
| 532 statusMessage.append(", " + glInfo + " = " + infostring); |
| 533 } |
| 534 |
| 535 static String extractWebGLContextCreationError(const WebGraphicsContext3D::WebGr
aphicsInfo& info) |
| 536 { |
| 537 String statusMessage("Could not create a WebGL context"); |
| 538 formatWebGLStatusString("VENDOR", info.vendorId ? String::format("0x%04x", i
nfo.vendorId).utf8().data() : "0xffff", statusMessage); |
| 539 formatWebGLStatusString("DEVICE", info.deviceId ? String::format("0x%04x", i
nfo.deviceId).utf8().data() : "0xffff", statusMessage); |
| 540 formatWebGLStatusString("GL_VENDOR", info.vendorInfo.utf8().data(), statusMe
ssage); |
| 541 formatWebGLStatusString("GL_RENDERER", info.rendererInfo.utf8().data(), stat
usMessage); |
| 542 formatWebGLStatusString("GL_VERSION", info.driverVersion.utf8().data(), stat
usMessage); |
| 543 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe
ssage); |
| 544 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag
e); |
| 545 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no",
statusMessage); |
| 546 formatWebGLStatusString("Reset notification strategy", String::format("0x%04
x", info.resetNotificationStrategy).utf8().data(), statusMessage); |
| 547 formatWebGLStatusString("GPU process crash count", String::number(info.proce
ssCrashCount).utf8().data(), statusMessage); |
| 548 formatWebGLStatusString("ErrorMessage", info.errorMessage.utf8().data(), sta
tusMessage); |
| 549 statusMessage.append("."); |
| 550 return statusMessage; |
| 551 } |
| 552 |
| 529 PassOwnPtr<WebGraphicsContext3D> WebGLRenderingContextBase::createWebGraphicsCon
text3D(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned we
bGLVersion) | 553 PassOwnPtr<WebGraphicsContext3D> WebGLRenderingContextBase::createWebGraphicsCon
text3D(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned we
bGLVersion) |
| 530 { | 554 { |
| 531 Document& document = canvas->document(); | 555 Document& document = canvas->document(); |
| 532 LocalFrame* frame = document.frame(); | 556 LocalFrame* frame = document.frame(); |
| 533 if (!frame) { | 557 if (!frame) { |
| 534 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); | 558 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); |
| 535 return nullptr; | 559 return nullptr; |
| 536 } | 560 } |
| 537 Settings* settings = frame->settings(); | 561 Settings* settings = frame->settings(); |
| 538 | 562 |
| 539 // The FrameLoaderClient might block creation of a new WebGL context despite
the page settings; in | 563 // The FrameLoaderClient might block creation of a new WebGL context despite
the page settings; in |
| 540 // particular, if WebGL contexts were lost one or more times via the GL_ARB_
robustness extension. | 564 // particular, if WebGL contexts were lost one or more times via the GL_ARB_
robustness extension. |
| 541 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) { | 565 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) { |
| 542 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); | 566 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Web page was not allowed to create a WebGL cont
ext.")); |
| 543 return nullptr; | 567 return nullptr; |
| 544 } | 568 } |
| 545 | 569 |
| 546 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt
ributes(attributes, document.topDocument().url().string(), settings, webGLVersio
n); | 570 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt
ributes(attributes, document.topDocument().url().string(), settings, webGLVersio
n); |
| 547 WebGLInfo glInfo; | 571 WebGraphicsContext3D::WebGraphicsInfo glInfo; |
| 572 glInfo.testFailContext = shouldFailContextCreationForTesting; |
| 548 OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createO
ffscreenGraphicsContext3D(wgc3dAttributes, 0, &glInfo)); | 573 OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createO
ffscreenGraphicsContext3D(wgc3dAttributes, 0, &glInfo)); |
| 549 if (!context || shouldFailContextCreationForTesting) { | 574 if (!context || shouldFailContextCreationForTesting) { |
| 550 shouldFailContextCreationForTesting = false; | 575 shouldFailContextCreationForTesting = false; |
| 551 String statusMessage; | 576 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, extractWebGLContextCreationError(glInfo))); |
| 552 if (!glInfo.contextInfoCollectionFailure.isEmpty()) { | |
| 553 statusMessage.append("Could not create a WebGL context. "); | |
| 554 statusMessage.append(glInfo.contextInfoCollectionFailure); | |
| 555 String vendorId = String::number(glInfo.vendorId); | |
| 556 String deviceId = String::number(glInfo.deviceId); | |
| 557 if (vendorId.isEmpty()) | |
| 558 statusMessage.append("VendorId = Not Available"); | |
| 559 else | |
| 560 statusMessage.append("VendorId = " + vendorId); | |
| 561 if (deviceId.isEmpty()) | |
| 562 statusMessage.append(", DeviceId = Not Available"); | |
| 563 else | |
| 564 statusMessage.append(", DeviceId = " + deviceId); | |
| 565 } else { | |
| 566 statusMessage.append("Could not create a WebGL context"); | |
| 567 if (!glInfo.vendorInfo.isEmpty()) { | |
| 568 statusMessage.append(", VendorInfo = "); | |
| 569 statusMessage.append(glInfo.vendorInfo); | |
| 570 } else { | |
| 571 statusMessage.append(", VendorInfo = Not Available"); | |
| 572 } | |
| 573 if (!glInfo.rendererInfo.isEmpty()) { | |
| 574 statusMessage.append(", RendererInfo = "); | |
| 575 statusMessage.append(glInfo.rendererInfo); | |
| 576 } else { | |
| 577 statusMessage.append(", RendererInfo = Not Available"); | |
| 578 } | |
| 579 if (!glInfo.driverVersion.isEmpty()) { | |
| 580 statusMessage.append(", DriverInfo = "); | |
| 581 statusMessage.append(glInfo.driverVersion); | |
| 582 } else { | |
| 583 statusMessage.append(", DriverInfo = Not Available"); | |
| 584 } | |
| 585 statusMessage.append("."); | |
| 586 } | |
| 587 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, statusMessage)); | |
| 588 return nullptr; | 577 return nullptr; |
| 589 } | 578 } |
| 590 | 579 |
| 591 return context.release(); | 580 return context.release(); |
| 592 } | 581 } |
| 593 | 582 |
| 594 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() | 583 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() |
| 595 { | 584 { |
| 596 shouldFailContextCreationForTesting = true; | 585 shouldFailContextCreationForTesting = true; |
| 597 } | 586 } |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); | 968 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); |
| 980 if (!buffer) { | 969 if (!buffer) { |
| 981 m_contextLostMode = SyntheticLostContext; | 970 m_contextLostMode = SyntheticLostContext; |
| 982 return; | 971 return; |
| 983 } | 972 } |
| 984 | 973 |
| 985 m_drawingBuffer = buffer.release(); | 974 m_drawingBuffer = buffer.release(); |
| 986 | 975 |
| 987 drawingBuffer()->bind(GL_FRAMEBUFFER); | 976 drawingBuffer()->bind(GL_FRAMEBUFFER); |
| 988 setupFlags(); | 977 setupFlags(); |
| 989 | 978 |
| 990 #define ADD_VALUES_TO_SET(set, values) \ | 979 #define ADD_VALUES_TO_SET(set, values) \ |
| 991 for (size_t i = 0; i < arraysize(values); ++i) { \ | 980 for (size_t i = 0; i < arraysize(values); ++i) { \ |
| 992 set.insert(values[i]); \ | 981 set.insert(values[i]); \ |
| 993 } | 982 } |
| 994 | 983 |
| 995 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2); | 984 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2); |
| 996 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); | 985 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); |
| 997 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); | 986 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); |
| 998 ADD_VALUES_TO_SET(m_supportedFormatTypeCombinations, kSupportedFormatTypesES
2); | 987 ADD_VALUES_TO_SET(m_supportedFormatTypeCombinations, kSupportedFormatTypesES
2); |
| 999 } | 988 } |
| (...skipping 5915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6915 | 6904 |
| 6916 return totalBytesPerPixel; | 6905 return totalBytesPerPixel; |
| 6917 } | 6906 } |
| 6918 | 6907 |
| 6919 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6908 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6920 { | 6909 { |
| 6921 return m_drawingBuffer.get(); | 6910 return m_drawingBuffer.get(); |
| 6922 } | 6911 } |
| 6923 | 6912 |
| 6924 } // namespace blink | 6913 } // namespace blink |
| OLD | NEW |