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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 if (!desiredSize.isEmpty()) { | 214 if (!desiredSize.isEmpty()) { |
215 forciblyEvictedContexts().remove(0); | 215 forciblyEvictedContexts().remove(0); |
216 evictedContext->forceRestoreContext(); | 216 evictedContext->forceRestoreContext(); |
217 } | 217 } |
218 break; | 218 break; |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 namespace { | 222 namespace { |
223 | 223 |
224 // ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubIm age2D to read from | |
225 // a multisampled DrawingBuffer. In this situation, we need to blit to a sin gle sampled buffer | |
226 // for reading, during which the bindings could be changed and need to be re covered. | |
224 class ScopedDrawingBufferBinder { | 227 class ScopedDrawingBufferBinder { |
225 STACK_ALLOCATED(); | 228 STACK_ALLOCATED(); |
226 public: | 229 public: |
227 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding) | 230 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, WebGLFramebuffer * framebufferBinding, GLenum target) |
228 : m_drawingBuffer(drawingBuffer) | 231 : m_drawingBuffer(drawingBuffer) |
229 , m_framebufferBinding(framebufferBinding) | 232 , m_readFramebufferBinding(framebufferBinding) |
233 , m_target(target) | |
230 { | 234 { |
231 // Commit DrawingBuffer if needed (e.g., for multisampling) | 235 // Commit DrawingBuffer if needed (e.g., for multisampling) |
232 if (!m_framebufferBinding && m_drawingBuffer) | 236 if (!m_readFramebufferBinding && m_drawingBuffer) |
233 m_drawingBuffer->commit(); | 237 m_drawingBuffer->commit(m_target); |
234 } | 238 } |
235 | 239 |
236 ~ScopedDrawingBufferBinder() | 240 ~ScopedDrawingBufferBinder() |
237 { | 241 { |
238 // Restore DrawingBuffer if needed | 242 // Restore DrawingBuffer if needed |
239 if (!m_framebufferBinding && m_drawingBuffer) | 243 if (!m_readFramebufferBinding && m_drawingBuffer) |
240 m_drawingBuffer->bind(); | 244 m_drawingBuffer->bind(m_target); |
Zhenyao Mo
2015/06/10 19:35:41
Instead of calling m_drawingBuffer->bind(m_target)
yunchao
2015/06/11 09:50:13
Yes, you are right. I removed the m_target variabl
| |
241 } | 245 } |
242 | 246 |
243 private: | 247 private: |
244 DrawingBuffer* m_drawingBuffer; | 248 DrawingBuffer* m_drawingBuffer; |
245 RawPtrWillBeMember<WebGLFramebuffer> m_framebufferBinding; | 249 RawPtrWillBeMember<WebGLFramebuffer> m_readFramebufferBinding; |
250 GLenum m_target; | |
246 }; | 251 }; |
247 | 252 |
248 GLint clamp(GLint value, GLint min, GLint max) | 253 GLint clamp(GLint value, GLint min, GLint max) |
249 { | 254 { |
250 if (value < min) | 255 if (value < min) |
251 value = min; | 256 value = min; |
252 if (value > max) | 257 if (value > max) |
253 value = max; | 258 value = max; |
254 return value; | 259 return value; |
255 } | 260 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 649 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); |
645 | 650 |
646 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); | 651 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); |
647 if (!buffer) { | 652 if (!buffer) { |
648 m_contextLostMode = SyntheticLostContext; | 653 m_contextLostMode = SyntheticLostContext; |
649 return; | 654 return; |
650 } | 655 } |
651 | 656 |
652 m_drawingBuffer = buffer.release(); | 657 m_drawingBuffer = buffer.release(); |
653 | 658 |
654 drawingBuffer()->bind(); | 659 drawingBuffer()->bind(GL_FRAMEBUFFER); |
655 setupFlags(); | 660 setupFlags(); |
656 } | 661 } |
657 | 662 |
658 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn Ptr<WebGraphicsContext3D> context) | 663 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn Ptr<WebGraphicsContext3D> context) |
659 { | 664 { |
660 WebGraphicsContext3D::Attributes attrs; | 665 WebGraphicsContext3D::Attributes attrs; |
661 attrs.alpha = m_requestedAttributes.alpha(); | 666 attrs.alpha = m_requestedAttributes.alpha(); |
662 attrs.depth = m_requestedAttributes.depth(); | 667 attrs.depth = m_requestedAttributes.depth(); |
663 attrs.stencil = m_requestedAttributes.stencil(); | 668 attrs.stencil = m_requestedAttributes.stencil(); |
664 attrs.antialias = m_requestedAttributes.antialias(); | 669 attrs.antialias = m_requestedAttributes.antialias(); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 webContext()->clearStencil(m_clearStencil & m_stencilMask); | 910 webContext()->clearStencil(m_clearStencil & m_stencilMask); |
906 else | 911 else |
907 webContext()->clearStencil(0); | 912 webContext()->clearStencil(0); |
908 clearMask |= GL_STENCIL_BUFFER_BIT; | 913 clearMask |= GL_STENCIL_BUFFER_BIT; |
909 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 914 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
910 } | 915 } |
911 | 916 |
912 drawingBuffer()->clearFramebuffers(clearMask); | 917 drawingBuffer()->clearFramebuffers(clearMask); |
913 | 918 |
914 restoreStateAfterClear(); | 919 restoreStateAfterClear(); |
915 if (m_framebufferBinding) | 920 drawingBuffer()->restoreFramebufferBindings(); |
916 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer Binding.get())); | |
917 drawingBuffer()->setBufferClearNeeded(false); | 921 drawingBuffer()->setBufferClearNeeded(false); |
918 | 922 |
919 return combinedClear ? CombinedClear : JustClear; | 923 return combinedClear ? CombinedClear : JustClear; |
920 } | 924 } |
921 | 925 |
922 void WebGLRenderingContextBase::restoreStateAfterClear() | 926 void WebGLRenderingContextBase::restoreStateAfterClear() |
923 { | 927 { |
924 if (isContextLost()) | 928 if (isContextLost()) |
925 return; | 929 return; |
926 | 930 |
(...skipping 30 matching lines...) Expand all Loading... | |
957 bool mustClearNow = clearIfComposited() != Skipped; | 961 bool mustClearNow = clearIfComposited() != Skipped; |
958 if (!m_markedCanvasDirty && !mustClearNow) | 962 if (!m_markedCanvasDirty && !mustClearNow) |
959 return false; | 963 return false; |
960 | 964 |
961 canvas()->clearCopiedImage(); | 965 canvas()->clearCopiedImage(); |
962 m_markedCanvasDirty = false; | 966 m_markedCanvasDirty = false; |
963 | 967 |
964 ScopedTexture2DRestorer restorer(this); | 968 ScopedTexture2DRestorer restorer(this); |
965 ScopedFramebufferRestorer fboRestorer(this); | 969 ScopedFramebufferRestorer fboRestorer(this); |
966 | 970 |
967 drawingBuffer()->commit(); | 971 drawingBuffer()->commit(GL_FRAMEBUFFER); |
968 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer (), sourceBuffer)) { | 972 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer (), sourceBuffer)) { |
969 canvas()->ensureUnacceleratedImageBuffer(); | 973 canvas()->ensureUnacceleratedImageBuffer(); |
970 if (canvas()->hasImageBuffer()) | 974 if (canvas()->hasImageBuffer()) |
971 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); | 975 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); |
972 } | 976 } |
973 | 977 |
974 return true; | 978 return true; |
975 } | 979 } |
976 | 980 |
977 ImageData* WebGLRenderingContextBase::paintRenderingResultsToImageData(SourceDra wingBuffer sourceBuffer) | 981 ImageData* WebGLRenderingContextBase::paintRenderingResultsToImageData(SourceDra wingBuffer sourceBuffer) |
978 { | 982 { |
979 if (isContextLost()) | 983 if (isContextLost()) |
980 return nullptr; | 984 return nullptr; |
981 if (m_requestedAttributes.premultipliedAlpha()) | 985 if (m_requestedAttributes.premultipliedAlpha()) |
982 return nullptr; | 986 return nullptr; |
983 | 987 |
984 clearIfComposited(); | 988 clearIfComposited(); |
985 drawingBuffer()->commit(); | 989 drawingBuffer()->commit(GL_FRAMEBUFFER); |
986 ScopedFramebufferRestorer restorer(this); | 990 ScopedFramebufferRestorer restorer(this); |
987 int width, height; | 991 int width, height; |
988 WTF::ArrayBufferContents contents; | 992 WTF::ArrayBufferContents contents; |
989 if (!drawingBuffer()->paintRenderingResultsToImageData(width, height, source Buffer, contents)) | 993 if (!drawingBuffer()->paintRenderingResultsToImageData(width, height, source Buffer, contents)) |
990 return nullptr; | 994 return nullptr; |
991 RefPtr<DOMArrayBuffer> imageDataPixels = DOMArrayBuffer::create(contents); | 995 RefPtr<DOMArrayBuffer> imageDataPixels = DOMArrayBuffer::create(contents); |
992 | 996 |
993 return ImageData::create( | 997 return ImageData::create( |
994 IntSize(width, height), | 998 IntSize(width, height), |
995 DOMUint8ClampedArray::create(imageDataPixels, 0, imageDataPixels->byteLe ngth())); | 999 DOMUint8ClampedArray::create(imageDataPixels, 0, imageDataPixels->byteLe ngth())); |
(...skipping 15 matching lines...) Expand all Loading... | |
1011 width = clamp(width, 1, maxWidth); | 1015 width = clamp(width, 1, maxWidth); |
1012 height = clamp(height, 1, maxHeight); | 1016 height = clamp(height, 1, maxHeight); |
1013 | 1017 |
1014 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off | 1018 // We don't have to mark the canvas as dirty, since the newly created image buffer will also start off |
1015 // clear (and this matches what reshape will do). | 1019 // clear (and this matches what reshape will do). |
1016 drawingBuffer()->reset(IntSize(width, height)); | 1020 drawingBuffer()->reset(IntSize(width, height)); |
1017 restoreStateAfterClear(); | 1021 restoreStateAfterClear(); |
1018 | 1022 |
1019 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ eTextureUnit].m_texture2DBinding.get())); | 1023 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ eTextureUnit].m_texture2DBinding.get())); |
1020 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB inding.get())); | 1024 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB inding.get())); |
1021 if (m_framebufferBinding) | 1025 drawingBuffer()->restoreFramebufferBindings(); |
1022 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer Binding.get())); | |
1023 } | 1026 } |
1024 | 1027 |
1025 int WebGLRenderingContextBase::drawingBufferWidth() const | 1028 int WebGLRenderingContextBase::drawingBufferWidth() const |
1026 { | 1029 { |
1027 return isContextLost() ? 0 : drawingBuffer()->size().width(); | 1030 return isContextLost() ? 0 : drawingBuffer()->size().width(); |
1028 } | 1031 } |
1029 | 1032 |
1030 int WebGLRenderingContextBase::drawingBufferHeight() const | 1033 int WebGLRenderingContextBase::drawingBufferHeight() const |
1031 { | 1034 { |
1032 return isContextLost() ? 0 : drawingBuffer()->size().height(); | 1035 return isContextLost() ? 0 : drawingBuffer()->size().height(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1363 | 1366 |
1364 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) | 1367 bool WebGLRenderingContextBase::validateFramebufferTarget(GLenum target) |
1365 { | 1368 { |
1366 if (target == GL_FRAMEBUFFER) | 1369 if (target == GL_FRAMEBUFFER) |
1367 return true; | 1370 return true; |
1368 return false; | 1371 return false; |
1369 } | 1372 } |
1370 | 1373 |
1371 WebGLFramebuffer* WebGLRenderingContextBase::getFramebufferBinding(GLenum target ) | 1374 WebGLFramebuffer* WebGLRenderingContextBase::getFramebufferBinding(GLenum target ) |
1372 { | 1375 { |
1373 return m_framebufferBinding.get(); | 1376 if (target == GL_FRAMEBUFFER) |
1377 return m_framebufferBinding.get(); | |
1378 return nullptr; | |
1374 } | 1379 } |
1375 | 1380 |
1376 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) | 1381 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) |
1377 { | 1382 { |
1378 if (isContextLost()) | 1383 if (isContextLost()) |
1379 return GL_FRAMEBUFFER_UNSUPPORTED; | 1384 return GL_FRAMEBUFFER_UNSUPPORTED; |
1380 if (!validateFramebufferTarget(target)) { | 1385 if (!validateFramebufferTarget(target)) { |
1381 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta rget"); | 1386 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta rget"); |
1382 return 0; | 1387 return 0; |
1383 } | 1388 } |
1384 if (!getFramebufferBinding(target) || !getFramebufferBinding(target)->object ()) | 1389 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
1390 if (!framebufferBinding || !framebufferBinding->object()) | |
1385 return GL_FRAMEBUFFER_COMPLETE; | 1391 return GL_FRAMEBUFFER_COMPLETE; |
1386 const char* reason = "framebuffer incomplete"; | 1392 const char* reason = "framebuffer incomplete"; |
1387 GLenum result = m_framebufferBinding->checkStatus(&reason); | 1393 GLenum result = framebufferBinding->checkStatus(&reason); |
1388 if (result != GL_FRAMEBUFFER_COMPLETE) { | 1394 if (result != GL_FRAMEBUFFER_COMPLETE) { |
1389 emitGLWarning("checkFramebufferStatus", reason); | 1395 emitGLWarning("checkFramebufferStatus", reason); |
1390 return result; | 1396 return result; |
1391 } | 1397 } |
1392 result = webContext()->checkFramebufferStatus(target); | 1398 result = webContext()->checkFramebufferStatus(target); |
1393 return result; | 1399 return result; |
1394 } | 1400 } |
1395 | 1401 |
1396 void WebGLRenderingContextBase::clear(GLbitfield mask) | 1402 void WebGLRenderingContextBase::clear(GLbitfield mask) |
1397 { | 1403 { |
1398 if (isContextLost()) | 1404 if (isContextLost()) |
1399 return; | 1405 return; |
1400 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) { | 1406 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B IT)) { |
1401 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); | 1407 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); |
1402 return; | 1408 return; |
1403 } | 1409 } |
1404 const char* reason = "framebuffer incomplete"; | 1410 const char* reason = "framebuffer incomplete"; |
1405 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 1411 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL _FRAMEBUFFER, &reason)) { |
1406 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); | 1412 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); |
1407 return; | 1413 return; |
1408 } | 1414 } |
1409 if (clearIfComposited(mask) != CombinedClear) | 1415 if (clearIfComposited(mask) != CombinedClear) |
1410 webContext()->clear(mask); | 1416 webContext()->clear(mask); |
1411 markContextChanged(CanvasChanged); | 1417 markContextChanged(CanvasChanged); |
1412 } | 1418 } |
1413 | 1419 |
1414 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl oat a) | 1420 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl oat a) |
1415 { | 1421 { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1556 } | 1562 } |
1557 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { | 1563 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { |
1558 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i s incompatible format"); | 1564 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i s incompatible format"); |
1559 return; | 1565 return; |
1560 } | 1566 } |
1561 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1567 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
1562 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow er of 2"); | 1568 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow er of 2"); |
1563 return; | 1569 return; |
1564 } | 1570 } |
1565 const char* reason = "framebuffer incomplete"; | 1571 const char* reason = "framebuffer incomplete"; |
1566 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 1572 if ((m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), G L_FRAMEBUFFER, &reason)) |
1573 || (getFramebufferBinding(GL_READ_FRAMEBUFFER) && !getFramebufferBinding (GL_READ_FRAMEBUFFER)->onAccess(webContext(), GL_READ_FRAMEBUFFER, &reason))) { | |
1567 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re ason); | 1574 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re ason); |
1568 return; | 1575 return; |
1569 } | 1576 } |
1570 clearIfComposited(); | 1577 clearIfComposited(); |
1571 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get() ); | 1578 GLenum framebufferTarget = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRA MEBUFFER; |
1579 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(framebuffer Target); | |
1580 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding, fr amebufferTarget); | |
1572 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei ght, border); | 1581 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei ght, border); |
1573 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. | 1582 // FIXME: if the framebuffer is not complete, none of the below should be ex ecuted. |
1574 tex->setLevelInfo(target, level, internalformat, width, height, 1, GL_UNSIGN ED_BYTE); | 1583 tex->setLevelInfo(target, level, internalformat, width, height, 1, GL_UNSIGN ED_BYTE); |
1575 } | 1584 } |
1576 | 1585 |
1577 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) | 1586 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
1578 { | 1587 { |
1579 if (isContextLost()) | 1588 if (isContextLost()) |
1580 return; | 1589 return; |
1581 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1590 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
(...skipping 17 matching lines...) Expand all Loading... | |
1599 return; | 1608 return; |
1600 } | 1609 } |
1601 GLenum internalformat = tex->getInternalFormat(target, level); | 1610 GLenum internalformat = tex->getInternalFormat(target, level); |
1602 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) | 1611 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) |
1603 return; | 1612 return; |
1604 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { | 1613 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra mebufferColorFormat())) { |
1605 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe r is incompatible format"); | 1614 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe r is incompatible format"); |
1606 return; | 1615 return; |
1607 } | 1616 } |
1608 const char* reason = "framebuffer incomplete"; | 1617 const char* reason = "framebuffer incomplete"; |
1609 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 1618 if ((m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), G L_FRAMEBUFFER, &reason)) |
1619 || (getFramebufferBinding(GL_READ_FRAMEBUFFER) && !getFramebufferBinding (GL_READ_FRAMEBUFFER)->onAccess(webContext(), GL_READ_FRAMEBUFFER, &reason))) { | |
1610 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason); | 1620 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason); |
1611 return; | 1621 return; |
1612 } | 1622 } |
1613 clearIfComposited(); | 1623 clearIfComposited(); |
1614 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.get() ); | 1624 GLenum framebufferTarget = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRA MEBUFFER; |
1625 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(framebuffer Target); | |
1626 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding, fr amebufferTarget); | |
1615 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height); | 1627 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width , height); |
1616 } | 1628 } |
1617 | 1629 |
1618 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() | 1630 PassRefPtrWillBeRawPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() |
1619 { | 1631 { |
1620 if (isContextLost()) | 1632 if (isContextLost()) |
1621 return nullptr; | 1633 return nullptr; |
1622 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); | 1634 RefPtrWillBeRawPtr<WebGLBuffer> o = WebGLBuffer::create(this); |
1623 addSharedObject(o.get()); | 1635 addSharedObject(o.get()); |
1624 return o.release(); | 1636 return o.release(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1724 return; | 1736 return; |
1725 removeBoundBuffer(buffer); | 1737 removeBoundBuffer(buffer); |
1726 } | 1738 } |
1727 | 1739 |
1728 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) | 1740 void WebGLRenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer) |
1729 { | 1741 { |
1730 if (!deleteObject(framebuffer)) | 1742 if (!deleteObject(framebuffer)) |
1731 return; | 1743 return; |
1732 if (framebuffer == m_framebufferBinding) { | 1744 if (framebuffer == m_framebufferBinding) { |
1733 m_framebufferBinding = nullptr; | 1745 m_framebufferBinding = nullptr; |
1734 drawingBuffer()->setFramebufferBinding(0); | 1746 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0); |
1735 // Have to call bindFramebuffer here to bind back to internal fbo. | 1747 // Have to call drawingBuffer()->bind() here to bind back to internal fb o. |
1736 drawingBuffer()->bind(); | 1748 drawingBuffer()->bind(GL_FRAMEBUFFER); |
1737 } | 1749 } |
1738 } | 1750 } |
1739 | 1751 |
1740 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) | 1752 void WebGLRenderingContextBase::deleteProgram(WebGLProgram* program) |
1741 { | 1753 { |
1742 deleteObject(program); | 1754 deleteObject(program); |
1743 // We don't reset m_currentProgram to 0 here because the deletion of the | 1755 // We don't reset m_currentProgram to 0 here because the deletion of the |
1744 // current program is delayed. | 1756 // current program is delayed. |
1745 } | 1757 } |
1746 | 1758 |
1747 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er) | 1759 void WebGLRenderingContextBase::deleteRenderbuffer(WebGLRenderbuffer* renderbuff er) |
1748 { | 1760 { |
1749 if (!deleteObject(renderbuffer)) | 1761 if (!deleteObject(renderbuffer)) |
1750 return; | 1762 return; |
1751 if (renderbuffer == m_renderbufferBinding) | 1763 if (renderbuffer == m_renderbufferBinding) |
1752 m_renderbufferBinding = nullptr; | 1764 m_renderbufferBinding = nullptr; |
1753 if (m_framebufferBinding) | 1765 if (m_framebufferBinding) |
1754 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(renderbuffer) ; | 1766 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFE R, renderbuffer); |
1767 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) | |
1768 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra mebuffer(GL_READ_FRAMEBUFFER, renderbuffer); | |
1755 } | 1769 } |
1756 | 1770 |
1757 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) | 1771 void WebGLRenderingContextBase::deleteShader(WebGLShader* shader) |
1758 { | 1772 { |
1759 deleteObject(shader); | 1773 deleteObject(shader); |
1760 } | 1774 } |
1761 | 1775 |
1762 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) | 1776 void WebGLRenderingContextBase::deleteTexture(WebGLTexture* texture) |
1763 { | 1777 { |
1764 if (!deleteObject(texture)) | 1778 if (!deleteObject(texture)) |
(...skipping 16 matching lines...) Expand all Loading... | |
1781 m_textureUnits[i].m_texture3DBinding = nullptr; | 1795 m_textureUnits[i].m_texture3DBinding = nullptr; |
1782 maxBoundTextureIndex = i; | 1796 maxBoundTextureIndex = i; |
1783 } | 1797 } |
1784 if (texture == m_textureUnits[i].m_texture2DArrayBinding) { | 1798 if (texture == m_textureUnits[i].m_texture2DArrayBinding) { |
1785 m_textureUnits[i].m_texture2DArrayBinding = nullptr; | 1799 m_textureUnits[i].m_texture2DArrayBinding = nullptr; |
1786 maxBoundTextureIndex = i; | 1800 maxBoundTextureIndex = i; |
1787 } | 1801 } |
1788 } | 1802 } |
1789 } | 1803 } |
1790 if (m_framebufferBinding) | 1804 if (m_framebufferBinding) |
1791 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(texture); | 1805 m_framebufferBinding->removeAttachmentFromBoundFramebuffer(GL_FRAMEBUFFE R, texture); |
1806 if (getFramebufferBinding(GL_READ_FRAMEBUFFER)) | |
1807 getFramebufferBinding(GL_READ_FRAMEBUFFER)->removeAttachmentFromBoundFra mebuffer(GL_READ_FRAMEBUFFER, texture); | |
1792 | 1808 |
1793 // If the deleted was bound to the the current maximum index, trace backward s to find the new max texture index | 1809 // If the deleted was bound to the the current maximum index, trace backward s to find the new max texture index |
1794 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound TextureIndex + 1)) { | 1810 if (m_onePlusMaxNonDefaultTextureUnit == static_cast<unsigned long>(maxBound TextureIndex + 1)) { |
1795 findNewMaxNonDefaultTextureUnit(); | 1811 findNewMaxNonDefaultTextureUnit(); |
1796 } | 1812 } |
1797 } | 1813 } |
1798 | 1814 |
1799 void WebGLRenderingContextBase::depthFunc(GLenum func) | 1815 void WebGLRenderingContextBase::depthFunc(GLenum func) |
1800 { | 1816 { |
1801 if (isContextLost()) | 1817 if (isContextLost()) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2001 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); | 2017 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); |
2002 return; | 2018 return; |
2003 } | 2019 } |
2004 if (buffer && !buffer->validate(contextGroup(), this)) { | 2020 if (buffer && !buffer->validate(contextGroup(), this)) { |
2005 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); | 2021 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); |
2006 return; | 2022 return; |
2007 } | 2023 } |
2008 // Don't allow the default framebuffer to be mutated; all current | 2024 // Don't allow the default framebuffer to be mutated; all current |
2009 // implementations use an FBO internally in place of the default | 2025 // implementations use an FBO internally in place of the default |
2010 // FBO. | 2026 // FBO. |
2011 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2027 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
2028 if (!framebufferBinding || !framebufferBinding->object()) { | |
2012 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound"); | 2029 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound"); |
2013 return; | 2030 return; |
2014 } | 2031 } |
2015 Platform3DObject bufferObject = objectOrZero(buffer); | 2032 Platform3DObject bufferObject = objectOrZero(buffer); |
2016 switch (attachment) { | 2033 switch (attachment) { |
2017 case GL_DEPTH_STENCIL_ATTACHMENT: | 2034 case GL_DEPTH_STENCIL_ATTACHMENT: |
2018 if (isDepthStencilSupported() || !buffer) { | 2035 if (isDepthStencilSupported() || !buffer) { |
2019 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject); | 2036 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject); |
2020 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, bufferObject); | 2037 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, bufferObject); |
2021 } else { | 2038 } else { |
2022 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer); | 2039 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(renderbuffertarget, buffer); |
2023 if (!emulatedStencilBuffer) { | 2040 if (!emulatedStencilBuffer) { |
2024 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", " out of memory"); | 2041 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", " out of memory"); |
2025 return; | 2042 return; |
2026 } | 2043 } |
2027 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject); | 2044 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r enderbuffertarget, bufferObject); |
2028 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 2045 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, objectOrZero(emulatedStencilBuffer)); |
2029 } | 2046 } |
2030 break; | 2047 break; |
2031 default: | 2048 default: |
2032 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta rget, bufferObject); | 2049 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta rget, bufferObject); |
2033 } | 2050 } |
2034 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); | 2051 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buf fer); |
2035 applyStencilTest(); | 2052 applyStencilTest(); |
2036 } | 2053 } |
2037 | 2054 |
2038 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) | 2055 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) |
2039 { | 2056 { |
2040 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) | 2057 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) |
2041 return; | 2058 return; |
2042 if (level) { | 2059 if (level) { |
2043 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); | 2060 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); |
2044 return; | 2061 return; |
2045 } | 2062 } |
2046 if (texture && !texture->validate(contextGroup(), this)) { | 2063 if (texture && !texture->validate(contextGroup(), this)) { |
2047 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context"); | 2064 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context"); |
2048 return; | 2065 return; |
2049 } | 2066 } |
2050 // Don't allow the default framebuffer to be mutated; all current | 2067 // Don't allow the default framebuffer to be mutated; all current |
2051 // implementations use an FBO internally in place of the default | 2068 // implementations use an FBO internally in place of the default |
2052 // FBO. | 2069 // FBO. |
2053 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2070 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); |
2071 if (!framebufferBinding || !framebufferBinding->object()) { | |
2054 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound"); | 2072 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound"); |
2055 return; | 2073 return; |
2056 } | 2074 } |
2057 Platform3DObject textureObject = objectOrZero(texture); | 2075 Platform3DObject textureObject = objectOrZero(texture); |
2058 switch (attachment) { | 2076 switch (attachment) { |
2059 case GL_DEPTH_STENCIL_ATTACHMENT: | 2077 case GL_DEPTH_STENCIL_ATTACHMENT: |
2060 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge t, textureObject, level); | 2078 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge t, textureObject, level); |
2061 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar get, textureObject, level); | 2079 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar get, textureObject, level); |
2062 break; | 2080 break; |
2063 case GL_DEPTH_ATTACHMENT: | |
Zhenyao Mo
2015/06/10 19:35:41
You haven't answered my question: why removing the
yunchao
2015/06/11 09:50:13
Sorry... seems that this code snippet is redundant
| |
2064 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | |
2065 break; | |
2066 case GL_STENCIL_ATTACHMENT: | |
2067 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | |
2068 break; | |
2069 default: | 2081 default: |
2070 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2082 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
2071 } | 2083 } |
2072 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); | 2084 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); |
2073 applyStencilTest(); | 2085 applyStencilTest(); |
2074 } | 2086 } |
2075 | 2087 |
2076 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2088 void WebGLRenderingContextBase::frontFace(GLenum mode) |
2077 { | 2089 { |
2078 if (isContextLost()) | 2090 if (isContextLost()) |
2079 return; | 2091 return; |
2080 switch (mode) { | 2092 switch (mode) { |
2081 case GL_CW: | 2093 case GL_CW: |
2082 case GL_CCW: | 2094 case GL_CCW: |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3316 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format/type n ot RGBA/UNSIGNED_BYTE or implementation-defined values"); | 3328 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format/type n ot RGBA/UNSIGNED_BYTE or implementation-defined values"); |
3317 return; | 3329 return; |
3318 } | 3330 } |
3319 } | 3331 } |
3320 // Validate array type against pixel type. | 3332 // Validate array type against pixel type. |
3321 if (pixels->type() != expectedViewType) { | 3333 if (pixels->type() != expectedViewType) { |
3322 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView w as the wrong type for the pixel format"); | 3334 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView w as the wrong type for the pixel format"); |
3323 return; | 3335 return; |
3324 } | 3336 } |
3325 const char* reason = "framebuffer incomplete"; | 3337 const char* reason = "framebuffer incomplete"; |
3326 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 3338 GLenum target = isWebGL2OrHigher() ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
3339 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(target); | |
3340 if (readFramebufferBinding && !readFramebufferBinding->onAccess(webContext() , target, &reason)) { | |
3327 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason ); | 3341 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason ); |
3328 return; | 3342 return; |
3329 } | 3343 } |
3330 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3344 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
3331 unsigned totalBytesRequired = 0; | 3345 unsigned totalBytesRequired = 0; |
3332 unsigned padding = 0; | 3346 unsigned padding = 0; |
3333 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w idth, height, m_packAlignment, &totalBytesRequired, &padding); | 3347 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w idth, height, m_packAlignment, &totalBytesRequired, &padding); |
3334 if (error != GL_NO_ERROR) { | 3348 if (error != GL_NO_ERROR) { |
3335 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3349 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
3336 return; | 3350 return; |
3337 } | 3351 } |
3338 if (pixels->byteLength() < totalBytesRequired) { | 3352 if (pixels->byteLength() < totalBytesRequired) { |
3339 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n ot large enough for dimensions"); | 3353 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n ot large enough for dimensions"); |
3340 return; | 3354 return; |
3341 } | 3355 } |
3342 | 3356 |
3343 clearIfComposited(); | 3357 clearIfComposited(); |
3344 void* data = pixels->baseAddress(); | 3358 void* data = pixels->baseAddress(); |
3345 | 3359 |
3346 { | 3360 { |
3347 ScopedDrawingBufferBinder binder(drawingBuffer(), m_framebufferBinding.g et()); | 3361 ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding , target); |
3348 webContext()->readPixels(x, y, width, height, format, type, data); | 3362 webContext()->readPixels(x, y, width, height, format, type, data); |
3349 } | 3363 } |
3350 | 3364 |
3351 #if OS(MACOSX) | 3365 #if OS(MACOSX) |
3352 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., | 3366 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., |
3353 // when alpha is off, readPixels should set alpha to 255 instead of 0. | 3367 // when alpha is off, readPixels should set alpha to 255 instead of 0. |
3354 if (!m_framebufferBinding && !drawingBuffer()->getActualAttributes().alpha) { | 3368 if (!readFramebufferBinding && !drawingBuffer()->getActualAttributes().alpha ) { |
3355 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); | 3369 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); |
3356 for (GLsizei iy = 0; iy < height; ++iy) { | 3370 for (GLsizei iy = 0; iy < height; ++iy) { |
3357 for (GLsizei ix = 0; ix < width; ++ix) { | 3371 for (GLsizei ix = 0; ix < width; ++ix) { |
3358 pixels[3] = 255; | 3372 pixels[3] = 255; |
3359 pixels += 4; | 3373 pixels += 4; |
3360 } | 3374 } |
3361 pixels += padding; | 3375 pixels += padding; |
3362 } | 3376 } |
3363 } | 3377 } |
3364 #endif | 3378 #endif |
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4622 | 4636 |
4623 if (mode == RealLostContext) { | 4637 if (mode == RealLostContext) { |
4624 // Inform the embedder that a lost context was received. In response, th e embedder might | 4638 // Inform the embedder that a lost context was received. In response, th e embedder might |
4625 // decide to take action such as asking the user for permission to use W ebGL again. | 4639 // decide to take action such as asking the user for permission to use W ebGL again. |
4626 if (LocalFrame* frame = canvas()->document().frame()) | 4640 if (LocalFrame* frame = canvas()->document().frame()) |
4627 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph icsResetStatusARB()); | 4641 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph icsResetStatusARB()); |
4628 } | 4642 } |
4629 | 4643 |
4630 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. | 4644 // Make absolutely sure we do not refer to an already-deleted texture or fra mebuffer. |
4631 drawingBuffer()->setTexture2DBinding(0); | 4645 drawingBuffer()->setTexture2DBinding(0); |
4632 drawingBuffer()->setFramebufferBinding(0); | 4646 drawingBuffer()->setFramebufferBinding(GL_FRAMEBUFFER, 0); |
4633 | 4647 |
4634 detachAndRemoveAllObjects(); | 4648 detachAndRemoveAllObjects(); |
4635 | 4649 |
4636 // Lose all the extensions. | 4650 // Lose all the extensions. |
4637 for (size_t i = 0; i < m_extensions.size(); ++i) { | 4651 for (size_t i = 0; i < m_extensions.size(); ++i) { |
4638 ExtensionTracker* tracker = m_extensions[i].get(); | 4652 ExtensionTracker* tracker = m_extensions[i].get(); |
4639 tracker->loseExtension(); | 4653 tracker->loseExtension(); |
4640 } | 4654 } |
4641 | 4655 |
4642 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) | 4656 for (size_t i = 0; i < WebGLExtensionNameCount; ++i) |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5725 if (!count) { | 5739 if (!count) { |
5726 markContextChanged(CanvasChanged); | 5740 markContextChanged(CanvasChanged); |
5727 return false; | 5741 return false; |
5728 } | 5742 } |
5729 | 5743 |
5730 if (!validateRenderingState(functionName)) { | 5744 if (!validateRenderingState(functionName)) { |
5731 return false; | 5745 return false; |
5732 } | 5746 } |
5733 | 5747 |
5734 const char* reason = "framebuffer incomplete"; | 5748 const char* reason = "framebuffer incomplete"; |
5735 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 5749 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL _FRAMEBUFFER, &reason)) { |
5736 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); | 5750 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); |
5737 return false; | 5751 return false; |
5738 } | 5752 } |
5739 | 5753 |
5740 return true; | 5754 return true; |
5741 } | 5755 } |
5742 | 5756 |
5743 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G Lenum mode, GLsizei count, GLenum type, long long offset) | 5757 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G Lenum mode, GLsizei count, GLenum type, long long offset) |
5744 { | 5758 { |
5745 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5759 if (isContextLost() || !validateDrawMode(functionName, mode)) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5777 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { | 5791 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { |
5778 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_ BUFFER bound"); | 5792 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_ BUFFER bound"); |
5779 return false; | 5793 return false; |
5780 } | 5794 } |
5781 | 5795 |
5782 if (!validateRenderingState(functionName)) { | 5796 if (!validateRenderingState(functionName)) { |
5783 return false; | 5797 return false; |
5784 } | 5798 } |
5785 | 5799 |
5786 const char* reason = "framebuffer incomplete"; | 5800 const char* reason = "framebuffer incomplete"; |
5787 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r eason)) { | 5801 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), GL _FRAMEBUFFER, &reason)) { |
5788 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); | 5802 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason ); |
5789 return false; | 5803 return false; |
5790 } | 5804 } |
5791 | 5805 |
5792 return true; | 5806 return true; |
5793 } | 5807 } |
5794 | 5808 |
5795 // Helper function to validate draw*Instanced calls | 5809 // Helper function to validate draw*Instanced calls |
5796 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName, GLsizei primcount) | 5810 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName, GLsizei primcount) |
5797 { | 5811 { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5935 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); | 5949 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); |
5936 } else { | 5950 } else { |
5937 // This likely shouldn't happen but is the best way to report it to the WebGL app. | 5951 // This likely shouldn't happen but is the best way to report it to the WebGL app. |
5938 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); | 5952 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); |
5939 } | 5953 } |
5940 return; | 5954 return; |
5941 } | 5955 } |
5942 | 5956 |
5943 m_drawingBuffer = buffer.release(); | 5957 m_drawingBuffer = buffer.release(); |
5944 | 5958 |
5945 drawingBuffer()->bind(); | 5959 drawingBuffer()->bind(GL_FRAMEBUFFER); |
5946 m_lostContextErrors.clear(); | 5960 m_lostContextErrors.clear(); |
5947 m_contextLostMode = NotLostContext; | 5961 m_contextLostMode = NotLostContext; |
5948 m_autoRecoveryMethod = Manual; | 5962 m_autoRecoveryMethod = Manual; |
5949 m_restoreAllowed = false; | 5963 m_restoreAllowed = false; |
5950 removeFromEvictedList(this); | 5964 removeFromEvictedList(this); |
5951 | 5965 |
5952 setupFlags(); | 5966 setupFlags(); |
5953 initializeNewContext(); | 5967 initializeNewContext(); |
5954 markContextChanged(CanvasContextChanged); | 5968 markContextChanged(CanvasContextChanged); |
5955 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); | 5969 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte xtrestored, false, true, "")); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6106 | 6120 |
6107 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer) | 6121 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer) |
6108 { | 6122 { |
6109 if (buffer) | 6123 if (buffer) |
6110 buffer->setHasEverBeenBound(); | 6124 buffer->setHasEverBeenBound(); |
6111 | 6125 |
6112 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { | 6126 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { |
6113 m_framebufferBinding = buffer; | 6127 m_framebufferBinding = buffer; |
6114 applyStencilTest(); | 6128 applyStencilTest(); |
6115 } | 6129 } |
6116 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ())); | 6130 drawingBuffer()->setFramebufferBinding(target, objectOrZero(getFramebufferBi nding(target))); |
6117 | 6131 |
6118 if (!buffer) { | 6132 if (!buffer) { |
6119 // Instead of binding fb 0, bind the drawing buffer. | 6133 // Instead of binding fb 0, bind the drawing buffer. |
6120 drawingBuffer()->bind(target); | 6134 drawingBuffer()->bind(target); |
6121 } else { | 6135 } else { |
6122 webContext()->bindFramebuffer(target, buffer->object()); | 6136 webContext()->bindFramebuffer(target, buffer->object()); |
6123 } | 6137 } |
6124 } | 6138 } |
6125 | 6139 |
6126 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6140 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6211 | 6225 |
6212 return totalBytesPerPixel; | 6226 return totalBytesPerPixel; |
6213 } | 6227 } |
6214 | 6228 |
6215 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6229 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6216 { | 6230 { |
6217 return m_drawingBuffer.get(); | 6231 return m_drawingBuffer.get(); |
6218 } | 6232 } |
6219 | 6233 |
6220 } // namespace blink | 6234 } // namespace blink |
OLD | NEW |