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

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

Issue 2586803003: Enable creation of offscreen contexts which own their backing surface. (Closed)
Patch Set: Rebase, update comment for alpha semantics Created 3 years, 11 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 28 matching lines...) Expand all
39 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
40 #include "core/html/HTMLCanvasElement.h" 40 #include "core/html/HTMLCanvasElement.h"
41 #include "core/html/HTMLImageElement.h" 41 #include "core/html/HTMLImageElement.h"
42 #include "core/html/HTMLVideoElement.h" 42 #include "core/html/HTMLVideoElement.h"
43 #include "core/html/ImageData.h" 43 #include "core/html/ImageData.h"
44 #include "core/inspector/ConsoleMessage.h" 44 #include "core/inspector/ConsoleMessage.h"
45 #include "core/inspector/InspectorInstrumentation.h" 45 #include "core/inspector/InspectorInstrumentation.h"
46 #include "core/layout/LayoutBox.h" 46 #include "core/layout/LayoutBox.h"
47 #include "core/loader/FrameLoader.h" 47 #include "core/loader/FrameLoader.h"
48 #include "core/loader/FrameLoaderClient.h" 48 #include "core/loader/FrameLoaderClient.h"
49 #include "core/origin_trials/OriginTrials.h"
49 #include "gpu/command_buffer/client/gles2_interface.h" 50 #include "gpu/command_buffer/client/gles2_interface.h"
50 #include "modules/webgl/ANGLEInstancedArrays.h" 51 #include "modules/webgl/ANGLEInstancedArrays.h"
51 #include "modules/webgl/EXTBlendMinMax.h" 52 #include "modules/webgl/EXTBlendMinMax.h"
52 #include "modules/webgl/EXTFragDepth.h" 53 #include "modules/webgl/EXTFragDepth.h"
53 #include "modules/webgl/EXTShaderTextureLOD.h" 54 #include "modules/webgl/EXTShaderTextureLOD.h"
54 #include "modules/webgl/EXTTextureFilterAnisotropic.h" 55 #include "modules/webgl/EXTTextureFilterAnisotropic.h"
55 #include "modules/webgl/GLStringQuery.h" 56 #include "modules/webgl/GLStringQuery.h"
56 #include "modules/webgl/OESElementIndexUint.h" 57 #include "modules/webgl/OESElementIndexUint.h"
57 #include "modules/webgl/OESStandardDerivatives.h" 58 #include "modules/webgl/OESStandardDerivatives.h"
58 #include "modules/webgl/OESTextureFloat.h" 59 #include "modules/webgl/OESTextureFloat.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 ScriptState* scriptState, 617 ScriptState* scriptState,
617 const CanvasContextCreationAttributes& attributes, 618 const CanvasContextCreationAttributes& attributes,
618 unsigned webGLVersion) { 619 unsigned webGLVersion) {
619 // Exactly one of these must be provided. 620 // Exactly one of these must be provided.
620 DCHECK_EQ(!canvas, !!scriptState); 621 DCHECK_EQ(!canvas, !!scriptState);
621 // The canvas is only given on the main thread. 622 // The canvas is only given on the main thread.
622 DCHECK(!canvas || isMainThread()); 623 DCHECK(!canvas || isMainThread());
623 624
624 Platform::ContextAttributes contextAttributes = 625 Platform::ContextAttributes contextAttributes =
625 toPlatformContextAttributes(attributes, webGLVersion); 626 toPlatformContextAttributes(attributes, webGLVersion);
627
628 // If there's a possibility this context may be used with WebVR make sure it
629 // is created with an offscreen surface that can be swapped out for a
630 // VR-specific surface if needed. We can only check the origin trial
631 // if called with a scriptState, not for a canvas.
632 if (RuntimeEnabledFeatures::webVREnabled() ||
633 (scriptState &&
634 OriginTrials::webVREnabled(scriptState->getExecutionContext()))) {
635 contextAttributes.supportOwnOffscreenSurface = true;
636 }
637
626 Platform::GraphicsInfo glInfo; 638 Platform::GraphicsInfo glInfo;
627 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider; 639 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider;
628 const auto& url = canvas ? canvas->document().topDocument().url() 640 const auto& url = canvas ? canvas->document().topDocument().url()
629 : scriptState->getExecutionContext()->url(); 641 : scriptState->getExecutionContext()->url();
630 if (isMainThread()) { 642 if (isMainThread()) {
631 contextProvider = WTF::wrapUnique( 643 contextProvider = WTF::wrapUnique(
632 Platform::current()->createOffscreenGraphicsContext3DProvider( 644 Platform::current()->createOffscreenGraphicsContext3DProvider(
633 contextAttributes, url, 0, &glInfo)); 645 contextAttributes, url, 0, &glInfo));
634 } else { 646 } else {
635 contextProvider = 647 contextProvider =
(...skipping 7159 matching lines...) Expand 10 before | Expand all | Expand 10 after
7795 7807
7796 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7808 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7797 HTMLCanvasElementOrOffscreenCanvas& result) const { 7809 HTMLCanvasElementOrOffscreenCanvas& result) const {
7798 if (canvas()) 7810 if (canvas())
7799 result.setHTMLCanvasElement(canvas()); 7811 result.setHTMLCanvasElement(canvas());
7800 else 7812 else
7801 result.setOffscreenCanvas(offscreenCanvas()); 7813 result.setOffscreenCanvas(offscreenCanvas());
7802 } 7814 }
7803 7815
7804 } // namespace blink 7816 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698