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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 if (canvas()->hasImageBuffer()) | 908 if (canvas()->hasImageBuffer()) |
909 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); | 909 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); |
910 } | 910 } |
911 | 911 |
912 if (m_framebufferBinding) | 912 if (m_framebufferBinding) |
913 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | 913 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
914 else | 914 else |
915 drawingBuffer()->bind(); | 915 drawingBuffer()->bind(); |
916 } | 916 } |
917 | 917 |
918 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul
tsToImageData() | |
919 { | |
920 if (isContextLost()) | |
921 return nullptr; | |
922 | |
923 clearIfComposited(); | |
924 drawingBuffer()->commit(); | |
925 int width, height; | |
926 RefPtr<Uint8ClampedArray> imageDataPixels = drawingBuffer()->paintRenderingR
esultsToImageData(width, height); | |
927 if (!imageDataPixels) | |
928 return nullptr; | |
929 | |
930 if (m_framebufferBinding) | |
931 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); | |
932 else | |
933 drawingBuffer()->bind(); | |
934 | |
935 return ImageData::create(IntSize(width, height), imageDataPixels); | |
936 } | |
937 | |
938 void WebGLRenderingContextBase::reshape(int width, int height) | 918 void WebGLRenderingContextBase::reshape(int width, int height) |
939 { | 919 { |
940 if (isContextLost()) | 920 if (isContextLost()) |
941 return; | 921 return; |
942 | 922 |
943 // This is an approximation because at WebGLRenderingContextBase level we do
n't | 923 // This is an approximation because at WebGLRenderingContextBase level we do
n't |
944 // know if the underlying FBO uses textures or renderbuffers. | 924 // know if the underlying FBO uses textures or renderbuffers. |
945 GLint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); | 925 GLint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize); |
946 // Limit drawing buffer size to 4k to avoid memory exhaustion. | 926 // Limit drawing buffer size to 4k to avoid memory exhaustion. |
947 const int sizeUpperLimit = 4096; | 927 const int sizeUpperLimit = 4096; |
(...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3550 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->
renderingContext()); | 3530 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->
renderingContext()); |
3551 ScopedTexture2DRestorer restorer(gl); | 3531 ScopedTexture2DRestorer restorer(gl); |
3552 if (gl && gl->drawingBuffer()->copyToPlatformTexture(webContext(), t
exture->object(), internalformat, type, | 3532 if (gl && gl->drawingBuffer()->copyToPlatformTexture(webContext(), t
exture->object(), internalformat, type, |
3553 level, m_unpackPremultiplyAlpha, !m_unpackFlipY, DrawingBuffer::
Back)) { | 3533 level, m_unpackPremultiplyAlpha, !m_unpackFlipY, DrawingBuffer::
Back)) { |
3554 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3534 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
3555 return; | 3535 return; |
3556 } | 3536 } |
3557 } | 3537 } |
3558 } | 3538 } |
3559 | 3539 |
3560 RefPtrWillBeRawPtr<ImageData> imageData = canvas->getImageData(); | 3540 texImage2DImpl(target, level, internalformat, format, type, canvas->copiedIm
age(HTMLCanvasElement::Back), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY
, m_unpackPremultiplyAlpha, exceptionState); |
3561 if (imageData) | |
3562 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); | |
3563 else | |
3564 texImage2DImpl(target, level, internalformat, format, type, canvas->copi
edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip
lyAlpha, exceptionState); | |
3565 } | 3541 } |
3566 | 3542 |
3567 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement*
video, BackingStoreCopy backingStoreCopy) | 3543 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement*
video, BackingStoreCopy backingStoreCopy) |
3568 { | 3544 { |
3569 IntSize size(video->videoWidth(), video->videoHeight()); | 3545 IntSize size(video->videoWidth(), video->videoHeight()); |
3570 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); | 3546 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); |
3571 if (!buf) { | 3547 if (!buf) { |
3572 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); | 3548 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory"); |
3573 return nullptr; | 3549 return nullptr; |
3574 } | 3550 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3788 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl
yAlpha, exceptionState); | 3764 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl
yAlpha, exceptionState); |
3789 } | 3765 } |
3790 | 3766 |
3791 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 3767 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
3792 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) | 3768 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) |
3793 { | 3769 { |
3794 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e
xceptionState) | 3770 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e
xceptionState) |
3795 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem
ent, target, level, format, canvas->width(), canvas->height(), 0, format, type,
xoffset, yoffset)) | 3771 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem
ent, target, level, format, canvas->width(), canvas->height(), 0, format, type,
xoffset, yoffset)) |
3796 return; | 3772 return; |
3797 | 3773 |
3798 RefPtrWillBeRawPtr<ImageData> imageData = canvas->getImageData(); | 3774 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->cop
iedImage(HTMLCanvasElement::Back), WebGLImageConversion::HtmlDomCanvas, m_unpack
FlipY, m_unpackPremultiplyAlpha, exceptionState); |
3799 if (imageData) | |
3800 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.g
et(), exceptionState); | |
3801 else | |
3802 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas-
>copiedImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPrem
ultiplyAlpha, exceptionState); | |
3803 } | 3775 } |
3804 | 3776 |
3805 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 3777 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
3806 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 3778 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
3807 { | 3779 { |
3808 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) | 3780 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) |
3809 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format,
type, xoffset, yoffset)) | 3781 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format,
type, xoffset, yoffset)) |
3810 return; | 3782 return; |
3811 | 3783 |
3812 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e()); | 3784 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e()); |
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5806 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; | 5778 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; |
5807 } | 5779 } |
5808 #else | 5780 #else |
5809 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 5781 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
5810 { | 5782 { |
5811 return m_drawingBuffer.get(); | 5783 return m_drawingBuffer.get(); |
5812 } | 5784 } |
5813 #endif | 5785 #endif |
5814 | 5786 |
5815 } // namespace blink | 5787 } // namespace blink |
OLD | NEW |