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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return nullptr; | 508 return nullptr; |
509 } | 509 } |
510 | 510 |
511 Extensions3DUtil extensionsUtil(context.get()); | 511 Extensions3DUtil extensionsUtil(context.get()); |
512 if (extensionsUtil.supportsExtension("GL_EXT_debug_marker")) | 512 if (extensionsUtil.supportsExtension("GL_EXT_debug_marker")) |
513 context->pushGroupMarkerEXT("WebGLRenderingContext"); | 513 context->pushGroupMarkerEXT("WebGLRenderingContext"); |
514 | 514 |
515 OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRendering
Context(canvas, context.release(), attrs)); | 515 OwnPtr<WebGLRenderingContext> renderingContext = adoptPtr(new WebGLRendering
Context(canvas, context.release(), attrs)); |
516 renderingContext->suspendIfNeeded(); | 516 renderingContext->suspendIfNeeded(); |
517 | 517 |
518 if (renderingContext->m_drawingBuffer->isZeroSized()) { | 518 if (!renderingContext->m_drawingBuffer) { |
519 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); | 519 canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcon
textcreationerror, false, true, "Could not create a WebGL context.")); |
520 return nullptr; | 520 return nullptr; |
521 } | 521 } |
522 | 522 |
523 return renderingContext.release(); | 523 return renderingContext.release(); |
524 } | 524 } |
525 | 525 |
526 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requested
Attributes) | 526 WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
ssOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* requested
Attributes) |
527 : CanvasRenderingContext(passedCanvas) | 527 : CanvasRenderingContext(passedCanvas) |
528 , ActiveDOMObject(&passedCanvas->document()) | 528 , ActiveDOMObject(&passedCanvas->document()) |
529 , m_context(context) | |
530 , m_drawingBuffer(0) | 529 , m_drawingBuffer(0) |
| 530 , m_context(context.get()) |
531 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont
extLostEvent) | 531 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContext::dispatchCont
extLostEvent) |
532 , m_restoreAllowed(false) | 532 , m_restoreAllowed(false) |
533 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext) | 533 , m_restoreTimer(this, &WebGLRenderingContext::maybeRestoreContext) |
534 , m_generatedImageCache(4) | 534 , m_generatedImageCache(4) |
535 , m_contextLost(false) | 535 , m_contextLost(false) |
536 , m_contextLostMode(SyntheticLostContext) | 536 , m_contextLostMode(SyntheticLostContext) |
537 , m_requestedAttributes(requestedAttributes->clone()) | 537 , m_requestedAttributes(requestedAttributes->clone()) |
538 , m_synthesizedErrorsToConsole(true) | 538 , m_synthesizedErrorsToConsole(true) |
539 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 539 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
540 , m_multisamplingAllowed(false) | 540 , m_multisamplingAllowed(false) |
541 , m_multisamplingObserverRegistered(false) | 541 , m_multisamplingObserverRegistered(false) |
542 , m_onePlusMaxEnabledAttribIndex(0) | 542 , m_onePlusMaxEnabledAttribIndex(0) |
543 , m_onePlusMaxNonDefaultTextureUnit(0) | 543 , m_onePlusMaxNonDefaultTextureUnit(0) |
544 { | 544 { |
545 ASSERT(m_context); | 545 ASSERT(m_context); |
546 ScriptWrappable::init(this); | 546 ScriptWrappable::init(this); |
547 | 547 |
548 m_contextGroup = WebGLContextGroup::create(); | 548 m_contextGroup = WebGLContextGroup::create(); |
549 m_contextGroup->addContext(this); | 549 m_contextGroup->addContext(this); |
550 | 550 |
551 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 551 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
552 m_context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 552 m_context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); |
553 | 553 |
554 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 554 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); |
555 | 555 |
556 // Create the DrawingBuffer and initialize the platform layer. | 556 // Create the DrawingBuffer and initialize the platform layer. |
557 DrawingBuffer::PreserveDrawingBuffer preserve = requestedAttributes->preserv
eDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 557 DrawingBuffer::PreserveDrawingBuffer preserve = requestedAttributes->preserv
eDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
558 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize()
, preserve, contextEvictionManager.release()); | 558 m_drawingBuffer = DrawingBuffer::create(context, clampedCanvasSize(), preser
ve, contextEvictionManager.release()); |
| 559 if (!m_drawingBuffer) |
| 560 return; |
559 | 561 |
560 if (!m_drawingBuffer->isZeroSized()) { | 562 m_drawingBuffer->bind(); |
561 m_drawingBuffer->bind(); | 563 setupFlags(); |
562 setupFlags(); | 564 initializeNewContext(); |
563 initializeNewContext(); | |
564 } | |
565 | 565 |
566 // Register extensions. | 566 // Register extensions. |
567 static const char* const webkitPrefix[] = { "WEBKIT_", 0, }; | 567 static const char* const webkitPrefix[] = { "WEBKIT_", 0, }; |
568 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; | 568 static const char* const bothPrefixes[] = { "", "WEBKIT_", 0, }; |
569 | 569 |
570 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); | 570 registerExtension<ANGLEInstancedArrays>(m_angleInstancedArrays); |
571 registerExtension<EXTTextureFilterAnisotropic>(m_extTextureFilterAnisotropic
, ApprovedExtension, bothPrefixes); | 571 registerExtension<EXTTextureFilterAnisotropic>(m_extTextureFilterAnisotropic
, ApprovedExtension, bothPrefixes); |
572 registerExtension<OESElementIndexUint>(m_oesElementIndexUint); | 572 registerExtension<OESElementIndexUint>(m_oesElementIndexUint); |
573 registerExtension<OESStandardDerivatives>(m_oesStandardDerivatives); | 573 registerExtension<OESStandardDerivatives>(m_oesStandardDerivatives); |
574 registerExtension<OESTextureFloat>(m_oesTextureFloat); | 574 registerExtension<OESTextureFloat>(m_oesTextureFloat); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 m_backDrawBuffer = GL_BACK; | 648 m_backDrawBuffer = GL_BACK; |
649 | 649 |
650 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe
rtexArrayObjectOES::VaoTypeDefault); | 650 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe
rtexArrayObjectOES::VaoTypeDefault); |
651 addContextObject(m_defaultVertexArrayObject.get()); | 651 addContextObject(m_defaultVertexArrayObject.get()); |
652 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 652 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
653 | 653 |
654 m_vertexAttribValue.resize(m_maxVertexAttribs); | 654 m_vertexAttribValue.resize(m_maxVertexAttribs); |
655 | 655 |
656 createFallbackBlackTextures1x1(); | 656 createFallbackBlackTextures1x1(); |
657 | 657 |
658 m_drawingBuffer->reset(clampedCanvasSize()); | |
659 | |
660 m_context->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 658 m_context->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
661 m_context->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 659 m_context->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
662 | 660 |
663 m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallbac
k(this)); | 661 m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallbac
k(this)); |
664 m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessa
geCallback(this)); | 662 m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessa
geCallback(this)); |
665 | 663 |
666 m_context->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 664 m_context->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
667 m_context->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 665 m_context->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
668 | 666 |
669 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. | 667 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 page->removeMultisamplingChangedObserver(this); | 748 page->removeMultisamplingChangedObserver(this); |
751 } | 749 } |
752 | 750 |
753 willDestroyContext(this); | 751 willDestroyContext(this); |
754 } | 752 } |
755 | 753 |
756 void WebGLRenderingContext::destroyContext() | 754 void WebGLRenderingContext::destroyContext() |
757 { | 755 { |
758 m_contextLost = true; | 756 m_contextLost = true; |
759 | 757 |
760 // The drawing buffer holds a context reference. It must also be destroyed | 758 if (!m_context) { |
761 // in order for the context to be released. | 759 ASSERT(!m_drawingBuffer); |
762 m_drawingBuffer->releaseResources(); | 760 return; |
| 761 } |
763 | 762 |
764 m_extensionsUtil.clear(); | 763 m_extensionsUtil.clear(); |
765 | 764 |
766 if (m_context) { | 765 m_context->setContextLostCallback(0); |
767 m_context->setContextLostCallback(0); | 766 m_context->setErrorMessageCallback(0); |
768 m_context->setErrorMessageCallback(0); | 767 m_context = 0; |
769 m_context.clear(); | 768 |
770 } | 769 ASSERT(m_drawingBuffer); |
| 770 m_drawingBuffer.clear(); |
771 } | 771 } |
772 | 772 |
773 void WebGLRenderingContext::markContextChanged() | 773 void WebGLRenderingContext::markContextChanged() |
774 { | 774 { |
775 if (m_framebufferBinding || isContextLost()) | 775 if (m_framebufferBinding || isContextLost()) |
776 return; | 776 return; |
777 | 777 |
778 m_drawingBuffer->markContentsChanged(); | 778 m_drawingBuffer->markContentsChanged(); |
779 | 779 |
780 m_layerCleared = false; | 780 m_layerCleared = false; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 restoreStateAfterClear(); | 952 restoreStateAfterClear(); |
953 | 953 |
954 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTe
xtureUnit].m_texture2DBinding.get())); | 954 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTe
xtureUnit].m_texture2DBinding.get())); |
955 m_context->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBind
ing.get())); | 955 m_context->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBind
ing.get())); |
956 if (m_framebufferBinding) | 956 if (m_framebufferBinding) |
957 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 957 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); |
958 } | 958 } |
959 | 959 |
960 int WebGLRenderingContext::drawingBufferWidth() const | 960 int WebGLRenderingContext::drawingBufferWidth() const |
961 { | 961 { |
962 return m_drawingBuffer->size().width(); | 962 return isContextLost() ? 0 : m_drawingBuffer->size().width(); |
963 } | 963 } |
964 | 964 |
965 int WebGLRenderingContext::drawingBufferHeight() const | 965 int WebGLRenderingContext::drawingBufferHeight() const |
966 { | 966 { |
967 return m_drawingBuffer->size().height(); | 967 return isContextLost() ? 0 : m_drawingBuffer->size().height(); |
968 } | 968 } |
969 | 969 |
970 unsigned WebGLRenderingContext::sizeInBytes(GLenum type) | 970 unsigned WebGLRenderingContext::sizeInBytes(GLenum type) |
971 { | 971 { |
972 switch (type) { | 972 switch (type) { |
973 case GL_BYTE: | 973 case GL_BYTE: |
974 return sizeof(GLbyte); | 974 return sizeof(GLbyte); |
975 case GL_UNSIGNED_BYTE: | 975 case GL_UNSIGNED_BYTE: |
976 return sizeof(GLubyte); | 976 return sizeof(GLubyte); |
977 case GL_SHORT: | 977 case GL_SHORT: |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 | 1305 |
1306 void WebGLRenderingContext::clear(GLbitfield mask) | 1306 void WebGLRenderingContext::clear(GLbitfield mask) |
1307 { | 1307 { |
1308 if (isContextLost()) | 1308 if (isContextLost()) |
1309 return; | 1309 return; |
1310 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { | 1310 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { |
1311 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); | 1311 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); |
1312 return; | 1312 return; |
1313 } | 1313 } |
1314 const char* reason = "framebuffer incomplete"; | 1314 const char* reason = "framebuffer incomplete"; |
1315 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 1315 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context, &reas
on)) { |
1316 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); | 1316 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); |
1317 return; | 1317 return; |
1318 } | 1318 } |
1319 if (!clearIfComposited(mask)) | 1319 if (!clearIfComposited(mask)) |
1320 m_context->clear(mask); | 1320 m_context->clear(mask); |
1321 markContextChanged(); | 1321 markContextChanged(); |
1322 } | 1322 } |
1323 | 1323 |
1324 void WebGLRenderingContext::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat
a) | 1324 void WebGLRenderingContext::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat
a) |
1325 { | 1325 { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 return; | 1459 return; |
1460 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1460 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
1461 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); | 1461 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); |
1462 return; | 1462 return; |
1463 } | 1463 } |
1464 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1464 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
1465 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); | 1465 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); |
1466 return; | 1466 return; |
1467 } | 1467 } |
1468 const char* reason = "framebuffer incomplete"; | 1468 const char* reason = "framebuffer incomplete"; |
1469 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 1469 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context, &reas
on)) { |
1470 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); | 1470 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); |
1471 return; | 1471 return; |
1472 } | 1472 } |
1473 clearIfComposited(); | 1473 clearIfComposited(); |
1474 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1474 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
1475 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); | 1475 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); |
1476 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. | 1476 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. |
1477 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); | 1477 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); |
1478 } | 1478 } |
1479 | 1479 |
(...skipping 22 matching lines...) Expand all Loading... |
1502 return; | 1502 return; |
1503 } | 1503 } |
1504 GLenum internalformat = tex->getInternalFormat(target, level); | 1504 GLenum internalformat = tex->getInternalFormat(target, level); |
1505 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) | 1505 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) |
1506 return; | 1506 return; |
1507 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1507 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
1508 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); | 1508 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); |
1509 return; | 1509 return; |
1510 } | 1510 } |
1511 const char* reason = "framebuffer incomplete"; | 1511 const char* reason = "framebuffer incomplete"; |
1512 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 1512 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context, &reas
on)) { |
1513 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); | 1513 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); |
1514 return; | 1514 return; |
1515 } | 1515 } |
1516 clearIfComposited(); | 1516 clearIfComposited(); |
1517 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1517 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
1518 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); | 1518 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); |
1519 } | 1519 } |
1520 | 1520 |
1521 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() | 1521 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() |
1522 { | 1522 { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 { | 1609 { |
1610 if (isContextLost() || !object) | 1610 if (isContextLost() || !object) |
1611 return false; | 1611 return false; |
1612 if (!object->validate(contextGroup(), this)) { | 1612 if (!object->validate(contextGroup(), this)) { |
1613 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); | 1613 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); |
1614 return false; | 1614 return false; |
1615 } | 1615 } |
1616 if (object->object()) { | 1616 if (object->object()) { |
1617 // We need to pass in context here because we want | 1617 // We need to pass in context here because we want |
1618 // things in this context unbound. | 1618 // things in this context unbound. |
1619 object->deleteObject(m_context.get()); | 1619 object->deleteObject(m_context); |
1620 } | 1620 } |
1621 return true; | 1621 return true; |
1622 } | 1622 } |
1623 | 1623 |
1624 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) | 1624 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) |
1625 { | 1625 { |
1626 if (!deleteObject(buffer)) | 1626 if (!deleteObject(buffer)) |
1627 return; | 1627 return; |
1628 if (m_boundArrayBuffer == buffer) | 1628 if (m_boundArrayBuffer == buffer) |
1629 m_boundArrayBuffer = 0; | 1629 m_boundArrayBuffer = 0; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 | 1722 |
1723 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
der) | 1723 void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
der) |
1724 { | 1724 { |
1725 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) | 1725 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) |
1726 return; | 1726 return; |
1727 if (!program->detachShader(shader)) { | 1727 if (!program->detachShader(shader)) { |
1728 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); | 1728 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); |
1729 return; | 1729 return; |
1730 } | 1730 } |
1731 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); | 1731 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); |
1732 shader->onDetached(m_context.get()); | 1732 shader->onDetached(m_context); |
1733 } | 1733 } |
1734 | 1734 |
1735 void WebGLRenderingContext::disable(GLenum cap) | 1735 void WebGLRenderingContext::disable(GLenum cap) |
1736 { | 1736 { |
1737 if (isContextLost() || !validateCapability("disable", cap)) | 1737 if (isContextLost() || !validateCapability("disable", cap)) |
1738 return; | 1738 return; |
1739 if (cap == GL_STENCIL_TEST) { | 1739 if (cap == GL_STENCIL_TEST) { |
1740 m_stencilEnabled = false; | 1740 m_stencilEnabled = false; |
1741 applyStencilTest(); | 1741 applyStencilTest(); |
1742 return; | 1742 return; |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 { | 2896 { |
2897 if (!buffer || isContextLost()) | 2897 if (!buffer || isContextLost()) |
2898 return 0; | 2898 return 0; |
2899 | 2899 |
2900 if (!buffer->hasEverBeenBound()) | 2900 if (!buffer->hasEverBeenBound()) |
2901 return 0; | 2901 return 0; |
2902 | 2902 |
2903 return m_context->isBuffer(buffer->object()); | 2903 return m_context->isBuffer(buffer->object()); |
2904 } | 2904 } |
2905 | 2905 |
2906 bool WebGLRenderingContext::isContextLost() | 2906 bool WebGLRenderingContext::isContextLost() const |
2907 { | 2907 { |
2908 return m_contextLost; | 2908 return m_contextLost; |
2909 } | 2909 } |
2910 | 2910 |
2911 GLboolean WebGLRenderingContext::isEnabled(GLenum cap) | 2911 GLboolean WebGLRenderingContext::isEnabled(GLenum cap) |
2912 { | 2912 { |
2913 if (isContextLost() || !validateCapability("isEnabled", cap)) | 2913 if (isContextLost() || !validateCapability("isEnabled", cap)) |
2914 return 0; | 2914 return 0; |
2915 if (cap == GL_STENCIL_TEST) | 2915 if (cap == GL_STENCIL_TEST) |
2916 return m_stencilEnabled; | 2916 return m_stencilEnabled; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) { | 3063 if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) { |
3064 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format not RGBA o
r type not UNSIGNED_BYTE"); | 3064 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format not RGBA o
r type not UNSIGNED_BYTE"); |
3065 return; | 3065 return; |
3066 } | 3066 } |
3067 // Validate array type against pixel type. | 3067 // Validate array type against pixel type. |
3068 if (pixels->type() != ArrayBufferView::TypeUint8) { | 3068 if (pixels->type() != ArrayBufferView::TypeUint8) { |
3069 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot Uint8Array"); | 3069 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot Uint8Array"); |
3070 return; | 3070 return; |
3071 } | 3071 } |
3072 const char* reason = "framebuffer incomplete"; | 3072 const char* reason = "framebuffer incomplete"; |
3073 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 3073 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context, &reas
on)) { |
3074 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); | 3074 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); |
3075 return; | 3075 return; |
3076 } | 3076 } |
3077 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3077 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
3078 unsigned totalBytesRequired = 0; | 3078 unsigned totalBytesRequired = 0; |
3079 unsigned padding = 0; | 3079 unsigned padding = 0; |
3080 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); | 3080 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); |
3081 if (error != GL_NO_ERROR) { | 3081 if (error != GL_NO_ERROR) { |
3082 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3082 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
3083 return; | 3083 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 return; | 3127 return; |
3128 switch (internalformat) { | 3128 switch (internalformat) { |
3129 case GL_DEPTH_COMPONENT16: | 3129 case GL_DEPTH_COMPONENT16: |
3130 case GL_RGBA4: | 3130 case GL_RGBA4: |
3131 case GL_RGB5_A1: | 3131 case GL_RGB5_A1: |
3132 case GL_RGB565: | 3132 case GL_RGB565: |
3133 case GL_STENCIL_INDEX8: | 3133 case GL_STENCIL_INDEX8: |
3134 m_context->renderbufferStorage(target, internalformat, width, height); | 3134 m_context->renderbufferStorage(target, internalformat, width, height); |
3135 m_renderbufferBinding->setInternalFormat(internalformat); | 3135 m_renderbufferBinding->setInternalFormat(internalformat); |
3136 m_renderbufferBinding->setSize(width, height); | 3136 m_renderbufferBinding->setSize(width, height); |
3137 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get()); | 3137 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context); |
3138 break; | 3138 break; |
3139 case GL_DEPTH_STENCIL_OES: | 3139 case GL_DEPTH_STENCIL_OES: |
3140 if (isDepthStencilSupported()) { | 3140 if (isDepthStencilSupported()) { |
3141 m_context->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, widt
h, height); | 3141 m_context->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, widt
h, height); |
3142 } else { | 3142 } else { |
3143 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(target, m_renderbufferBinding.get()); | 3143 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(target, m_renderbufferBinding.get()); |
3144 if (!emulatedStencilBuffer) { | 3144 if (!emulatedStencilBuffer) { |
3145 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out
of memory"); | 3145 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out
of memory"); |
3146 return; | 3146 return; |
3147 } | 3147 } |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3456 { | 3456 { |
3457 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce
ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas
Element, target, level, internalformat, canvas->width(), canvas->height(), 0, fo
rmat, type, 0, 0)) | 3457 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce
ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas
Element, target, level, internalformat, canvas->width(), canvas->height(), 0, fo
rmat, type, 0, 0)) |
3458 return; | 3458 return; |
3459 | 3459 |
3460 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3460 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
3461 // If possible, copy from the canvas element directly to the texture | 3461 // If possible, copy from the canvas element directly to the texture |
3462 // via the GPU, without a read-back to system memory. | 3462 // via the GPU, without a read-back to system memory. |
3463 if (GL_TEXTURE_2D == target && texture) { | 3463 if (GL_TEXTURE_2D == target && texture) { |
3464 if (!canvas->is3D()) { | 3464 if (!canvas->is3D()) { |
3465 ImageBuffer* buffer = canvas->buffer(); | 3465 ImageBuffer* buffer = canvas->buffer(); |
3466 if (buffer && buffer->copyToPlatformTexture(m_context.get(), texture
->object(), internalformat, type, | 3466 if (buffer && buffer->copyToPlatformTexture(m_context, texture->obje
ct(), internalformat, type, |
3467 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3467 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
3468 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3468 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
3469 return; | 3469 return; |
3470 } | 3470 } |
3471 } else { | 3471 } else { |
3472 WebGLRenderingContext* gl = toWebGLRenderingContext(canvas->renderin
gContext()); | 3472 WebGLRenderingContext* gl = toWebGLRenderingContext(canvas->renderin
gContext()); |
3473 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context.get()
, texture->object(), internalformat, type, | 3473 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context, text
ure->object(), internalformat, type, |
3474 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3474 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
3475 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3475 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
3476 return; | 3476 return; |
3477 } | 3477 } |
3478 } | 3478 } |
3479 } | 3479 } |
3480 | 3480 |
3481 RefPtr<ImageData> imageData = canvas->getImageData(); | 3481 RefPtr<ImageData> imageData = canvas->getImageData(); |
3482 if (imageData) | 3482 if (imageData) |
3483 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); | 3483 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); |
(...skipping 19 matching lines...) Expand all Loading... |
3503 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 3503 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
3504 { | 3504 { |
3505 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) | 3505 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) |
3506 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) | 3506 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) |
3507 return; | 3507 return; |
3508 | 3508 |
3509 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 3509 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
3510 // Otherwise, it will fall back to the normal SW path. | 3510 // Otherwise, it will fall back to the normal SW path. |
3511 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3511 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
3512 if (GL_TEXTURE_2D == target && texture) { | 3512 if (GL_TEXTURE_2D == target && texture) { |
3513 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o
bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ | 3513 if (video->copyVideoTextureToPlatformTexture(m_context, texture->object(
), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
3514 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), type); | 3514 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), type); |
3515 return; | 3515 return; |
3516 } | 3516 } |
3517 } | 3517 } |
3518 | 3518 |
3519 // Normal pure SW path. | 3519 // Normal pure SW path. |
3520 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e()); | 3520 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e()); |
3521 if (!image) | 3521 if (!image) |
3522 return; | 3522 return; |
3523 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, except
ionState); | 3523 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, except
ionState); |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3997 if (!checkObjectToBeBound("useProgram", program, deleted)) | 3997 if (!checkObjectToBeBound("useProgram", program, deleted)) |
3998 return; | 3998 return; |
3999 if (deleted) | 3999 if (deleted) |
4000 program = 0; | 4000 program = 0; |
4001 if (program && !program->linkStatus()) { | 4001 if (program && !program->linkStatus()) { |
4002 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid
"); | 4002 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid
"); |
4003 return; | 4003 return; |
4004 } | 4004 } |
4005 if (m_currentProgram != program) { | 4005 if (m_currentProgram != program) { |
4006 if (m_currentProgram) | 4006 if (m_currentProgram) |
4007 m_currentProgram->onDetached(m_context.get()); | 4007 m_currentProgram->onDetached(m_context); |
4008 m_currentProgram = program; | 4008 m_currentProgram = program; |
4009 m_context->useProgram(objectOrZero(program)); | 4009 m_context->useProgram(objectOrZero(program)); |
4010 if (program) | 4010 if (program) |
4011 program->onAttached(); | 4011 program->onAttached(); |
4012 } | 4012 } |
4013 } | 4013 } |
4014 | 4014 |
4015 void WebGLRenderingContext::validateProgram(WebGLProgram* program) | 4015 void WebGLRenderingContext::validateProgram(WebGLProgram* program) |
4016 { | 4016 { |
4017 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 4017 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4211 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); | 4211 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); |
4212 return; | 4212 return; |
4213 } | 4213 } |
4214 | 4214 |
4215 if (!m_restoreTimer.isActive()) | 4215 if (!m_restoreTimer.isActive()) |
4216 m_restoreTimer.startOneShot(0); | 4216 m_restoreTimer.startOneShot(0); |
4217 } | 4217 } |
4218 | 4218 |
4219 blink::WebLayer* WebGLRenderingContext::platformLayer() const | 4219 blink::WebLayer* WebGLRenderingContext::platformLayer() const |
4220 { | 4220 { |
4221 return m_drawingBuffer->platformLayer(); | 4221 return isContextLost() ? 0 : m_drawingBuffer->platformLayer(); |
4222 } | 4222 } |
4223 | 4223 |
4224 Extensions3DUtil* WebGLRenderingContext::extensionsUtil() | 4224 Extensions3DUtil* WebGLRenderingContext::extensionsUtil() |
4225 { | 4225 { |
4226 if (!m_extensionsUtil) | 4226 if (!m_extensionsUtil) |
4227 m_extensionsUtil = adoptPtr(new Extensions3DUtil(m_context.get())); | 4227 m_extensionsUtil = adoptPtr(new Extensions3DUtil(m_context)); |
4228 return m_extensionsUtil.get(); | 4228 return m_extensionsUtil.get(); |
4229 } | 4229 } |
4230 | 4230 |
4231 void WebGLRenderingContext::removeSharedObject(WebGLSharedObject* object) | 4231 void WebGLRenderingContext::removeSharedObject(WebGLSharedObject* object) |
4232 { | 4232 { |
4233 m_contextGroup->removeObject(object); | 4233 m_contextGroup->removeObject(object); |
4234 } | 4234 } |
4235 | 4235 |
4236 void WebGLRenderingContext::addSharedObject(WebGLSharedObject* object) | 4236 void WebGLRenderingContext::addSharedObject(WebGLSharedObject* object) |
4237 { | 4237 { |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5192 if (!count) { | 5192 if (!count) { |
5193 markContextChanged(); | 5193 markContextChanged(); |
5194 return false; | 5194 return false; |
5195 } | 5195 } |
5196 | 5196 |
5197 if (!validateRenderingState(functionName)) { | 5197 if (!validateRenderingState(functionName)) { |
5198 return false; | 5198 return false; |
5199 } | 5199 } |
5200 | 5200 |
5201 const char* reason = "framebuffer incomplete"; | 5201 const char* reason = "framebuffer incomplete"; |
5202 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 5202 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context, &reas
on)) { |
5203 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); | 5203 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); |
5204 return false; | 5204 return false; |
5205 } | 5205 } |
5206 | 5206 |
5207 return true; | 5207 return true; |
5208 } | 5208 } |
5209 | 5209 |
5210 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GLenu
m mode, GLsizei count, GLenum type, long long offset) | 5210 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GLenu
m mode, GLsizei count, GLenum type, long long offset) |
5211 { | 5211 { |
5212 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5212 if (isContextLost() || !validateDrawMode(functionName, mode)) |
(...skipping 29 matching lines...) Expand all Loading... |
5242 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { | 5242 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { |
5243 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_
BUFFER bound"); | 5243 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_
BUFFER bound"); |
5244 return false; | 5244 return false; |
5245 } | 5245 } |
5246 | 5246 |
5247 if (!validateRenderingState(functionName)) { | 5247 if (!validateRenderingState(functionName)) { |
5248 return false; | 5248 return false; |
5249 } | 5249 } |
5250 | 5250 |
5251 const char* reason = "framebuffer incomplete"; | 5251 const char* reason = "framebuffer incomplete"; |
5252 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 5252 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context, &reas
on)) { |
5253 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); | 5253 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); |
5254 return false; | 5254 return false; |
5255 } | 5255 } |
5256 | 5256 |
5257 return true; | 5257 return true; |
5258 } | 5258 } |
5259 | 5259 |
5260 // Helper function to validate draw*Instanced calls | 5260 // Helper function to validate draw*Instanced calls |
5261 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GLsi
zei primcount) | 5261 bool WebGLRenderingContext::validateDrawInstanced(const char* functionName, GLsi
zei primcount) |
5262 { | 5262 { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5381 if (!frame) | 5381 if (!frame) |
5382 return; | 5382 return; |
5383 | 5383 |
5384 Settings* settings = frame->settings(); | 5384 Settings* settings = frame->settings(); |
5385 | 5385 |
5386 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 5386 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
5387 return; | 5387 return; |
5388 | 5388 |
5389 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument()->url().string(), settings); | 5389 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument()->url().string(), settings); |
5390 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes)); | 5390 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes)); |
5391 if (!context) { | 5391 |
| 5392 ASSERT(!m_drawingBuffer); |
| 5393 if (context) { |
| 5394 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad
optRef(new WebGLRenderingContextEvictionManager()); |
| 5395 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p
reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 5396 m_drawingBuffer = DrawingBuffer::create(context.release(), clampedCanvas
Size(), preserve, contextEvictionManager.release()); |
| 5397 } |
| 5398 |
| 5399 bool failToRestore = !m_drawingBuffer; |
| 5400 if (failToRestore) { |
5392 if (m_contextLostMode == RealLostContext) { | 5401 if (m_contextLostMode == RealLostContext) { |
5393 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); | 5402 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); |
5394 } else { | 5403 } else { |
5395 // This likely shouldn't happen but is the best way to report it to
the WebGL app. | 5404 // This likely shouldn't happen but is the best way to report it to
the WebGL app. |
5396 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); | 5405 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); |
5397 } | 5406 } |
5398 return; | 5407 return; |
5399 } | 5408 } |
5400 | 5409 |
5401 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | |
5402 | |
5403 // Construct a new drawing buffer with the new WebGraphicsContext3D. | |
5404 m_drawingBuffer->releaseResources(); | |
5405 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->prese
rveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | |
5406 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(),
preserve, contextEvictionManager.release()); | |
5407 | |
5408 if (m_drawingBuffer->isZeroSized()) | |
5409 return; | |
5410 | |
5411 m_drawingBuffer->bind(); | 5410 m_drawingBuffer->bind(); |
5412 | 5411 |
5413 m_lostContextErrors.clear(); | 5412 m_lostContextErrors.clear(); |
5414 | 5413 |
5415 m_context = context.release(); | 5414 m_context = m_drawingBuffer->context(); |
5416 m_contextLost = false; | 5415 m_contextLost = false; |
5417 | 5416 |
5418 setupFlags(); | 5417 setupFlags(); |
5419 initializeNewContext(); | 5418 initializeNewContext(); |
5420 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte
xtrestored, false, true, "")); | 5419 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte
xtrestored, false, true, "")); |
5421 } | 5420 } |
5422 | 5421 |
5423 String WebGLRenderingContext::ensureNotNull(const String& text) const | 5422 String WebGLRenderingContext::ensureNotNull(const String& text) const |
5424 { | 5423 { |
5425 if (text.isNull()) | 5424 if (text.isNull()) |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5607 if (m_textureUnits[i].m_texture2DBinding | 5606 if (m_textureUnits[i].m_texture2DBinding |
5608 || m_textureUnits[i].m_textureCubeMapBinding) { | 5607 || m_textureUnits[i].m_textureCubeMapBinding) { |
5609 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5608 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
5610 return; | 5609 return; |
5611 } | 5610 } |
5612 } | 5611 } |
5613 m_onePlusMaxNonDefaultTextureUnit = 0; | 5612 m_onePlusMaxNonDefaultTextureUnit = 0; |
5614 } | 5613 } |
5615 | 5614 |
5616 } // namespace WebCore | 5615 } // namespace WebCore |
OLD | NEW |