| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 Platform::GraphicsInfo* gl_info; | 585 Platform::GraphicsInfo* gl_info; |
| 586 KURL url; | 586 KURL url; |
| 587 // Outputs. | 587 // Outputs. |
| 588 std::unique_ptr<WebGraphicsContext3DProvider> created_context_provider; | 588 std::unique_ptr<WebGraphicsContext3DProvider> created_context_provider; |
| 589 }; | 589 }; |
| 590 | 590 |
| 591 static void CreateContextProviderOnMainThread( | 591 static void CreateContextProviderOnMainThread( |
| 592 ContextProviderCreationInfo* creation_info, | 592 ContextProviderCreationInfo* creation_info, |
| 593 WaitableEvent* waitable_event) { | 593 WaitableEvent* waitable_event) { |
| 594 ASSERT(IsMainThread()); | 594 ASSERT(IsMainThread()); |
| 595 creation_info->created_context_provider = | 595 creation_info->created_context_provider = WTF::WrapUnique( |
| 596 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( | 596 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( |
| 597 creation_info->context_attributes, creation_info->url, 0, | 597 creation_info->context_attributes, creation_info->url, 0, |
| 598 creation_info->gl_info); | 598 creation_info->gl_info)); |
| 599 waitable_event->Signal(); | 599 waitable_event->Signal(); |
| 600 } | 600 } |
| 601 | 601 |
| 602 static std::unique_ptr<WebGraphicsContext3DProvider> | 602 static std::unique_ptr<WebGraphicsContext3DProvider> |
| 603 CreateContextProviderOnWorkerThread( | 603 CreateContextProviderOnWorkerThread( |
| 604 Platform::ContextAttributes context_attributes, | 604 Platform::ContextAttributes context_attributes, |
| 605 Platform::GraphicsInfo* gl_info, | 605 Platform::GraphicsInfo* gl_info, |
| 606 const KURL& url) { | 606 const KURL& url) { |
| 607 WaitableEvent waitable_event; | 607 WaitableEvent waitable_event; |
| 608 ContextProviderCreationInfo creation_info; | 608 ContextProviderCreationInfo creation_info; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 : ExecutionContext::From(script_state); | 652 : ExecutionContext::From(script_state); |
| 653 Platform::ContextAttributes context_attributes = ToPlatformContextAttributes( | 653 Platform::ContextAttributes context_attributes = ToPlatformContextAttributes( |
| 654 attributes, web_gl_version, | 654 attributes, web_gl_version, |
| 655 SupportOwnOffscreenSurface(execution_context)); | 655 SupportOwnOffscreenSurface(execution_context)); |
| 656 | 656 |
| 657 Platform::GraphicsInfo gl_info; | 657 Platform::GraphicsInfo gl_info; |
| 658 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; | 658 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; |
| 659 const auto& url = canvas ? canvas->GetDocument().TopDocument().Url() | 659 const auto& url = canvas ? canvas->GetDocument().TopDocument().Url() |
| 660 : ExecutionContext::From(script_state)->Url(); | 660 : ExecutionContext::From(script_state)->Url(); |
| 661 if (IsMainThread()) { | 661 if (IsMainThread()) { |
| 662 context_provider = | 662 context_provider = WTF::WrapUnique( |
| 663 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( | 663 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( |
| 664 context_attributes, url, 0, &gl_info); | 664 context_attributes, url, 0, &gl_info)); |
| 665 } else { | 665 } else { |
| 666 context_provider = | 666 context_provider = |
| 667 CreateContextProviderOnWorkerThread(context_attributes, &gl_info, url); | 667 CreateContextProviderOnWorkerThread(context_attributes, &gl_info, url); |
| 668 } | 668 } |
| 669 if (context_provider && !context_provider->BindToCurrentThread()) { | 669 if (context_provider && !context_provider->BindToCurrentThread()) { |
| 670 context_provider = nullptr; | 670 context_provider = nullptr; |
| 671 gl_info.error_message = | 671 gl_info.error_message = |
| 672 String("bindToCurrentThread failed: " + String(gl_info.error_message)); | 672 String("bindToCurrentThread failed: " + String(gl_info.error_message)); |
| 673 } | 673 } |
| 674 if (!context_provider || g_should_fail_context_creation_for_testing) { | 674 if (!context_provider || g_should_fail_context_creation_for_testing) { |
| (...skipping 6817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7492 | 7492 |
| 7493 auto execution_context = host()->GetTopExecutionContext(); | 7493 auto execution_context = host()->GetTopExecutionContext(); |
| 7494 Platform::ContextAttributes attributes = ToPlatformContextAttributes( | 7494 Platform::ContextAttributes attributes = ToPlatformContextAttributes( |
| 7495 CreationAttributes(), Version(), | 7495 CreationAttributes(), Version(), |
| 7496 SupportOwnOffscreenSurface(execution_context)); | 7496 SupportOwnOffscreenSurface(execution_context)); |
| 7497 Platform::GraphicsInfo gl_info; | 7497 Platform::GraphicsInfo gl_info; |
| 7498 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; | 7498 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; |
| 7499 const auto& url = host()->GetExecutionContextUrl(); | 7499 const auto& url = host()->GetExecutionContextUrl(); |
| 7500 | 7500 |
| 7501 if (IsMainThread()) { | 7501 if (IsMainThread()) { |
| 7502 context_provider = | 7502 context_provider = WTF::WrapUnique( |
| 7503 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( | 7503 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( |
| 7504 attributes, url, 0, &gl_info); | 7504 attributes, url, 0, &gl_info)); |
| 7505 } else { | 7505 } else { |
| 7506 context_provider = | 7506 context_provider = |
| 7507 CreateContextProviderOnWorkerThread(attributes, &gl_info, url); | 7507 CreateContextProviderOnWorkerThread(attributes, &gl_info, url); |
| 7508 } | 7508 } |
| 7509 RefPtr<DrawingBuffer> buffer; | 7509 RefPtr<DrawingBuffer> buffer; |
| 7510 if (context_provider && context_provider->BindToCurrentThread()) { | 7510 if (context_provider && context_provider->BindToCurrentThread()) { |
| 7511 // Construct a new drawing buffer with the new GL context. | 7511 // Construct a new drawing buffer with the new GL context. |
| 7512 buffer = CreateDrawingBuffer(std::move(context_provider)); | 7512 buffer = CreateDrawingBuffer(std::move(context_provider)); |
| 7513 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is | 7513 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is |
| 7514 // set to null. | 7514 // set to null. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7823 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7823 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7824 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7824 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7825 if (canvas()) { | 7825 if (canvas()) { |
| 7826 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host())); | 7826 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host())); |
| 7827 } else { | 7827 } else { |
| 7828 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host())); | 7828 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host())); |
| 7829 } | 7829 } |
| 7830 } | 7830 } |
| 7831 | 7831 |
| 7832 } // namespace blink | 7832 } // namespace blink |
| OLD | NEW |