Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2485443002: Change WebGL API arg nullable behavior. (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 return; 1852 return;
1853 } 1853 }
1854 bufferDataImpl(target, data->byteLength(), data->data(), usage); 1854 bufferDataImpl(target, data->byteLength(), data->data(), usage);
1855 } 1855 }
1856 1856
1857 void WebGLRenderingContextBase::bufferData(GLenum target, 1857 void WebGLRenderingContextBase::bufferData(GLenum target,
1858 DOMArrayBufferView* data, 1858 DOMArrayBufferView* data,
1859 GLenum usage) { 1859 GLenum usage) {
1860 if (isContextLost()) 1860 if (isContextLost())
1861 return; 1861 return;
1862 if (!data) { 1862 DCHECK(data);
1863 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data");
1864 return;
1865 }
1866 bufferDataImpl(target, data->byteLength(), data->baseAddress(), usage); 1863 bufferDataImpl(target, data->byteLength(), data->baseAddress(), usage);
1867 } 1864 }
1868 1865
1869 void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target, 1866 void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target,
1870 long long offset, 1867 long long offset,
1871 GLsizeiptr size, 1868 GLsizeiptr size,
1872 const void* data) { 1869 const void* data) {
1873 WebGLBuffer* buffer = validateBufferDataTarget("bufferSubData", target); 1870 WebGLBuffer* buffer = validateBufferDataTarget("bufferSubData", target);
1874 if (!buffer) 1871 if (!buffer)
1875 return; 1872 return;
1876 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) 1873 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset))
1877 return; 1874 return;
1878 if (!data) 1875 if (!data)
1879 return; 1876 return;
1880 if (offset + static_cast<long long>(size) > buffer->getSize()) { 1877 if (offset + static_cast<long long>(size) > buffer->getSize()) {
1881 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "buffer overflow"); 1878 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "buffer overflow");
1882 return; 1879 return;
1883 } 1880 }
1884 1881
1885 contextGL()->BufferSubData(target, static_cast<GLintptr>(offset), size, data); 1882 contextGL()->BufferSubData(target, static_cast<GLintptr>(offset), size, data);
1886 } 1883 }
1887 1884
1888 void WebGLRenderingContextBase::bufferSubData(GLenum target, 1885 void WebGLRenderingContextBase::bufferSubData(GLenum target,
1889 long long offset, 1886 long long offset,
1890 DOMArrayBuffer* data) { 1887 DOMArrayBuffer* data) {
1891 if (isContextLost()) 1888 if (isContextLost())
1892 return; 1889 return;
1893 if (!data) { 1890 DCHECK(data);
1894 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "no data");
1895 return;
1896 }
1897 bufferSubDataImpl(target, offset, data->byteLength(), data->data()); 1891 bufferSubDataImpl(target, offset, data->byteLength(), data->data());
1898 } 1892 }
1899 1893
1900 void WebGLRenderingContextBase::bufferSubData( 1894 void WebGLRenderingContextBase::bufferSubData(
1901 GLenum target, 1895 GLenum target,
1902 long long offset, 1896 long long offset,
1903 const FlexibleArrayBufferView& data) { 1897 const FlexibleArrayBufferView& data) {
1904 if (isContextLost()) 1898 if (isContextLost())
1905 return; 1899 return;
1906 if (!data) { 1900 DCHECK(data);
1907 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "no data");
1908 return;
1909 }
1910 bufferSubDataImpl(target, offset, data.byteLength(), 1901 bufferSubDataImpl(target, offset, data.byteLength(),
1911 data.baseAddressMaybeOnStack()); 1902 data.baseAddressMaybeOnStack());
1912 } 1903 }
1913 1904
1914 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) { 1905 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) {
1915 if (target == GL_FRAMEBUFFER) 1906 if (target == GL_FRAMEBUFFER)
1916 return true; 1907 return true;
1917 return false; 1908 return false;
1918 } 1909 }
1919 1910
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 synthesizeGLError(GL_INVALID_OPERATION, functionName, 2381 synthesizeGLError(GL_INVALID_OPERATION, functionName,
2391 "no valid shader program in use"); 2382 "no valid shader program in use");
2392 return false; 2383 return false;
2393 } 2384 }
2394 2385
2395 return true; 2386 return true;
2396 } 2387 }
2397 2388
2398 bool WebGLRenderingContextBase::validateWebGLObject(const char* functionName, 2389 bool WebGLRenderingContextBase::validateWebGLObject(const char* functionName,
2399 WebGLObject* object) { 2390 WebGLObject* object) {
2400 if (!object || !object->hasObject()) { 2391 DCHECK(object);
2392 if (!object->hasObject()) {
2401 synthesizeGLError(GL_INVALID_VALUE, functionName, 2393 synthesizeGLError(GL_INVALID_VALUE, functionName,
2402 "no object or object deleted"); 2394 "no object or object deleted");
2403 return false; 2395 return false;
2404 } 2396 }
2405 if (!object->validate(contextGroup(), this)) { 2397 if (!object->validate(contextGroup(), this)) {
2406 synthesizeGLError(GL_INVALID_OPERATION, functionName, 2398 synthesizeGLError(GL_INVALID_OPERATION, functionName,
2407 "object does not belong to this context"); 2399 "object does not belong to this context");
2408 return false; 2400 return false;
2409 } 2401 }
2410 return true; 2402 return true;
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 return ScriptValue::createNull(scriptState); 3406 return ScriptValue::createNull(scriptState);
3415 } 3407 }
3416 } 3408 }
3417 3409
3418 ScriptValue WebGLRenderingContextBase::getUniform( 3410 ScriptValue WebGLRenderingContextBase::getUniform(
3419 ScriptState* scriptState, 3411 ScriptState* scriptState,
3420 WebGLProgram* program, 3412 WebGLProgram* program,
3421 const WebGLUniformLocation* uniformLocation) { 3413 const WebGLUniformLocation* uniformLocation) {
3422 if (isContextLost() || !validateWebGLObject("getUniform", program)) 3414 if (isContextLost() || !validateWebGLObject("getUniform", program))
3423 return ScriptValue::createNull(scriptState); 3415 return ScriptValue::createNull(scriptState);
3424 if (!uniformLocation || uniformLocation->program() != program) { 3416 DCHECK(uniformLocation);
3417 if (uniformLocation->program() != program) {
3425 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", 3418 synthesizeGLError(GL_INVALID_OPERATION, "getUniform",
3426 "no uniformlocation or not valid for this program"); 3419 "no uniformlocation or not valid for this program");
3427 return ScriptValue::createNull(scriptState); 3420 return ScriptValue::createNull(scriptState);
3428 } 3421 }
3429 GLint location = uniformLocation->location(); 3422 GLint location = uniformLocation->location();
3430 3423
3431 GLuint programId = objectNonZero(program); 3424 GLuint programId = objectNonZero(program);
3432 GLint maxNameLength = -1; 3425 GLint maxNameLength = -1;
3433 contextGL()->GetProgramiv(programId, GL_ACTIVE_UNIFORM_MAX_LENGTH, 3426 contextGL()->GetProgramiv(programId, GL_ACTIVE_UNIFORM_MAX_LENGTH,
3434 &maxNameLength); 3427 &maxNameLength);
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
4685 GLenum format, 4678 GLenum format,
4686 GLenum type, 4679 GLenum type,
4687 GLsizei depth, 4680 GLsizei depth,
4688 GLint xoffset, 4681 GLint xoffset,
4689 GLint yoffset, 4682 GLint yoffset,
4690 GLint zoffset, 4683 GLint zoffset,
4691 ImageData* pixels) { 4684 ImageData* pixels) {
4692 const char* funcName = getTexImageFunctionName(functionID); 4685 const char* funcName = getTexImageFunctionName(functionID);
4693 if (isContextLost()) 4686 if (isContextLost())
4694 return; 4687 return;
4695 if (!pixels) { 4688 DCHECK(pixels);
4696 synthesizeGLError(GL_INVALID_VALUE, funcName, "no image data");
4697 return;
4698 }
4699 if (pixels->data()->bufferBase()->isNeutered()) { 4689 if (pixels->data()->bufferBase()->isNeutered()) {
4700 synthesizeGLError(GL_INVALID_VALUE, funcName, 4690 synthesizeGLError(GL_INVALID_VALUE, funcName,
4701 "The source data has been neutered."); 4691 "The source data has been neutered.");
4702 return; 4692 return;
4703 } 4693 }
4704 if (!validateTexImageBinding(funcName, functionID, target)) 4694 if (!validateTexImageBinding(funcName, functionID, target))
4705 return; 4695 return;
4706 TexImageFunctionType functionType; 4696 TexImageFunctionType functionType;
4707 if (functionID == TexImage2D) 4697 if (functionID == TexImage2D)
4708 functionType = TexImage; 4698 functionType = TexImage;
(...skipping 2920 matching lines...) Expand 10 before | Expand all | Expand 10 after
7629 7619
7630 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7620 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7631 HTMLCanvasElementOrOffscreenCanvas& result) const { 7621 HTMLCanvasElementOrOffscreenCanvas& result) const {
7632 if (canvas()) 7622 if (canvas())
7633 result.setHTMLCanvasElement(canvas()); 7623 result.setHTMLCanvasElement(canvas());
7634 else 7624 else
7635 result.setOffscreenCanvas(getOffscreenCanvas()); 7625 result.setOffscreenCanvas(getOffscreenCanvas());
7636 } 7626 }
7637 7627
7638 } // namespace blink 7628 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698