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