| OLD | NEW |
| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext() | 144 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext() |
| 145 { | 145 { |
| 146 if (activeContexts().isEmpty()) | 146 if (activeContexts().isEmpty()) |
| 147 return nullptr; | 147 return nullptr; |
| 148 | 148 |
| 149 WebGLRenderingContextBase* candidate = *(activeContexts().begin()); | 149 WebGLRenderingContextBase* candidate = *(activeContexts().begin()); |
| 150 ASSERT(!candidate->isContextLost()); | 150 ASSERT(!candidate->isContextLost()); |
| 151 for (WebGLRenderingContextBase* context : activeContexts()) { | 151 for (WebGLRenderingContextBase* context : activeContexts()) { |
| 152 ASSERT(!context->isContextLost()); | 152 ASSERT(!context->isContextLost()); |
| 153 if (context->webContext()->lastFlushID() < candidate->webContext()->last
FlushID()) { | 153 if (context->contextGL()->GetLastFlushIdCHROMIUM() < candidate->contextG
L()->GetLastFlushIdCHROMIUM()) { |
| 154 candidate = context; | 154 candidate = context; |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 return candidate; | 158 return candidate; |
| 159 } | 159 } |
| 160 | 160 |
| 161 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestEvictedContext() | 161 WebGLRenderingContextBase* WebGLRenderingContextBase::oldestEvictedContext() |
| 162 { | 162 { |
| 163 if (forciblyEvictedContexts().isEmpty()) | 163 if (forciblyEvictedContexts().isEmpty()) |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 Nullable<WebGLContextAttributes> contextAttributes; | 1148 Nullable<WebGLContextAttributes> contextAttributes; |
| 1149 getContextAttributes(contextAttributes); | 1149 getContextAttributes(contextAttributes); |
| 1150 if (contextAttributes.isNull()) { | 1150 if (contextAttributes.isNull()) { |
| 1151 // Unlikely, but context was lost. | 1151 // Unlikely, but context was lost. |
| 1152 return Skipped; | 1152 return Skipped; |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 // Determine if it's possible to combine the clear the user asked for and th
is clear. | 1155 // Determine if it's possible to combine the clear the user asked for and th
is clear. |
| 1156 bool combinedClear = mask && !m_scissorEnabled; | 1156 bool combinedClear = mask && !m_scissorEnabled; |
| 1157 | 1157 |
| 1158 webContext()->disable(GL_SCISSOR_TEST); | 1158 contextGL()->Disable(GL_SCISSOR_TEST); |
| 1159 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { | 1159 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { |
| 1160 webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 1160 contextGL()->ClearColor(m_colorMask[0] ? m_clearColor[0] : 0, |
| 1161 m_colorMask[1] ? m_clearColor[1] : 0, | 1161 m_colorMask[1] ? m_clearColor[1] : 0, |
| 1162 m_colorMask[2] ? m_clearColor[2] : 0, | 1162 m_colorMask[2] ? m_clearColor[2] : 0, |
| 1163 m_colorMask[3] ? m_clearColor[3] : 0); | 1163 m_colorMask[3] ? m_clearColor[3] : 0); |
| 1164 } else { | 1164 } else { |
| 1165 webContext()->clearColor(0, 0, 0, 0); | 1165 contextGL()->ClearColor(0, 0, 0, 0); |
| 1166 } | 1166 } |
| 1167 webContext()->colorMask(true, true, true, true); | 1167 contextGL()->ColorMask(true, true, true, true); |
| 1168 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 1168 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; |
| 1169 if (contextAttributes.get().depth()) { | 1169 if (contextAttributes.get().depth()) { |
| 1170 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) | 1170 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) |
| 1171 webContext()->clearDepth(1.0f); | 1171 contextGL()->ClearDepthf(1.0f); |
| 1172 clearMask |= GL_DEPTH_BUFFER_BIT; | 1172 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 1173 webContext()->depthMask(true); | 1173 contextGL()->DepthMask(true); |
| 1174 } | 1174 } |
| 1175 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil
Buffer()) { | 1175 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil
Buffer()) { |
| 1176 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 1176 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 1177 webContext()->clearStencil(m_clearStencil & m_stencilMask); | 1177 contextGL()->ClearStencil(m_clearStencil & m_stencilMask); |
| 1178 else | 1178 else |
| 1179 webContext()->clearStencil(0); | 1179 contextGL()->ClearStencil(0); |
| 1180 clearMask |= GL_STENCIL_BUFFER_BIT; | 1180 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 1181 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 1181 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 drawingBuffer()->clearFramebuffers(clearMask); | 1184 drawingBuffer()->clearFramebuffers(clearMask); |
| 1185 | 1185 |
| 1186 restoreStateAfterClear(); | 1186 restoreStateAfterClear(); |
| 1187 drawingBuffer()->restoreFramebufferBindings(); | 1187 drawingBuffer()->restoreFramebufferBindings(); |
| 1188 drawingBuffer()->setBufferClearNeeded(false); | 1188 drawingBuffer()->setBufferClearNeeded(false); |
| 1189 | 1189 |
| 1190 return combinedClear ? CombinedClear : JustClear; | 1190 return combinedClear ? CombinedClear : JustClear; |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void WebGLRenderingContextBase::restoreStateAfterClear() | 1193 void WebGLRenderingContextBase::restoreStateAfterClear() |
| 1194 { | 1194 { |
| 1195 if (isContextLost()) | 1195 if (isContextLost()) |
| 1196 return; | 1196 return; |
| 1197 | 1197 |
| 1198 // Restore the state that the context set. | 1198 // Restore the state that the context set. |
| 1199 if (m_scissorEnabled) | 1199 if (m_scissorEnabled) |
| 1200 webContext()->enable(GL_SCISSOR_TEST); | 1200 contextGL()->Enable(GL_SCISSOR_TEST); |
| 1201 webContext()->clearColor(m_clearColor[0], m_clearColor[1], | 1201 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], |
| 1202 m_clearColor[2], m_clearColor[3]); | 1202 m_clearColor[2], m_clearColor[3]); |
| 1203 webContext()->colorMask(m_colorMask[0], m_colorMask[1], | 1203 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], |
| 1204 m_colorMask[2], m_colorMask[3]); | 1204 m_colorMask[2], m_colorMask[3]); |
| 1205 webContext()->clearDepth(m_clearDepth); | 1205 contextGL()->ClearDepthf(m_clearDepth); |
| 1206 webContext()->clearStencil(m_clearStencil); | 1206 contextGL()->ClearStencil(m_clearStencil); |
| 1207 webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); | 1207 webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 1208 webContext()->depthMask(m_depthMask); | 1208 contextGL()->DepthMask(m_depthMask); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 void WebGLRenderingContextBase::markLayerComposited() | 1211 void WebGLRenderingContextBase::markLayerComposited() |
| 1212 { | 1212 { |
| 1213 if (!isContextLost()) | 1213 if (!isContextLost()) |
| 1214 drawingBuffer()->setBufferClearNeeded(true); | 1214 drawingBuffer()->setBufferClearNeeded(true); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 void WebGLRenderingContextBase::setIsHidden(bool hidden) | 1217 void WebGLRenderingContextBase::setIsHidden(bool hidden) |
| 1218 { | 1218 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 float scaleFactor = sqrtf(static_cast<float>(maxArea) / static_cast<floa
t>(currentArea)); | 1300 float scaleFactor = sqrtf(static_cast<float>(maxArea) / static_cast<floa
t>(currentArea)); |
| 1301 width = std::max(1, static_cast<int>(width * scaleFactor)); | 1301 width = std::max(1, static_cast<int>(width * scaleFactor)); |
| 1302 height = std::max(1, static_cast<int>(height * scaleFactor)); | 1302 height = std::max(1, static_cast<int>(height * scaleFactor)); |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off | 1305 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off |
| 1306 // clear (and this matches what reshape will do). | 1306 // clear (and this matches what reshape will do). |
| 1307 drawingBuffer()->reset(IntSize(width, height)); | 1307 drawingBuffer()->reset(IntSize(width, height)); |
| 1308 restoreStateAfterClear(); | 1308 restoreStateAfterClear(); |
| 1309 | 1309 |
| 1310 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ
eTextureUnit].m_texture2DBinding.get())); | 1310 contextGL()->BindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_active
TextureUnit].m_texture2DBinding.get())); |
| 1311 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB
inding.get())); | 1311 contextGL()->BindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBi
nding.get())); |
| 1312 drawingBuffer()->restoreFramebufferBindings(); | 1312 drawingBuffer()->restoreFramebufferBindings(); |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 int WebGLRenderingContextBase::drawingBufferWidth() const | 1315 int WebGLRenderingContextBase::drawingBufferWidth() const |
| 1316 { | 1316 { |
| 1317 return isContextLost() ? 0 : drawingBuffer()->size().width(); | 1317 return isContextLost() ? 0 : drawingBuffer()->size().width(); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 int WebGLRenderingContextBase::drawingBufferHeight() const | 1320 int WebGLRenderingContextBase::drawingBufferHeight() const |
| 1321 { | 1321 { |
| 1322 return isContextLost() ? 0 : drawingBuffer()->size().height(); | 1322 return isContextLost() ? 0 : drawingBuffer()->size().height(); |
| 1323 } | 1323 } |
| 1324 | 1324 |
| 1325 void WebGLRenderingContextBase::activeTexture(GLenum texture) | 1325 void WebGLRenderingContextBase::activeTexture(GLenum texture) |
| 1326 { | 1326 { |
| 1327 if (isContextLost()) | 1327 if (isContextLost()) |
| 1328 return; | 1328 return; |
| 1329 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { | 1329 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { |
| 1330 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); | 1330 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); |
| 1331 return; | 1331 return; |
| 1332 } | 1332 } |
| 1333 m_activeTextureUnit = texture - GL_TEXTURE0; | 1333 m_activeTextureUnit = texture - GL_TEXTURE0; |
| 1334 webContext()->activeTexture(texture); | 1334 contextGL()->ActiveTexture(texture); |
| 1335 | 1335 |
| 1336 drawingBuffer()->setActiveTextureUnit(texture); | 1336 drawingBuffer()->setActiveTextureUnit(texture); |
| 1337 | 1337 |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 void WebGLRenderingContextBase::attachShader(ScriptState* scriptState, WebGLProg
ram* program, WebGLShader* shader) | 1340 void WebGLRenderingContextBase::attachShader(ScriptState* scriptState, WebGLProg
ram* program, WebGLShader* shader) |
| 1341 { | 1341 { |
| 1342 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) | 1342 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) |
| 1343 return; | 1343 return; |
| 1344 if (!program->attachShader(shader)) { | 1344 if (!program->attachShader(shader)) { |
| 1345 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); | 1345 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); |
| 1346 return; | 1346 return; |
| 1347 } | 1347 } |
| 1348 webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); | 1348 contextGL()->AttachShader(objectOrZero(program), objectOrZero(shader)); |
| 1349 shader->onAttached(); | 1349 shader->onAttached(); |
| 1350 preserveObjectWrapper(scriptState, program, "shader", shader->type(), shader
); | 1350 preserveObjectWrapper(scriptState, program, "shader", shader->type(), shader
); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint
index, const String& name) | 1353 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint
index, const String& name) |
| 1354 { | 1354 { |
| 1355 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 1355 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) |
| 1356 return; | 1356 return; |
| 1357 if (!validateLocationLength("bindAttribLocation", name)) | 1357 if (!validateLocationLength("bindAttribLocation", name)) |
| 1358 return; | 1358 return; |
| 1359 if (isPrefixReserved(name)) { | 1359 if (isPrefixReserved(name)) { |
| 1360 synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved
prefix"); | 1360 synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved
prefix"); |
| 1361 return; | 1361 return; |
| 1362 } | 1362 } |
| 1363 webContext()->bindAttribLocation(objectOrZero(program), index, name.utf8().d
ata()); | 1363 contextGL()->BindAttribLocation(objectOrZero(program), index, name.utf8().da
ta()); |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, W
ebGLObject* object, bool& deleted) | 1366 bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, W
ebGLObject* object, bool& deleted) |
| 1367 { | 1367 { |
| 1368 deleted = false; | 1368 deleted = false; |
| 1369 if (isContextLost()) | 1369 if (isContextLost()) |
| 1370 return false; | 1370 return false; |
| 1371 if (object) { | 1371 if (object) { |
| 1372 if (!object->validate(contextGroup(), this)) { | 1372 if (!object->validate(contextGroup(), this)) { |
| 1373 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object not fr
om this context"); | 1373 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object not fr
om this context"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 void WebGLRenderingContextBase::bindBuffer(ScriptState* scriptState, GLenum targ
et, WebGLBuffer* buffer) | 1408 void WebGLRenderingContextBase::bindBuffer(ScriptState* scriptState, GLenum targ
et, WebGLBuffer* buffer) |
| 1409 { | 1409 { |
| 1410 bool deleted; | 1410 bool deleted; |
| 1411 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) | 1411 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) |
| 1412 return; | 1412 return; |
| 1413 if (deleted) | 1413 if (deleted) |
| 1414 buffer = 0; | 1414 buffer = 0; |
| 1415 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) | 1415 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) |
| 1416 return; | 1416 return; |
| 1417 | 1417 |
| 1418 webContext()->bindBuffer(target, objectOrZero(buffer)); | 1418 contextGL()->BindBuffer(target, objectOrZero(buffer)); |
| 1419 preserveObjectWrapper(scriptState, this, "buffer", target, buffer); | 1419 preserveObjectWrapper(scriptState, this, "buffer", target, buffer); |
| 1420 maybePreserveDefaultVAOObjectWrapper(scriptState); | 1420 maybePreserveDefaultVAOObjectWrapper(scriptState); |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 void WebGLRenderingContextBase::bindFramebuffer(ScriptState* scriptState, GLenum
target, WebGLFramebuffer* buffer) | 1423 void WebGLRenderingContextBase::bindFramebuffer(ScriptState* scriptState, GLenum
target, WebGLFramebuffer* buffer) |
| 1424 { | 1424 { |
| 1425 bool deleted; | 1425 bool deleted; |
| 1426 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1426 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1427 return; | 1427 return; |
| 1428 | 1428 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1446 bool deleted; | 1446 bool deleted; |
| 1447 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1447 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
| 1448 return; | 1448 return; |
| 1449 if (deleted) | 1449 if (deleted) |
| 1450 renderBuffer = 0; | 1450 renderBuffer = 0; |
| 1451 if (target != GL_RENDERBUFFER) { | 1451 if (target != GL_RENDERBUFFER) { |
| 1452 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target")
; | 1452 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target")
; |
| 1453 return; | 1453 return; |
| 1454 } | 1454 } |
| 1455 m_renderbufferBinding = renderBuffer; | 1455 m_renderbufferBinding = renderBuffer; |
| 1456 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1456 contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer)); |
| 1457 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); | 1457 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); |
| 1458 if (renderBuffer) | 1458 if (renderBuffer) |
| 1459 renderBuffer->setHasEverBeenBound(); | 1459 renderBuffer->setHasEverBeenBound(); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar
get, WebGLTexture* texture) | 1462 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar
get, WebGLTexture* texture) |
| 1463 { | 1463 { |
| 1464 bool deleted; | 1464 bool deleted; |
| 1465 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1465 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
| 1466 return; | 1466 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1485 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; | 1485 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; |
| 1486 bindingPointName = "texture_2d_array"; | 1486 bindingPointName = "texture_2d_array"; |
| 1487 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { | 1487 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { |
| 1488 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; | 1488 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; |
| 1489 bindingPointName = "texture_3d"; | 1489 bindingPointName = "texture_3d"; |
| 1490 } else { | 1490 } else { |
| 1491 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1491 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
| 1492 return; | 1492 return; |
| 1493 } | 1493 } |
| 1494 | 1494 |
| 1495 webContext()->bindTexture(target, objectOrZero(texture)); | 1495 contextGL()->BindTexture(target, objectOrZero(texture)); |
| 1496 // This is called both internally and externally (from JavaScript). We only
update which wrapper | 1496 // This is called both internally and externally (from JavaScript). We only
update which wrapper |
| 1497 // is preserved when it's called from JavaScript. | 1497 // is preserved when it's called from JavaScript. |
| 1498 if (scriptState) { | 1498 if (scriptState) { |
| 1499 preserveObjectWrapper(scriptState, this, bindingPointName, m_activeTextu
reUnit, texture); | 1499 preserveObjectWrapper(scriptState, this, bindingPointName, m_activeTextu
reUnit, texture); |
| 1500 } | 1500 } |
| 1501 if (texture) { | 1501 if (texture) { |
| 1502 texture->setTarget(target); | 1502 texture->setTarget(target); |
| 1503 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl
usMaxNonDefaultTextureUnit); | 1503 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl
usMaxNonDefaultTextureUnit); |
| 1504 } else { | 1504 } else { |
| 1505 // If the disabled index is the current maximum, trace backwards to find
the new max enabled texture index | 1505 // If the disabled index is the current maximum, trace backwards to find
the new max enabled texture index |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1516 // platforms is fairly involved (will require a HashMap from texture ID | 1516 // platforms is fairly involved (will require a HashMap from texture ID |
| 1517 // in all ports), and we have not had any complaints, so the logic has | 1517 // in all ports), and we have not had any complaints, so the logic has |
| 1518 // been removed. | 1518 // been removed. |
| 1519 | 1519 |
| 1520 } | 1520 } |
| 1521 | 1521 |
| 1522 void WebGLRenderingContextBase::blendColor(GLfloat red, GLfloat green, GLfloat b
lue, GLfloat alpha) | 1522 void WebGLRenderingContextBase::blendColor(GLfloat red, GLfloat green, GLfloat b
lue, GLfloat alpha) |
| 1523 { | 1523 { |
| 1524 if (isContextLost()) | 1524 if (isContextLost()) |
| 1525 return; | 1525 return; |
| 1526 webContext()->blendColor(red, green, blue, alpha); | 1526 contextGL()->BlendColor(red, green, blue, alpha); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 void WebGLRenderingContextBase::blendEquation(GLenum mode) | 1529 void WebGLRenderingContextBase::blendEquation(GLenum mode) |
| 1530 { | 1530 { |
| 1531 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) | 1531 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) |
| 1532 return; | 1532 return; |
| 1533 webContext()->blendEquation(mode); | 1533 contextGL()->BlendEquation(mode); |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 void WebGLRenderingContextBase::blendEquationSeparate(GLenum modeRGB, GLenum mod
eAlpha) | 1536 void WebGLRenderingContextBase::blendEquationSeparate(GLenum modeRGB, GLenum mod
eAlpha) |
| 1537 { | 1537 { |
| 1538 if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeR
GB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) | 1538 if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeR
GB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) |
| 1539 return; | 1539 return; |
| 1540 webContext()->blendEquationSeparate(modeRGB, modeAlpha); | 1540 contextGL()->BlendEquationSeparate(modeRGB, modeAlpha); |
| 1541 } | 1541 } |
| 1542 | 1542 |
| 1543 | 1543 |
| 1544 void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) | 1544 void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) |
| 1545 { | 1545 { |
| 1546 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfact
or)) | 1546 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfact
or)) |
| 1547 return; | 1547 return; |
| 1548 webContext()->blendFunc(sfactor, dfactor); | 1548 contextGL()->BlendFunc(sfactor, dfactor); |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha) | 1551 void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha) |
| 1552 { | 1552 { |
| 1553 // Note: Alpha does not have the same restrictions as RGB. | 1553 // Note: Alpha does not have the same restrictions as RGB. |
| 1554 if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB
, dstRGB)) | 1554 if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB
, dstRGB)) |
| 1555 return; | 1555 return; |
| 1556 webContext()->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); | 1556 contextGL()->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 void WebGLRenderingContextBase::bufferDataImpl(GLenum target, long long size, co
nst void* data, GLenum usage) | 1559 void WebGLRenderingContextBase::bufferDataImpl(GLenum target, long long size, co
nst void* data, GLenum usage) |
| 1560 { | 1560 { |
| 1561 WebGLBuffer* buffer = validateBufferDataTarget("bufferData", target); | 1561 WebGLBuffer* buffer = validateBufferDataTarget("bufferData", target); |
| 1562 if (!buffer) | 1562 if (!buffer) |
| 1563 return; | 1563 return; |
| 1564 | 1564 |
| 1565 if (!validateBufferDataUsage("bufferData", usage)) | 1565 if (!validateBufferDataUsage("bufferData", usage)) |
| 1566 return; | 1566 return; |
| 1567 | 1567 |
| 1568 if (!validateValueFitNonNegInt32("bufferData", "size", size)) | 1568 if (!validateValueFitNonNegInt32("bufferData", "size", size)) |
| 1569 return; | 1569 return; |
| 1570 | 1570 |
| 1571 buffer->setSize(size); | 1571 buffer->setSize(size); |
| 1572 | 1572 |
| 1573 webContext()->bufferData(target, static_cast<GLsizeiptr>(size), data, usage)
; | 1573 contextGL()->BufferData(target, static_cast<GLsizeiptr>(size), data, usage); |
| 1574 } | 1574 } |
| 1575 | 1575 |
| 1576 void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum
usage) | 1576 void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum
usage) |
| 1577 { | 1577 { |
| 1578 if (isContextLost()) | 1578 if (isContextLost()) |
| 1579 return; | 1579 return; |
| 1580 bufferDataImpl(target, size, 0, usage); | 1580 bufferDataImpl(target, size, 0, usage); |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 void WebGLRenderingContextBase::bufferData(GLenum target, DOMArrayBuffer* data,
GLenum usage) | 1583 void WebGLRenderingContextBase::bufferData(GLenum target, DOMArrayBuffer* data,
GLenum usage) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1609 return; | 1609 return; |
| 1610 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) | 1610 if (!validateValueFitNonNegInt32("bufferSubData", "offset", offset)) |
| 1611 return; | 1611 return; |
| 1612 if (!data) | 1612 if (!data) |
| 1613 return; | 1613 return; |
| 1614 if (offset + static_cast<long long>(size) > buffer->getSize()) { | 1614 if (offset + static_cast<long long>(size) > buffer->getSize()) { |
| 1615 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "buffer overflow"); | 1615 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "buffer overflow"); |
| 1616 return; | 1616 return; |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), size, dat
a); | 1619 contextGL()->BufferSubData(target, static_cast<GLintptr>(offset), size, data
); |
| 1620 } | 1620 } |
| 1621 | 1621 |
| 1622 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, D
OMArrayBuffer* data) | 1622 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, D
OMArrayBuffer* data) |
| 1623 { | 1623 { |
| 1624 if (isContextLost()) | 1624 if (isContextLost()) |
| 1625 return; | 1625 return; |
| 1626 if (!data) { | 1626 if (!data) { |
| 1627 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "no data"); | 1627 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "no data"); |
| 1628 return; | 1628 return; |
| 1629 } | 1629 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 } | 1670 } |
| 1671 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); | 1671 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
| 1672 if (framebufferBinding) { | 1672 if (framebufferBinding) { |
| 1673 const char* reason = "framebuffer incomplete"; | 1673 const char* reason = "framebuffer incomplete"; |
| 1674 GLenum status = framebufferBinding->checkDepthStencilStatus(&reason); | 1674 GLenum status = framebufferBinding->checkDepthStencilStatus(&reason); |
| 1675 if (status != GL_FRAMEBUFFER_COMPLETE) { | 1675 if (status != GL_FRAMEBUFFER_COMPLETE) { |
| 1676 emitGLWarning("checkFramebufferStatus", reason); | 1676 emitGLWarning("checkFramebufferStatus", reason); |
| 1677 return status; | 1677 return status; |
| 1678 } | 1678 } |
| 1679 } | 1679 } |
| 1680 return webContext()->checkFramebufferStatus(target); | 1680 return contextGL()->CheckFramebufferStatus(target); |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 void WebGLRenderingContextBase::clear(GLbitfield mask) | 1683 void WebGLRenderingContextBase::clear(GLbitfield mask) |
| 1684 { | 1684 { |
| 1685 if (isContextLost()) | 1685 if (isContextLost()) |
| 1686 return; | 1686 return; |
| 1687 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { | 1687 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { |
| 1688 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); | 1688 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); |
| 1689 return; | 1689 return; |
| 1690 } | 1690 } |
| 1691 const char* reason = "framebuffer incomplete"; | 1691 const char* reason = "framebuffer incomplete"; |
| 1692 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r
eason) != GL_FRAMEBUFFER_COMPLETE) { | 1692 if (m_framebufferBinding && m_framebufferBinding->checkDepthStencilStatus(&r
eason) != GL_FRAMEBUFFER_COMPLETE) { |
| 1693 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); | 1693 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); |
| 1694 return; | 1694 return; |
| 1695 } | 1695 } |
| 1696 if (clearIfComposited(mask) != CombinedClear) { | 1696 if (clearIfComposited(mask) != CombinedClear) { |
| 1697 // If clearing the default back buffer's depth buffer, also clear the st
encil buffer, if one | 1697 // If clearing the default back buffer's depth buffer, also clear the st
encil buffer, if one |
| 1698 // was allocated implicitly. This avoids performance problems on some GP
Us. | 1698 // was allocated implicitly. This avoids performance problems on some GP
Us. |
| 1699 if (!m_framebufferBinding && drawingBuffer()->hasImplicitStencilBuffer()
&& (mask & GL_DEPTH_BUFFER_BIT)) { | 1699 if (!m_framebufferBinding && drawingBuffer()->hasImplicitStencilBuffer()
&& (mask & GL_DEPTH_BUFFER_BIT)) { |
| 1700 // It shouldn't matter what value it's cleared to, since in other qu
eries in the API, we | 1700 // It shouldn't matter what value it's cleared to, since in other qu
eries in the API, we |
| 1701 // claim that the stencil buffer doesn't exist. | 1701 // claim that the stencil buffer doesn't exist. |
| 1702 mask |= GL_STENCIL_BUFFER_BIT; | 1702 mask |= GL_STENCIL_BUFFER_BIT; |
| 1703 } | 1703 } |
| 1704 webContext()->clear(mask); | 1704 contextGL()->Clear(mask); |
| 1705 } | 1705 } |
| 1706 markContextChanged(CanvasChanged); | 1706 markContextChanged(CanvasChanged); |
| 1707 } | 1707 } |
| 1708 | 1708 |
| 1709 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl
oat a) | 1709 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl
oat a) |
| 1710 { | 1710 { |
| 1711 if (isContextLost()) | 1711 if (isContextLost()) |
| 1712 return; | 1712 return; |
| 1713 if (std::isnan(r)) | 1713 if (std::isnan(r)) |
| 1714 r = 0; | 1714 r = 0; |
| 1715 if (std::isnan(g)) | 1715 if (std::isnan(g)) |
| 1716 g = 0; | 1716 g = 0; |
| 1717 if (std::isnan(b)) | 1717 if (std::isnan(b)) |
| 1718 b = 0; | 1718 b = 0; |
| 1719 if (std::isnan(a)) | 1719 if (std::isnan(a)) |
| 1720 a = 1; | 1720 a = 1; |
| 1721 m_clearColor[0] = r; | 1721 m_clearColor[0] = r; |
| 1722 m_clearColor[1] = g; | 1722 m_clearColor[1] = g; |
| 1723 m_clearColor[2] = b; | 1723 m_clearColor[2] = b; |
| 1724 m_clearColor[3] = a; | 1724 m_clearColor[3] = a; |
| 1725 webContext()->clearColor(r, g, b, a); | 1725 contextGL()->ClearColor(r, g, b, a); |
| 1726 } | 1726 } |
| 1727 | 1727 |
| 1728 void WebGLRenderingContextBase::clearDepth(GLfloat depth) | 1728 void WebGLRenderingContextBase::clearDepth(GLfloat depth) |
| 1729 { | 1729 { |
| 1730 if (isContextLost()) | 1730 if (isContextLost()) |
| 1731 return; | 1731 return; |
| 1732 m_clearDepth = depth; | 1732 m_clearDepth = depth; |
| 1733 webContext()->clearDepth(depth); | 1733 contextGL()->ClearDepthf(depth); |
| 1734 } | 1734 } |
| 1735 | 1735 |
| 1736 void WebGLRenderingContextBase::clearStencil(GLint s) | 1736 void WebGLRenderingContextBase::clearStencil(GLint s) |
| 1737 { | 1737 { |
| 1738 if (isContextLost()) | 1738 if (isContextLost()) |
| 1739 return; | 1739 return; |
| 1740 m_clearStencil = s; | 1740 m_clearStencil = s; |
| 1741 webContext()->clearStencil(s); | 1741 contextGL()->ClearStencil(s); |
| 1742 } | 1742 } |
| 1743 | 1743 |
| 1744 void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool
ean blue, GLboolean alpha) | 1744 void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool
ean blue, GLboolean alpha) |
| 1745 { | 1745 { |
| 1746 if (isContextLost()) | 1746 if (isContextLost()) |
| 1747 return; | 1747 return; |
| 1748 m_colorMask[0] = red; | 1748 m_colorMask[0] = red; |
| 1749 m_colorMask[1] = green; | 1749 m_colorMask[1] = green; |
| 1750 m_colorMask[2] = blue; | 1750 m_colorMask[2] = blue; |
| 1751 m_colorMask[3] = alpha; | 1751 m_colorMask[3] = alpha; |
| 1752 webContext()->colorMask(red, green, blue, alpha); | 1752 contextGL()->ColorMask(red, green, blue, alpha); |
| 1753 } | 1753 } |
| 1754 | 1754 |
| 1755 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) | 1755 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) |
| 1756 { | 1756 { |
| 1757 if (isContextLost() || !validateWebGLObject("compileShader", shader)) | 1757 if (isContextLost() || !validateWebGLObject("compileShader", shader)) |
| 1758 return; | 1758 return; |
| 1759 webContext()->compileShader(objectOrZero(shader)); | 1759 contextGL()->CompileShader(objectOrZero(shader)); |
| 1760 } | 1760 } |
| 1761 | 1761 |
| 1762 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLsizei height, GLint border, DOMArrayBuf
ferView* data) | 1762 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLsizei height, GLint border, DOMArrayBuf
ferView* data) |
| 1763 { | 1763 { |
| 1764 if (isContextLost()) | 1764 if (isContextLost()) |
| 1765 return; | 1765 return; |
| 1766 if (!validateTexture2DBinding("compressedTexImage2D", target)) | 1766 if (!validateTexture2DBinding("compressedTexImage2D", target)) |
| 1767 return; | 1767 return; |
| 1768 if (!validateCompressedTexFormat("compressedTexImage2D", internalformat)) | 1768 if (!validateCompressedTexFormat("compressedTexImage2D", internalformat)) |
| 1769 return; | 1769 return; |
| 1770 webContext()->compressedTexImage2D(target, level, internalformat, width, hei
ght, | 1770 contextGL()->CompressedTexImage2D(target, level, internalformat, width, heig
ht, |
| 1771 border, data->byteLength(), data->baseAddress()); | 1771 border, data->byteLength(), data->baseAddress()); |
| 1772 } | 1772 } |
| 1773 | 1773 |
| 1774 void WebGLRenderingContextBase::compressedTexSubImage2D(GLenum target, GLint lev
el, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
DOMArrayBufferView* data) | 1774 void WebGLRenderingContextBase::compressedTexSubImage2D(GLenum target, GLint lev
el, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
DOMArrayBufferView* data) |
| 1775 { | 1775 { |
| 1776 if (isContextLost()) | 1776 if (isContextLost()) |
| 1777 return; | 1777 return; |
| 1778 if (!validateTexture2DBinding("compressedTexSubImage2D", target)) | 1778 if (!validateTexture2DBinding("compressedTexSubImage2D", target)) |
| 1779 return; | 1779 return; |
| 1780 if (!validateCompressedTexFormat("compressedTexSubImage2D", format)) | 1780 if (!validateCompressedTexFormat("compressedTexSubImage2D", format)) |
| 1781 return; | 1781 return; |
| 1782 webContext()->compressedTexSubImage2D(target, level, xoffset, yoffset, | 1782 contextGL()->CompressedTexSubImage2D(target, level, xoffset, yoffset, |
| 1783 width, height, format, data->byteLength(), data->baseAddress()); | 1783 width, height, format, data->byteLength(), data->baseAddress()); |
| 1784 } | 1784 } |
| 1785 | 1785 |
| 1786 bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa
me, GLenum format) | 1786 bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa
me, GLenum format) |
| 1787 { | 1787 { |
| 1788 if (isWebGL2OrHigher()) | 1788 if (isWebGL2OrHigher()) |
| 1789 return true; | 1789 return true; |
| 1790 | 1790 |
| 1791 if (WebGLImageConversion::getChannelBitsByFormat(format) & WebGLImageConvers
ion::ChannelDepthStencil) { | 1791 if (WebGLImageConversion::getChannelBitsByFormat(format) & WebGLImageConvers
ion::ChannelDepthStencil) { |
| 1792 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format can not be
set, only rendered to"); | 1792 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format can not be
set, only rendered to"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1818 return; | 1818 return; |
| 1819 if (!validateCopyTexFormat("copyTexImage2D", internalformat)) | 1819 if (!validateCopyTexFormat("copyTexImage2D", internalformat)) |
| 1820 return; | 1820 return; |
| 1821 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) | 1821 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) |
| 1822 return; | 1822 return; |
| 1823 WebGLFramebuffer* readFramebufferBinding = nullptr; | 1823 WebGLFramebuffer* readFramebufferBinding = nullptr; |
| 1824 if (!validateReadBufferAndGetInfo("copyTexImage2D", readFramebufferBinding)) | 1824 if (!validateReadBufferAndGetInfo("copyTexImage2D", readFramebufferBinding)) |
| 1825 return; | 1825 return; |
| 1826 clearIfComposited(); | 1826 clearIfComposited(); |
| 1827 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); | 1827 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); |
| 1828 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei
ght, border); | 1828 contextGL()->CopyTexImage2D(target, level, internalformat, x, y, width, heig
ht, border); |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) | 1831 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 1832 { | 1832 { |
| 1833 if (isContextLost()) | 1833 if (isContextLost()) |
| 1834 return; | 1834 return; |
| 1835 if (!validateTexture2DBinding("copyTexSubImage2D", target)) | 1835 if (!validateTexture2DBinding("copyTexSubImage2D", target)) |
| 1836 return; | 1836 return; |
| 1837 WebGLFramebuffer* readFramebufferBinding = nullptr; | 1837 WebGLFramebuffer* readFramebufferBinding = nullptr; |
| 1838 if (!validateReadBufferAndGetInfo("copyTexSubImage2D", readFramebufferBindin
g)) | 1838 if (!validateReadBufferAndGetInfo("copyTexSubImage2D", readFramebufferBindin
g)) |
| 1839 return; | 1839 return; |
| 1840 clearIfComposited(); | 1840 clearIfComposited(); |
| 1841 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); | 1841 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); |
| 1842 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width
, height); | 1842 contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width,
height); |
| 1843 } | 1843 } |
| 1844 | 1844 |
| 1845 WebGLBuffer* WebGLRenderingContextBase::createBuffer() | 1845 WebGLBuffer* WebGLRenderingContextBase::createBuffer() |
| 1846 { | 1846 { |
| 1847 if (isContextLost()) | 1847 if (isContextLost()) |
| 1848 return nullptr; | 1848 return nullptr; |
| 1849 WebGLBuffer* o = WebGLBuffer::create(this); | 1849 WebGLBuffer* o = WebGLBuffer::create(this); |
| 1850 addSharedObject(o); | 1850 addSharedObject(o); |
| 1851 return o; | 1851 return o; |
| 1852 } | 1852 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 | 1908 |
| 1909 WebGLShader* o = WebGLShader::create(this, type); | 1909 WebGLShader* o = WebGLShader::create(this, type); |
| 1910 addSharedObject(o); | 1910 addSharedObject(o); |
| 1911 return o; | 1911 return o; |
| 1912 } | 1912 } |
| 1913 | 1913 |
| 1914 void WebGLRenderingContextBase::cullFace(GLenum mode) | 1914 void WebGLRenderingContextBase::cullFace(GLenum mode) |
| 1915 { | 1915 { |
| 1916 if (isContextLost()) | 1916 if (isContextLost()) |
| 1917 return; | 1917 return; |
| 1918 webContext()->cullFace(mode); | 1918 contextGL()->CullFace(mode); |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) | 1921 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) |
| 1922 { | 1922 { |
| 1923 if (isContextLost() || !object) | 1923 if (isContextLost() || !object) |
| 1924 return false; | 1924 return false; |
| 1925 if (!object->validate(contextGroup(), this)) { | 1925 if (!object->validate(contextGroup(), this)) { |
| 1926 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); | 1926 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); |
| 1927 return false; | 1927 return false; |
| 1928 } | 1928 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index | 2013 // If the deleted was bound to the the current maximum index, trace backward
s to find the new max texture index |
| 2014 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound
TextureIndex + 1)) { | 2014 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound
TextureIndex + 1)) { |
| 2015 findNewMaxNonDefaultTextureUnit(); | 2015 findNewMaxNonDefaultTextureUnit(); |
| 2016 } | 2016 } |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 void WebGLRenderingContextBase::depthFunc(GLenum func) | 2019 void WebGLRenderingContextBase::depthFunc(GLenum func) |
| 2020 { | 2020 { |
| 2021 if (isContextLost()) | 2021 if (isContextLost()) |
| 2022 return; | 2022 return; |
| 2023 webContext()->depthFunc(func); | 2023 contextGL()->DepthFunc(func); |
| 2024 } | 2024 } |
| 2025 | 2025 |
| 2026 void WebGLRenderingContextBase::depthMask(GLboolean flag) | 2026 void WebGLRenderingContextBase::depthMask(GLboolean flag) |
| 2027 { | 2027 { |
| 2028 if (isContextLost()) | 2028 if (isContextLost()) |
| 2029 return; | 2029 return; |
| 2030 m_depthMask = flag; | 2030 m_depthMask = flag; |
| 2031 webContext()->depthMask(flag); | 2031 contextGL()->DepthMask(flag); |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) | 2034 void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) |
| 2035 { | 2035 { |
| 2036 if (isContextLost()) | 2036 if (isContextLost()) |
| 2037 return; | 2037 return; |
| 2038 // Check required by WebGL spec section 6.12 | 2038 // Check required by WebGL spec section 6.12 |
| 2039 if (zNear > zFar) { | 2039 if (zNear > zFar) { |
| 2040 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 2040 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
| 2041 return; | 2041 return; |
| 2042 } | 2042 } |
| 2043 webContext()->depthRange(zNear, zFar); | 2043 contextGL()->DepthRangef(zNear, zFar); |
| 2044 } | 2044 } |
| 2045 | 2045 |
| 2046 void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg
ram* program, WebGLShader* shader) | 2046 void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg
ram* program, WebGLShader* shader) |
| 2047 { | 2047 { |
| 2048 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) | 2048 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) |
| 2049 return; | 2049 return; |
| 2050 if (!program->detachShader(shader)) { | 2050 if (!program->detachShader(shader)) { |
| 2051 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); | 2051 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); |
| 2052 return; | 2052 return; |
| 2053 } | 2053 } |
| 2054 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); | 2054 contextGL()->DetachShader(objectOrZero(program), objectOrZero(shader)); |
| 2055 shader->onDetached(webContext()); | 2055 shader->onDetached(webContext()); |
| 2056 preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullpt
r); | 2056 preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullpt
r); |
| 2057 } | 2057 } |
| 2058 | 2058 |
| 2059 void WebGLRenderingContextBase::disable(GLenum cap) | 2059 void WebGLRenderingContextBase::disable(GLenum cap) |
| 2060 { | 2060 { |
| 2061 if (isContextLost() || !validateCapability("disable", cap)) | 2061 if (isContextLost() || !validateCapability("disable", cap)) |
| 2062 return; | 2062 return; |
| 2063 if (cap == GL_STENCIL_TEST) { | 2063 if (cap == GL_STENCIL_TEST) { |
| 2064 m_stencilEnabled = false; | 2064 m_stencilEnabled = false; |
| 2065 applyStencilTest(); | 2065 applyStencilTest(); |
| 2066 return; | 2066 return; |
| 2067 } | 2067 } |
| 2068 if (cap == GL_SCISSOR_TEST) { | 2068 if (cap == GL_SCISSOR_TEST) { |
| 2069 m_scissorEnabled = false; | 2069 m_scissorEnabled = false; |
| 2070 drawingBuffer()->setScissorEnabled(m_scissorEnabled); | 2070 drawingBuffer()->setScissorEnabled(m_scissorEnabled); |
| 2071 } | 2071 } |
| 2072 webContext()->disable(cap); | 2072 contextGL()->Disable(cap); |
| 2073 } | 2073 } |
| 2074 | 2074 |
| 2075 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) | 2075 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) |
| 2076 { | 2076 { |
| 2077 if (isContextLost()) | 2077 if (isContextLost()) |
| 2078 return; | 2078 return; |
| 2079 if (index >= m_maxVertexAttribs) { | 2079 if (index >= m_maxVertexAttribs) { |
| 2080 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); | 2080 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); |
| 2081 return; | 2081 return; |
| 2082 } | 2082 } |
| 2083 | 2083 |
| 2084 webContext()->disableVertexAttribArray(index); | 2084 contextGL()->DisableVertexAttribArray(index); |
| 2085 } | 2085 } |
| 2086 | 2086 |
| 2087 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) | 2087 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) |
| 2088 { | 2088 { |
| 2089 // Command buffer will not error if no program is bound. | 2089 // Command buffer will not error if no program is bound. |
| 2090 if (!m_currentProgram) { | 2090 if (!m_currentProgram) { |
| 2091 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p
rogram in use"); | 2091 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p
rogram in use"); |
| 2092 return false; | 2092 return false; |
| 2093 } | 2093 } |
| 2094 | 2094 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2107 } | 2107 } |
| 2108 return true; | 2108 return true; |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou
nt) | 2111 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou
nt) |
| 2112 { | 2112 { |
| 2113 if (!validateDrawArrays("drawArrays")) | 2113 if (!validateDrawArrays("drawArrays")) |
| 2114 return; | 2114 return; |
| 2115 | 2115 |
| 2116 clearIfComposited(); | 2116 clearIfComposited(); |
| 2117 webContext()->drawArrays(mode, first, count); | 2117 contextGL()->DrawArrays(mode, first, count); |
| 2118 markContextChanged(CanvasChanged); | 2118 markContextChanged(CanvasChanged); |
| 2119 } | 2119 } |
| 2120 | 2120 |
| 2121 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum
type, long long offset) | 2121 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum
type, long long offset) |
| 2122 { | 2122 { |
| 2123 if (!validateDrawElements("drawElements", type, offset)) | 2123 if (!validateDrawElements("drawElements", type, offset)) |
| 2124 return; | 2124 return; |
| 2125 | 2125 |
| 2126 if (transformFeedbackActive() && !transformFeedbackPaused()) { | 2126 if (transformFeedbackActive() && !transformFeedbackPaused()) { |
| 2127 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "transform feedb
ack is active and not paused"); | 2127 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "transform feedb
ack is active and not paused"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 return; | 2159 return; |
| 2160 if (cap == GL_STENCIL_TEST) { | 2160 if (cap == GL_STENCIL_TEST) { |
| 2161 m_stencilEnabled = true; | 2161 m_stencilEnabled = true; |
| 2162 applyStencilTest(); | 2162 applyStencilTest(); |
| 2163 return; | 2163 return; |
| 2164 } | 2164 } |
| 2165 if (cap == GL_SCISSOR_TEST) { | 2165 if (cap == GL_SCISSOR_TEST) { |
| 2166 m_scissorEnabled = true; | 2166 m_scissorEnabled = true; |
| 2167 drawingBuffer()->setScissorEnabled(m_scissorEnabled); | 2167 drawingBuffer()->setScissorEnabled(m_scissorEnabled); |
| 2168 } | 2168 } |
| 2169 webContext()->enable(cap); | 2169 contextGL()->Enable(cap); |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) | 2172 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) |
| 2173 { | 2173 { |
| 2174 if (isContextLost()) | 2174 if (isContextLost()) |
| 2175 return; | 2175 return; |
| 2176 if (index >= m_maxVertexAttribs) { | 2176 if (index >= m_maxVertexAttribs) { |
| 2177 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); | 2177 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); |
| 2178 return; | 2178 return; |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 webContext()->enableVertexAttribArray(index); | 2181 contextGL()->EnableVertexAttribArray(index); |
| 2182 } | 2182 } |
| 2183 | 2183 |
| 2184 void WebGLRenderingContextBase::finish() | 2184 void WebGLRenderingContextBase::finish() |
| 2185 { | 2185 { |
| 2186 if (isContextLost()) | 2186 if (isContextLost()) |
| 2187 return; | 2187 return; |
| 2188 webContext()->flush(); // Intentionally a flush, not a finish. | 2188 webContext()->flush(); // Intentionally a flush, not a finish. |
| 2189 } | 2189 } |
| 2190 | 2190 |
| 2191 void WebGLRenderingContextBase::flush() | 2191 void WebGLRenderingContextBase::flush() |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3797 } | 3797 } |
| 3798 | 3798 |
| 3799 void WebGLRenderingContextBase::bindValuebufferCHROMIUM(GLenum target, CHROMIUMV
aluebuffer* valuebuffer) | 3799 void WebGLRenderingContextBase::bindValuebufferCHROMIUM(GLenum target, CHROMIUMV
aluebuffer* valuebuffer) |
| 3800 { | 3800 { |
| 3801 bool deleted; | 3801 bool deleted; |
| 3802 if (!checkObjectToBeBound("bindValuebufferCHROMIUM", valuebuffer, deleted)) | 3802 if (!checkObjectToBeBound("bindValuebufferCHROMIUM", valuebuffer, deleted)) |
| 3803 return; | 3803 return; |
| 3804 if (deleted) | 3804 if (deleted) |
| 3805 valuebuffer = 0; | 3805 valuebuffer = 0; |
| 3806 m_valuebufferBinding = valuebuffer; | 3806 m_valuebufferBinding = valuebuffer; |
| 3807 webContext()->bindValuebufferCHROMIUM(target, objectOrZero(valuebuffer)); | 3807 contextGL()->BindValuebufferCHROMIUM(target, objectOrZero(valuebuffer)); |
| 3808 if (valuebuffer) | 3808 if (valuebuffer) |
| 3809 valuebuffer->setHasEverBeenBound(); | 3809 valuebuffer->setHasEverBeenBound(); |
| 3810 } | 3810 } |
| 3811 | 3811 |
| 3812 void WebGLRenderingContextBase::subscribeValueCHROMIUM(GLenum target, GLenum sub
scription) | 3812 void WebGLRenderingContextBase::subscribeValueCHROMIUM(GLenum target, GLenum sub
scription) |
| 3813 { | 3813 { |
| 3814 if (isContextLost()) | 3814 if (isContextLost()) |
| 3815 return; | 3815 return; |
| 3816 webContext()->subscribeValueCHROMIUM(target, subscription); | 3816 webContext()->subscribeValueCHROMIUM(target, subscription); |
| 3817 } | 3817 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4055 if (functionType == TexImage2DByGPU) { | 4055 if (functionType == TexImage2DByGPU) { |
| 4056 possibleDirectCopy = Extensions3DUtil::canUseCopyTextureCHROMIUM(target,
internalformat, type, level); | 4056 possibleDirectCopy = Extensions3DUtil::canUseCopyTextureCHROMIUM(target,
internalformat, type, level); |
| 4057 } | 4057 } |
| 4058 | 4058 |
| 4059 // if direct copy is not possible, create a temporary texture and then copy
from canvas to temporary texture to target texture. | 4059 // if direct copy is not possible, create a temporary texture and then copy
from canvas to temporary texture to target texture. |
| 4060 if (!possibleDirectCopy) { | 4060 if (!possibleDirectCopy) { |
| 4061 targetLevel = 0; | 4061 targetLevel = 0; |
| 4062 targetInternalformat = GL_RGBA; | 4062 targetInternalformat = GL_RGBA; |
| 4063 targetType = GL_UNSIGNED_BYTE; | 4063 targetType = GL_UNSIGNED_BYTE; |
| 4064 targetTexture = webContext()->createTexture(); | 4064 targetTexture = webContext()->createTexture(); |
| 4065 webContext()->bindTexture(GL_TEXTURE_2D, targetTexture); | 4065 contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture); |
| 4066 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEA
REST); | 4066 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEA
REST); |
| 4067 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA
REST); | 4067 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEA
REST); |
| 4068 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_T
O_EDGE); | 4068 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_T
O_EDGE); |
| 4069 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_T
O_EDGE); | 4069 webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_T
O_EDGE); |
| 4070 webContext()->texImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-
>width(), | 4070 webContext()->texImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-
>width(), |
| 4071 canvas->height(), 0, GL_RGBA, targetType, 0); | 4071 canvas->height(), 0, GL_RGBA, targetType, 0); |
| 4072 } | 4072 } |
| 4073 | 4073 |
| 4074 if (!canvas->is3D()) { | 4074 if (!canvas->is3D()) { |
| 4075 ImageBuffer* buffer = canvas->buffer(); | 4075 ImageBuffer* buffer = canvas->buffer(); |
| 4076 if (!buffer->copyToPlatformTexture(webContext(), targetTexture, targetIn
ternalformat, targetType, | 4076 if (!buffer->copyToPlatformTexture(webContext(), contextGL(), targetText
ure, targetInternalformat, targetType, |
| 4077 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4077 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 4078 ASSERT_NOT_REACHED(); | 4078 ASSERT_NOT_REACHED(); |
| 4079 } | 4079 } |
| 4080 } else { | 4080 } else { |
| 4081 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); | 4081 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend
eringContext()); |
| 4082 ScopedTexture2DRestorer restorer(gl); | 4082 ScopedTexture2DRestorer restorer(gl); |
| 4083 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetText
ure, targetInternalformat, targetType, | 4083 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), contextGL(
), targetTexture, targetInternalformat, targetType, |
| 4084 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ | 4084 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer))
{ |
| 4085 ASSERT_NOT_REACHED(); | 4085 ASSERT_NOT_REACHED(); |
| 4086 } | 4086 } |
| 4087 } | 4087 } |
| 4088 | 4088 |
| 4089 if (!possibleDirectCopy) { | 4089 if (!possibleDirectCopy) { |
| 4090 WebGLId tmpFBO = webContext()->createFramebuffer(); | 4090 WebGLId tmpFBO = webContext()->createFramebuffer(); |
| 4091 webContext()->bindFramebuffer(GL_FRAMEBUFFER, tmpFBO); | 4091 contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO); |
| 4092 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, targetTexture, 0); | 4092 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, targetTexture, 0); |
| 4093 webContext()->bindTexture(texture->getTarget(), texture->object()); | 4093 contextGL()->BindTexture(texture->getTarget(), texture->object()); |
| 4094 if (functionType == TexImage2DByGPU) { | 4094 if (functionType == TexImage2DByGPU) { |
| 4095 webContext()->copyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->w
idth(), canvas->height()); | 4095 contextGL()->CopyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->wi
dth(), canvas->height()); |
| 4096 } else if (functionType == TexSubImage2DByGPU) { | 4096 } else if (functionType == TexSubImage2DByGPU) { |
| 4097 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, 0,
0, canvas->width(), canvas->height()); | 4097 contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, 0, 0
, canvas->width(), canvas->height()); |
| 4098 } else if (functionType == TexSubImage3DByGPU) { | 4098 } else if (functionType == TexSubImage3DByGPU) { |
| 4099 webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zof
fset, 0, 0, canvas->width(), canvas->height()); | 4099 webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zof
fset, 0, 0, canvas->width(), canvas->height()); |
| 4100 } | 4100 } |
| 4101 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0); | 4101 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0); |
| 4102 restoreCurrentFramebuffer(); | 4102 restoreCurrentFramebuffer(); |
| 4103 webContext()->deleteFramebuffer(tmpFBO); | 4103 webContext()->deleteFramebuffer(tmpFBO); |
| 4104 webContext()->deleteTexture(targetTexture); | 4104 webContext()->deleteTexture(targetTexture); |
| 4105 } | 4105 } |
| 4106 } | 4106 } |
| 4107 | 4107 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4169 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); | 4169 OwnPtr<ImageBufferSurface> surface = adoptPtr(new AcceleratedImageBuffer
Surface(IntSize(video->videoWidth(), video->videoHeight()))); |
| 4170 if (surface->isValid()) { | 4170 if (surface->isValid()) { |
| 4171 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); | 4171 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(surface.release(
))); |
| 4172 if (imageBuffer) { | 4172 if (imageBuffer) { |
| 4173 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, | 4173 // The video element paints an RGBA frame into our surface here.
By using an AcceleratedImageBufferSurface, |
| 4174 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it | 4174 // we enable the WebMediaPlayer implementation to do any necessa
ry color space conversion on the GPU (though it |
| 4175 // may still do a CPU conversion and upload the results). | 4175 // may still do a CPU conversion and upload the results). |
| 4176 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); | 4176 video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, vi
deo->videoWidth(), video->videoHeight()), nullptr); |
| 4177 | 4177 |
| 4178 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. | 4178 // This is a straight GPU-GPU copy, any necessary color space co
nversion was handled in the paintCurrentFrameInContext() call. |
| 4179 if (imageBuffer->copyToPlatformTexture(webContext(), texture->ob
ject(), internalformat, type, | 4179 if (imageBuffer->copyToPlatformTexture(webContext(), contextGL()
, texture->object(), internalformat, type, |
| 4180 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4180 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 4181 return; | 4181 return; |
| 4182 } | 4182 } |
| 4183 } | 4183 } |
| 4184 } | 4184 } |
| 4185 } | 4185 } |
| 4186 | 4186 |
| 4187 // Normal pure SW path. | 4187 // Normal pure SW path. |
| 4188 RefPtr<Image> image = videoFrameToImage(video); | 4188 RefPtr<Image> image = videoFrameToImage(video); |
| 4189 if (!image) | 4189 if (!image) |
| (...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6083 haveStencilBuffer = !attributes.isNull() && attributes.get().stencil(); | 6083 haveStencilBuffer = !attributes.isNull() && attributes.get().stencil(); |
| 6084 } | 6084 } |
| 6085 enableOrDisable(GL_STENCIL_TEST, m_stencilEnabled && haveStencilBuffer); | 6085 enableOrDisable(GL_STENCIL_TEST, m_stencilEnabled && haveStencilBuffer); |
| 6086 } | 6086 } |
| 6087 | 6087 |
| 6088 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 6088 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) |
| 6089 { | 6089 { |
| 6090 if (isContextLost()) | 6090 if (isContextLost()) |
| 6091 return; | 6091 return; |
| 6092 if (enable) | 6092 if (enable) |
| 6093 webContext()->enable(capability); | 6093 contextGL()->Enable(capability); |
| 6094 else | 6094 else |
| 6095 webContext()->disable(capability); | 6095 contextGL()->Disable(capability); |
| 6096 } | 6096 } |
| 6097 | 6097 |
| 6098 IntSize WebGLRenderingContextBase::clampedCanvasSize() | 6098 IntSize WebGLRenderingContextBase::clampedCanvasSize() |
| 6099 { | 6099 { |
| 6100 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), | 6100 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), |
| 6101 clamp(canvas()->height(), 1, m_maxViewportDims[1])); | 6101 clamp(canvas()->height(), 1, m_maxViewportDims[1])); |
| 6102 } | 6102 } |
| 6103 | 6103 |
| 6104 GLint WebGLRenderingContextBase::maxDrawBuffers() | 6104 GLint WebGLRenderingContextBase::maxDrawBuffers() |
| 6105 { | 6105 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 6135 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { | 6135 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { |
| 6136 m_framebufferBinding = buffer; | 6136 m_framebufferBinding = buffer; |
| 6137 applyStencilTest(); | 6137 applyStencilTest(); |
| 6138 } | 6138 } |
| 6139 drawingBuffer()->setFramebufferBinding(target, objectOrZero(getFramebufferBi
nding(target))); | 6139 drawingBuffer()->setFramebufferBinding(target, objectOrZero(getFramebufferBi
nding(target))); |
| 6140 | 6140 |
| 6141 if (!buffer) { | 6141 if (!buffer) { |
| 6142 // Instead of binding fb 0, bind the drawing buffer. | 6142 // Instead of binding fb 0, bind the drawing buffer. |
| 6143 drawingBuffer()->bind(target); | 6143 drawingBuffer()->bind(target); |
| 6144 } else { | 6144 } else { |
| 6145 webContext()->bindFramebuffer(target, buffer->object()); | 6145 contextGL()->BindFramebuffer(target, buffer->object()); |
| 6146 } | 6146 } |
| 6147 } | 6147 } |
| 6148 | 6148 |
| 6149 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6149 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| 6150 { | 6150 { |
| 6151 bindFramebuffer(nullptr, GL_FRAMEBUFFER, m_framebufferBinding.get()); | 6151 bindFramebuffer(nullptr, GL_FRAMEBUFFER, m_framebufferBinding.get()); |
| 6152 } | 6152 } |
| 6153 | 6153 |
| 6154 void WebGLRenderingContextBase::restoreCurrentTexture2D() | 6154 void WebGLRenderingContextBase::restoreCurrentTexture2D() |
| 6155 { | 6155 { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6288 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6288 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6289 } | 6289 } |
| 6290 | 6290 |
| 6291 void WebGLRenderingContextBase::restoreUnpackParameters() | 6291 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6292 { | 6292 { |
| 6293 if (m_unpackAlignment != 1) | 6293 if (m_unpackAlignment != 1) |
| 6294 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6294 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6295 } | 6295 } |
| 6296 | 6296 |
| 6297 } // namespace blink | 6297 } // namespace blink |
| OLD | NEW |