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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include <memory> | 28 #include <memory> |
29 #include "bindings/core/v8/ExceptionMessages.h" | 29 #include "bindings/core/v8/ExceptionMessages.h" |
30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
31 #include "bindings/core/v8/ScriptWrappableVisitor.h" | 31 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
32 #include "bindings/core/v8/V8BindingMacros.h" | 32 #include "bindings/core/v8/V8BindingMacros.h" |
33 #include "bindings/modules/v8/HTMLCanvasElementOrOffscreenCanvas.h" | 33 #include "bindings/modules/v8/HTMLCanvasElementOrOffscreenCanvas.h" |
34 #include "bindings/modules/v8/WebGLAny.h" | 34 #include "bindings/modules/v8/WebGLAny.h" |
35 #include "core/dom/DOMArrayBuffer.h" | 35 #include "core/dom/DOMArrayBuffer.h" |
36 #include "core/dom/DOMTypedArray.h" | 36 #include "core/dom/DOMTypedArray.h" |
37 #include "core/dom/ExecutionContext.h" | |
38 #include "core/dom/FlexibleArrayBufferView.h" | 37 #include "core/dom/FlexibleArrayBufferView.h" |
39 #include "core/dom/TaskRunnerHelper.h" | 38 #include "core/dom/TaskRunnerHelper.h" |
40 #include "core/frame/ImageBitmap.h" | 39 #include "core/frame/ImageBitmap.h" |
41 #include "core/frame/LocalFrame.h" | 40 #include "core/frame/LocalFrame.h" |
42 #include "core/frame/LocalFrameClient.h" | 41 #include "core/frame/LocalFrameClient.h" |
43 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
44 #include "core/html/HTMLCanvasElement.h" | 43 #include "core/html/HTMLCanvasElement.h" |
45 #include "core/html/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
46 #include "core/html/HTMLVideoElement.h" | 45 #include "core/html/HTMLVideoElement.h" |
47 #include "core/html/ImageData.h" | 46 #include "core/html/ImageData.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 HTMLCanvasElement* canvas, | 640 HTMLCanvasElement* canvas, |
642 ScriptState* script_state, | 641 ScriptState* script_state, |
643 const CanvasContextCreationAttributes& attributes, | 642 const CanvasContextCreationAttributes& attributes, |
644 unsigned web_gl_version) { | 643 unsigned web_gl_version) { |
645 // Exactly one of these must be provided. | 644 // Exactly one of these must be provided. |
646 DCHECK_EQ(!canvas, !!script_state); | 645 DCHECK_EQ(!canvas, !!script_state); |
647 // The canvas is only given on the main thread. | 646 // The canvas is only given on the main thread. |
648 DCHECK(!canvas || IsMainThread()); | 647 DCHECK(!canvas || IsMainThread()); |
649 | 648 |
650 auto execution_context = canvas ? canvas->GetDocument().GetExecutionContext() | 649 auto execution_context = canvas ? canvas->GetDocument().GetExecutionContext() |
651 : ExecutionContext::From(script_state); | 650 : script_state->GetExecutionContext(); |
652 Platform::ContextAttributes context_attributes = ToPlatformContextAttributes( | 651 Platform::ContextAttributes context_attributes = ToPlatformContextAttributes( |
653 attributes, web_gl_version, | 652 attributes, web_gl_version, |
654 SupportOwnOffscreenSurface(execution_context)); | 653 SupportOwnOffscreenSurface(execution_context)); |
655 | 654 |
656 Platform::GraphicsInfo gl_info; | 655 Platform::GraphicsInfo gl_info; |
657 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; | 656 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; |
658 const auto& url = canvas ? canvas->GetDocument().TopDocument().Url() | 657 const auto& url = canvas ? canvas->GetDocument().TopDocument().Url() |
659 : ExecutionContext::From(script_state)->Url(); | 658 : script_state->GetExecutionContext()->Url(); |
660 if (IsMainThread()) { | 659 if (IsMainThread()) { |
661 context_provider = WTF::WrapUnique( | 660 context_provider = WTF::WrapUnique( |
662 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( | 661 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( |
663 context_attributes, url, 0, &gl_info)); | 662 context_attributes, url, 0, &gl_info)); |
664 } else { | 663 } else { |
665 context_provider = | 664 context_provider = |
666 CreateContextProviderOnWorkerThread(context_attributes, &gl_info, url); | 665 CreateContextProviderOnWorkerThread(context_attributes, &gl_info, url); |
667 } | 666 } |
668 if (context_provider && !context_provider->BindToCurrentThread()) { | 667 if (context_provider && !context_provider->BindToCurrentThread()) { |
669 context_provider = nullptr; | 668 context_provider = nullptr; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 729 } |
731 | 730 |
732 void WebGLRenderingContextBase::ForceNextWebGLContextCreationToFail() { | 731 void WebGLRenderingContextBase::ForceNextWebGLContextCreationToFail() { |
733 g_should_fail_context_creation_for_testing = true; | 732 g_should_fail_context_creation_for_testing = true; |
734 } | 733 } |
735 | 734 |
736 ImageBitmap* WebGLRenderingContextBase::TransferToImageBitmapBase( | 735 ImageBitmap* WebGLRenderingContextBase::TransferToImageBitmapBase( |
737 ScriptState* script_state) { | 736 ScriptState* script_state) { |
738 UseCounter::Feature feature = | 737 UseCounter::Feature feature = |
739 UseCounter::kOffscreenCanvasTransferToImageBitmapWebGL; | 738 UseCounter::kOffscreenCanvasTransferToImageBitmapWebGL; |
740 UseCounter::Count(ExecutionContext::From(script_state), feature); | 739 UseCounter::Count(script_state->GetExecutionContext(), feature); |
741 if (!GetDrawingBuffer()) | 740 if (!GetDrawingBuffer()) |
742 return nullptr; | 741 return nullptr; |
743 return ImageBitmap::Create(GetDrawingBuffer()->TransferToStaticBitmapImage()); | 742 return ImageBitmap::Create(GetDrawingBuffer()->TransferToStaticBitmapImage()); |
744 } | 743 } |
745 | 744 |
746 ScriptPromise WebGLRenderingContextBase::commit( | 745 ScriptPromise WebGLRenderingContextBase::commit( |
747 ScriptState* script_state, | 746 ScriptState* script_state, |
748 ExceptionState& exception_state) { | 747 ExceptionState& exception_state) { |
749 UseCounter::Feature feature = UseCounter::kOffscreenCanvasCommitWebGL; | 748 UseCounter::Feature feature = UseCounter::kOffscreenCanvasCommitWebGL; |
750 UseCounter::Count(ExecutionContext::From(script_state), feature); | 749 UseCounter::Count(script_state->GetExecutionContext(), feature); |
751 if (!offscreenCanvas()) { | 750 if (!offscreenCanvas()) { |
752 exception_state.ThrowDOMException(kInvalidStateError, | 751 exception_state.ThrowDOMException(kInvalidStateError, |
753 "Commit() was called on a rendering " | 752 "Commit() was called on a rendering " |
754 "context that was not created from an " | 753 "context that was not created from an " |
755 "OffscreenCanvas."); | 754 "OffscreenCanvas."); |
756 return exception_state.Reject(script_state); | 755 return exception_state.Reject(script_state); |
757 } | 756 } |
758 // no HTMLCanvas associated, thrown InvalidStateError | 757 // no HTMLCanvas associated, thrown InvalidStateError |
759 if (!offscreenCanvas()->HasPlaceholderCanvas()) { | 758 if (!offscreenCanvas()->HasPlaceholderCanvas()) { |
760 exception_state.ThrowDOMException( | 759 exception_state.ThrowDOMException( |
(...skipping 7073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7834 | 7833 |
7835 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7834 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7836 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7835 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7837 if (canvas()) | 7836 if (canvas()) |
7838 result.setHTMLCanvasElement(canvas()); | 7837 result.setHTMLCanvasElement(canvas()); |
7839 else | 7838 else |
7840 result.setOffscreenCanvas(offscreenCanvas()); | 7839 result.setOffscreenCanvas(offscreenCanvas()); |
7841 } | 7840 } |
7842 | 7841 |
7843 } // namespace blink | 7842 } // namespace blink |
OLD | NEW |