Commit 6e2439b1 authored by thakis's avatar thakis Committed by Commit bot

reflow comments in modules/webgl

BUG=563793
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2389203002
Cr-Commit-Position: refs/heads/master@{#422803}
parent 41b43609
......@@ -143,7 +143,8 @@ void EXTDisjointTimerQuery::queryCounterEXT(WebGLTimerQueryEXT* query,
return;
}
// Timestamps are disabled in WebGL due to lack of driver support on multiple platforms, so we don't actually perform a GL call
// Timestamps are disabled in WebGL due to lack of driver support on multiple
// platforms, so we don't actually perform a GL call.
query->setTarget(target);
query->resetCachedResult();
}
......
......@@ -473,8 +473,9 @@ void WebGL2RenderingContextBase::framebufferTextureLayer(GLenum target,
objectOrZero(texture), level, layer);
}
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
// On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT + STENCIL_ATTACHMENT.
// We divide it here so in WebGLFramebuffer, we don't have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
// On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT +
// STENCIL_ATTACHMENT. We divide it here so in WebGLFramebuffer, we don't
// have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
framebufferBinding->setAttachmentForBoundFramebuffer(
target, GL_DEPTH_ATTACHMENT, textarget, texture, level, layer);
framebufferBinding->setAttachmentForBoundFramebuffer(
......@@ -505,7 +506,8 @@ ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(
// though GL_RGB and GL_RGBA are color-renderable.
case GL_RGB:
case GL_RGBA:
// Multisampling is not supported for signed and unsigned integer internal formats.
// Multisampling is not supported for signed and unsigned integer internal
// formats.
case GL_R8UI:
case GL_R8I:
case GL_R16UI:
......@@ -597,8 +599,8 @@ bool WebGL2RenderingContextBase::checkAndTranslateAttachments(
WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
ASSERT(framebufferBinding || drawingBuffer());
if (!framebufferBinding) {
// For the default framebuffer
// Translate GL_COLOR/GL_DEPTH/GL_STENCIL, because the default framebuffer of WebGL is not fb 0, it is an internal fbo
// For the default framebuffer, translate GL_COLOR/GL_DEPTH/GL_STENCIL.
// The default framebuffer of WebGL is not fb 0, it is an internal fbo.
for (size_t i = 0; i < attachments.size(); ++i) {
switch (attachments[i]) {
case GL_COLOR:
......@@ -806,8 +808,9 @@ void WebGL2RenderingContextBase::readPixels(GLint x,
}
long long size = buffer->getSize() - offset;
// If size is negative, or size is not large enough to store pixels, those cases
// are handled by validateReadPixelsFuncParameters to generate INVALID_OPERATION.
// If size is negative, or size is not large enough to store pixels, those
// cases are handled by validateReadPixelsFuncParameters to generate
// INVALID_OPERATION.
if (!validateReadPixelsFuncParameters(width, height, format, type, nullptr,
size))
return;
......@@ -2354,7 +2357,8 @@ void WebGL2RenderingContextBase::drawBuffers(const Vector<GLenum>& buffers) {
synthesizeGLError(GL_INVALID_OPERATION, "drawBuffers", "BACK or NONE");
return;
}
// Because the backbuffer is simulated on all current WebKit ports, we need to change BACK to COLOR_ATTACHMENT0.
// Because the backbuffer is simulated on all current WebKit ports, we need
// to change BACK to COLOR_ATTACHMENT0.
GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE;
contextGL()->DrawBuffersEXT(1, &value);
setBackDrawBuffer(bufs[0]);
......@@ -4135,7 +4139,8 @@ ScriptValue WebGL2RenderingContextBase::getFramebufferAttachmentParameter(
// Default framebuffer (an internal fbo)
if (!framebufferBinding) {
// We can use creationAttributes() because in WebGL 2, they are required to be honored.
// We can use creationAttributes() because in WebGL 2, they are required to
// be honored.
bool hasDepth = creationAttributes().depth();
bool hasStencil = creationAttributes().stencil();
bool hasAlpha = creationAttributes().alpha();
......
......@@ -30,8 +30,9 @@ class WebGL2RenderingContextBase : public WebGLRenderingContextBase {
/* Buffer objects */
void bufferData(GLenum, DOMArrayBufferView*, GLenum, GLuint, GLuint);
void bufferSubData(GLenum, GLintptr, DOMArrayBufferView*, GLuint, GLuint);
// Have to re-declare/re-define the following buffer{Sub}Data functions from base class.
// This is because the above buffer{Sub}Data() hides the name from base class.
// Have to re-declare/re-define the following buffer{Sub}Data functions from
// base class. This is because the above buffer{Sub}Data() hides the name
// from base class.
void bufferData(GLenum target, long long size, GLenum usage);
void bufferData(GLenum target, DOMArrayBuffer* data, GLenum usage);
void bufferData(GLenum target, DOMArrayBufferView* data, GLenum usage);
......@@ -212,8 +213,9 @@ class WebGL2RenderingContextBase : public WebGLRenderingContextBase {
DOMArrayBufferView*,
GLuint);
// Have to re-declare/re-define the following tex{Sub}Image2D functions from base class.
// This is because the above tex{Sub}Image2D() hides the name from base class.
// Have to re-declare/re-define the following tex{Sub}Image2D functions from
// base class. This is because the above tex{Sub}Image2D() hides the name
// from base class.
void texImage2D(GLenum, GLint, GLint, GLenum, GLenum, ImageData*);
void texImage2D(GLenum,
GLint,
......@@ -725,8 +727,9 @@ class WebGL2RenderingContextBase : public WebGLRenderingContextBase {
std::unique_ptr<WebGraphicsContext3DProvider>,
const CanvasContextCreationAttributes& requestedAttributes);
// Helper function to validate target and the attachment combination for getFramebufferAttachmentParameters.
// Generate GL error and return false if parameters are illegal.
// Helper function to validate target and the attachment combination for
// getFramebufferAttachmentParameters. Generate GL error and return false if
// parameters are illegal.
bool validateGetFramebufferAttachmentParameterFunc(const char* functionName,
GLenum target,
GLenum attachment);
......
......@@ -62,7 +62,8 @@ bool WebGLCompressedTextureASTC::supported(WebGLRenderingContextBase* context) {
}
const char* WebGLCompressedTextureASTC::extensionName() {
// TODO(cyzero.kim): implement extension for GL_KHR_texture_compression_astc_hdr.
// TODO(cyzero.kim): implement extension for
// GL_KHR_texture_compression_astc_hdr.
return "WEBGL_compressed_texture_astc";
}
......
......@@ -74,8 +74,8 @@ void WebGLContextGroup::detachAndRemoveAllObjects() {
void WebGLContextGroup::loseContextGroup(
WebGLRenderingContextBase::LostContextMode mode,
WebGLRenderingContextBase::AutoRecoveryMethod autoRecoveryMethod) {
// Detach must happen before loseContextImpl, which destroys the GraphicsContext3D
// and prevents groupObjects from being properly deleted.
// Detach must happen before loseContextImpl, which destroys the
// GraphicsContext3D and prevents groupObjects from being properly deleted.
detachAndRemoveAllObjects();
for (WebGLRenderingContextBase* const context : m_contexts)
......
......@@ -74,7 +74,8 @@ void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GLenum>& buffers) {
"drawBuffersWEBGL", "BACK or NONE");
return;
}
// Because the backbuffer is simulated on all current WebKit ports, we need to change BACK to COLOR_ATTACHMENT0.
// Because the backbuffer is simulated on all current WebKit ports, we need
// to change BACK to COLOR_ATTACHMENT0.
GLenum value = (bufs[0] == GL_BACK) ? GL_COLOR_ATTACHMENT0 : GL_NONE;
scoped.context()->contextGL()->DrawBuffersEXT(1, &value);
scoped.context()->setBackDrawBuffer(bufs[0]);
......@@ -168,8 +169,8 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(
GL_TEXTURE_2D, 0, 0);
}
if (supportsDepthStencil) {
// For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we emulate it
// at the command buffer level for WebGL contexts.
// For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we
// emulate it at the command buffer level for WebGL contexts.
gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, depthStencil, 0);
if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) !=
......
......@@ -82,12 +82,14 @@ class WebGLFramebuffer final : public WebGLContextObject {
WebGLRenderbuffer*);
// If an object is attached to the currently bound framebuffer, remove it.
void removeAttachmentFromBoundFramebuffer(GLenum target, WebGLSharedObject*);
// If a given attachment point for the currently bound framebuffer is not null, remove the attached object.
// If a given attachment point for the currently bound framebuffer is not
// null, remove the attached object.
void removeAttachmentFromBoundFramebuffer(GLenum target, GLenum attachment);
WebGLSharedObject* getAttachmentObject(GLenum) const;
// WebGL 1 specific:
// 1) can't allow depth_stencil for depth/stencil attachments, and vice versa.
// 1) can't allow depth_stencil for depth/stencil attachments, and vice
// versa.
// 2) no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments.
GLenum checkDepthStencilStatus(const char** reason) const;
......@@ -126,7 +128,8 @@ class WebGLFramebuffer final : public WebGLContextObject {
// attach 'attachment' at 'attachmentPoint'.
void attach(GLenum target, GLenum attachment, GLenum attachmentPoint);
// Check if a new drawBuffers call should be issued. This is called when we add or remove an attachment.
// Check if a new drawBuffers call should be issued. This is called when we
// add or remove an attachment.
void drawBuffersIfNecessary(bool force);
GLuint m_object;
......
......@@ -649,8 +649,9 @@ WebGLRenderingContextBase::createWebGraphicsContext3DProvider(
}
Settings* settings = frame->settings();
// The FrameLoaderClient might block creation of a new WebGL context despite the page settings; in
// particular, if WebGL contexts were lost one or more times via the GL_ARB_robustness extension.
// The FrameLoaderClient might block creation of a new WebGL context despite
// the page settings; in particular, if WebGL contexts were lost one or more
// times via the GL_ARB_robustness extension.
if (!frame->loader().client()->allowWebGL(settings &&
settings->webGLEnabled())) {
canvas->dispatchEvent(WebGLContextEvent::create(
......@@ -700,7 +701,8 @@ void WebGLRenderingContextBase::commit(ExceptionState& exceptionState) {
}
if (!drawingBuffer())
return;
// TODO(crbug.com/646864): Make commit() work correctly with { preserveDrawingBuffer : true }.
// TODO(crbug.com/646864): Make commit() work correctly with
// { preserveDrawingBuffer : true }.
getOffscreenCanvas()->getOrCreateFrameDispatcher()->dispatchFrame(
std::move(drawingBuffer()->transferToStaticBitmapImage()));
}
......@@ -722,8 +724,9 @@ PassRefPtr<Image> WebGLRenderingContextBase::getImage(
std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface));
if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(),
BackBuffer)) {
// copyRenderingResultsFromDrawingBuffer is expected to always succeed because we've
// explicitly created an Accelerated surface and have already validated it.
// copyRenderingResultsFromDrawingBuffer is expected to always succeed
// because we've explicitly created an Accelerated surface and have already
// validated it.
NOTREACHED();
return nullptr;
}
......@@ -1154,7 +1157,8 @@ void WebGLRenderingContextBase::initializeNewContext() {
if (isWebGL2OrHigher())
contextGL()->Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
// This ensures that the context has a valid "lastFlushID" and won't be mistakenly identified as the "least recently used" context.
// This ensures that the context has a valid "lastFlushID" and won't be
// mistakenly identified as the "least recently used" context.
contextGL()->Flush();
for (int i = 0; i < WebGLExtensionNameCount; ++i)
......@@ -1210,7 +1214,8 @@ void WebGLRenderingContextBase::removeAllCompressedTextureFormats() {
m_compressedTextureFormats.clear();
}
// Helper function for V8 bindings to identify what version of WebGL a CanvasRenderingContext supports.
// Helper function for V8 bindings to identify what version of WebGL a
// CanvasRenderingContext supports.
unsigned WebGLRenderingContextBase::getWebGLVersion(
const CanvasRenderingContext* context) {
if (!context->is3d())
......@@ -1220,7 +1225,8 @@ unsigned WebGLRenderingContextBase::getWebGLVersion(
WebGLRenderingContextBase::~WebGLRenderingContextBase() {
// Remove all references to WebGLObjects so if they are the last reference
// they will be freed before the last context is removed from the context group.
// they will be freed before the last context is removed from the context
// group.
m_boundArrayBuffer = nullptr;
m_defaultVertexArrayObject = nullptr;
m_boundVertexArrayObject = nullptr;
......@@ -1229,8 +1235,9 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase() {
m_renderbufferBinding = nullptr;
// WebGLTexture shared objects will be detached and deleted
// m_contextGroup->removeContext(this), which will bring about deleteTexture() calls.
// We null these out to avoid accessing those members in deleteTexture().
// m_contextGroup->removeContext(this), which will bring about deleteTexture()
// calls. We null these out to avoid accessing those members in
// deleteTexture().
for (size_t i = 0; i < m_textureUnits.size(); ++i) {
m_textureUnits[i].m_texture2DBinding = nullptr;
m_textureUnits[i].m_textureCubeMapBinding = nullptr;
......@@ -1327,7 +1334,8 @@ WebGLRenderingContextBase::clearIfComposited(GLbitfield mask) {
return Skipped;
}
// Determine if it's possible to combine the clear the user asked for and this clear.
// Determine if it's possible to combine the clear the user asked for and this
// clear.
bool combinedClear = mask && !m_scissorEnabled;
contextGL()->Disable(GL_SCISSOR_TEST);
......@@ -1425,9 +1433,10 @@ bool WebGLRenderingContextBase::paintRenderingResultsToCanvas(
drawingBuffer()->commit();
if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(
drawingBuffer(), sourceBuffer)) {
// Currently, copyRenderingResultsFromDrawingBuffer is expected to always succeed because cases
// where canvas()-buffer() is not accelerated are handle before reaching this point.
// If that assumption ever stops holding true, we may need to implement a fallback right here.
// Currently, copyRenderingResultsFromDrawingBuffer is expected to always
// succeed because cases where canvas()-buffer() is not accelerated are
// handle before reaching this point. If that assumption ever stops holding
// true, we may need to implement a fallback right here.
ASSERT_NOT_REACHED();
return false;
}
......@@ -1466,29 +1475,31 @@ void WebGLRenderingContextBase::reshape(int width, int height) {
contextGL()->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
// This is an approximation because at WebGLRenderingContextBase level we don't
// know if the underlying FBO uses textures or renderbuffers.
// This is an approximation because at WebGLRenderingContextBase level we
// don't know if the underlying FBO uses textures or renderbuffers.
GLint maxSize = std::min(m_maxTextureSize, m_maxRenderbufferSize);
GLint maxWidth = std::min(maxSize, m_maxViewportDims[0]);
GLint maxHeight = std::min(maxSize, m_maxViewportDims[1]);
width = clamp(width, 1, maxWidth);
height = clamp(height, 1, maxHeight);
// Limit drawing buffer area to 4k*4k to avoid memory exhaustion. Width or height may be larger than
// 4k as long as it's within the max viewport dimensions and total area remains within the limit.
// Limit drawing buffer area to 4k*4k to avoid memory exhaustion. Width or
// height may be larger than 4k as long as it's within the max viewport
// dimensions and total area remains within the limit.
// For example: 5120x2880 should be fine.
const int maxArea = 4096 * 4096;
int currentArea = width * height;
if (currentArea > maxArea) {
// If we've exceeded the area limit scale the buffer down, preserving ascpect ratio, until it fits.
// If we've exceeded the area limit scale the buffer down, preserving
// ascpect ratio, until it fits.
float scaleFactor =
sqrtf(static_cast<float>(maxArea) / static_cast<float>(currentArea));
width = std::max(1, static_cast<int>(width * scaleFactor));
height = std::max(1, static_cast<int>(height * scaleFactor));
}
// We don't have to mark the canvas as dirty, since the newly created image buffer will also start off
// clear (and this matches what reshape will do).
// We don't have to mark the canvas as dirty, since the newly created image
// buffer will also start off clear (and this matches what reshape will do).
drawingBuffer()->reset(IntSize(width, height));
restoreStateAfterClear();
......@@ -1701,7 +1712,8 @@ void WebGLRenderingContextBase::bindTexture(GLenum target,
m_onePlusMaxNonDefaultTextureUnit =
max(m_activeTextureUnit + 1, m_onePlusMaxNonDefaultTextureUnit);
} else {
// If the disabled index is the current maximum, trace backwards to find the new max enabled texture index
// If the disabled index is the current maximum, trace backwards to find the
// new max enabled texture index
if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) {
findNewMaxNonDefaultTextureUnit();
}
......@@ -1912,12 +1924,13 @@ void WebGLRenderingContextBase::clear(GLbitfield mask) {
m_drawingBuffer.get());
if (clearIfComposited(mask) != CombinedClear) {
// If clearing the default back buffer's depth buffer, also clear the stencil buffer, if one
// was allocated implicitly. This avoids performance problems on some GPUs.
// If clearing the default back buffer's depth buffer, also clear the
// stencil buffer, if one was allocated implicitly. This avoids performance
// problems on some GPUs.
if (!m_framebufferBinding && drawingBuffer()->hasImplicitStencilBuffer() &&
(mask & GL_DEPTH_BUFFER_BIT)) {
// It shouldn't matter what value it's cleared to, since in other queries in the API, we
// claim that the stencil buffer doesn't exist.
// It shouldn't matter what value it's cleared to, since in other queries
// in the API, we claim that the stencil buffer doesn't exist.
mask |= GL_STENCIL_BUFFER_BIT;
}
contextGL()->Clear(mask);
......@@ -2262,7 +2275,8 @@ void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) {
getFramebufferBinding(GL_READ_FRAMEBUFFER)
->removeAttachmentFromBoundFramebuffer(GL_READ_FRAMEBUFFER, texture);
// If the deleted was bound to the the current maximum index, trace backwards to find the new max texture index
// If the deleted was bound to the the current maximum index, trace backwards
// to find the new max texture index.
if (m_onePlusMaxNonDefaultTextureUnit ==
static_cast<unsigned long>(maxBoundTextureIndex + 1)) {
findNewMaxNonDefaultTextureUnit();
......@@ -2516,8 +2530,9 @@ void WebGLRenderingContextBase::framebufferRenderbuffer(
}
GLuint bufferObject = objectOrZero(buffer);
if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
// On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT + STENCIL_ATTACHMENT.
// We divide it here so in WebGLFramebuffer, we don't have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
// On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT +
// STENCIL_ATTACHMENT. We divide it here so in WebGLFramebuffer, we don't
// have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
contextGL()->FramebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT,
renderbuffertarget, bufferObject);
contextGL()->FramebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
......@@ -2560,8 +2575,9 @@ void WebGLRenderingContextBase::framebufferTexture2D(GLenum target,
}
GLuint textureObject = objectOrZero(texture);
if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
// On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT + STENCIL_ATTACHMENT.
// We divide it here so in WebGLFramebuffer, we don't have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
// On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT +
// STENCIL_ATTACHMENT. We divide it here so in WebGLFramebuffer, we don't
// have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
contextGL()->FramebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget,
textureObject, level);
contextGL()->FramebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget,
......@@ -2729,8 +2745,8 @@ void WebGLRenderingContextBase::getContextAttributes(
if (isContextLost())
return;
result.set(toWebGLContextAttributes(creationAttributes()));
// Some requested attributes may not be honored, so we need to query the underlying
// context/drawing buffer and adjust accordingly.
// Some requested attributes may not be honored, so we need to query the
// underlying context/drawing buffer and adjust accordingly.
if (creationAttributes().depth() && !drawingBuffer()->hasDepthBuffer())
result.get().setDepth(false);
if (creationAttributes().stencil() && !drawingBuffer()->hasStencilBuffer())
......@@ -3426,7 +3442,8 @@ ScriptValue WebGLRenderingContextBase::getUniform(
return ScriptValue::createNull(scriptState);
}
// FIXME: make this more efficient using WebGLUniformLocation and caching types in it
// FIXME: make this more efficient using WebGLUniformLocation and caching
// types in it.
GLint activeUniforms = 0;
contextGL()->GetProgramiv(programId, GL_ACTIVE_UNIFORMS, &activeUniforms);
for (GLint i = 0; i < activeUniforms; i++) {
......@@ -3445,7 +3462,8 @@ ScriptValue WebGLRenderingContextBase::getUniform(
// Strip "[0]" from the name if it's an array.
if (size > 1 && name.endsWith("[0]"))
name = name.left(name.length() - 3);
// If it's an array, we need to iterate through each element, appending "[index]" to the name.
// If it's an array, we need to iterate through each element, appending
// "[index]" to the name.
for (GLint index = 0; index < size; ++index) {
nameBuilder.clear();
nameBuilder.append(name);
......@@ -3458,7 +3476,8 @@ ScriptValue WebGLRenderingContextBase::getUniform(
GLint loc = contextGL()->GetUniformLocation(
objectOrZero(program), nameBuilder.toString().utf8().data());
if (loc == location) {
// Found it. Use the type in the ActiveInfo to determine the return type.
// Found it. Use the type in the ActiveInfo to determine the return
// type.
GLenum baseType;
unsigned length;
switch (type) {
......@@ -3628,7 +3647,8 @@ ScriptValue WebGLRenderingContextBase::getUniform(
}
}
}
// If we get here, something went wrong in our unfortunately complex logic above
// If we get here, something went wrong in our unfortunately complex logic
// above
synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error");
return ScriptValue::createNull(scriptState);
}
......@@ -4084,8 +4104,8 @@ void WebGLRenderingContextBase::renderbufferStorageImpl(
GLsizei width,
GLsizei height,
const char* functionName) {
ASSERT(
!samples); // |samples| > 0 is only valid in WebGL2's renderbufferStorageMultisample().
ASSERT(!samples); // |samples| > 0 is only valid in WebGL2's
// renderbufferStorageMultisample().
ASSERT(!isWebGL2OrHigher()); // Make sure this is overridden in WebGL 2.
switch (internalformat) {
case GL_DEPTH_COMPONENT16:
......@@ -4164,8 +4184,8 @@ void WebGLRenderingContextBase::shaderSource(WebGLShader* shader,
if (isContextLost() || !validateWebGLObject("shaderSource", shader))
return;
String stringWithoutComments = StripComments(string).result();
// TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16 Strings)
// so we don't need to use StringUTF8Adaptor.
// TODO(danakj): Make validateShaderSource reject characters > 255 (or utf16
// Strings) so we don't need to use StringUTF8Adaptor.
if (!validateShaderSource(stringWithoutComments))
return;
shader->setSource(string);
......@@ -4270,7 +4290,8 @@ void WebGLRenderingContextBase::stencilOpSeparate(GLenum face,
GLenum WebGLRenderingContextBase::convertTexInternalFormat(
GLenum internalformat,
GLenum type) {
// Convert to sized internal formats that are renderable with GL_CHROMIUM_color_buffer_float_rgb(a).
// Convert to sized internal formats that are renderable with
// GL_CHROMIUM_color_buffer_float_rgb(a).
if (type == GL_FLOAT && internalformat == GL_RGBA &&
extensionsUtil()->isExtensionEnabled(
"GL_CHROMIUM_color_buffer_float_rgba"))
......@@ -4291,7 +4312,8 @@ void WebGLRenderingContextBase::texImage2DBase(GLenum target,
GLenum format,
GLenum type,
const void* pixels) {
// All calling functions check isContextLost, so a duplicate check is not needed here.
// All calling functions check isContextLost, so a duplicate check is not
// needed here.
contextGL()->TexImage2D(target, level,
convertTexInternalFormat(internalformat, type), width,
height, border, format, type, pixels);
......@@ -4312,7 +4334,8 @@ void WebGLRenderingContextBase::texImageImpl(
bool flipY,
bool premultiplyAlpha) {
const char* funcName = getTexImageFunctionName(functionID);
// All calling functions check isContextLost, so a duplicate check is not needed here.
// All calling functions check isContextLost, so a duplicate check is not
// needed here.
if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) {
// The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented.
type = GL_FLOAT;
......@@ -4397,7 +4420,8 @@ bool WebGLRenderingContextBase::validateTexFunc(
if (!validateSize(functionName, xoffset, yoffset, zoffset))
return false;
} else {
// For SourceArrayBufferView, function validateTexFuncData() would handle whether to validate the SettableTexFormat
// For SourceArrayBufferView, function validateTexFuncData() would handle
// whether to validate the SettableTexFormat
// by checking if the ArrayBufferView is null or not.
if (sourceType != SourceArrayBufferView) {
if (!validateSettableTexFormat(functionName, format))
......@@ -4426,8 +4450,8 @@ bool WebGLRenderingContextBase::validateValueFitNonNegInt32(
return true;
}
// TODO(fmalita): figure why WebGLImageConversion::ImageExtractor can't handle SVG-backed images,
// and get rid of this intermediate step.
// TODO(fmalita): figure why WebGLImageConversion::ImageExtractor can't handle
// SVG-backed images, and get rid of this intermediate step.
PassRefPtr<Image> WebGLRenderingContextBase::drawImageIntoBuffer(
PassRefPtr<Image> passImage,
int width,
......@@ -4614,7 +4638,8 @@ void WebGLRenderingContextBase::texImageHelperImageData(
Vector<uint8_t> data;
bool needConversion = true;
// The data from ImageData is always of format RGBA8.
// No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
// No conversion is needed if destination format is RGBA and type is
// USIGNED_BYTE and no Flip or Premultiply operation is required.
if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GL_RGBA &&
type == GL_UNSIGNED_BYTE) {
needConversion = false;
......@@ -4722,7 +4747,8 @@ bool WebGLRenderingContextBase::canUseTexImageByGPU(
(isFloatType(type) || isIntegerFormat(internalformat) ||
isSRGBFormat(internalformat)))
return false;
// TODO(crbug.com/622958): Implement GPU-to-GPU path for WebGL 2 and more internal formats.
// TODO(crbug.com/622958): Implement GPU-to-GPU path for WebGL 2 and more
// internal formats.
if (functionID == TexSubImage2D &&
(isWebGL2OrHigher() || extensionEnabled(OESTextureFloatName) ||
extensionEnabled(OESTextureHalfFloatName) ||
......@@ -4783,7 +4809,8 @@ void WebGLRenderingContextBase::texImageByGPU(TexImageByGPUType functionType,
target, internalformat, type, level);
}
// if direct copy is not possible, create a temporary texture and then copy from canvas to temporary texture to target texture.
// if direct copy is not possible, create a temporary texture and then copy
// from canvas to temporary texture to target texture.
if (!possibleDirectCopy) {
targetLevel = 0;
targetInternalformat = GL_RGBA;
......@@ -4864,8 +4891,10 @@ void WebGLRenderingContextBase::texImageHelperHTMLCanvasElement(
1, 0, format, type, xoffset, yoffset, zoffset))
return;
if (functionID == TexImage2D || functionID == TexSubImage2D) {
// texImageByGPU relies on copyTextureCHROMIUM which doesn't support float/integer/sRGB internal format.
// TODO(crbug.com/622958): relax the constrains if copyTextureCHROMIUM is upgraded to handle more formats.
// texImageByGPU relies on copyTextureCHROMIUM which doesn't support
// float/integer/sRGB internal format.
// TODO(crbug.com/622958): relax the constrains if copyTextureCHROMIUM is
// upgraded to handle more formats.
if (!canvas->renderingContext() ||
!canvas->renderingContext()->isAccelerated() ||
!canUseTexImageByGPU(functionID, internalformat, type)) {
......@@ -4955,8 +4984,9 @@ void WebGLRenderingContextBase::texImageHelperHTMLVideoElement(
return;
if (functionID == TexImage2D) {
// Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
// Otherwise, it will fall back to the normal SW path.
// Go through the fast path doing a GPU-GPU textures copy without a readback
// to system memory if possible. Otherwise, it will fall back to the normal
// SW path.
if (GL_TEXTURE_2D == target) {
if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) &&
......@@ -4966,7 +4996,8 @@ void WebGLRenderingContextBase::texImageHelperHTMLVideoElement(
return;
}
// Try using an accelerated image buffer, this allows YUV conversion to be done on the GPU.
// Try using an accelerated image buffer, this allows YUV conversion to be
// done on the GPU.
std::unique_ptr<ImageBufferSurface> surface =
wrapUnique(new AcceleratedImageBufferSurface(
IntSize(video->videoWidth(), video->videoHeight())));
......@@ -4974,15 +5005,18 @@ void WebGLRenderingContextBase::texImageHelperHTMLVideoElement(
std::unique_ptr<ImageBuffer> imageBuffer(
ImageBuffer::create(std::move(surface)));
if (imageBuffer) {
// The video element paints an RGBA frame into our surface here. By using an AcceleratedImageBufferSurface,
// we enable the WebMediaPlayer implementation to do any necessary color space conversion on the GPU (though it
// The video element paints an RGBA frame into our surface here. By
// using an AcceleratedImageBufferSurface, we enable the
// WebMediaPlayer implementation to do any necessary color space
// conversion on the GPU (though it
// may still do a CPU conversion and upload the results).
video->paintCurrentFrame(
imageBuffer->canvas(),
IntRect(0, 0, video->videoWidth(), video->videoHeight()),
nullptr);
// This is a straight GPU-GPU copy, any necessary color space conversion was handled in the paintCurrentFrameInContext() call.
// This is a straight GPU-GPU copy, any necessary color space
// conversion was handled in the paintCurrentFrameInContext() call.
if (imageBuffer->copyToPlatformTexture(
contextGL(), texture->object(), internalformat, type, level,
m_unpackPremultiplyAlpha, m_unpackFlipY)) {
......@@ -5072,8 +5106,9 @@ void WebGLRenderingContextBase::texImageHelperImageBitmap(
SkPixmap pixmap;
uint8_t* pixelDataPtr = nullptr;
RefPtr<Uint8Array> pixelData;
// In the case where an ImageBitmap is not texture backed, peekPixels() always succeed.
// However, when it is texture backed and !canUseTexImageByGPU, we do a GPU read back.
// In the case where an ImageBitmap is not texture backed, peekPixels() always
// succeed. However, when it is texture backed and !canUseTexImageByGPU, we
// do a GPU read back.
bool peekSucceed = skImage->peekPixels(&pixmap);
if (peekSucceed) {
pixelDataPtr = static_cast<uint8_t*>(pixmap.writable_addr());
......@@ -5095,7 +5130,8 @@ void WebGLRenderingContextBase::texImageHelperImageBitmap(
// The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented.
type = GL_FLOAT;
}
// In the case of ImageBitmap, we do not need to apply flipY or premultiplyAlpha.
// In the case of ImageBitmap, we do not need to apply flipY or
// premultiplyAlpha.
bool isPixelDataBGRA =
pixmap.colorType() == SkColorType::kBGRA_8888_SkColorType;
if ((isPixelDataBGRA &&
......@@ -5857,7 +5893,8 @@ void WebGLRenderingContextBase::viewport(GLint x,
contextGL()->Viewport(x, y, width, height);
}
// Added to provide a unified interface with CanvasRenderingContext2D. Prefer calling forceLostContext instead.
// Added to provide a unified interface with CanvasRenderingContext2D. Prefer
// calling forceLostContext instead.
void WebGLRenderingContextBase::loseContext(LostContextMode mode) {
forceLostContext(mode, Manual);
}
......@@ -5884,7 +5921,8 @@ void WebGLRenderingContextBase::loseContextImpl(
ASSERT(m_contextLostMode != NotLostContext);
m_autoRecoveryMethod = autoRecoveryMethod;
// Make absolutely sure we do not refer to an already-deleted texture or framebuffer.
// Make absolutely sure we do not refer to an already-deleted texture or
// framebuffer.
drawingBuffer()->setTexture2DBinding(0);
drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0);
drawingBuffer()->setRenderbufferBinding(0);
......@@ -5955,7 +5993,8 @@ Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() {
if (!m_extensionsUtil) {
gpu::gles2::GLES2Interface* gl = contextGL();
m_extensionsUtil = Extensions3DUtil::create(gl);
// The only reason the ExtensionsUtil should be invalid is if the gl context is lost.
// The only reason the ExtensionsUtil should be invalid is if the gl context
// is lost.
ASSERT(m_extensionsUtil->isValid() ||
gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
}
......@@ -6485,7 +6524,8 @@ bool WebGLRenderingContextBase::validateTexFuncDimensions(
return false;
}
// No need to check height here. For texImage width == height.
// For texSubImage that will be checked when checking yoffset + height is in range.
// For texSubImage that will be checked when checking yoffset + height is
// in range.
if (width > (m_maxCubeMapTextureSize >> level)) {
synthesizeGLError(GL_INVALID_VALUE, functionName,
"width or height out of range for cube map");
......@@ -6576,7 +6616,8 @@ bool WebGLRenderingContextBase::validateTexFuncData(
DOMArrayBufferView* pixels,
NullDisposition disposition,
GLuint srcOffset) {
// All calling functions check isContextLost, so a duplicate check is not needed here.
// All calling functions check isContextLost, so a duplicate check is not
// needed here.
if (!pixels) {
DCHECK_NE(disposition, NullNotReachable);
if (disposition == NullAllowed)
......@@ -6650,8 +6691,8 @@ bool WebGLRenderingContextBase::validateTexFuncData(
break;
case GL_HALF_FLOAT:
case GL_HALF_FLOAT_OES: // OES_texture_half_float
// As per the specification, ArrayBufferView should be null or a Uint16Array when
// OES_texture_half_float is enabled.
// As per the specification, ArrayBufferView should be null or a
// Uint16Array when OES_texture_half_float is enabled.
if (pixels->type() != DOMArrayBufferView::TypeUint16) {
synthesizeGLError(GL_INVALID_OPERATION, functionName,
"type HALF_FLOAT_OES but ArrayBufferView is not NULL "
......@@ -7114,7 +7155,9 @@ void WebGLRenderingContextBase::maybeRestoreContext(TimerBase*) {
settings->webGLEnabled()))
return;
// If the context was lost due to RealLostContext, we need to destroy the old DrawingBuffer before creating new DrawingBuffer to ensure resource budget enough.
// If the context was lost due to RealLostContext, we need to destroy the old
// DrawingBuffer before creating new DrawingBuffer to ensure resource budget
// enough.
if (drawingBuffer()) {
m_drawingBuffer->beginDestruction();
m_drawingBuffer.clear();
......@@ -7129,17 +7172,20 @@ void WebGLRenderingContextBase::maybeRestoreContext(TimerBase*) {
RefPtr<DrawingBuffer> buffer;
if (contextProvider && contextProvider->bindToCurrentThread()) {
// Construct a new drawing buffer with the new GL context.
// TODO(xidachen): make sure that the second parameter is correct for OffscreenCanvas.
// TODO(xidachen): make sure that the second parameter is correct for
// OffscreenCanvas.
buffer = createDrawingBuffer(std::move(contextProvider),
DrawingBuffer::AllowChromiumImage);
// If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is set to null.
// If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is
// set to null.
}
if (!buffer) {
if (m_contextLostMode == RealLostContext) {
m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts,
BLINK_FROM_HERE);
} else {
// This likely shouldn't happen but is the best way to report it to the WebGL app.
// This likely shouldn't happen but is the best way to report it to the
// WebGL app.
synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context");
}
return;
......@@ -7351,7 +7397,8 @@ void WebGLRenderingContextBase::restoreCurrentTexture2D() {
}
void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() {
// Trace backwards from the current max to find the new max non-default texture unit
// Trace backwards from the current max to find the new max non-default
// texture unit
int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1;
for (int i = startIndex; i >= 0; --i) {
if (m_textureUnits[i].m_texture2DBinding ||
......
......@@ -684,10 +684,10 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
LostContextMode m_contextLostMode;
AutoRecoveryMethod m_autoRecoveryMethod;
// Dispatches a context lost event once it is determined that one is needed.
// This is used for synthetic, WEBGL_lose_context and real context losses. For real ones, it's
// likely that there's no JavaScript on the stack, but that might be dependent
// on how exactly the platform discovers that the context was lost. For better
// portability we always defer the dispatch of the event.
// This is used for synthetic, WEBGL_lose_context and real context losses. For
// real ones, it's likely that there's no JavaScript on the stack, but that
// might be dependent on how exactly the platform discovers that the context
// was lost. For better portability we always defer the dispatch of the event.
Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
bool m_restoreAllowed;
Timer<WebGLRenderingContextBase> m_restoreTimer;
......@@ -695,7 +695,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
bool m_markedCanvasDirty;
HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects;
// List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and stored values for ELEMENT_ARRAY_BUFFER
// List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and
// stored values for ELEMENT_ARRAY_BUFFER
Member<WebGLBuffer> m_boundArrayBuffer;
Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject;
......@@ -769,7 +770,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
bool m_stencilEnabled;
GLuint m_stencilMask, m_stencilMaskBack;
GLint m_stencilFuncRef,
m_stencilFuncRefBack; // Note that these are the user specified values, not the internal clamped value.
m_stencilFuncRefBack; // Note that these are the user specified values,
// not the internal clamped value.
GLuint m_stencilFuncMask, m_stencilFuncMaskBack;
bool m_isDepthStencilSupported;
......@@ -883,9 +885,11 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
return m_extensionEnabled[name];
}
// ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubImage2D to read from
// a multisampled DrawingBuffer. In this situation, we need to blit to a single sampled buffer
// for reading, during which the bindings could be changed and need to be recovered.
// ScopedDrawingBufferBinder is used for
// ReadPixels/CopyTexImage2D/CopySubImage2D to read from a multisampled
// DrawingBuffer. In this situation, we need to blit to a single sampled
// buffer for reading, during which the bindings could be changed and need to
// be recovered.
class ScopedDrawingBufferBinder {
STACK_ALLOCATED();
......@@ -942,8 +946,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
ScriptValue getWebGLIntArrayParameter(ScriptState*, GLenum);
// Clear the backbuffer if it was composited since the last operation.
// clearMask is set to the bitfield of any clear that would happen anyway at this time
// and the function returns |CombinedClear| if that clear is now unnecessary.
// clearMask is set to the bitfield of any clear that would happen anyway at
// this time and the function returns |CombinedClear| if that clear is now
// unnecessary.
enum HowToClear {
// Skip clearing the backbuffer.
Skipped,
......@@ -1002,8 +1007,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
bool flipY,
bool premultiplyAlpha);
// Copy from the source directly to the texture via the gpu, without a read-back to system memory.
// Souce could be canvas or imageBitmap.
// Copy from the source directly to the texture via the gpu, without a
// read-back to system memory. Souce could be canvas or imageBitmap.
void texImageByGPU(TexImageByGPUType,
WebGLTexture*,
GLenum target,
......@@ -1028,29 +1033,33 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat,
GLenum colorBufferFormat);
// Helper function to verify limits on the length of uniform and attribute locations.
// Helper function to verify limits on the length of uniform and attribute
// locations.
virtual unsigned getMaxWebGLLocationLength() const { return 256; }
bool validateLocationLength(const char* functionName, const String&);
// Helper function to check if size is non-negative.
// Generate GL error and return false for negative inputs; otherwise, return true.
// Generate GL error and return false for negative inputs; otherwise, return
// true.
bool validateSize(const char* functionName, GLint x, GLint y, GLint z = 0);
// Helper function to check if all characters in the string belong to the
// ASCII subset as defined in GLSL ES 1.0 spec section 3.1.
bool validateString(const char* functionName, const String&);
// Helper function to check if all characters in the shader source belong to the ASCII
// subset as defined in GLSL ES 1.0 spec section 3.1 Character Set for WebGL 1.0 and
// in GLSL ES 3.00 spec section 3.1 Character Set for WebGL 2.0.
// Helper function to check if all characters in the shader source belong to
// the ASCII subset as defined in GLSL ES 1.0 spec section 3.1 Character Set
// for WebGL 1.0 and in GLSL ES 3.00 spec section 3.1 Character Set for WebGL
// 2.0.
bool validateShaderSource(const String&);
// Helper function to check texture binding target and texture bound to the target.
// Generate GL errors and return 0 if target is invalid or texture bound is
// null. Otherwise, return the texture bound to the target.
// Helper function to check texture binding target and texture bound to the
// target. Generate GL errors and return 0 if target is invalid or texture
// bound is null. Otherwise, return the texture bound to the target.
WebGLTexture* validateTextureBinding(const char* functionName, GLenum target);
// Wrapper function for validateTexture2D(3D)Binding, used in texImageHelper functions.
// Wrapper function for validateTexture2D(3D)Binding, used in texImageHelper
// functions.
virtual WebGLTexture* validateTexImageBinding(const char*,
TexImageFunctionID,
GLenum);
......@@ -1063,16 +1072,18 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
void addExtensionSupportedFormatsTypes();
// Helper function to check input internalformat/format/type for functions Tex{Sub}Image taking TexImageSource source data.
// Generates GL error and returns false if parameters are invalid.
// Helper function to check input internalformat/format/type for functions
// Tex{Sub}Image taking TexImageSource source data. Generates GL error and
// returns false if parameters are invalid.
bool validateTexImageSourceFormatAndType(const char* functionName,
TexImageFunctionType,
GLenum internalformat,
GLenum format,
GLenum type);
// Helper function to check input internalformat/format/type for functions Tex{Sub}Image.
// Generates GL error and returns false if parameters are invalid.
// Helper function to check input internalformat/format/type for functions
// Tex{Sub}Image. Generates GL error and returns false if parameters are
// invalid.
bool validateTexFuncFormatAndType(const char* functionName,
TexImageFunctionType,
GLenum internalformat,
......@@ -1086,15 +1097,18 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
bool validateReadBufferAndGetInfo(const char* functionName,
WebGLFramebuffer*& readFramebufferBinding);
// Helper function to check format/type and ArrayBuffer view type for readPixels.
// Helper function to check format/type and ArrayBuffer view type for
// readPixels.
// Generates INVALID_ENUM and returns false if parameters are invalid.
// Generates INVALID_OPERATION if ArrayBuffer view type is incompatible with type.
// Generates INVALID_OPERATION if ArrayBuffer view type is incompatible with
// type.
virtual bool validateReadPixelsFormatAndType(GLenum format,
GLenum type,
DOMArrayBufferView*);
// Helper function to check parameters of readPixels. Returns true if all parameters
// are valid. Otherwise, generates appropriate error and returns false.
// Helper function to check parameters of readPixels. Returns true if all
// parameters are valid. Otherwise, generates appropriate error and returns
// false.
bool validateReadPixelsFuncParameters(GLsizei width,
GLsizei height,
GLenum format,
......@@ -1110,8 +1124,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
GLenum target,
GLint level);
// Helper function to check if a 64-bit value is non-negative and can fit into a 32-bit integer.
// Generates GL error and returns false if not.
// Helper function to check if a 64-bit value is non-negative and can fit into
// a 32-bit integer. Generates GL error and returns false if not.
bool validateValueFitNonNegInt32(const char* functionName,
const char* paramName,
long long value);
......@@ -1126,8 +1140,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
SourceUnpackBuffer,
};
// Helper function for tex{Sub}Image{2|3}D to check if the input format/type/level/target/width/height/depth/border/xoffset/yoffset/zoffset are valid.
// Otherwise, it would return quickly without doing other work.
// Helper function for tex{Sub}Image{2|3}D to check if the input
// format/type/level/target/width/height/depth/border/xoffset/yoffset/zoffset
// are valid. Otherwise, it would return quickly without doing other work.
bool validateTexFunc(const char* functionName,
TexImageFunctionType,
TexFuncValidationSourceType,
......@@ -1144,8 +1159,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
GLint yoffset,
GLint zoffset);
// Helper function to check input width and height for functions {copy, compressed}Tex{Sub}Image.
// Generates GL error and returns false if width or height is invalid.
// Helper function to check input width and height for functions {copy,
// compressed}Tex{Sub}Image. Generates GL error and returns false if width or
// height is invalid.
bool validateTexFuncDimensions(const char* functionName,
TexImageFunctionType,
GLenum target,
......@@ -1154,8 +1170,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
GLsizei height,
GLsizei depth);
// Helper function to check input parameters for functions {copy}Tex{Sub}Image.
// Generates GL error and returns false if parameters are invalid.
// Helper function to check input parameters for functions
// {copy}Tex{Sub}Image. Generates GL error and returns false if parameters
// are invalid.
bool validateTexFuncParameters(const char* functionName,
TexImageFunctionType,
TexFuncValidationSourceType,
......@@ -1198,7 +1215,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
// Helper function for validating compressed texture formats.
bool validateCompressedTexFormat(const char* functionName, GLenum format);
// Helper function to validate if front/back stencilMask and stencilFunc settings are the same.
// Helper function to validate if front/back stencilMask and stencilFunc
// settings are the same.
bool validateStencilSettings(const char* functionName);
// Helper function to validate stencil or depth func.
......@@ -1218,7 +1236,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
// used only to warn about use of obsolete functions.
void printWarningToConsole(const String&);
// Helper function to validate the target for checkFramebufferStatus and validateFramebufferFuncParameters.
// Helper function to validate the target for checkFramebufferStatus and
// validateFramebufferFuncParameters.
virtual bool validateFramebufferTarget(GLenum target);
// Get the framebuffer bound to given target
......@@ -1284,7 +1303,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
requiredMinSize);
}
// Helper function to validate the target for bufferData and getBufferParameter.
// Helper function to validate the target for bufferData and
// getBufferParameter.
virtual bool validateBufferTarget(const char* functionName, GLenum target);
// Helper function to validate the target for bufferData.
......@@ -1300,22 +1320,26 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
virtual void removeBoundBuffer(WebGLBuffer*);
// Helper function for tex{Sub}Image2D to make sure image is ready and wouldn't taint Origin.
// Helper function for tex{Sub}Image2D to make sure image is ready and
// wouldn't taint Origin.
bool validateHTMLImageElement(const char* functionName,
HTMLImageElement*,
ExceptionState&);
// Helper function for tex{Sub}Image2D to make sure canvas is ready and wouldn't taint Origin.
// Helper function for tex{Sub}Image2D to make sure canvas is ready and
// wouldn't taint Origin.
bool validateHTMLCanvasElement(const char* functionName,
HTMLCanvasElement*,
ExceptionState&);
// Helper function for tex{Sub}Image2D to make sure video is ready wouldn't taint Origin.
// Helper function for tex{Sub}Image2D to make sure video is ready wouldn't
// taint Origin.
bool validateHTMLVideoElement(const char* functionName,
HTMLVideoElement*,
ExceptionState&);
// Helper function for tex{Sub}Image2D to make sure imagebitmap is ready and wouldn't taint Origin.
// Helper function for tex{Sub}Image2D to make sure imagebitmap is ready and
// wouldn't taint Origin.
bool validateImageBitmap(const char* functionName,
ImageBitmap*,
ExceptionState&);
......@@ -1375,8 +1399,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
// Clamp the width and height to GL_MAX_VIEWPORT_DIMS.
IntSize clampedCanvasSize() const;
// First time called, if EXT_draw_buffers is supported, query the value; otherwise return 0.
// Later, return the cached value.
// First time called, if EXT_draw_buffers is supported, query the value;
// otherwise return 0. Later, return the cached value.
GLint maxDrawBuffers();
GLint maxColorAttachments();
......@@ -1404,8 +1428,9 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext {
static void removeFromEvictedList(WebGLRenderingContextBase*);
static void willDestroyContext(WebGLRenderingContextBase*);
static void forciblyLoseOldestContext(const String& reason);
// Return the least recently used context's position in the active context vector.
// If the vector is empty, return the maximum allowed active context number.
// Return the least recently used context's position in the active context
// vector. If the vector is empty, return the maximum allowed active context
// number.
static WebGLRenderingContextBase* oldestContext();
static WebGLRenderingContextBase* oldestEvictedContext();
......
......@@ -56,7 +56,9 @@ void WebGLTimerQueryEXT::updateCachedResult(gpu::gles2::GLES2Interface* gl) {
if (!hasTarget())
return;
// If this is a timestamp query, set the result to 0 and make it available as we don't support timestamps in WebGL due to very poor driver support for them
// If this is a timestamp query, set the result to 0 and make it available as
// we don't support timestamps in WebGL due to very poor driver support for
// them.
if (m_target == GL_TIMESTAMP_EXT) {
m_queryResult = 0;
m_queryResultAvailable = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment