OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/webgl/WebGL2RenderingContextBase.h" | 5 #include "modules/webgl/WebGL2RenderingContextBase.h" |
6 | 6 |
7 #include "bindings/modules/v8/WebGLAny.h" | 7 #include "bindings/modules/v8/WebGLAny.h" |
8 #include "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
11 #include "core/html/HTMLVideoElement.h" | 11 #include "core/html/HTMLVideoElement.h" |
12 #include "core/html/ImageData.h" | 12 #include "core/html/ImageData.h" |
13 #include "gpu/command_buffer/client/gles2_interface.h" | 13 #include "gpu/command_buffer/client/gles2_interface.h" |
14 #include "modules/webgl/WebGLActiveInfo.h" | 14 #include "modules/webgl/WebGLActiveInfo.h" |
15 #include "modules/webgl/WebGLBuffer.h" | 15 #include "modules/webgl/WebGLBuffer.h" |
16 #include "modules/webgl/WebGLFenceSync.h" | 16 #include "modules/webgl/WebGLFenceSync.h" |
17 #include "modules/webgl/WebGLFramebuffer.h" | 17 #include "modules/webgl/WebGLFramebuffer.h" |
18 #include "modules/webgl/WebGLProgram.h" | 18 #include "modules/webgl/WebGLProgram.h" |
19 #include "modules/webgl/WebGLQuery.h" | 19 #include "modules/webgl/WebGLQuery.h" |
20 #include "modules/webgl/WebGLRenderbuffer.h" | 20 #include "modules/webgl/WebGLRenderbuffer.h" |
21 #include "modules/webgl/WebGLSampler.h" | 21 #include "modules/webgl/WebGLSampler.h" |
22 #include "modules/webgl/WebGLSync.h" | 22 #include "modules/webgl/WebGLSync.h" |
23 #include "modules/webgl/WebGLTexture.h" | 23 #include "modules/webgl/WebGLTexture.h" |
24 #include "modules/webgl/WebGLTransformFeedback.h" | 24 #include "modules/webgl/WebGLTransformFeedback.h" |
25 #include "modules/webgl/WebGLUniformLocation.h" | 25 #include "modules/webgl/WebGLUniformLocation.h" |
26 #include "modules/webgl/WebGLVertexArrayObject.h" | 26 #include "modules/webgl/WebGLVertexArrayObject.h" |
27 #include "platform/CheckedInt.h" | |
28 #include "public/platform/WebGraphicsContext3DProvider.h" | 27 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 28 #include "wtf/CheckedNumeric.h" |
29 #include "wtf/PtrUtil.h" | 29 #include "wtf/PtrUtil.h" |
30 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
31 #include <memory> | 31 #include <memory> |
32 | 32 |
33 using WTF::String; | 33 using WTF::String; |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
(...skipping 12 matching lines...) Expand all Loading... |
51 long long byteLength = 0; | 51 long long byteLength = 0; |
52 if (subLength) { | 52 if (subLength) { |
53 // type size is at most 8, so no overflow. | 53 // type size is at most 8, so no overflow. |
54 byteLength = subLength * typeSize; | 54 byteLength = subLength * typeSize; |
55 } | 55 } |
56 long long byteOffset = 0; | 56 long long byteOffset = 0; |
57 if (subOffset) { | 57 if (subOffset) { |
58 // type size is at most 8, so no overflow. | 58 // type size is at most 8, so no overflow. |
59 byteOffset = subOffset * typeSize; | 59 byteOffset = subOffset * typeSize; |
60 } | 60 } |
61 CheckedInt<long long> total = byteOffset; | 61 CheckedNumeric<long long> total = byteOffset; |
62 total += byteLength; | 62 total += byteLength; |
63 if (!total.isValid() || total.value() > view->byteLength()) { | 63 if (!total.IsValid() || total.ValueOrDie() > view->byteLength()) { |
64 return false; | 64 return false; |
65 } | 65 } |
66 if (!byteLength) { | 66 if (!byteLength) { |
67 byteLength = view->byteLength() - byteOffset; | 67 byteLength = view->byteLength() - byteOffset; |
68 } | 68 } |
69 uint8_t* data = static_cast<uint8_t*>(view->baseAddress()); | 69 uint8_t* data = static_cast<uint8_t*>(view->baseAddress()); |
70 data += byteOffset; | 70 data += byteOffset; |
71 *outBaseAddress = data; | 71 *outBaseAddress = data; |
72 *outByteLength = byteLength; | 72 *outByteLength = byteLength; |
73 return true; | 73 return true; |
(...skipping 3576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 params.skipPixels = m_unpackSkipPixels; | 3650 params.skipPixels = m_unpackSkipPixels; |
3651 params.skipRows = m_unpackSkipRows; | 3651 params.skipRows = m_unpackSkipRows; |
3652 if (dimension == Tex3D) { | 3652 if (dimension == Tex3D) { |
3653 params.imageHeight = m_unpackImageHeight; | 3653 params.imageHeight = m_unpackImageHeight; |
3654 params.skipImages = m_unpackSkipImages; | 3654 params.skipImages = m_unpackSkipImages; |
3655 } | 3655 } |
3656 return params; | 3656 return params; |
3657 } | 3657 } |
3658 | 3658 |
3659 } // namespace blink | 3659 } // namespace blink |
OLD | NEW |