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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 Platform::GraphicsInfo* glInfo; | 575 Platform::GraphicsInfo* glInfo; |
576 KURL url; | 576 KURL url; |
577 // Outputs. | 577 // Outputs. |
578 std::unique_ptr<WebGraphicsContext3DProvider> createdContextProvider; | 578 std::unique_ptr<WebGraphicsContext3DProvider> createdContextProvider; |
579 }; | 579 }; |
580 | 580 |
581 static void createContextProviderOnMainThread( | 581 static void createContextProviderOnMainThread( |
582 ContextProviderCreationInfo* creationInfo, | 582 ContextProviderCreationInfo* creationInfo, |
583 WaitableEvent* waitableEvent) { | 583 WaitableEvent* waitableEvent) { |
584 ASSERT(isMainThread()); | 584 ASSERT(isMainThread()); |
585 creationInfo->createdContextProvider = | 585 creationInfo->createdContextProvider = WTF::wrapUnique( |
586 wrapUnique(Platform::current()->createOffscreenGraphicsContext3DProvider( | 586 Platform::current()->createOffscreenGraphicsContext3DProvider( |
587 creationInfo->contextAttributes, creationInfo->url, 0, | 587 creationInfo->contextAttributes, creationInfo->url, 0, |
588 creationInfo->glInfo)); | 588 creationInfo->glInfo)); |
589 waitableEvent->signal(); | 589 waitableEvent->signal(); |
590 } | 590 } |
591 | 591 |
592 static std::unique_ptr<WebGraphicsContext3DProvider> | 592 static std::unique_ptr<WebGraphicsContext3DProvider> |
593 createContextProviderOnWorkerThread( | 593 createContextProviderOnWorkerThread( |
594 Platform::ContextAttributes contextAttributes, | 594 Platform::ContextAttributes contextAttributes, |
595 Platform::GraphicsInfo* glInfo, | 595 Platform::GraphicsInfo* glInfo, |
596 const KURL& url) { | 596 const KURL& url) { |
(...skipping 23 matching lines...) Expand all Loading... |
620 // The canvas is only given on the main thread. | 620 // The canvas is only given on the main thread. |
621 DCHECK(!canvas || isMainThread()); | 621 DCHECK(!canvas || isMainThread()); |
622 | 622 |
623 Platform::ContextAttributes contextAttributes = | 623 Platform::ContextAttributes contextAttributes = |
624 toPlatformContextAttributes(attributes, webGLVersion); | 624 toPlatformContextAttributes(attributes, webGLVersion); |
625 Platform::GraphicsInfo glInfo; | 625 Platform::GraphicsInfo glInfo; |
626 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider; | 626 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider; |
627 const auto& url = canvas ? canvas->document().topDocument().url() | 627 const auto& url = canvas ? canvas->document().topDocument().url() |
628 : scriptState->getExecutionContext()->url(); | 628 : scriptState->getExecutionContext()->url(); |
629 if (isMainThread()) { | 629 if (isMainThread()) { |
630 contextProvider = wrapUnique( | 630 contextProvider = WTF::wrapUnique( |
631 Platform::current()->createOffscreenGraphicsContext3DProvider( | 631 Platform::current()->createOffscreenGraphicsContext3DProvider( |
632 contextAttributes, url, 0, &glInfo)); | 632 contextAttributes, url, 0, &glInfo)); |
633 } else { | 633 } else { |
634 contextProvider = | 634 contextProvider = |
635 createContextProviderOnWorkerThread(contextAttributes, &glInfo, url); | 635 createContextProviderOnWorkerThread(contextAttributes, &glInfo, url); |
636 } | 636 } |
637 if (contextProvider && !contextProvider->bindToCurrentThread()) { | 637 if (contextProvider && !contextProvider->bindToCurrentThread()) { |
638 contextProvider = nullptr; | 638 contextProvider = nullptr; |
639 String errorString(glInfo.errorMessage.utf8().data()); | 639 String errorString(glInfo.errorMessage.utf8().data()); |
640 errorString.insert("bindToCurrentThread failed: ", 0); | 640 errorString.insert("bindToCurrentThread failed: ", 0); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 AccelerationHint hint, | 747 AccelerationHint hint, |
748 SnapshotReason reason) const { | 748 SnapshotReason reason) const { |
749 if (!drawingBuffer()) | 749 if (!drawingBuffer()) |
750 return nullptr; | 750 return nullptr; |
751 | 751 |
752 drawingBuffer()->resolveAndBindForReadAndDraw(); | 752 drawingBuffer()->resolveAndBindForReadAndDraw(); |
753 IntSize size = clampedCanvasSize(); | 753 IntSize size = clampedCanvasSize(); |
754 OpacityMode opacityMode = | 754 OpacityMode opacityMode = |
755 creationAttributes().hasAlpha() ? NonOpaque : Opaque; | 755 creationAttributes().hasAlpha() ? NonOpaque : Opaque; |
756 std::unique_ptr<AcceleratedImageBufferSurface> surface = | 756 std::unique_ptr<AcceleratedImageBufferSurface> surface = |
757 makeUnique<AcceleratedImageBufferSurface>(size, opacityMode); | 757 WTF::makeUnique<AcceleratedImageBufferSurface>(size, opacityMode); |
758 if (!surface->isValid()) | 758 if (!surface->isValid()) |
759 return nullptr; | 759 return nullptr; |
760 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface)); | 760 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface)); |
761 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), | 761 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), |
762 BackBuffer)) { | 762 BackBuffer)) { |
763 // copyRenderingResultsFromDrawingBuffer is expected to always succeed | 763 // copyRenderingResultsFromDrawingBuffer is expected to always succeed |
764 // because we've explicitly created an Accelerated surface and have already | 764 // because we've explicitly created an Accelerated surface and have already |
765 // validated it. | 765 // validated it. |
766 NOTREACHED(); | 766 NOTREACHED(); |
767 return nullptr; | 767 return nullptr; |
(...skipping 4377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5145 // SW path. | 5145 // SW path. |
5146 if (video->copyVideoTextureToPlatformTexture( | 5146 if (video->copyVideoTextureToPlatformTexture( |
5147 contextGL(), texture->object(), internalformat, type, | 5147 contextGL(), texture->object(), internalformat, type, |
5148 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 5148 m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
5149 return; | 5149 return; |
5150 } | 5150 } |
5151 | 5151 |
5152 // Try using an accelerated image buffer, this allows YUV conversion to be | 5152 // Try using an accelerated image buffer, this allows YUV conversion to be |
5153 // done on the GPU. | 5153 // done on the GPU. |
5154 std::unique_ptr<ImageBufferSurface> surface = | 5154 std::unique_ptr<ImageBufferSurface> surface = |
5155 wrapUnique(new AcceleratedImageBufferSurface( | 5155 WTF::wrapUnique(new AcceleratedImageBufferSurface( |
5156 IntSize(video->videoWidth(), video->videoHeight()))); | 5156 IntSize(video->videoWidth(), video->videoHeight()))); |
5157 if (surface->isValid()) { | 5157 if (surface->isValid()) { |
5158 std::unique_ptr<ImageBuffer> imageBuffer( | 5158 std::unique_ptr<ImageBuffer> imageBuffer( |
5159 ImageBuffer::create(std::move(surface))); | 5159 ImageBuffer::create(std::move(surface))); |
5160 if (imageBuffer) { | 5160 if (imageBuffer) { |
5161 // The video element paints an RGBA frame into our surface here. By | 5161 // The video element paints an RGBA frame into our surface here. By |
5162 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer | 5162 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
5163 // implementation to do any necessary color space conversion on the GPU | 5163 // implementation to do any necessary color space conversion on the GPU |
5164 // (though it may still do a CPU conversion and upload the results). | 5164 // (though it may still do a CPU conversion and upload the results). |
5165 video->paintCurrentFrame( | 5165 video->paintCurrentFrame( |
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7395 } | 7395 } |
7396 | 7396 |
7397 Platform::ContextAttributes attributes = | 7397 Platform::ContextAttributes attributes = |
7398 toPlatformContextAttributes(creationAttributes(), version()); | 7398 toPlatformContextAttributes(creationAttributes(), version()); |
7399 Platform::GraphicsInfo glInfo; | 7399 Platform::GraphicsInfo glInfo; |
7400 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider; | 7400 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider; |
7401 const auto& url = canvas() | 7401 const auto& url = canvas() |
7402 ? canvas()->document().topDocument().url() | 7402 ? canvas()->document().topDocument().url() |
7403 : getOffscreenCanvas()->getExecutionContext()->url(); | 7403 : getOffscreenCanvas()->getExecutionContext()->url(); |
7404 if (isMainThread()) { | 7404 if (isMainThread()) { |
7405 contextProvider = wrapUnique( | 7405 contextProvider = WTF::wrapUnique( |
7406 Platform::current()->createOffscreenGraphicsContext3DProvider( | 7406 Platform::current()->createOffscreenGraphicsContext3DProvider( |
7407 attributes, url, 0, &glInfo)); | 7407 attributes, url, 0, &glInfo)); |
7408 } else { | 7408 } else { |
7409 contextProvider = | 7409 contextProvider = |
7410 createContextProviderOnWorkerThread(attributes, &glInfo, url); | 7410 createContextProviderOnWorkerThread(attributes, &glInfo, url); |
7411 } | 7411 } |
7412 RefPtr<DrawingBuffer> buffer; | 7412 RefPtr<DrawingBuffer> buffer; |
7413 if (contextProvider && contextProvider->bindToCurrentThread()) { | 7413 if (contextProvider && contextProvider->bindToCurrentThread()) { |
7414 // Construct a new drawing buffer with the new GL context. | 7414 // Construct a new drawing buffer with the new GL context. |
7415 if (canvas()) { | 7415 if (canvas()) { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7741 | 7741 |
7742 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7742 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7743 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7743 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7744 if (canvas()) | 7744 if (canvas()) |
7745 result.setHTMLCanvasElement(canvas()); | 7745 result.setHTMLCanvasElement(canvas()); |
7746 else | 7746 else |
7747 result.setOffscreenCanvas(getOffscreenCanvas()); | 7747 result.setOffscreenCanvas(getOffscreenCanvas()); |
7748 } | 7748 } |
7749 | 7749 |
7750 } // namespace blink | 7750 } // namespace blink |
OLD | NEW |