diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-29 11:06:39 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-29 13:26:42 +0000 |
commit | ce4d3b4e0a6050a81fec26b85abb8f6b86198fb2 (patch) | |
tree | 4bfbdb243883a552d44db02cd32ae48bf6bcb6d2 /chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp | |
parent | cf3a94e300853fc3620d1ac73922232da14e5919 (diff) | |
download | qtwebengine-chromium-ce4d3b4e0a6050a81fec26b85abb8f6b86198fb2.tar.gz |
[Backport] Implement 2D texture uploading from client array with FLIP_Y or PREMULTIPLY_ALPHA.
BUG=774174
TEST=https://github.com/KhronosGroup/WebGL/pull/2555
R=kbr@chromium.org
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/808665
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#522003}(cherry picked from commit 9b99a43fc119a2533a87e2357cad8f603779a7b9)
Reviewed-on: https://chromium-review.googlesource.com/814698
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/branch-heads/3282@{#75}
Cr-Branched-From: 5fdc0fab22ce7efd32532ee989b223fa12f8171e-refs/heads/master@{#520840}
(CVE-2018-6038)
Change-Id: I01bd0d359c985f1148128d17ea593f5d32e05943
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp index a025578e8cf..db33e27ad97 100644 --- a/chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp +++ b/chromium/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp @@ -4635,22 +4635,31 @@ void WebGLRenderingContextBase::TexImageHelperDOMArrayBufferView( data += src_offset * pixels->TypeSize(); } Vector<uint8_t> temp_data; - bool change_unpack_alignment = false; - if (data && (unpack_flip_y_ || unpack_premultiply_alpha_)) { - if (source_type == kTex2D) { - if (!WebGLImageConversion::ExtractTextureData( - width, height, format, type, unpack_alignment_, unpack_flip_y_, - unpack_premultiply_alpha_, data, temp_data)) { - SynthesizeGLError(GL_INVALID_OPERATION, func_name, - "Invalid format/type combination."); - return; - } - data = temp_data.data(); + bool change_unpack_params = false; + if (data && width && height && + (unpack_flip_y_ || unpack_premultiply_alpha_)) { + DCHECK_EQ(kTex2D, source_type); + // Only enter here if width or height is non-zero. Otherwise, call to the + // underlying driver to generate appropriate GL errors if needed. + WebGLImageConversion::PixelStoreParams unpack_params = + GetUnpackPixelStoreParams(kTex2D); + GLint data_store_width = + unpack_params.row_length ? unpack_params.row_length : width; + if (unpack_params.skip_pixels + width > data_store_width) { + SynthesizeGLError(GL_INVALID_OPERATION, func_name, + "Invalid unpack params combination."); + return; + } + if (!WebGLImageConversion::ExtractTextureData( + width, height, format, type, unpack_params, unpack_flip_y_, + unpack_premultiply_alpha_, data, temp_data)) { + SynthesizeGLError(GL_INVALID_OPERATION, func_name, + "Invalid format/type combination."); + return; } - change_unpack_alignment = true; + data = temp_data.data(); + change_unpack_params = true; } - // TODO(crbug.com/666064): implement flipY and premultiplyAlpha for - // tex(Sub)3D. if (function_id == kTexImage3D) { ContextGL()->TexImage3D(target, level, ConvertTexInternalFormat(internalformat, type), @@ -4664,7 +4673,7 @@ void WebGLRenderingContextBase::TexImageHelperDOMArrayBufferView( } ScopedUnpackParametersResetRestore temporary_reset_unpack( - this, change_unpack_alignment); + this, change_unpack_params); if (function_id == kTexImage2D) TexImage2DBase(target, level, internalformat, width, height, border, format, type, data); |