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 2985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2996 return getUnsignedIntParameter(scriptState, pname); | 2996 return getUnsignedIntParameter(scriptState, pname); |
2997 case GL_BLEND_SRC_RGB: | 2997 case GL_BLEND_SRC_RGB: |
2998 return getUnsignedIntParameter(scriptState, pname); | 2998 return getUnsignedIntParameter(scriptState, pname); |
2999 case GL_BLUE_BITS: | 2999 case GL_BLUE_BITS: |
3000 return getIntParameter(scriptState, pname); | 3000 return getIntParameter(scriptState, pname); |
3001 case GL_COLOR_CLEAR_VALUE: | 3001 case GL_COLOR_CLEAR_VALUE: |
3002 return getWebGLFloatArrayParameter(scriptState, pname); | 3002 return getWebGLFloatArrayParameter(scriptState, pname); |
3003 case GL_COLOR_WRITEMASK: | 3003 case GL_COLOR_WRITEMASK: |
3004 return getBooleanArrayParameter(scriptState, pname); | 3004 return getBooleanArrayParameter(scriptState, pname); |
3005 case GL_COMPRESSED_TEXTURE_FORMATS: | 3005 case GL_COMPRESSED_TEXTURE_FORMATS: |
3006 return WebGLAny(scriptState, DOMUint32Array::create( | 3006 return WebGLAny( |
3007 m_compressedTextureFormats.data(), | 3007 scriptState, |
3008 m_compressedTextureFormats.size())); | 3008 DOMUint32Array::create(m_compressedTextureFormats.data(), |
| 3009 m_compressedTextureFormats.size())); |
3009 case GL_CULL_FACE: | 3010 case GL_CULL_FACE: |
3010 return getBooleanParameter(scriptState, pname); | 3011 return getBooleanParameter(scriptState, pname); |
3011 case GL_CULL_FACE_MODE: | 3012 case GL_CULL_FACE_MODE: |
3012 return getUnsignedIntParameter(scriptState, pname); | 3013 return getUnsignedIntParameter(scriptState, pname); |
3013 case GL_CURRENT_PROGRAM: | 3014 case GL_CURRENT_PROGRAM: |
3014 return WebGLAny(scriptState, m_currentProgram.get()); | 3015 return WebGLAny(scriptState, m_currentProgram.get()); |
3015 case GL_DEPTH_BITS: | 3016 case GL_DEPTH_BITS: |
3016 if (!m_framebufferBinding && !creationAttributes().depth()) | 3017 if (!m_framebufferBinding && !creationAttributes().depth()) |
3017 return WebGLAny(scriptState, intZero); | 3018 return WebGLAny(scriptState, intZero); |
3018 return getIntParameter(scriptState, pname); | 3019 return getIntParameter(scriptState, pname); |
(...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5151 } else { | 5152 } else { |
5152 texImageByGPU(functionID, texture, target, level, GL_RGBA, type, xoffset, | 5153 texImageByGPU(functionID, texture, target, level, GL_RGBA, type, xoffset, |
5153 yoffset, 0, canvas, adjustedSourceSubRectangle); | 5154 yoffset, 0, canvas, adjustedSourceSubRectangle); |
5154 } | 5155 } |
5155 } else { | 5156 } else { |
5156 // 3D functions. | 5157 // 3D functions. |
5157 | 5158 |
5158 // TODO(zmo): Implement GPU-to-GPU copy path (crbug.com/612542). | 5159 // TODO(zmo): Implement GPU-to-GPU copy path (crbug.com/612542). |
5159 // Note that code will also be needed to copy to layers of 3D | 5160 // Note that code will also be needed to copy to layers of 3D |
5160 // textures, and elements of 2D texture arrays. | 5161 // textures, and elements of 2D texture arrays. |
5161 texImageImpl( | 5162 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, |
5162 functionID, target, level, internalformat, xoffset, yoffset, zoffset, | 5163 zoffset, format, type, |
5163 format, type, canvas | 5164 canvas |
5164 ->copiedImage(FrontBuffer, PreferAcceleration, | 5165 ->copiedImage(FrontBuffer, PreferAcceleration, |
5165 functionIDToSnapshotReason(functionID)) | 5166 functionIDToSnapshotReason(functionID)) |
5166 .get(), | 5167 .get(), |
5167 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, | 5168 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, |
5168 m_unpackPremultiplyAlpha, sourceSubRectangle, depth, unpackImageHeight); | 5169 m_unpackPremultiplyAlpha, sourceSubRectangle, depth, |
| 5170 unpackImageHeight); |
5169 } | 5171 } |
5170 } | 5172 } |
5171 | 5173 |
5172 void WebGLRenderingContextBase::texImage2D(GLenum target, | 5174 void WebGLRenderingContextBase::texImage2D(GLenum target, |
5173 GLint level, | 5175 GLint level, |
5174 GLint internalformat, | 5176 GLint internalformat, |
5175 GLenum format, | 5177 GLenum format, |
5176 GLenum type, | 5178 GLenum type, |
5177 HTMLCanvasElement* canvas, | 5179 HTMLCanvasElement* canvas, |
5178 ExceptionState& exceptionState) { | 5180 ExceptionState& exceptionState) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5226 level, internalformat, video->videoWidth(), | 5228 level, internalformat, video->videoWidth(), |
5227 video->videoHeight(), 1, 0, format, type, xoffset, | 5229 video->videoHeight(), 1, 0, format, type, xoffset, |
5228 yoffset, zoffset)) | 5230 yoffset, zoffset)) |
5229 return; | 5231 return; |
5230 | 5232 |
5231 bool sourceImageRectIsDefault = | 5233 bool sourceImageRectIsDefault = |
5232 sourceImageRect == sentinelEmptyRect() || | 5234 sourceImageRect == sentinelEmptyRect() || |
5233 sourceImageRect == | 5235 sourceImageRect == |
5234 IntRect(0, 0, video->videoWidth(), video->videoHeight()); | 5236 IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
5235 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && | 5237 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && |
5236 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( | 5238 GL_TEXTURE_2D == target && |
5237 target, internalformat, type, level)) { | 5239 Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, |
| 5240 level)) { |
5238 DCHECK_EQ(xoffset, 0); | 5241 DCHECK_EQ(xoffset, 0); |
5239 DCHECK_EQ(yoffset, 0); | 5242 DCHECK_EQ(yoffset, 0); |
5240 DCHECK_EQ(zoffset, 0); | 5243 DCHECK_EQ(zoffset, 0); |
5241 // Go through the fast path doing a GPU-GPU textures copy without a readback | 5244 // Go through the fast path doing a GPU-GPU textures copy without a readback |
5242 // to system memory if possible. Otherwise, it will fall back to the normal | 5245 // to system memory if possible. Otherwise, it will fall back to the normal |
5243 // SW path. | 5246 // SW path. |
5244 | 5247 |
5245 // Note that neither | 5248 // Note that neither |
5246 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor | 5249 // HTMLVideoElement::copyVideoTextureToPlatformTexture nor |
5247 // ImageBuffer::copyToPlatformTexture allocate the destination texture | 5250 // ImageBuffer::copyToPlatformTexture allocate the destination texture |
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6980 break; | 6983 break; |
6981 case GL_FLOAT: // OES_texture_float | 6984 case GL_FLOAT: // OES_texture_float |
6982 if (pixels->type() != DOMArrayBufferView::TypeFloat32) { | 6985 if (pixels->type() != DOMArrayBufferView::TypeFloat32) { |
6983 synthesizeGLError(GL_INVALID_OPERATION, functionName, | 6986 synthesizeGLError(GL_INVALID_OPERATION, functionName, |
6984 "type FLOAT but ArrayBufferView not Float32Array"); | 6987 "type FLOAT but ArrayBufferView not Float32Array"); |
6985 return false; | 6988 return false; |
6986 } | 6989 } |
6987 break; | 6990 break; |
6988 case GL_HALF_FLOAT: | 6991 case GL_HALF_FLOAT: |
6989 case GL_HALF_FLOAT_OES: // OES_texture_half_float | 6992 case GL_HALF_FLOAT_OES: // OES_texture_half_float |
6990 // As per the specification, ArrayBufferView should be null or a | 6993 // As per the specification, ArrayBufferView should |
6991 // Uint16Array when OES_texture_half_float is enabled. | 6994 // be null or a Uint16Array when |
| 6995 // OES_texture_half_float is enabled. |
6992 if (pixels->type() != DOMArrayBufferView::TypeUint16) { | 6996 if (pixels->type() != DOMArrayBufferView::TypeUint16) { |
6993 synthesizeGLError(GL_INVALID_OPERATION, functionName, | 6997 synthesizeGLError(GL_INVALID_OPERATION, functionName, |
6994 "type HALF_FLOAT_OES but ArrayBufferView is not NULL " | 6998 "type HALF_FLOAT_OES but ArrayBufferView is not NULL " |
6995 "and not Uint16Array"); | 6999 "and not Uint16Array"); |
6996 return false; | 7000 return false; |
6997 } | 7001 } |
6998 break; | 7002 break; |
6999 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: | 7003 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
7000 synthesizeGLError(GL_INVALID_OPERATION, functionName, | 7004 synthesizeGLError(GL_INVALID_OPERATION, functionName, |
7001 "type FLOAT_32_UNSIGNED_INT_24_8_REV but " | 7005 "type FLOAT_32_UNSIGNED_INT_24_8_REV but " |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7522 } | 7526 } |
7523 | 7527 |
7524 String WebGLRenderingContextBase::ensureNotNull(const String& text) const { | 7528 String WebGLRenderingContextBase::ensureNotNull(const String& text) const { |
7525 if (text.isNull()) | 7529 if (text.isNull()) |
7526 return WTF::emptyString; | 7530 return WTF::emptyString; |
7527 return text; | 7531 return text; |
7528 } | 7532 } |
7529 | 7533 |
7530 WebGLRenderingContextBase::LRUImageBufferCache::LRUImageBufferCache( | 7534 WebGLRenderingContextBase::LRUImageBufferCache::LRUImageBufferCache( |
7531 int capacity) | 7535 int capacity) |
7532 : m_buffers(wrapArrayUnique(new std::unique_ptr<ImageBuffer>[ capacity ])), | 7536 : m_buffers(wrapArrayUnique(new std::unique_ptr<ImageBuffer>[capacity])), |
7533 m_capacity(capacity) {} | 7537 m_capacity(capacity) {} |
7534 | 7538 |
7535 ImageBuffer* WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer( | 7539 ImageBuffer* WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer( |
7536 const IntSize& size) { | 7540 const IntSize& size) { |
7537 int i; | 7541 int i; |
7538 for (i = 0; i < m_capacity; ++i) { | 7542 for (i = 0; i < m_capacity; ++i) { |
7539 ImageBuffer* buf = m_buffers[i].get(); | 7543 ImageBuffer* buf = m_buffers[i].get(); |
7540 if (!buf) | 7544 if (!buf) |
7541 break; | 7545 break; |
7542 if (buf->size() != size) | 7546 if (buf->size() != size) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7804 | 7808 |
7805 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7809 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7806 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7810 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7807 if (canvas()) | 7811 if (canvas()) |
7808 result.setHTMLCanvasElement(canvas()); | 7812 result.setHTMLCanvasElement(canvas()); |
7809 else | 7813 else |
7810 result.setOffscreenCanvas(offscreenCanvas()); | 7814 result.setOffscreenCanvas(offscreenCanvas()); |
7811 } | 7815 } |
7812 | 7816 |
7813 } // namespace blink | 7817 } // namespace blink |
OLD | NEW |