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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "modules/webgl/WebGLVertexArrayObject.h" | 84 #include "modules/webgl/WebGLVertexArrayObject.h" |
85 #include "modules/webgl/WebGLVertexArrayObjectOES.h" | 85 #include "modules/webgl/WebGLVertexArrayObjectOES.h" |
86 #include "platform/CheckedInt.h" | 86 #include "platform/CheckedInt.h" |
87 #include "platform/RuntimeEnabledFeatures.h" | 87 #include "platform/RuntimeEnabledFeatures.h" |
88 #include "platform/geometry/IntSize.h" | 88 #include "platform/geometry/IntSize.h" |
89 #include "platform/graphics/GraphicsContext.h" | 89 #include "platform/graphics/GraphicsContext.h" |
90 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 90 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
91 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 91 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
92 #include "platform/graphics/gpu/DrawingBuffer.h" | 92 #include "platform/graphics/gpu/DrawingBuffer.h" |
93 #include "public/platform/Platform.h" | 93 #include "public/platform/Platform.h" |
94 #include "public/platform/WebGraphicsContext3D.h" | |
95 #include "public/platform/WebGraphicsContext3DProvider.h" | 94 #include "public/platform/WebGraphicsContext3DProvider.h" |
96 #include "public/platform/functional/WebFunction.h" | 95 #include "public/platform/functional/WebFunction.h" |
97 #include "wtf/Functional.h" | 96 #include "wtf/Functional.h" |
98 #include "wtf/PassOwnPtr.h" | 97 #include "wtf/PassOwnPtr.h" |
99 #include "wtf/text/StringBuilder.h" | 98 #include "wtf/text/StringBuilder.h" |
100 #include "wtf/text/StringUTF8Adaptor.h" | 99 #include "wtf/text/StringUTF8Adaptor.h" |
101 #include "wtf/typed_arrays/ArrayBufferContents.h" | 100 #include "wtf/typed_arrays/ArrayBufferContents.h" |
102 | 101 |
103 namespace blink { | 102 namespace blink { |
104 | 103 |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1052 |
1054 detachAndRemoveAllObjects(); | 1053 detachAndRemoveAllObjects(); |
1055 | 1054 |
1056 // Release all extensions now. | 1055 // Release all extensions now. |
1057 for (ExtensionTracker* tracker : m_extensions) { | 1056 for (ExtensionTracker* tracker : m_extensions) { |
1058 tracker->loseExtension(true); | 1057 tracker->loseExtension(true); |
1059 } | 1058 } |
1060 m_extensions.clear(); | 1059 m_extensions.clear(); |
1061 | 1060 |
1062 // Context must be removed from the group prior to the destruction of the | 1061 // Context must be removed from the group prior to the destruction of the |
1063 // WebGraphicsContext3D, otherwise shared objects may not be properly delete
d. | 1062 // GL context, otherwise shared objects may not be properly deleted. |
1064 m_contextGroup->removeContext(this); | 1063 m_contextGroup->removeContext(this); |
1065 | 1064 |
1066 destroyContext(); | 1065 destroyContext(); |
1067 | 1066 |
1068 willDestroyContext(this); | 1067 willDestroyContext(this); |
1069 } | 1068 } |
1070 | 1069 |
1071 void WebGLRenderingContextBase::destroyContext() | 1070 void WebGLRenderingContextBase::destroyContext() |
1072 { | 1071 { |
1073 if (!drawingBuffer()) | 1072 if (!drawingBuffer()) |
(...skipping 2971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4045 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAR
EST); | 4044 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAR
EST); |
4046 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAR
EST); | 4045 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAR
EST); |
4047 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO
_EDGE); | 4046 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO
_EDGE); |
4048 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO
_EDGE); | 4047 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO
_EDGE); |
4049 contextGL()->TexImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas->
width(), | 4048 contextGL()->TexImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas->
width(), |
4050 canvas->height(), 0, GL_RGBA, targetType, 0); | 4049 canvas->height(), 0, GL_RGBA, targetType, 0); |
4051 } | 4050 } |
4052 | 4051 |
4053 if (!canvas->is3D()) { | 4052 if (!canvas->is3D()) { |
4054 ImageBuffer* buffer = canvas->buffer(); | 4053 ImageBuffer* buffer = canvas->buffer(); |
4055 if (!buffer->copyToPlatformTexture(webContext(), contextGL(), targetText
ure, targetInternalformat, targetType, | 4054 if (!buffer->copyToPlatformTexture(contextGL(), targetTexture, targetInt
ernalformat, targetType, |
4056 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4055 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4057 ASSERT_NOT_REACHED(); | 4056 ASSERT_NOT_REACHED(); |
4058 } | 4057 } |
4059 } else { | 4058 } else { |
4060 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); | 4059 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); |
4061 ScopedTexture2DRestorer restorer(gl); | 4060 ScopedTexture2DRestorer restorer(gl); |
4062 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), contextGL(
), targetTexture, targetInternalformat, targetType, | 4061 if (!gl->drawingBuffer()->copyToPlatformTexture(contextGL(), targetTextu
re, targetInternalformat, targetType, |
4063 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ | 4062 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ |
4064 ASSERT_NOT_REACHED(); | 4063 ASSERT_NOT_REACHED(); |
4065 } | 4064 } |
4066 } | 4065 } |
4067 | 4066 |
4068 if (!possibleDirectCopy) { | 4067 if (!possibleDirectCopy) { |
4069 GLuint tmpFBO; | 4068 GLuint tmpFBO; |
4070 contextGL()->GenFramebuffers(1, &tmpFBO); | 4069 contextGL()->GenFramebuffers(1, &tmpFBO); |
4071 contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO); | 4070 contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO); |
4072 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, targetTexture, 0); | 4071 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, targetTexture, 0); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4149 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); | 4148 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); |
4150 if (surface->isValid()) { | 4149 if (surface->isValid()) { |
4151 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); | 4150 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); |
4152 if (imageBuffer) { | 4151 if (imageBuffer) { |
4153 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, | 4152 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, |
4154 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it | 4153 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it |
4155 // may still do a CPU conversion and upload the results). | 4154 // may still do a CPU conversion and upload the results). |
4156 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); | 4155 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); |
4157 | 4156 |
4158 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. | 4157 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. |
4159 if (imageBuffer->copyToPlatformTexture(webContext(), contextGL()
, texture->object(), internalformat, type, | 4158 if (imageBuffer->copyToPlatformTexture(contextGL(), texture->obj
ect(), internalformat, type, |
4160 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4159 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4161 return; | 4160 return; |
4162 } | 4161 } |
4163 } | 4162 } |
4164 } | 4163 } |
4165 } | 4164 } |
4166 | 4165 |
4167 // Normal pure SW path. | 4166 // Normal pure SW path. |
4168 RefPtr<Image> image = videoFrameToImage(video); | 4167 RefPtr<Image> image = videoFrameToImage(video); |
4169 if (!image) | 4168 if (!image) |
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5929 m_drawingBuffer->beginDestruction(); | 5928 m_drawingBuffer->beginDestruction(); |
5930 m_drawingBuffer.clear(); | 5929 m_drawingBuffer.clear(); |
5931 } | 5930 } |
5932 | 5931 |
5933 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque
stedAttributes, version()); | 5932 Platform::ContextAttributes attributes = toPlatformContextAttributes(m_reque
stedAttributes, version()); |
5934 Platform::GraphicsInfo glInfo; | 5933 Platform::GraphicsInfo glInfo; |
5935 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider( | 5934 OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::cu
rrent()->createOffscreenGraphicsContext3DProvider( |
5936 attributes, canvas()->document().topDocument().url(), 0, &glInfo)); | 5935 attributes, canvas()->document().topDocument().url(), 0, &glInfo)); |
5937 RefPtr<DrawingBuffer> buffer; | 5936 RefPtr<DrawingBuffer> buffer; |
5938 if (contextProvider) { | 5937 if (contextProvider) { |
5939 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 5938 // Construct a new drawing buffer with the new GL context. |
5940 buffer = createDrawingBuffer(contextProvider.release()); | 5939 buffer = createDrawingBuffer(contextProvider.release()); |
5941 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. | 5940 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. |
5942 } | 5941 } |
5943 if (!buffer) { | 5942 if (!buffer) { |
5944 if (m_contextLostMode == RealLostContext) { | 5943 if (m_contextLostMode == RealLostContext) { |
5945 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); | 5944 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, BLINK_FRO
M_HERE); |
5946 } else { | 5945 } else { |
5947 // This likely shouldn't happen but is the best way to report it to
the WebGL app. | 5946 // This likely shouldn't happen but is the best way to report it to
the WebGL app. |
5948 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); | 5947 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); |
5949 } | 5948 } |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6271 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6270 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6272 } | 6271 } |
6273 | 6272 |
6274 void WebGLRenderingContextBase::restoreUnpackParameters() | 6273 void WebGLRenderingContextBase::restoreUnpackParameters() |
6275 { | 6274 { |
6276 if (m_unpackAlignment != 1) | 6275 if (m_unpackAlignment != 1) |
6277 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6276 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6278 } | 6277 } |
6279 | 6278 |
6280 } // namespace blink | 6279 } // namespace blink |
OLD | NEW |