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

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

Issue 1384233003: Improve usefulness of webglcontextcreationerror statusMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 aphicsContext3DInfo& info)
536 {
537 String statusMessage("Could not create a WebGL context");
538 if (info.vendorId)
539 formatWebGLStatusString("VENDOR", String::format("0x%04x", info.vendorId ).utf8().data(), statusMessage);
540 if (info.deviceId)
541 formatWebGLStatusString("DEVICE", String::format("0x%04x", info.deviceId ).utf8().data(), statusMessage);
542 formatWebGLStatusString("GL_VENDOR", info.vendorInfo.utf8().data(), statusMe ssage);
543 formatWebGLStatusString("GL_RENDERER", info.rendererInfo.utf8().data(), stat usMessage);
544 formatWebGLStatusString("GL_VERSION", info.driverVersion.utf8().data(), stat usMessage);
545 formatWebGLStatusString("Sandboxed", info.sandboxed ? "yes" : "no", statusMe ssage);
546 formatWebGLStatusString("Optimus", info.optimus ? "yes" : "no", statusMessag e);
547 formatWebGLStatusString("AMD switchable", info.amdSwitchable ? "yes" : "no", statusMessage);
548 formatWebGLStatusString("Reset notification strategy", info.resetNotificatio nStrategy ? "yes" : "no", statusMessage);
549 formatWebGLStatusString("LenovoDCute", info.lenovoDcute ? "yes" : "no", stat usMessage);
550 formatWebGLStatusString("GPU process crash count", String::number(info.proce ssCrashCount).utf8().data(), statusMessage);
551 formatWebGLStatusString("DisplayLinkVersion", info.displayLinkVersion.utf8() .data(), statusMessage);
552 formatWebGLStatusString("ErrorMessage", info.errorMessage.utf8().data(), sta tusMessage);
553 statusMessage.append(".");
554 return statusMessage;
555 }
556
529 PassOwnPtr<WebGraphicsContext3D> WebGLRenderingContextBase::createWebGraphicsCon text3D(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned we bGLVersion) 557 PassOwnPtr<WebGraphicsContext3D> WebGLRenderingContextBase::createWebGraphicsCon text3D(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned we bGLVersion)
530 { 558 {
531 Document& document = canvas->document(); 559 Document& document = canvas->document();
532 LocalFrame* frame = document.frame(); 560 LocalFrame* frame = document.frame();
533 if (!frame) { 561 if (!frame) {
534 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."));
535 return nullptr; 563 return nullptr;
536 } 564 }
537 Settings* settings = frame->settings(); 565 Settings* settings = frame->settings();
538 566
539 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in 567 // 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. 568 // 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 ())) { 569 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.")); 570 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
543 return nullptr; 571 return nullptr;
544 } 572 }
545 573
546 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt ributes(attributes, document.topDocument().url().string(), settings, webGLVersio n); 574 WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAtt ributes(attributes, document.topDocument().url().string(), settings, webGLVersio n);
547 WebGLInfo glInfo; 575 WebGraphicsContext3D::WebGraphicsContext3DInfo glInfo;
576 glInfo.testFailContext = shouldFailContextCreationForTesting;
548 OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createO ffscreenGraphicsContext3D(wgc3dAttributes, 0, &glInfo)); 577 OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createO ffscreenGraphicsContext3D(wgc3dAttributes, 0, &glInfo));
549 if (!context || shouldFailContextCreationForTesting) { 578 if (!context || shouldFailContextCreationForTesting) {
550 shouldFailContextCreationForTesting = false; 579 shouldFailContextCreationForTesting = false;
551 String statusMessage; 580 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; 581 return nullptr;
589 } 582 }
590 583
591 return context.release(); 584 return context.release();
592 } 585 }
593 586
594 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() 587 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail()
595 { 588 {
596 shouldFailContextCreationForTesting = true; 589 shouldFailContextCreationForTesting = true;
597 } 590 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); 890 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context);
898 if (!buffer) { 891 if (!buffer) {
899 m_contextLostMode = SyntheticLostContext; 892 m_contextLostMode = SyntheticLostContext;
900 return; 893 return;
901 } 894 }
902 895
903 m_drawingBuffer = buffer.release(); 896 m_drawingBuffer = buffer.release();
904 897
905 drawingBuffer()->bind(GL_FRAMEBUFFER); 898 drawingBuffer()->bind(GL_FRAMEBUFFER);
906 setupFlags(); 899 setupFlags();
907 900
908 #define ADD_VALUES_TO_SET(set, values) \ 901 #define ADD_VALUES_TO_SET(set, values) \
909 for (size_t i = 0; i < arraysize(values); ++i) { \ 902 for (size_t i = 0; i < arraysize(values); ++i) { \
910 set.insert(values[i]); \ 903 set.insert(values[i]); \
911 } 904 }
912 905
913 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2); 906 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2);
914 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); 907 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2);
915 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); 908 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2);
916 ADD_VALUES_TO_SET(m_supportedFormatTypeCombinations, kSupportedFormatTypesES 2); 909 ADD_VALUES_TO_SET(m_supportedFormatTypeCombinations, kSupportedFormatTypesES 2);
917 } 910 }
(...skipping 5813 matching lines...) Expand 10 before | Expand all | Expand 10 after
6731 6724
6732 return totalBytesPerPixel; 6725 return totalBytesPerPixel;
6733 } 6726 }
6734 6727
6735 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6728 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6736 { 6729 {
6737 return m_drawingBuffer.get(); 6730 return m_drawingBuffer.get();
6738 } 6731 }
6739 6732
6740 } // namespace blink 6733 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698