Files
brave-core/patches/third_party-blink-renderer-modules-webgl-webgl_rendering_context_base.cc.patch
T

173 lines
8.9 KiB
Diff

diff --git a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
index 172759394d7e02b5b4395e5bb9a16d4cd7591e79..f5f1688c038510c6faf0d947aea4870d994645d6 100644
--- a/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
+++ b/third_party/blink/renderer/modules/webgl/webgl_rendering_context_base.cc
@@ -3549,6 +3549,7 @@ WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(
GLuint index) {
if (!ValidateWebGLProgramOrShader("getActiveAttrib", program))
return nullptr;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLPTR
GLuint program_id = ObjectNonZero(program);
GLint max_name_length = -1;
ContextGL()->GetProgramiv(program_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH,
@@ -3580,6 +3581,7 @@ WebGLActiveInfo* WebGLRenderingContextBase::getActiveUniform(
GLuint index) {
if (!ValidateWebGLProgramOrShader("getActiveUniform", program))
return nullptr;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLPTR
GLuint program_id = ObjectNonZero(program);
GLint max_name_length = -1;
ContextGL()->GetProgramiv(program_id, GL_ACTIVE_UNIFORM_MAX_LENGTH,
@@ -3610,6 +3612,7 @@ std::optional<HeapVector<Member<WebGLShader>>>
WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program) {
if (!ValidateWebGLProgramOrShader("getAttachedShaders", program))
return std::nullopt;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLOPT
HeapVector<Member<WebGLShader>> shader_objects;
for (GLenum shaderType : {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER}) {
@@ -3624,6 +3627,7 @@ GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program,
const String& name) {
if (!ValidateWebGLProgramOrShader("getAttribLocation", program))
return -1;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_MINUS_ONE
if (!ValidateLocationLength("getAttribLocation", name))
return -1;
if (!ValidateString("getAttribLocation", name))
@@ -3659,6 +3663,7 @@ ScriptValue WebGLRenderingContextBase::getBufferParameter(
GLenum pname) {
if (isContextLost() || !ValidateBufferTarget("getBufferParameter", target))
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
switch (pname) {
case GL_BUFFER_USAGE: {
@@ -3798,6 +3803,7 @@ ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(
return ScriptValue::CreateNull(script_state->GetIsolate());
}
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!framebuffer_binding_ || !framebuffer_binding_->Object()) {
SynthesizeGLError(GL_INVALID_OPERATION, kFunctionName,
"no framebuffer bound");
@@ -4100,6 +4106,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state,
"invalid parameter name, OES_standard_derivatives not enabled");
return ScriptValue::CreateNull(script_state->GetIsolate());
case WebGLDebugRendererInfo::kUnmaskedRendererWebgl:
+ BRAVE_WEBGL_GET_PARAMETER_UNMASKED_RENDERER
if (ExtensionEnabled(kWebGLDebugRendererInfoName)) {
return WebGLAny(script_state,
String(ContextGL()->GetString(GL_RENDERER)));
@@ -4109,6 +4116,7 @@ ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* script_state,
"invalid parameter name, WEBGL_debug_renderer_info not enabled");
return ScriptValue::CreateNull(script_state->GetIsolate());
case WebGLDebugRendererInfo::kUnmaskedVendorWebgl:
+ BRAVE_WEBGL_GET_PARAMETER_UNMASKED_VENDOR
if (ExtensionEnabled(kWebGLDebugRendererInfoName)) {
return WebGLAny(script_state,
String(ContextGL()->GetString(GL_VENDOR)));
@@ -4238,6 +4246,7 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter(
// intended to prevent applications from entering an infinite polling loop.
if (isContextLost() && pname == GL_COMPLETION_STATUS_KHR)
return WebGLAny(script_state, true);
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!ValidateWebGLProgramOrShader("getProgramParamter", program)) {
return ScriptValue::CreateNull(script_state->GetIsolate());
}
@@ -4293,6 +4302,7 @@ ScriptValue WebGLRenderingContextBase::getProgramParameter(
String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) {
if (!ValidateWebGLProgramOrShader("getProgramInfoLog", program))
return String();
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_STRING
GLStringQuery query(ContextGL());
return query.Run<GLStringQuery::ProgramInfoLog>(ObjectNonZero(program));
}
@@ -4303,6 +4313,7 @@ ScriptValue WebGLRenderingContextBase::getRenderbufferParameter(
GLenum pname) {
if (isContextLost())
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (target != GL_RENDERBUFFER) {
SynthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter",
"invalid target");
@@ -4350,6 +4361,7 @@ ScriptValue WebGLRenderingContextBase::getShaderParameter(
// intended to prevent applications from entering an infinite polling loop.
if (isContextLost() && pname == GL_COMPLETION_STATUS_KHR)
return WebGLAny(script_state, true);
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!ValidateWebGLProgramOrShader("getShaderParameter", shader)) {
return ScriptValue::CreateNull(script_state->GetIsolate());
}
@@ -4381,6 +4393,7 @@ ScriptValue WebGLRenderingContextBase::getShaderParameter(
String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) {
if (!ValidateWebGLProgramOrShader("getShaderInfoLog", shader))
return String();
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_STRING
GLStringQuery query(ContextGL());
return query.Run<GLStringQuery::ShaderInfoLog>(ObjectNonZero(shader));
}
@@ -4411,6 +4424,7 @@ WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat(
GLint precision = 0;
ContextGL()->GetShaderPrecisionFormat(shader_type, precision_type, range,
&precision);
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_GETSHADERINFOLOG
return MakeGarbageCollected<WebGLShaderPrecisionFormat>(range[0], range[1],
precision);
}
@@ -4418,6 +4432,7 @@ WebGLShaderPrecisionFormat* WebGLRenderingContextBase::getShaderPrecisionFormat(
String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) {
if (!ValidateWebGLProgramOrShader("getShaderSource", shader))
return String();
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_STRING
return EnsureNotNull(shader->Source());
}
@@ -4443,6 +4458,7 @@ ScriptValue WebGLRenderingContextBase::getTexParameter(
GLenum pname) {
if (isContextLost())
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (!ValidateTextureBinding("getTexParameter", target))
return ScriptValue::CreateNull(script_state->GetIsolate());
switch (pname) {
@@ -4477,6 +4493,7 @@ ScriptValue WebGLRenderingContextBase::getUniform(
const WebGLUniformLocation* uniform_location) {
if (!ValidateWebGLProgramOrShader("getUniform", program))
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
DCHECK(uniform_location);
if (!ValidateUniformLocation("getUniform", uniform_location, program)) {
return ScriptValue::CreateNull(script_state->GetIsolate());
@@ -4730,6 +4747,7 @@ WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(
const String& name) {
if (!ValidateWebGLProgramOrShader("getUniformLocation", program))
return nullptr;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_NULLPTR
if (!ValidateLocationLength("getUniformLocation", name))
return nullptr;
if (!ValidateString("getUniformLocation", name))
@@ -4756,6 +4774,7 @@ ScriptValue WebGLRenderingContextBase::getVertexAttrib(
GLenum pname) {
if (isContextLost())
return ScriptValue::CreateNull(script_state->GetIsolate());
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_SCRIPT_VALUE
if (index >= max_vertex_attribs_) {
SynthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib",
"index out of range");
@@ -4830,6 +4849,7 @@ int64_t WebGLRenderingContextBase::getVertexAttribOffset(GLuint index,
GLenum pname) {
if (isContextLost())
return 0;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_ZERO
GLvoid* result = nullptr;
// NOTE: If pname is ever a value that returns more than 1 element
// this will corrupt memory.
@@ -5192,6 +5212,7 @@ void WebGLRenderingContextBase::ReadPixelsHelper(GLint x,
int64_t offset) {
if (isContextLost())
return;
+ BRAVE_WEBGL_RENDERING_CONTEXT_BASE_RETURN
// Due to WebGL's same-origin restrictions, it is not possible to
// taint the origin using the WebGL API.
DCHECK(Host()->OriginClean());