| 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 4986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4997 | 4997 |
| 4998 // Note that the sub-rectangle validation is needed for the GPU-GPU | 4998 // Note that the sub-rectangle validation is needed for the GPU-GPU |
| 4999 // copy case, but is redundant for the software upload case | 4999 // copy case, but is redundant for the software upload case |
| 5000 // (texImageImpl). | 5000 // (texImageImpl). |
| 5001 bool selectingSubRectangle = false; | 5001 bool selectingSubRectangle = false; |
| 5002 if (!validateTexImageSubRectangle( | 5002 if (!validateTexImageSubRectangle( |
| 5003 funcName, functionID, canvas, sourceSubRectangle, depth, | 5003 funcName, functionID, canvas, sourceSubRectangle, depth, |
| 5004 unpackImageHeight, &selectingSubRectangle)) { | 5004 unpackImageHeight, &selectingSubRectangle)) { |
| 5005 return; | 5005 return; |
| 5006 } | 5006 } |
| 5007 | 5007 bool forceRedundant2dCanvasCopy = |
| 5008 this->canvas() && this->canvas()->document().settings() && |
| 5009 this->canvas()->document().settings()->forceRedundant2dCanvasCopy(); |
| 5010 AccelerationHint hint; |
| 5011 if (forceRedundant2dCanvasCopy) |
| 5012 hint = PreferAccelerationWithExtraSurfaceCopy; |
| 5013 else |
| 5014 hint = PreferAcceleration; |
| 5008 if (functionID == TexImage2D || functionID == TexSubImage2D) { | 5015 if (functionID == TexImage2D || functionID == TexSubImage2D) { |
| 5009 // texImageByGPU relies on copyTextureCHROMIUM which doesn't support | 5016 // texImageByGPU relies on copyTextureCHROMIUM which doesn't support |
| 5010 // float/integer/sRGB internal format. | 5017 // float/integer/sRGB internal format. |
| 5011 // TODO(crbug.com/622958): relax the constrains if copyTextureCHROMIUM is | 5018 // TODO(crbug.com/622958): relax the constrains if copyTextureCHROMIUM is |
| 5012 // upgraded to handle more formats. | 5019 // upgraded to handle more formats. |
| 5013 if (!canvas->renderingContext() || | 5020 if (!canvas->renderingContext() || |
| 5014 !canvas->renderingContext()->isAccelerated() || | 5021 !canvas->renderingContext()->isAccelerated() || |
| 5015 !canUseTexImageByGPU(functionID, internalformat, type)) { | 5022 !canUseTexImageByGPU(functionID, internalformat, type)) { |
| 5016 // 2D canvas has only FrontBuffer. | 5023 // 2D canvas has only FrontBuffer. |
| 5017 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, | 5024 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, |
| 5018 zoffset, format, type, | 5025 zoffset, format, type, |
| 5019 canvas->copiedImage(FrontBuffer, PreferAcceleration).get(), | 5026 canvas->copiedImage(FrontBuffer, hint).get(), |
| 5020 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, | 5027 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, |
| 5021 m_unpackPremultiplyAlpha, sourceSubRectangle, 1, 0); | 5028 m_unpackPremultiplyAlpha, sourceSubRectangle, 1, 0); |
| 5022 return; | 5029 return; |
| 5023 } | 5030 } |
| 5024 | 5031 |
| 5025 // The GPU-GPU copy path uses the Y-up coordinate system. | 5032 // The GPU-GPU copy path uses the Y-up coordinate system. |
| 5026 IntRect adjustedSourceSubRectangle = sourceSubRectangle; | 5033 IntRect adjustedSourceSubRectangle = sourceSubRectangle; |
| 5027 if (!m_unpackFlipY) { | 5034 if (!m_unpackFlipY) { |
| 5028 adjustedSourceSubRectangle.setY(canvas->height() - | 5035 adjustedSourceSubRectangle.setY(canvas->height() - |
| 5029 adjustedSourceSubRectangle.maxY()); | 5036 adjustedSourceSubRectangle.maxY()); |
| 5030 } | 5037 } |
| 5031 | 5038 |
| 5032 if (functionID == TexImage2D) { | 5039 if (functionID == TexImage2D) { |
| 5033 texImage2DBase(target, level, internalformat, sourceSubRectangle.width(), | 5040 texImage2DBase(target, level, internalformat, sourceSubRectangle.width(), |
| 5034 sourceSubRectangle.height(), 0, format, type, 0); | 5041 sourceSubRectangle.height(), 0, format, type, 0); |
| 5035 texImageByGPU(TexImage2DByGPU, texture, target, level, internalformat, | 5042 texImageByGPU(TexImage2DByGPU, texture, target, level, internalformat, |
| 5036 type, 0, 0, 0, canvas, adjustedSourceSubRectangle); | 5043 type, 0, 0, 0, canvas, adjustedSourceSubRectangle); |
| 5037 } else { | 5044 } else { |
| 5038 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, type, | 5045 texImageByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, type, |
| 5039 xoffset, yoffset, 0, canvas, adjustedSourceSubRectangle); | 5046 xoffset, yoffset, 0, canvas, adjustedSourceSubRectangle); |
| 5040 } | 5047 } |
| 5041 } else { | 5048 } else { |
| 5042 // 3D functions. | 5049 // 3D functions. |
| 5043 | 5050 |
| 5044 // TODO(zmo): Implement GPU-to-GPU copy path (crbug.com/612542). | 5051 // TODO(zmo): Implement GPU-to-GPU copy path (crbug.com/612542). |
| 5045 // Note that code will also be needed to copy to layers of 3D | 5052 // Note that code will also be needed to copy to layers of 3D |
| 5046 // textures, and elements of 2D texture arrays. | 5053 // textures, and elements of 2D texture arrays. |
| 5047 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, | 5054 texImageImpl( |
| 5048 zoffset, format, type, | 5055 functionID, target, level, internalformat, xoffset, yoffset, zoffset, |
| 5049 canvas->copiedImage(FrontBuffer, PreferAcceleration).get(), | 5056 format, type, canvas->copiedImage(FrontBuffer, hint).get(), |
| 5050 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, | 5057 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, |
| 5051 m_unpackPremultiplyAlpha, sourceSubRectangle, depth, | 5058 m_unpackPremultiplyAlpha, sourceSubRectangle, depth, unpackImageHeight); |
| 5052 unpackImageHeight); | |
| 5053 } | 5059 } |
| 5054 } | 5060 } |
| 5055 | 5061 |
| 5056 void WebGLRenderingContextBase::texImage2D(GLenum target, | 5062 void WebGLRenderingContextBase::texImage2D(GLenum target, |
| 5057 GLint level, | 5063 GLint level, |
| 5058 GLint internalformat, | 5064 GLint internalformat, |
| 5059 GLenum format, | 5065 GLenum format, |
| 5060 GLenum type, | 5066 GLenum type, |
| 5061 HTMLCanvasElement* canvas, | 5067 HTMLCanvasElement* canvas, |
| 5062 ExceptionState& exceptionState) { | 5068 ExceptionState& exceptionState) { |
| (...skipping 2651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7714 | 7720 |
| 7715 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7721 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7716 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7722 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7717 if (canvas()) | 7723 if (canvas()) |
| 7718 result.setHTMLCanvasElement(canvas()); | 7724 result.setHTMLCanvasElement(canvas()); |
| 7719 else | 7725 else |
| 7720 result.setOffscreenCanvas(getOffscreenCanvas()); | 7726 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7721 } | 7727 } |
| 7722 | 7728 |
| 7723 } // namespace blink | 7729 } // namespace blink |
| OLD | NEW |