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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.cpp

Issue 703903002: [WebGL-blink] Add test function to force fail the webgl-context (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added test case Created 6 years, 1 month 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
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "core/loader/FrameLoader.h" 54 #include "core/loader/FrameLoader.h"
55 #include "core/loader/FrameLoaderClient.h" 55 #include "core/loader/FrameLoaderClient.h"
56 #include "core/frame/Settings.h" 56 #include "core/frame/Settings.h"
57 #include "core/rendering/RenderBox.h" 57 #include "core/rendering/RenderBox.h"
58 #include "platform/CheckedInt.h" 58 #include "platform/CheckedInt.h"
59 #include "platform/graphics/gpu/DrawingBuffer.h" 59 #include "platform/graphics/gpu/DrawingBuffer.h"
60 #include "public/platform/Platform.h" 60 #include "public/platform/Platform.h"
61 61
62 namespace blink { 62 namespace blink {
63 63
64 static bool contextShouldFail = false;
Ken Russell (switch to Gerrit) 2014/11/10 19:55:28 Please name this something like shouldFailContextC
sivag 2014/11/11 12:55:15 Done.
65
64 PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTML CanvasElement* canvas, WebGLContextAttributes* attrs) 66 PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTML CanvasElement* canvas, WebGLContextAttributes* attrs)
65 { 67 {
66 Document& document = canvas->document(); 68 Document& document = canvas->document();
67 LocalFrame* frame = document.frame(); 69 LocalFrame* frame = document.frame();
68 if (!frame) { 70 if (!frame) {
69 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); 71 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
70 return nullptr; 72 return nullptr;
71 } 73 }
72 Settings* settings = frame->settings(); 74 Settings* settings = frame->settings();
73 75
74 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in 76 // The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
75 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension. 77 // particular, if WebGL contexts were lost one or more times via the GL_ARB_ robustness extension.
76 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) { 78 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) {
77 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext.")); 79 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, "Web page was not allowed to create a WebGL cont ext."));
78 return nullptr; 80 return nullptr;
79 } 81 }
80 82
81 // The only situation that attrs is null is through Document::getCSSCanvasCo ntext(). 83 // The only situation that attrs is null is through Document::getCSSCanvasCo ntext().
82 RefPtrWillBeRawPtr<WebGLContextAttributes> defaultAttrs = nullptr; 84 RefPtrWillBeRawPtr<WebGLContextAttributes> defaultAttrs = nullptr;
83 if (!attrs) { 85 if (!attrs) {
84 defaultAttrs = WebGLContextAttributes::create(); 86 defaultAttrs = WebGLContextAttributes::create();
85 attrs = defaultAttrs.get(); 87 attrs = defaultAttrs.get();
86 } 88 }
87 blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(docum ent.topDocument().url().string(), settings, 1); 89 blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(docum ent.topDocument().url().string(), settings, 1);
88 blink::WebGLInfo glInfo; 90 blink::WebGLInfo glInfo;
89 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0, &glInfo)); 91 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0, &glInfo));
90 if (!context) { 92 if (!context || contextShouldFail) {
Ken Russell (switch to Gerrit) 2014/11/10 19:55:28 This code path must set the "should fail" flag bac
sivag 2014/11/11 12:55:14 Done.
91 String statusMessage("Could not create a WebGL context for VendorInfo = "); 93 String statusMessage("Could not create a WebGL context for VendorInfo = ");
92 statusMessage.append(glInfo.vendorInfo); 94 statusMessage.append(glInfo.vendorInfo);
93 statusMessage.append(", RendererInfo = "); 95 statusMessage.append(", RendererInfo = ");
94 statusMessage.append(glInfo.rendererInfo); 96 statusMessage.append(glInfo.rendererInfo);
95 statusMessage.append(", DriverInfo = "); 97 statusMessage.append(", DriverInfo = ");
96 statusMessage.append(glInfo.driverVersion); 98 statusMessage.append(glInfo.driverVersion);
97 statusMessage.append("."); 99 statusMessage.append(".");
98 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, statusMessage)); 100 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon textcreationerror, false, true, statusMessage));
99 return nullptr; 101 return nullptr;
100 } 102 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 visitor->trace(m_webglDebugShaders); 177 visitor->trace(m_webglDebugShaders);
176 visitor->trace(m_webglDrawBuffers); 178 visitor->trace(m_webglDrawBuffers);
177 visitor->trace(m_webglCompressedTextureATC); 179 visitor->trace(m_webglCompressedTextureATC);
178 visitor->trace(m_webglCompressedTextureETC1); 180 visitor->trace(m_webglCompressedTextureETC1);
179 visitor->trace(m_webglCompressedTexturePVRTC); 181 visitor->trace(m_webglCompressedTexturePVRTC);
180 visitor->trace(m_webglCompressedTextureS3TC); 182 visitor->trace(m_webglCompressedTextureS3TC);
181 visitor->trace(m_webglDepthTexture); 183 visitor->trace(m_webglDepthTexture);
182 WebGLRenderingContextBase::trace(visitor); 184 WebGLRenderingContextBase::trace(visitor);
183 } 185 }
184 186
187 void WebGLRenderingContext::forceNextWebGLContextCreationToFail(bool failContext )
Ken Russell (switch to Gerrit) 2014/11/10 19:55:28 Per comments on the Chromium side CL, this shouldn
sivag 2014/11/11 12:55:15 Done.
188 {
189 contextShouldFail = failContext;
190 }
191
185 } // namespace blink 192 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContext.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698