| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 size_t WebGLRenderingContextBase::oldestContextIndex() | 120 size_t WebGLRenderingContextBase::oldestContextIndex() |
| 121 { | 121 { |
| 122 if (!activeContexts().size()) | 122 if (!activeContexts().size()) |
| 123 return maxGLActiveContexts; | 123 return maxGLActiveContexts; |
| 124 | 124 |
| 125 WebGLRenderingContextBase* candidate = activeContexts().first(); | 125 WebGLRenderingContextBase* candidate = activeContexts().first(); |
| 126 size_t candidateID = 0; | 126 size_t candidateID = 0; |
| 127 for (size_t ii = 1; ii < activeContexts().size(); ++ii) { | 127 for (size_t ii = 1; ii < activeContexts().size(); ++ii) { |
| 128 WebGLRenderingContextBase* context = activeContexts()[ii]; | 128 WebGLRenderingContextBase* context = activeContexts()[ii]; |
| 129 if (context->webGraphicsContext3D() && candidate->webGraphicsContext3D()
&& context->webGraphicsContext3D()->lastFlushID() < candidate->webGraphicsConte
xt3D()->lastFlushID()) { | 129 if (context->webContext() && candidate->webContext() && context->webCont
ext()->lastFlushID() < candidate->webContext()->lastFlushID()) { |
| 130 candidate = context; | 130 candidate = context; |
| 131 candidateID = ii; | 131 candidateID = ii; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 return candidateID; | 135 return candidateID; |
| 136 } | 136 } |
| 137 | 137 |
| 138 IntSize WebGLRenderingContextBase::oldestContextSize() | 138 IntSize WebGLRenderingContextBase::oldestContextSize() |
| 139 { | 139 { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas()
, message); | 476 InspectorInstrumentation::didFireWebGLErrorOrWarning(m_context->canvas()
, message); |
| 477 } | 477 } |
| 478 virtual ~WebGLRenderingContextErrorMessageCallback() { } | 478 virtual ~WebGLRenderingContextErrorMessageCallback() { } |
| 479 private: | 479 private: |
| 480 WebGLRenderingContextBase* m_context; | 480 WebGLRenderingContextBase* m_context; |
| 481 }; | 481 }; |
| 482 | 482 |
| 483 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
nvas, PassOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* r
equestedAttributes) | 483 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
nvas, PassOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* r
equestedAttributes) |
| 484 : CanvasRenderingContext(passedCanvas) | 484 : CanvasRenderingContext(passedCanvas) |
| 485 , ActiveDOMObject(&passedCanvas->document()) | 485 , ActiveDOMObject(&passedCanvas->document()) |
| 486 , m_context(context) | |
| 487 , m_drawingBuffer(nullptr) | 486 , m_drawingBuffer(nullptr) |
| 488 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch
ContextLostEvent) | 487 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch
ContextLostEvent) |
| 489 , m_restoreAllowed(false) | 488 , m_restoreAllowed(false) |
| 490 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 489 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
| 491 , m_generatedImageCache(4) | 490 , m_generatedImageCache(4) |
| 492 , m_contextLost(false) | 491 , m_contextLost(false) |
| 493 , m_contextLostMode(SyntheticLostContext) | 492 , m_contextLostMode(SyntheticLostContext) |
| 494 , m_requestedAttributes(requestedAttributes->clone()) | 493 , m_requestedAttributes(requestedAttributes->clone()) |
| 495 , m_synthesizedErrorsToConsole(true) | 494 , m_synthesizedErrorsToConsole(true) |
| 496 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 495 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
| 497 , m_multisamplingAllowed(false) | 496 , m_multisamplingAllowed(false) |
| 498 , m_multisamplingObserverRegistered(false) | 497 , m_multisamplingObserverRegistered(false) |
| 499 , m_onePlusMaxEnabledAttribIndex(0) | 498 , m_onePlusMaxEnabledAttribIndex(0) |
| 500 , m_onePlusMaxNonDefaultTextureUnit(0) | 499 , m_onePlusMaxNonDefaultTextureUnit(0) |
| 501 { | 500 { |
| 502 ASSERT(m_context); | 501 ASSERT(context); |
| 503 ScriptWrappable::init(this); | 502 ScriptWrappable::init(this); |
| 504 | 503 |
| 505 m_contextGroup = WebGLContextGroup::create(); | 504 m_contextGroup = WebGLContextGroup::create(); |
| 506 m_contextGroup->addContext(this); | 505 m_contextGroup->addContext(this); |
| 507 | 506 |
| 508 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 507 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
| 509 m_context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 508 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); |
| 510 | 509 |
| 511 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 510 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); |
| 512 | 511 |
| 513 // Create the DrawingBuffer and initialize the platform layer. | 512 // Create the DrawingBuffer and initialize the platform layer. |
| 514 DrawingBuffer::PreserveDrawingBuffer preserve = requestedAttributes->preserv
eDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 513 DrawingBuffer::PreserveDrawingBuffer preserve = requestedAttributes->preserv
eDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 515 m_drawingBuffer = DrawingBuffer::create(m_context.get(), clampedCanvasSize()
, preserve, contextEvictionManager.release()); | 514 m_drawingBuffer = DrawingBuffer::create(context, clampedCanvasSize(), preser
ve, contextEvictionManager.release()); |
| 515 if (!m_drawingBuffer) |
| 516 return; |
| 516 | 517 |
| 517 if (!m_drawingBuffer->isZeroSized()) { | 518 m_drawingBuffer->bind(); |
| 518 m_drawingBuffer->bind(); | 519 setupFlags(); |
| 519 setupFlags(); | 520 initializeNewContext(); |
| 520 initializeNewContext(); | |
| 521 } | |
| 522 } | 521 } |
| 523 | 522 |
| 524 void WebGLRenderingContextBase::initializeNewContext() | 523 void WebGLRenderingContextBase::initializeNewContext() |
| 525 { | 524 { |
| 526 ASSERT(!isContextLost()); | 525 ASSERT(!isContextLost()); |
| 527 m_needsUpdate = true; | 526 m_needsUpdate = true; |
| 528 m_markedCanvasDirty = false; | 527 m_markedCanvasDirty = false; |
| 529 m_activeTextureUnit = 0; | 528 m_activeTextureUnit = 0; |
| 530 m_packAlignment = 4; | 529 m_packAlignment = 4; |
| 531 m_unpackAlignment = 4; | 530 m_unpackAlignment = 4; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 547 m_layerCleared = false; | 546 m_layerCleared = false; |
| 548 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; | 547 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; |
| 549 | 548 |
| 550 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; | 549 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; |
| 551 m_scissorEnabled = false; | 550 m_scissorEnabled = false; |
| 552 m_clearDepth = 1; | 551 m_clearDepth = 1; |
| 553 m_clearStencil = 0; | 552 m_clearStencil = 0; |
| 554 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; | 553 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; |
| 555 | 554 |
| 556 GLint numCombinedTextureImageUnits = 0; | 555 GLint numCombinedTextureImageUnits = 0; |
| 557 m_context->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedText
ureImageUnits); | 556 webContext()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedT
extureImageUnits); |
| 558 m_textureUnits.clear(); | 557 m_textureUnits.clear(); |
| 559 m_textureUnits.resize(numCombinedTextureImageUnits); | 558 m_textureUnits.resize(numCombinedTextureImageUnits); |
| 560 | 559 |
| 561 GLint numVertexAttribs = 0; | 560 GLint numVertexAttribs = 0; |
| 562 m_context->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); | 561 webContext()->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); |
| 563 m_maxVertexAttribs = numVertexAttribs; | 562 m_maxVertexAttribs = numVertexAttribs; |
| 564 | 563 |
| 565 m_maxTextureSize = 0; | 564 m_maxTextureSize = 0; |
| 566 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 565 webContext()->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 567 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT
extureSize); | 566 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT
extureSize); |
| 568 m_maxCubeMapTextureSize = 0; | 567 m_maxCubeMapTextureSize = 0; |
| 569 m_context->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureSiz
e); | 568 webContext()->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTexture
Size); |
| 570 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu
reSize, m_maxCubeMapTextureSize); | 569 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu
reSize, m_maxCubeMapTextureSize); |
| 571 m_maxRenderbufferSize = 0; | 570 m_maxRenderbufferSize = 0; |
| 572 m_context->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); | 571 webContext()->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); |
| 573 | 572 |
| 574 // These two values from EXT_draw_buffers are lazily queried. | 573 // These two values from EXT_draw_buffers are lazily queried. |
| 575 m_maxDrawBuffers = 0; | 574 m_maxDrawBuffers = 0; |
| 576 m_maxColorAttachments = 0; | 575 m_maxColorAttachments = 0; |
| 577 | 576 |
| 578 m_backDrawBuffer = GL_BACK; | 577 m_backDrawBuffer = GL_BACK; |
| 579 | 578 |
| 580 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe
rtexArrayObjectOES::VaoTypeDefault); | 579 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe
rtexArrayObjectOES::VaoTypeDefault); |
| 581 addContextObject(m_defaultVertexArrayObject.get()); | 580 addContextObject(m_defaultVertexArrayObject.get()); |
| 582 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 581 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 583 | 582 |
| 584 m_vertexAttribValue.resize(m_maxVertexAttribs); | 583 m_vertexAttribValue.resize(m_maxVertexAttribs); |
| 585 | 584 |
| 586 createFallbackBlackTextures1x1(); | 585 createFallbackBlackTextures1x1(); |
| 587 | 586 |
| 588 m_drawingBuffer->reset(clampedCanvasSize()); | 587 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 589 | 588 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 590 m_context->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | |
| 591 m_context->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | |
| 592 | 589 |
| 593 m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallbac
k(this)); | 590 m_contextLostCallbackAdapter = adoptPtr(new WebGLRenderingContextLostCallbac
k(this)); |
| 594 m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessa
geCallback(this)); | 591 m_errorMessageCallbackAdapter = adoptPtr(new WebGLRenderingContextErrorMessa
geCallback(this)); |
| 595 | 592 |
| 596 m_context->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 593 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
| 597 m_context->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 594 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
| 598 | 595 |
| 599 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. | 596 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. |
| 600 m_context->flush(); | 597 webContext()->flush(); |
| 601 | 598 |
| 602 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 599 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
| 603 m_extensionEnabled[i] = false; | 600 m_extensionEnabled[i] = false; |
| 604 | 601 |
| 605 activateContext(this); | 602 activateContext(this); |
| 606 } | 603 } |
| 607 | 604 |
| 608 void WebGLRenderingContextBase::setupFlags() | 605 void WebGLRenderingContextBase::setupFlags() |
| 609 { | 606 { |
| 610 ASSERT(m_context); | 607 ASSERT(m_drawingBuffer); |
| 611 if (Page* p = canvas()->document().page()) { | 608 if (Page* p = canvas()->document().page()) { |
| 612 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled
(); | 609 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled
(); |
| 613 | 610 |
| 614 if (!m_multisamplingObserverRegistered && m_requestedAttributes->antiali
as()) { | 611 if (!m_multisamplingObserverRegistered && m_requestedAttributes->antiali
as()) { |
| 615 m_multisamplingAllowed = m_drawingBuffer->multisample(); | 612 m_multisamplingAllowed = m_drawingBuffer->multisample(); |
| 616 p->addMultisamplingChangedObserver(this); | 613 p->addMultisamplingChangedObserver(this); |
| 617 m_multisamplingObserverRegistered = true; | 614 m_multisamplingObserverRegistered = true; |
| 618 } | 615 } |
| 619 } | 616 } |
| 620 | 617 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 page->removeMultisamplingChangedObserver(this); | 688 page->removeMultisamplingChangedObserver(this); |
| 692 } | 689 } |
| 693 | 690 |
| 694 willDestroyContext(this); | 691 willDestroyContext(this); |
| 695 } | 692 } |
| 696 | 693 |
| 697 void WebGLRenderingContextBase::destroyContext() | 694 void WebGLRenderingContextBase::destroyContext() |
| 698 { | 695 { |
| 699 m_contextLost = true; | 696 m_contextLost = true; |
| 700 | 697 |
| 701 // The drawing buffer holds a context reference. It must also be destroyed | 698 if (!m_drawingBuffer) |
| 702 // in order for the context to be released. | 699 return; |
| 703 m_drawingBuffer->releaseResources(); | |
| 704 | 700 |
| 705 m_extensionsUtil.clear(); | 701 m_extensionsUtil.clear(); |
| 706 | 702 |
| 707 if (m_context) { | 703 webContext()->setContextLostCallback(0); |
| 708 m_context->setContextLostCallback(0); | 704 webContext()->setErrorMessageCallback(0); |
| 709 m_context->setErrorMessageCallback(0); | 705 |
| 710 m_context.clear(); | 706 ASSERT(m_drawingBuffer); |
| 711 } | 707 m_drawingBuffer.clear(); |
| 712 } | 708 } |
| 713 | 709 |
| 714 void WebGLRenderingContextBase::markContextChanged() | 710 void WebGLRenderingContextBase::markContextChanged() |
| 715 { | 711 { |
| 716 if (m_framebufferBinding || isContextLost()) | 712 if (m_framebufferBinding || isContextLost()) |
| 717 return; | 713 return; |
| 718 | 714 |
| 719 m_drawingBuffer->markContentsChanged(); | 715 m_drawingBuffer->markContentsChanged(); |
| 720 | 716 |
| 721 m_layerCleared = false; | 717 m_layerCleared = false; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 739 | 735 |
| 740 if (!m_drawingBuffer->layerComposited() || m_layerCleared | 736 if (!m_drawingBuffer->layerComposited() || m_layerCleared |
| 741 || m_requestedAttributes->preserveDrawingBuffer() || (mask && m_framebuf
ferBinding)) | 737 || m_requestedAttributes->preserveDrawingBuffer() || (mask && m_framebuf
ferBinding)) |
| 742 return false; | 738 return false; |
| 743 | 739 |
| 744 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); | 740 RefPtr<WebGLContextAttributes> contextAttributes = getContextAttributes(); |
| 745 | 741 |
| 746 // Determine if it's possible to combine the clear the user asked for and th
is clear. | 742 // Determine if it's possible to combine the clear the user asked for and th
is clear. |
| 747 bool combinedClear = mask && !m_scissorEnabled; | 743 bool combinedClear = mask && !m_scissorEnabled; |
| 748 | 744 |
| 749 m_context->disable(GL_SCISSOR_TEST); | 745 webContext()->disable(GL_SCISSOR_TEST); |
| 750 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) | 746 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { |
| 751 m_context->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 747 webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, |
| 752 m_colorMask[1] ? m_clearColor[1] : 0, | 748 m_colorMask[1] ? m_clearColor[1] : 0, |
| 753 m_colorMask[2] ? m_clearColor[2] : 0, | 749 m_colorMask[2] ? m_clearColor[2] : 0, |
| 754 m_colorMask[3] ? m_clearColor[3] : 0); | 750 m_colorMask[3] ? m_clearColor[3] : 0); |
| 755 else | 751 } else { |
| 756 m_context->clearColor(0, 0, 0, 0); | 752 webContext()->clearColor(0, 0, 0, 0); |
| 757 m_context->colorMask(true, true, true, true); | 753 } |
| 754 webContext()->colorMask(true, true, true, true); |
| 758 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 755 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; |
| 759 if (contextAttributes->depth()) { | 756 if (contextAttributes->depth()) { |
| 760 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) | 757 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) |
| 761 m_context->clearDepth(1.0f); | 758 webContext()->clearDepth(1.0f); |
| 762 clearMask |= GL_DEPTH_BUFFER_BIT; | 759 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 763 m_context->depthMask(true); | 760 webContext()->depthMask(true); |
| 764 } | 761 } |
| 765 if (contextAttributes->stencil()) { | 762 if (contextAttributes->stencil()) { |
| 766 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 763 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 767 m_context->clearStencil(m_clearStencil & m_stencilMask); | 764 webContext()->clearStencil(m_clearStencil & m_stencilMask); |
| 768 else | 765 else |
| 769 m_context->clearStencil(0); | 766 webContext()->clearStencil(0); |
| 770 clearMask |= GL_STENCIL_BUFFER_BIT; | 767 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 771 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 768 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 772 } | 769 } |
| 773 | 770 |
| 774 m_drawingBuffer->clearFramebuffers(clearMask); | 771 m_drawingBuffer->clearFramebuffers(clearMask); |
| 775 | 772 |
| 776 restoreStateAfterClear(); | 773 restoreStateAfterClear(); |
| 777 if (m_framebufferBinding) | 774 if (m_framebufferBinding) |
| 778 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 775 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 779 m_layerCleared = true; | 776 m_layerCleared = true; |
| 780 | 777 |
| 781 return combinedClear; | 778 return combinedClear; |
| 782 } | 779 } |
| 783 | 780 |
| 784 void WebGLRenderingContextBase::restoreStateAfterClear() | 781 void WebGLRenderingContextBase::restoreStateAfterClear() |
| 785 { | 782 { |
| 786 if (isContextLost()) | 783 if (isContextLost()) |
| 787 return; | 784 return; |
| 788 | 785 |
| 789 // Restore the state that the context set. | 786 // Restore the state that the context set. |
| 790 if (m_scissorEnabled) | 787 if (m_scissorEnabled) |
| 791 m_context->enable(GL_SCISSOR_TEST); | 788 webContext()->enable(GL_SCISSOR_TEST); |
| 792 m_context->clearColor(m_clearColor[0], m_clearColor[1], | 789 webContext()->clearColor(m_clearColor[0], m_clearColor[1], |
| 793 m_clearColor[2], m_clearColor[3]); | 790 m_clearColor[2], m_clearColor[3]); |
| 794 m_context->colorMask(m_colorMask[0], m_colorMask[1], | 791 webContext()->colorMask(m_colorMask[0], m_colorMask[1], |
| 795 m_colorMask[2], m_colorMask[3]); | 792 m_colorMask[2], m_colorMask[3]); |
| 796 m_context->clearDepth(m_clearDepth); | 793 webContext()->clearDepth(m_clearDepth); |
| 797 m_context->clearStencil(m_clearStencil); | 794 webContext()->clearStencil(m_clearStencil); |
| 798 m_context->stencilMaskSeparate(GL_FRONT, m_stencilMask); | 795 webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 799 m_context->depthMask(m_depthMask); | 796 webContext()->depthMask(m_depthMask); |
| 800 } | 797 } |
| 801 | 798 |
| 802 void WebGLRenderingContextBase::markLayerComposited() | 799 void WebGLRenderingContextBase::markLayerComposited() |
| 803 { | 800 { |
| 804 if (!isContextLost()) | 801 if (!isContextLost()) |
| 805 m_drawingBuffer->markLayerComposited(); | 802 m_drawingBuffer->markLayerComposited(); |
| 806 } | 803 } |
| 807 | 804 |
| 808 void WebGLRenderingContextBase::paintRenderingResultsToCanvas() | 805 void WebGLRenderingContextBase::paintRenderingResultsToCanvas() |
| 809 { | 806 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 832 m_markedCanvasDirty = false; | 829 m_markedCanvasDirty = false; |
| 833 | 830 |
| 834 m_drawingBuffer->commit(); | 831 m_drawingBuffer->commit(); |
| 835 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu
ffer.get())) { | 832 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu
ffer.get())) { |
| 836 canvas()->ensureUnacceleratedImageBuffer(); | 833 canvas()->ensureUnacceleratedImageBuffer(); |
| 837 if (canvas()->hasImageBuffer()) | 834 if (canvas()->hasImageBuffer()) |
| 838 m_drawingBuffer->paintRenderingResultsToCanvas(canvas()->buffer()); | 835 m_drawingBuffer->paintRenderingResultsToCanvas(canvas()->buffer()); |
| 839 } | 836 } |
| 840 | 837 |
| 841 if (m_framebufferBinding) | 838 if (m_framebufferBinding) |
| 842 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 839 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 843 else | 840 else |
| 844 m_drawingBuffer->bind(); | 841 m_drawingBuffer->bind(); |
| 845 } | 842 } |
| 846 | 843 |
| 847 PassRefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageDat
a() | 844 PassRefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageDat
a() |
| 848 { | 845 { |
| 849 if (isContextLost()) | 846 if (isContextLost()) |
| 850 return nullptr; | 847 return nullptr; |
| 851 | 848 |
| 852 clearIfComposited(); | 849 clearIfComposited(); |
| 853 m_drawingBuffer->commit(); | 850 m_drawingBuffer->commit(); |
| 854 int width, height; | 851 int width, height; |
| 855 RefPtr<Uint8ClampedArray> imageDataPixels = m_drawingBuffer->paintRenderingR
esultsToImageData(width, height); | 852 RefPtr<Uint8ClampedArray> imageDataPixels = m_drawingBuffer->paintRenderingR
esultsToImageData(width, height); |
| 856 if (!imageDataPixels) | 853 if (!imageDataPixels) |
| 857 return nullptr; | 854 return nullptr; |
| 858 | 855 |
| 859 if (m_framebufferBinding) | 856 if (m_framebufferBinding) |
| 860 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 857 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 861 else | 858 else |
| 862 m_drawingBuffer->bind(); | 859 m_drawingBuffer->bind(); |
| 863 | 860 |
| 864 return ImageData::create(IntSize(width, height), imageDataPixels); | 861 return ImageData::create(IntSize(width, height), imageDataPixels); |
| 865 } | 862 } |
| 866 | 863 |
| 867 void WebGLRenderingContextBase::reshape(int width, int height) | 864 void WebGLRenderingContextBase::reshape(int width, int height) |
| 868 { | 865 { |
| 869 if (isContextLost()) | 866 if (isContextLost()) |
| 870 return; | 867 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 885 if (renderBox && renderBox->hasAcceleratedCompositing()) | 882 if (renderBox && renderBox->hasAcceleratedCompositing()) |
| 886 renderBox->contentChanged(CanvasChanged); | 883 renderBox->contentChanged(CanvasChanged); |
| 887 m_needsUpdate = false; | 884 m_needsUpdate = false; |
| 888 } | 885 } |
| 889 | 886 |
| 890 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off | 887 // We don't have to mark the canvas as dirty, since the newly created image
buffer will also start off |
| 891 // clear (and this matches what reshape will do). | 888 // clear (and this matches what reshape will do). |
| 892 m_drawingBuffer->reset(IntSize(width, height)); | 889 m_drawingBuffer->reset(IntSize(width, height)); |
| 893 restoreStateAfterClear(); | 890 restoreStateAfterClear(); |
| 894 | 891 |
| 895 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTe
xtureUnit].m_texture2DBinding.get())); | 892 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activ
eTextureUnit].m_texture2DBinding.get())); |
| 896 m_context->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBind
ing.get())); | 893 webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferB
inding.get())); |
| 897 if (m_framebufferBinding) | 894 if (m_framebufferBinding) |
| 898 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin
ding.get())); | 895 webContext()->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebuffer
Binding.get())); |
| 899 } | 896 } |
| 900 | 897 |
| 901 int WebGLRenderingContextBase::drawingBufferWidth() const | 898 int WebGLRenderingContextBase::drawingBufferWidth() const |
| 902 { | 899 { |
| 903 return m_drawingBuffer->size().width(); | 900 return isContextLost() ? 0 : m_drawingBuffer->size().width(); |
| 904 } | 901 } |
| 905 | 902 |
| 906 int WebGLRenderingContextBase::drawingBufferHeight() const | 903 int WebGLRenderingContextBase::drawingBufferHeight() const |
| 907 { | 904 { |
| 908 return m_drawingBuffer->size().height(); | 905 return isContextLost() ? 0 : m_drawingBuffer->size().height(); |
| 909 } | 906 } |
| 910 | 907 |
| 911 unsigned WebGLRenderingContextBase::sizeInBytes(GLenum type) | 908 unsigned WebGLRenderingContextBase::sizeInBytes(GLenum type) |
| 912 { | 909 { |
| 913 switch (type) { | 910 switch (type) { |
| 914 case GL_BYTE: | 911 case GL_BYTE: |
| 915 return sizeof(GLbyte); | 912 return sizeof(GLbyte); |
| 916 case GL_UNSIGNED_BYTE: | 913 case GL_UNSIGNED_BYTE: |
| 917 return sizeof(GLubyte); | 914 return sizeof(GLubyte); |
| 918 case GL_SHORT: | 915 case GL_SHORT: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 932 | 929 |
| 933 void WebGLRenderingContextBase::activeTexture(GLenum texture) | 930 void WebGLRenderingContextBase::activeTexture(GLenum texture) |
| 934 { | 931 { |
| 935 if (isContextLost()) | 932 if (isContextLost()) |
| 936 return; | 933 return; |
| 937 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { | 934 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { |
| 938 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); | 935 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); |
| 939 return; | 936 return; |
| 940 } | 937 } |
| 941 m_activeTextureUnit = texture - GL_TEXTURE0; | 938 m_activeTextureUnit = texture - GL_TEXTURE0; |
| 942 m_context->activeTexture(texture); | 939 webContext()->activeTexture(texture); |
| 943 | 940 |
| 944 m_drawingBuffer->setActiveTextureUnit(texture); | 941 m_drawingBuffer->setActiveTextureUnit(texture); |
| 945 | 942 |
| 946 } | 943 } |
| 947 | 944 |
| 948 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader*
shader) | 945 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader*
shader) |
| 949 { | 946 { |
| 950 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) | 947 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val
idateWebGLObject("attachShader", shader)) |
| 951 return; | 948 return; |
| 952 if (!program->attachShader(shader)) { | 949 if (!program->attachShader(shader)) { |
| 953 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); | 950 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme
nt already has shader"); |
| 954 return; | 951 return; |
| 955 } | 952 } |
| 956 m_context->attachShader(objectOrZero(program), objectOrZero(shader)); | 953 webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); |
| 957 shader->onAttached(); | 954 shader->onAttached(); |
| 958 } | 955 } |
| 959 | 956 |
| 960 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint
index, const String& name) | 957 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint
index, const String& name) |
| 961 { | 958 { |
| 962 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 959 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) |
| 963 return; | 960 return; |
| 964 if (!validateLocationLength("bindAttribLocation", name)) | 961 if (!validateLocationLength("bindAttribLocation", name)) |
| 965 return; | 962 return; |
| 966 if (!validateString("bindAttribLocation", name)) | 963 if (!validateString("bindAttribLocation", name)) |
| 967 return; | 964 return; |
| 968 if (isPrefixReserved(name)) { | 965 if (isPrefixReserved(name)) { |
| 969 synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved
prefix"); | 966 synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved
prefix"); |
| 970 return; | 967 return; |
| 971 } | 968 } |
| 972 if (index >= m_maxVertexAttribs) { | 969 if (index >= m_maxVertexAttribs) { |
| 973 synthesizeGLError(GL_INVALID_VALUE, "bindAttribLocation", "index out of
range"); | 970 synthesizeGLError(GL_INVALID_VALUE, "bindAttribLocation", "index out of
range"); |
| 974 return; | 971 return; |
| 975 } | 972 } |
| 976 m_context->bindAttribLocation(objectOrZero(program), index, name.utf8().data
()); | 973 webContext()->bindAttribLocation(objectOrZero(program), index, name.utf8().d
ata()); |
| 977 } | 974 } |
| 978 | 975 |
| 979 bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, W
ebGLObject* object, bool& deleted) | 976 bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, W
ebGLObject* object, bool& deleted) |
| 980 { | 977 { |
| 981 deleted = false; | 978 deleted = false; |
| 982 if (isContextLost()) | 979 if (isContextLost()) |
| 983 return false; | 980 return false; |
| 984 if (object) { | 981 if (object) { |
| 985 if (!object->validate(contextGroup(), this)) { | 982 if (!object->validate(contextGroup(), this)) { |
| 986 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object not fr
om this context"); | 983 synthesizeGLError(GL_INVALID_OPERATION, functionName, "object not fr
om this context"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1004 } | 1001 } |
| 1005 if (target == GL_ARRAY_BUFFER) | 1002 if (target == GL_ARRAY_BUFFER) |
| 1006 m_boundArrayBuffer = buffer; | 1003 m_boundArrayBuffer = buffer; |
| 1007 else if (target == GL_ELEMENT_ARRAY_BUFFER) | 1004 else if (target == GL_ELEMENT_ARRAY_BUFFER) |
| 1008 m_boundVertexArrayObject->setElementArrayBuffer(buffer); | 1005 m_boundVertexArrayObject->setElementArrayBuffer(buffer); |
| 1009 else { | 1006 else { |
| 1010 synthesizeGLError(GL_INVALID_ENUM, "bindBuffer", "invalid target"); | 1007 synthesizeGLError(GL_INVALID_ENUM, "bindBuffer", "invalid target"); |
| 1011 return; | 1008 return; |
| 1012 } | 1009 } |
| 1013 | 1010 |
| 1014 m_context->bindBuffer(target, objectOrZero(buffer)); | 1011 webContext()->bindBuffer(target, objectOrZero(buffer)); |
| 1015 if (buffer) | 1012 if (buffer) |
| 1016 buffer->setTarget(target); | 1013 buffer->setTarget(target); |
| 1017 } | 1014 } |
| 1018 | 1015 |
| 1019 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer*
buffer) | 1016 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer*
buffer) |
| 1020 { | 1017 { |
| 1021 bool deleted; | 1018 bool deleted; |
| 1022 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1019 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1023 return; | 1020 return; |
| 1024 if (deleted) | 1021 if (deleted) |
| 1025 buffer = 0; | 1022 buffer = 0; |
| 1026 if (target != GL_FRAMEBUFFER) { | 1023 if (target != GL_FRAMEBUFFER) { |
| 1027 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1024 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
| 1028 return; | 1025 return; |
| 1029 } | 1026 } |
| 1030 m_framebufferBinding = buffer; | 1027 m_framebufferBinding = buffer; |
| 1031 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); | 1028 m_drawingBuffer->setFramebufferBinding(objectOrZero(m_framebufferBinding.get
())); |
| 1032 if (!m_framebufferBinding) { | 1029 if (!m_framebufferBinding) { |
| 1033 // Instead of binding fb 0, bind the drawing buffer. | 1030 // Instead of binding fb 0, bind the drawing buffer. |
| 1034 m_drawingBuffer->bind(); | 1031 m_drawingBuffer->bind(); |
| 1035 } else | 1032 } else { |
| 1036 m_context->bindFramebuffer(target, objectOrZero(buffer)); | 1033 webContext()->bindFramebuffer(target, objectOrZero(buffer)); |
| 1034 } |
| 1037 if (buffer) | 1035 if (buffer) |
| 1038 buffer->setHasEverBeenBound(); | 1036 buffer->setHasEverBeenBound(); |
| 1039 applyStencilTest(); | 1037 applyStencilTest(); |
| 1040 } | 1038 } |
| 1041 | 1039 |
| 1042 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe
r* renderBuffer) | 1040 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe
r* renderBuffer) |
| 1043 { | 1041 { |
| 1044 bool deleted; | 1042 bool deleted; |
| 1045 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1043 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
| 1046 return; | 1044 return; |
| 1047 if (deleted) | 1045 if (deleted) |
| 1048 renderBuffer = 0; | 1046 renderBuffer = 0; |
| 1049 if (target != GL_RENDERBUFFER) { | 1047 if (target != GL_RENDERBUFFER) { |
| 1050 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target")
; | 1048 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target")
; |
| 1051 return; | 1049 return; |
| 1052 } | 1050 } |
| 1053 m_renderbufferBinding = renderBuffer; | 1051 m_renderbufferBinding = renderBuffer; |
| 1054 m_context->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1052 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
| 1055 if (renderBuffer) | 1053 if (renderBuffer) |
| 1056 renderBuffer->setHasEverBeenBound(); | 1054 renderBuffer->setHasEverBeenBound(); |
| 1057 } | 1055 } |
| 1058 | 1056 |
| 1059 void WebGLRenderingContextBase::bindTexture(GLenum target, WebGLTexture* texture
) | 1057 void WebGLRenderingContextBase::bindTexture(GLenum target, WebGLTexture* texture
) |
| 1060 { | 1058 { |
| 1061 bool deleted; | 1059 bool deleted; |
| 1062 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1060 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
| 1063 return; | 1061 return; |
| 1064 if (deleted) | 1062 if (deleted) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1076 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); | 1074 m_drawingBuffer->setTexture2DBinding(objectOrZero(texture)); |
| 1077 | 1075 |
| 1078 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1076 } else if (target == GL_TEXTURE_CUBE_MAP) { |
| 1079 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1077 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
| 1080 maxLevel = m_maxCubeMapTextureLevel; | 1078 maxLevel = m_maxCubeMapTextureLevel; |
| 1081 } else { | 1079 } else { |
| 1082 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1080 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
| 1083 return; | 1081 return; |
| 1084 } | 1082 } |
| 1085 | 1083 |
| 1086 m_context->bindTexture(target, objectOrZero(texture)); | 1084 webContext()->bindTexture(target, objectOrZero(texture)); |
| 1087 if (texture) { | 1085 if (texture) { |
| 1088 texture->setTarget(target, maxLevel); | 1086 texture->setTarget(target, maxLevel); |
| 1089 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl
usMaxNonDefaultTextureUnit); | 1087 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl
usMaxNonDefaultTextureUnit); |
| 1090 } else { | 1088 } else { |
| 1091 // If the disabled index is the current maximum, trace backwards to find
the new max enabled texture index | 1089 // If the disabled index is the current maximum, trace backwards to find
the new max enabled texture index |
| 1092 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { | 1090 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { |
| 1093 findNewMaxNonDefaultTextureUnit(); | 1091 findNewMaxNonDefaultTextureUnit(); |
| 1094 } | 1092 } |
| 1095 } | 1093 } |
| 1096 | 1094 |
| 1097 // Note: previously we used to automatically set the TEXTURE_WRAP_R | 1095 // Note: previously we used to automatically set the TEXTURE_WRAP_R |
| 1098 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL | 1096 // repeat mode to CLAMP_TO_EDGE for cube map textures, because OpenGL |
| 1099 // ES 2.0 doesn't expose this flag (a bug in the specification) and | 1097 // ES 2.0 doesn't expose this flag (a bug in the specification) and |
| 1100 // otherwise the application has no control over the seams in this | 1098 // otherwise the application has no control over the seams in this |
| 1101 // dimension. However, it appears that supporting this properly on all | 1099 // dimension. However, it appears that supporting this properly on all |
| 1102 // platforms is fairly involved (will require a HashMap from texture ID | 1100 // platforms is fairly involved (will require a HashMap from texture ID |
| 1103 // in all ports), and we have not had any complaints, so the logic has | 1101 // in all ports), and we have not had any complaints, so the logic has |
| 1104 // been removed. | 1102 // been removed. |
| 1105 | 1103 |
| 1106 } | 1104 } |
| 1107 | 1105 |
| 1108 void WebGLRenderingContextBase::blendColor(GLfloat red, GLfloat green, GLfloat b
lue, GLfloat alpha) | 1106 void WebGLRenderingContextBase::blendColor(GLfloat red, GLfloat green, GLfloat b
lue, GLfloat alpha) |
| 1109 { | 1107 { |
| 1110 if (isContextLost()) | 1108 if (isContextLost()) |
| 1111 return; | 1109 return; |
| 1112 m_context->blendColor(red, green, blue, alpha); | 1110 webContext()->blendColor(red, green, blue, alpha); |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 void WebGLRenderingContextBase::blendEquation(GLenum mode) | 1113 void WebGLRenderingContextBase::blendEquation(GLenum mode) |
| 1116 { | 1114 { |
| 1117 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) | 1115 if (isContextLost() || !validateBlendEquation("blendEquation", mode)) |
| 1118 return; | 1116 return; |
| 1119 m_context->blendEquation(mode); | 1117 webContext()->blendEquation(mode); |
| 1120 } | 1118 } |
| 1121 | 1119 |
| 1122 void WebGLRenderingContextBase::blendEquationSeparate(GLenum modeRGB, GLenum mod
eAlpha) | 1120 void WebGLRenderingContextBase::blendEquationSeparate(GLenum modeRGB, GLenum mod
eAlpha) |
| 1123 { | 1121 { |
| 1124 if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeR
GB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) | 1122 if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeR
GB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) |
| 1125 return; | 1123 return; |
| 1126 m_context->blendEquationSeparate(modeRGB, modeAlpha); | 1124 webContext()->blendEquationSeparate(modeRGB, modeAlpha); |
| 1127 } | 1125 } |
| 1128 | 1126 |
| 1129 | 1127 |
| 1130 void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) | 1128 void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) |
| 1131 { | 1129 { |
| 1132 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfact
or)) | 1130 if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfact
or)) |
| 1133 return; | 1131 return; |
| 1134 m_context->blendFunc(sfactor, dfactor); | 1132 webContext()->blendFunc(sfactor, dfactor); |
| 1135 } | 1133 } |
| 1136 | 1134 |
| 1137 void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha) | 1135 void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha) |
| 1138 { | 1136 { |
| 1139 // Note: Alpha does not have the same restrictions as RGB. | 1137 // Note: Alpha does not have the same restrictions as RGB. |
| 1140 if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB
, dstRGB)) | 1138 if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB
, dstRGB)) |
| 1141 return; | 1139 return; |
| 1142 m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); | 1140 webContext()->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); |
| 1143 } | 1141 } |
| 1144 | 1142 |
| 1145 void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum
usage) | 1143 void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum
usage) |
| 1146 { | 1144 { |
| 1147 if (isContextLost()) | 1145 if (isContextLost()) |
| 1148 return; | 1146 return; |
| 1149 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); | 1147 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); |
| 1150 if (!buffer) | 1148 if (!buffer) |
| 1151 return; | 1149 return; |
| 1152 if (size < 0) { | 1150 if (size < 0) { |
| 1153 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size < 0"); | 1151 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size < 0"); |
| 1154 return; | 1152 return; |
| 1155 } | 1153 } |
| 1156 if (!size) { | 1154 if (!size) { |
| 1157 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size == 0"); | 1155 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "size == 0"); |
| 1158 return; | 1156 return; |
| 1159 } | 1157 } |
| 1160 | 1158 |
| 1161 m_context->bufferData(target, static_cast<GLsizeiptr>(size), 0, usage); | 1159 webContext()->bufferData(target, static_cast<GLsizeiptr>(size), 0, usage); |
| 1162 } | 1160 } |
| 1163 | 1161 |
| 1164 void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBuffer* data, GLe
num usage) | 1162 void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBuffer* data, GLe
num usage) |
| 1165 { | 1163 { |
| 1166 if (isContextLost()) | 1164 if (isContextLost()) |
| 1167 return; | 1165 return; |
| 1168 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); | 1166 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); |
| 1169 if (!buffer) | 1167 if (!buffer) |
| 1170 return; | 1168 return; |
| 1171 if (!data) { | 1169 if (!data) { |
| 1172 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); | 1170 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); |
| 1173 return; | 1171 return; |
| 1174 } | 1172 } |
| 1175 m_context->bufferData(target, data->byteLength(), data->data(), usage); | 1173 webContext()->bufferData(target, data->byteLength(), data->data(), usage); |
| 1176 } | 1174 } |
| 1177 | 1175 |
| 1178 void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBufferView* data,
GLenum usage) | 1176 void WebGLRenderingContextBase::bufferData(GLenum target, ArrayBufferView* data,
GLenum usage) |
| 1179 { | 1177 { |
| 1180 if (isContextLost()) | 1178 if (isContextLost()) |
| 1181 return; | 1179 return; |
| 1182 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); | 1180 WebGLBuffer* buffer = validateBufferDataParameters("bufferData", target, usa
ge); |
| 1183 if (!buffer) | 1181 if (!buffer) |
| 1184 return; | 1182 return; |
| 1185 if (!data) { | 1183 if (!data) { |
| 1186 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); | 1184 synthesizeGLError(GL_INVALID_VALUE, "bufferData", "no data"); |
| 1187 return; | 1185 return; |
| 1188 } | 1186 } |
| 1189 | 1187 |
| 1190 m_context->bufferData(target, data->byteLength(), data->baseAddress(), usage
); | 1188 webContext()->bufferData(target, data->byteLength(), data->baseAddress(), us
age); |
| 1191 } | 1189 } |
| 1192 | 1190 |
| 1193 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, A
rrayBuffer* data) | 1191 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, A
rrayBuffer* data) |
| 1194 { | 1192 { |
| 1195 if (isContextLost()) | 1193 if (isContextLost()) |
| 1196 return; | 1194 return; |
| 1197 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GL_STATIC_DRAW); | 1195 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GL_STATIC_DRAW); |
| 1198 if (!buffer) | 1196 if (!buffer) |
| 1199 return; | 1197 return; |
| 1200 if (offset < 0) { | 1198 if (offset < 0) { |
| 1201 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0"); | 1199 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0"); |
| 1202 return; | 1200 return; |
| 1203 } | 1201 } |
| 1204 if (!data) | 1202 if (!data) |
| 1205 return; | 1203 return; |
| 1206 | 1204 |
| 1207 m_context->bufferSubData(target, static_cast<GLintptr>(offset), data->byteLe
ngth(), data->data()); | 1205 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), data->byt
eLength(), data->data()); |
| 1208 } | 1206 } |
| 1209 | 1207 |
| 1210 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, A
rrayBufferView* data) | 1208 void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, A
rrayBufferView* data) |
| 1211 { | 1209 { |
| 1212 if (isContextLost()) | 1210 if (isContextLost()) |
| 1213 return; | 1211 return; |
| 1214 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GL_STATIC_DRAW); | 1212 WebGLBuffer* buffer = validateBufferDataParameters("bufferSubData", target,
GL_STATIC_DRAW); |
| 1215 if (!buffer) | 1213 if (!buffer) |
| 1216 return; | 1214 return; |
| 1217 if (offset < 0) { | 1215 if (offset < 0) { |
| 1218 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0"); | 1216 synthesizeGLError(GL_INVALID_VALUE, "bufferSubData", "offset < 0"); |
| 1219 return; | 1217 return; |
| 1220 } | 1218 } |
| 1221 if (!data) | 1219 if (!data) |
| 1222 return; | 1220 return; |
| 1223 | 1221 |
| 1224 m_context->bufferSubData(target, static_cast<GLintptr>(offset), data->byteLe
ngth(), data->baseAddress()); | 1222 webContext()->bufferSubData(target, static_cast<GLintptr>(offset), data->byt
eLength(), data->baseAddress()); |
| 1225 } | 1223 } |
| 1226 | 1224 |
| 1227 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) | 1225 GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) |
| 1228 { | 1226 { |
| 1229 if (isContextLost()) | 1227 if (isContextLost()) |
| 1230 return GL_FRAMEBUFFER_UNSUPPORTED; | 1228 return GL_FRAMEBUFFER_UNSUPPORTED; |
| 1231 if (target != GL_FRAMEBUFFER) { | 1229 if (target != GL_FRAMEBUFFER) { |
| 1232 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta
rget"); | 1230 synthesizeGLError(GL_INVALID_ENUM, "checkFramebufferStatus", "invalid ta
rget"); |
| 1233 return 0; | 1231 return 0; |
| 1234 } | 1232 } |
| 1235 if (!m_framebufferBinding || !m_framebufferBinding->object()) | 1233 if (!m_framebufferBinding || !m_framebufferBinding->object()) |
| 1236 return GL_FRAMEBUFFER_COMPLETE; | 1234 return GL_FRAMEBUFFER_COMPLETE; |
| 1237 const char* reason = "framebuffer incomplete"; | 1235 const char* reason = "framebuffer incomplete"; |
| 1238 GLenum result = m_framebufferBinding->checkStatus(&reason); | 1236 GLenum result = m_framebufferBinding->checkStatus(&reason); |
| 1239 if (result != GL_FRAMEBUFFER_COMPLETE) { | 1237 if (result != GL_FRAMEBUFFER_COMPLETE) { |
| 1240 emitGLWarning("checkFramebufferStatus", reason); | 1238 emitGLWarning("checkFramebufferStatus", reason); |
| 1241 return result; | 1239 return result; |
| 1242 } | 1240 } |
| 1243 result = m_context->checkFramebufferStatus(target); | 1241 result = webContext()->checkFramebufferStatus(target); |
| 1244 return result; | 1242 return result; |
| 1245 } | 1243 } |
| 1246 | 1244 |
| 1247 void WebGLRenderingContextBase::clear(GLbitfield mask) | 1245 void WebGLRenderingContextBase::clear(GLbitfield mask) |
| 1248 { | 1246 { |
| 1249 if (isContextLost()) | 1247 if (isContextLost()) |
| 1250 return; | 1248 return; |
| 1251 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { | 1249 if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_B
IT)) { |
| 1252 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); | 1250 synthesizeGLError(GL_INVALID_VALUE, "clear", "invalid mask"); |
| 1253 return; | 1251 return; |
| 1254 } | 1252 } |
| 1255 const char* reason = "framebuffer incomplete"; | 1253 const char* reason = "framebuffer incomplete"; |
| 1256 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 1254 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 1257 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); | 1255 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "clear", reason); |
| 1258 return; | 1256 return; |
| 1259 } | 1257 } |
| 1260 if (!clearIfComposited(mask)) | 1258 if (!clearIfComposited(mask)) |
| 1261 m_context->clear(mask); | 1259 webContext()->clear(mask); |
| 1262 markContextChanged(); | 1260 markContextChanged(); |
| 1263 } | 1261 } |
| 1264 | 1262 |
| 1265 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl
oat a) | 1263 void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl
oat a) |
| 1266 { | 1264 { |
| 1267 if (isContextLost()) | 1265 if (isContextLost()) |
| 1268 return; | 1266 return; |
| 1269 if (std::isnan(r)) | 1267 if (std::isnan(r)) |
| 1270 r = 0; | 1268 r = 0; |
| 1271 if (std::isnan(g)) | 1269 if (std::isnan(g)) |
| 1272 g = 0; | 1270 g = 0; |
| 1273 if (std::isnan(b)) | 1271 if (std::isnan(b)) |
| 1274 b = 0; | 1272 b = 0; |
| 1275 if (std::isnan(a)) | 1273 if (std::isnan(a)) |
| 1276 a = 1; | 1274 a = 1; |
| 1277 m_clearColor[0] = r; | 1275 m_clearColor[0] = r; |
| 1278 m_clearColor[1] = g; | 1276 m_clearColor[1] = g; |
| 1279 m_clearColor[2] = b; | 1277 m_clearColor[2] = b; |
| 1280 m_clearColor[3] = a; | 1278 m_clearColor[3] = a; |
| 1281 m_context->clearColor(r, g, b, a); | 1279 webContext()->clearColor(r, g, b, a); |
| 1282 } | 1280 } |
| 1283 | 1281 |
| 1284 void WebGLRenderingContextBase::clearDepth(GLfloat depth) | 1282 void WebGLRenderingContextBase::clearDepth(GLfloat depth) |
| 1285 { | 1283 { |
| 1286 if (isContextLost()) | 1284 if (isContextLost()) |
| 1287 return; | 1285 return; |
| 1288 m_clearDepth = depth; | 1286 m_clearDepth = depth; |
| 1289 m_context->clearDepth(depth); | 1287 webContext()->clearDepth(depth); |
| 1290 } | 1288 } |
| 1291 | 1289 |
| 1292 void WebGLRenderingContextBase::clearStencil(GLint s) | 1290 void WebGLRenderingContextBase::clearStencil(GLint s) |
| 1293 { | 1291 { |
| 1294 if (isContextLost()) | 1292 if (isContextLost()) |
| 1295 return; | 1293 return; |
| 1296 m_clearStencil = s; | 1294 m_clearStencil = s; |
| 1297 m_context->clearStencil(s); | 1295 webContext()->clearStencil(s); |
| 1298 } | 1296 } |
| 1299 | 1297 |
| 1300 void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool
ean blue, GLboolean alpha) | 1298 void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool
ean blue, GLboolean alpha) |
| 1301 { | 1299 { |
| 1302 if (isContextLost()) | 1300 if (isContextLost()) |
| 1303 return; | 1301 return; |
| 1304 m_colorMask[0] = red; | 1302 m_colorMask[0] = red; |
| 1305 m_colorMask[1] = green; | 1303 m_colorMask[1] = green; |
| 1306 m_colorMask[2] = blue; | 1304 m_colorMask[2] = blue; |
| 1307 m_colorMask[3] = alpha; | 1305 m_colorMask[3] = alpha; |
| 1308 m_context->colorMask(red, green, blue, alpha); | 1306 webContext()->colorMask(red, green, blue, alpha); |
| 1309 } | 1307 } |
| 1310 | 1308 |
| 1311 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) | 1309 void WebGLRenderingContextBase::compileShader(WebGLShader* shader) |
| 1312 { | 1310 { |
| 1313 if (isContextLost() || !validateWebGLObject("compileShader", shader)) | 1311 if (isContextLost() || !validateWebGLObject("compileShader", shader)) |
| 1314 return; | 1312 return; |
| 1315 m_context->compileShader(objectOrZero(shader)); | 1313 webContext()->compileShader(objectOrZero(shader)); |
| 1316 } | 1314 } |
| 1317 | 1315 |
| 1318 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBuffer
View* data) | 1316 void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLsizei height, GLint border, ArrayBuffer
View* data) |
| 1319 { | 1317 { |
| 1320 if (isContextLost()) | 1318 if (isContextLost()) |
| 1321 return; | 1319 return; |
| 1322 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) | 1320 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) |
| 1323 return; | 1321 return; |
| 1324 | 1322 |
| 1325 if (!validateCompressedTexFormat(internalformat)) { | 1323 if (!validateCompressedTexFormat(internalformat)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1337 | 1335 |
| 1338 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t
rue); | 1336 WebGLTexture* tex = validateTextureBinding("compressedTexImage2D", target, t
rue); |
| 1339 if (!tex) | 1337 if (!tex) |
| 1340 return; | 1338 return; |
| 1341 if (!isGLES2NPOTStrict()) { | 1339 if (!isGLES2NPOTStrict()) { |
| 1342 if (level && WebGLTexture::isNPOT(width, height)) { | 1340 if (level && WebGLTexture::isNPOT(width, height)) { |
| 1343 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "level >
0 not power of 2"); | 1341 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "level >
0 not power of 2"); |
| 1344 return; | 1342 return; |
| 1345 } | 1343 } |
| 1346 } | 1344 } |
| 1347 m_context->compressedTexImage2D(target, level, internalformat, width, height
, | 1345 webContext()->compressedTexImage2D(target, level, internalformat, width, hei
ght, |
| 1348 border, data->byteLength(), data->
baseAddress()); | 1346 border, data->byteLength(), data->baseAddress()); |
| 1349 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); | 1347 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); |
| 1350 } | 1348 } |
| 1351 | 1349 |
| 1352 void WebGLRenderingContextBase::compressedTexSubImage2D(GLenum target, GLint lev
el, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
ArrayBufferView* data) | 1350 void WebGLRenderingContextBase::compressedTexSubImage2D(GLenum target, GLint lev
el, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
ArrayBufferView* data) |
| 1353 { | 1351 { |
| 1354 if (isContextLost()) | 1352 if (isContextLost()) |
| 1355 return; | 1353 return; |
| 1356 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) | 1354 if (!validateTexFuncLevel("compressedTexSubImage2D", target, level)) |
| 1357 return; | 1355 return; |
| 1358 if (!validateCompressedTexFormat(format)) { | 1356 if (!validateCompressedTexFormat(format)) { |
| 1359 synthesizeGLError(GL_INVALID_ENUM, "compressedTexSubImage2D", "invalid f
ormat"); | 1357 synthesizeGLError(GL_INVALID_ENUM, "compressedTexSubImage2D", "invalid f
ormat"); |
| 1360 return; | 1358 return; |
| 1361 } | 1359 } |
| 1362 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height,
format, data)) | 1360 if (!validateCompressedTexFuncData("compressedTexSubImage2D", width, height,
format, data)) |
| 1363 return; | 1361 return; |
| 1364 | 1362 |
| 1365 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target
, true); | 1363 WebGLTexture* tex = validateTextureBinding("compressedTexSubImage2D", target
, true); |
| 1366 if (!tex) | 1364 if (!tex) |
| 1367 return; | 1365 return; |
| 1368 | 1366 |
| 1369 if (format != tex->getInternalFormat(target, level)) { | 1367 if (format != tex->getInternalFormat(target, level)) { |
| 1370 synthesizeGLError(GL_INVALID_OPERATION, "compressedTexSubImage2D", "form
at does not match texture format"); | 1368 synthesizeGLError(GL_INVALID_OPERATION, "compressedTexSubImage2D", "form
at does not match texture format"); |
| 1371 return; | 1369 return; |
| 1372 } | 1370 } |
| 1373 | 1371 |
| 1374 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l
evel, xoffset, yoffset, width, height, format, tex)) | 1372 if (!validateCompressedTexSubDimensions("compressedTexSubImage2D", target, l
evel, xoffset, yoffset, width, height, format, tex)) |
| 1375 return; | 1373 return; |
| 1376 | 1374 |
| 1377 m_context->compressedTexSubImage2D(target, level, xoffset, yoffset, | 1375 webContext()->compressedTexSubImage2D(target, level, xoffset, yoffset, |
| 1378 width, height, format, data->by
teLength(), data->baseAddress()); | 1376 width, height, format, data->byteLength(), data->baseAddress()); |
| 1379 } | 1377 } |
| 1380 | 1378 |
| 1381 bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa
me, GLenum format) | 1379 bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa
me, GLenum format) |
| 1382 { | 1380 { |
| 1383 if (WebGLImageConversion::getClearBitsByFormat(format) & (GL_DEPTH_BUFFER_BI
T | GL_STENCIL_BUFFER_BIT)) { | 1381 if (WebGLImageConversion::getClearBitsByFormat(format) & (GL_DEPTH_BUFFER_BI
T | GL_STENCIL_BUFFER_BIT)) { |
| 1384 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format can not be
set, only rendered to"); | 1382 synthesizeGLError(GL_INVALID_OPERATION, functionName, "format can not be
set, only rendered to"); |
| 1385 return false; | 1383 return false; |
| 1386 } | 1384 } |
| 1387 return true; | 1385 return true; |
| 1388 } | 1386 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1400 return; | 1398 return; |
| 1401 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1399 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1402 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); | 1400 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "framebuffer i
s incompatible format"); |
| 1403 return; | 1401 return; |
| 1404 } | 1402 } |
| 1405 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1403 if (!isGLES2NPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
| 1406 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); | 1404 synthesizeGLError(GL_INVALID_VALUE, "copyTexImage2D", "level > 0 not pow
er of 2"); |
| 1407 return; | 1405 return; |
| 1408 } | 1406 } |
| 1409 const char* reason = "framebuffer incomplete"; | 1407 const char* reason = "framebuffer incomplete"; |
| 1410 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 1408 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 1411 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); | 1409 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", re
ason); |
| 1412 return; | 1410 return; |
| 1413 } | 1411 } |
| 1414 clearIfComposited(); | 1412 clearIfComposited(); |
| 1415 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1413 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
| 1416 m_context->copyTexImage2D(target, level, internalformat, x, y, width, height
, border); | 1414 webContext()->copyTexImage2D(target, level, internalformat, x, y, width, hei
ght, border); |
| 1417 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. | 1415 // FIXME: if the framebuffer is not complete, none of the below should be ex
ecuted. |
| 1418 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); | 1416 tex->setLevelInfo(target, level, internalformat, width, height, GL_UNSIGNED_
BYTE); |
| 1419 } | 1417 } |
| 1420 | 1418 |
| 1421 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) | 1419 void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 1422 { | 1420 { |
| 1423 if (isContextLost()) | 1421 if (isContextLost()) |
| 1424 return; | 1422 return; |
| 1425 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) | 1423 if (!validateTexFuncLevel("copyTexSubImage2D", target, level)) |
| 1426 return; | 1424 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1443 return; | 1441 return; |
| 1444 } | 1442 } |
| 1445 GLenum internalformat = tex->getInternalFormat(target, level); | 1443 GLenum internalformat = tex->getInternalFormat(target, level); |
| 1446 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) | 1444 if (!validateSettableTexFormat("copyTexSubImage2D", internalformat)) |
| 1447 return; | 1445 return; |
| 1448 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { | 1446 if (!isTexInternalFormatColorBufferCombinationValid(internalformat, boundFra
mebufferColorFormat())) { |
| 1449 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); | 1447 synthesizeGLError(GL_INVALID_OPERATION, "copyTexSubImage2D", "framebuffe
r is incompatible format"); |
| 1450 return; | 1448 return; |
| 1451 } | 1449 } |
| 1452 const char* reason = "framebuffer incomplete"; | 1450 const char* reason = "framebuffer incomplete"; |
| 1453 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 1451 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 1454 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); | 1452 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D",
reason); |
| 1455 return; | 1453 return; |
| 1456 } | 1454 } |
| 1457 clearIfComposited(); | 1455 clearIfComposited(); |
| 1458 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); | 1456 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding
.get()); |
| 1459 m_context->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, h
eight); | 1457 webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width
, height); |
| 1460 } | 1458 } |
| 1461 | 1459 |
| 1462 PassRefPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() | 1460 PassRefPtr<WebGLBuffer> WebGLRenderingContextBase::createBuffer() |
| 1463 { | 1461 { |
| 1464 if (isContextLost()) | 1462 if (isContextLost()) |
| 1465 return nullptr; | 1463 return nullptr; |
| 1466 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); | 1464 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); |
| 1467 addSharedObject(o.get()); | 1465 addSharedObject(o.get()); |
| 1468 return o; | 1466 return o; |
| 1469 } | 1467 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 addSharedObject(o.get()); | 1501 addSharedObject(o.get()); |
| 1504 return o; | 1502 return o; |
| 1505 } | 1503 } |
| 1506 | 1504 |
| 1507 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum
target, WebGLRenderbuffer* renderbuffer) | 1505 WebGLRenderbuffer* WebGLRenderingContextBase::ensureEmulatedStencilBuffer(GLenum
target, WebGLRenderbuffer* renderbuffer) |
| 1508 { | 1506 { |
| 1509 if (isContextLost()) | 1507 if (isContextLost()) |
| 1510 return 0; | 1508 return 0; |
| 1511 if (!renderbuffer->emulatedStencilBuffer()) { | 1509 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1512 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1510 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1513 m_context->bindRenderbuffer(target, objectOrZero(renderbuffer->emulatedS
tencilBuffer())); | 1511 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat
edStencilBuffer())); |
| 1514 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBinding.g
et())); | 1512 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin
g.get())); |
| 1515 } | 1513 } |
| 1516 return renderbuffer->emulatedStencilBuffer(); | 1514 return renderbuffer->emulatedStencilBuffer(); |
| 1517 } | 1515 } |
| 1518 | 1516 |
| 1519 PassRefPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLenum type) | 1517 PassRefPtr<WebGLShader> WebGLRenderingContextBase::createShader(GLenum type) |
| 1520 { | 1518 { |
| 1521 if (isContextLost()) | 1519 if (isContextLost()) |
| 1522 return nullptr; | 1520 return nullptr; |
| 1523 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1521 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1524 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type"
); | 1522 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type"
); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1536 return; | 1534 return; |
| 1537 switch (mode) { | 1535 switch (mode) { |
| 1538 case GL_FRONT_AND_BACK: | 1536 case GL_FRONT_AND_BACK: |
| 1539 case GL_FRONT: | 1537 case GL_FRONT: |
| 1540 case GL_BACK: | 1538 case GL_BACK: |
| 1541 break; | 1539 break; |
| 1542 default: | 1540 default: |
| 1543 synthesizeGLError(GL_INVALID_ENUM, "cullFace", "invalid mode"); | 1541 synthesizeGLError(GL_INVALID_ENUM, "cullFace", "invalid mode"); |
| 1544 return; | 1542 return; |
| 1545 } | 1543 } |
| 1546 m_context->cullFace(mode); | 1544 webContext()->cullFace(mode); |
| 1547 } | 1545 } |
| 1548 | 1546 |
| 1549 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) | 1547 bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) |
| 1550 { | 1548 { |
| 1551 if (isContextLost() || !object) | 1549 if (isContextLost() || !object) |
| 1552 return false; | 1550 return false; |
| 1553 if (!object->validate(contextGroup(), this)) { | 1551 if (!object->validate(contextGroup(), this)) { |
| 1554 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); | 1552 synthesizeGLError(GL_INVALID_OPERATION, "delete", "object does not belon
g to this context"); |
| 1555 return false; | 1553 return false; |
| 1556 } | 1554 } |
| 1557 if (object->object()) { | 1555 if (object->object()) { |
| 1558 // We need to pass in context here because we want | 1556 // We need to pass in context here because we want |
| 1559 // things in this context unbound. | 1557 // things in this context unbound. |
| 1560 object->deleteObject(m_context.get()); | 1558 object->deleteObject(webContext()); |
| 1561 } | 1559 } |
| 1562 return true; | 1560 return true; |
| 1563 } | 1561 } |
| 1564 | 1562 |
| 1565 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) | 1563 void WebGLRenderingContextBase::deleteBuffer(WebGLBuffer* buffer) |
| 1566 { | 1564 { |
| 1567 if (!deleteObject(buffer)) | 1565 if (!deleteObject(buffer)) |
| 1568 return; | 1566 return; |
| 1569 if (m_boundArrayBuffer == buffer) | 1567 if (m_boundArrayBuffer == buffer) |
| 1570 m_boundArrayBuffer = nullptr; | 1568 m_boundArrayBuffer = nullptr; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 findNewMaxNonDefaultTextureUnit(); | 1630 findNewMaxNonDefaultTextureUnit(); |
| 1633 } | 1631 } |
| 1634 } | 1632 } |
| 1635 | 1633 |
| 1636 void WebGLRenderingContextBase::depthFunc(GLenum func) | 1634 void WebGLRenderingContextBase::depthFunc(GLenum func) |
| 1637 { | 1635 { |
| 1638 if (isContextLost()) | 1636 if (isContextLost()) |
| 1639 return; | 1637 return; |
| 1640 if (!validateStencilOrDepthFunc("depthFunc", func)) | 1638 if (!validateStencilOrDepthFunc("depthFunc", func)) |
| 1641 return; | 1639 return; |
| 1642 m_context->depthFunc(func); | 1640 webContext()->depthFunc(func); |
| 1643 } | 1641 } |
| 1644 | 1642 |
| 1645 void WebGLRenderingContextBase::depthMask(GLboolean flag) | 1643 void WebGLRenderingContextBase::depthMask(GLboolean flag) |
| 1646 { | 1644 { |
| 1647 if (isContextLost()) | 1645 if (isContextLost()) |
| 1648 return; | 1646 return; |
| 1649 m_depthMask = flag; | 1647 m_depthMask = flag; |
| 1650 m_context->depthMask(flag); | 1648 webContext()->depthMask(flag); |
| 1651 } | 1649 } |
| 1652 | 1650 |
| 1653 void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) | 1651 void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) |
| 1654 { | 1652 { |
| 1655 if (isContextLost()) | 1653 if (isContextLost()) |
| 1656 return; | 1654 return; |
| 1657 if (zNear > zFar) { | 1655 if (zNear > zFar) { |
| 1658 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 1656 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
| 1659 return; | 1657 return; |
| 1660 } | 1658 } |
| 1661 m_context->depthRange(zNear, zFar); | 1659 webContext()->depthRange(zNear, zFar); |
| 1662 } | 1660 } |
| 1663 | 1661 |
| 1664 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader*
shader) | 1662 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader*
shader) |
| 1665 { | 1663 { |
| 1666 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) | 1664 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val
idateWebGLObject("detachShader", shader)) |
| 1667 return; | 1665 return; |
| 1668 if (!program->detachShader(shader)) { | 1666 if (!program->detachShader(shader)) { |
| 1669 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); | 1667 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta
ched"); |
| 1670 return; | 1668 return; |
| 1671 } | 1669 } |
| 1672 m_context->detachShader(objectOrZero(program), objectOrZero(shader)); | 1670 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); |
| 1673 shader->onDetached(m_context.get()); | 1671 shader->onDetached(webContext()); |
| 1674 } | 1672 } |
| 1675 | 1673 |
| 1676 void WebGLRenderingContextBase::disable(GLenum cap) | 1674 void WebGLRenderingContextBase::disable(GLenum cap) |
| 1677 { | 1675 { |
| 1678 if (isContextLost() || !validateCapability("disable", cap)) | 1676 if (isContextLost() || !validateCapability("disable", cap)) |
| 1679 return; | 1677 return; |
| 1680 if (cap == GL_STENCIL_TEST) { | 1678 if (cap == GL_STENCIL_TEST) { |
| 1681 m_stencilEnabled = false; | 1679 m_stencilEnabled = false; |
| 1682 applyStencilTest(); | 1680 applyStencilTest(); |
| 1683 return; | 1681 return; |
| 1684 } | 1682 } |
| 1685 if (cap == GL_SCISSOR_TEST) { | 1683 if (cap == GL_SCISSOR_TEST) { |
| 1686 m_scissorEnabled = false; | 1684 m_scissorEnabled = false; |
| 1687 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1685 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); |
| 1688 } | 1686 } |
| 1689 m_context->disable(cap); | 1687 webContext()->disable(cap); |
| 1690 } | 1688 } |
| 1691 | 1689 |
| 1692 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) | 1690 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) |
| 1693 { | 1691 { |
| 1694 if (isContextLost()) | 1692 if (isContextLost()) |
| 1695 return; | 1693 return; |
| 1696 if (index >= m_maxVertexAttribs) { | 1694 if (index >= m_maxVertexAttribs) { |
| 1697 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); | 1695 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); |
| 1698 return; | 1696 return; |
| 1699 } | 1697 } |
| 1700 | 1698 |
| 1701 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); | 1699 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); |
| 1702 state.enabled = false; | 1700 state.enabled = false; |
| 1703 | 1701 |
| 1704 // If the disabled index is the current maximum, trace backwards to find the
new max enabled attrib index | 1702 // If the disabled index is the current maximum, trace backwards to find the
new max enabled attrib index |
| 1705 if (m_onePlusMaxEnabledAttribIndex == index + 1) { | 1703 if (m_onePlusMaxEnabledAttribIndex == index + 1) { |
| 1706 findNewMaxEnabledAttribIndex(); | 1704 findNewMaxEnabledAttribIndex(); |
| 1707 } | 1705 } |
| 1708 | 1706 |
| 1709 m_context->disableVertexAttribArray(index); | 1707 webContext()->disableVertexAttribArray(index); |
| 1710 } | 1708 } |
| 1711 | 1709 |
| 1712 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) | 1710 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) |
| 1713 { | 1711 { |
| 1714 if (!m_currentProgram) { | 1712 if (!m_currentProgram) { |
| 1715 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p
rogram in use"); | 1713 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p
rogram in use"); |
| 1716 return false; | 1714 return false; |
| 1717 } | 1715 } |
| 1718 | 1716 |
| 1719 // Look in each enabled vertex attrib and check if they've been bound to a b
uffer. | 1717 // Look in each enabled vertex attrib and check if they've been bound to a b
uffer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1743 } | 1741 } |
| 1744 | 1742 |
| 1745 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou
nt) | 1743 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou
nt) |
| 1746 { | 1744 { |
| 1747 if (!validateDrawArrays("drawArrays", mode, first, count)) | 1745 if (!validateDrawArrays("drawArrays", mode, first, count)) |
| 1748 return; | 1746 return; |
| 1749 | 1747 |
| 1750 clearIfComposited(); | 1748 clearIfComposited(); |
| 1751 | 1749 |
| 1752 handleTextureCompleteness("drawArrays", true); | 1750 handleTextureCompleteness("drawArrays", true); |
| 1753 m_context->drawArrays(mode, first, count); | 1751 webContext()->drawArrays(mode, first, count); |
| 1754 handleTextureCompleteness("drawArrays", false); | 1752 handleTextureCompleteness("drawArrays", false); |
| 1755 markContextChanged(); | 1753 markContextChanged(); |
| 1756 } | 1754 } |
| 1757 | 1755 |
| 1758 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum
type, long long offset) | 1756 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum
type, long long offset) |
| 1759 { | 1757 { |
| 1760 if (!validateDrawElements("drawElements", mode, count, type, offset)) | 1758 if (!validateDrawElements("drawElements", mode, count, type, offset)) |
| 1761 return; | 1759 return; |
| 1762 | 1760 |
| 1763 clearIfComposited(); | 1761 clearIfComposited(); |
| 1764 | 1762 |
| 1765 handleTextureCompleteness("drawElements", true); | 1763 handleTextureCompleteness("drawElements", true); |
| 1766 m_context->drawElements(mode, count, type, static_cast<GLintptr>(offset)); | 1764 webContext()->drawElements(mode, count, type, static_cast<GLintptr>(offset))
; |
| 1767 handleTextureCompleteness("drawElements", false); | 1765 handleTextureCompleteness("drawElements", false); |
| 1768 markContextChanged(); | 1766 markContextChanged(); |
| 1769 } | 1767 } |
| 1770 | 1768 |
| 1771 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs
t, GLsizei count, GLsizei primcount) | 1769 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs
t, GLsizei count, GLsizei primcount) |
| 1772 { | 1770 { |
| 1773 if (!validateDrawArrays("drawArraysInstancedANGLE", mode, first, count)) | 1771 if (!validateDrawArrays("drawArraysInstancedANGLE", mode, first, count)) |
| 1774 return; | 1772 return; |
| 1775 | 1773 |
| 1776 if (!validateDrawInstanced("drawArraysInstancedANGLE", primcount)) | 1774 if (!validateDrawInstanced("drawArraysInstancedANGLE", primcount)) |
| 1777 return; | 1775 return; |
| 1778 | 1776 |
| 1779 clearIfComposited(); | 1777 clearIfComposited(); |
| 1780 | 1778 |
| 1781 handleTextureCompleteness("drawArraysInstancedANGLE", true); | 1779 handleTextureCompleteness("drawArraysInstancedANGLE", true); |
| 1782 m_context->drawArraysInstancedANGLE(mode, first, count, primcount); | 1780 webContext()->drawArraysInstancedANGLE(mode, first, count, primcount); |
| 1783 handleTextureCompleteness("drawArraysInstancedANGLE", false); | 1781 handleTextureCompleteness("drawArraysInstancedANGLE", false); |
| 1784 markContextChanged(); | 1782 markContextChanged(); |
| 1785 } | 1783 } |
| 1786 | 1784 |
| 1787 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei
count, GLenum type, GLintptr offset, GLsizei primcount) | 1785 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei
count, GLenum type, GLintptr offset, GLsizei primcount) |
| 1788 { | 1786 { |
| 1789 if (!validateDrawElements("drawElementsInstancedANGLE", mode, count, type, o
ffset)) | 1787 if (!validateDrawElements("drawElementsInstancedANGLE", mode, count, type, o
ffset)) |
| 1790 return; | 1788 return; |
| 1791 | 1789 |
| 1792 if (!validateDrawInstanced("drawElementsInstancedANGLE", primcount)) | 1790 if (!validateDrawInstanced("drawElementsInstancedANGLE", primcount)) |
| 1793 return; | 1791 return; |
| 1794 | 1792 |
| 1795 clearIfComposited(); | 1793 clearIfComposited(); |
| 1796 | 1794 |
| 1797 handleTextureCompleteness("drawElementsInstancedANGLE", true); | 1795 handleTextureCompleteness("drawElementsInstancedANGLE", true); |
| 1798 m_context->drawElementsInstancedANGLE(mode, count, type, static_cast<GLintpt
r>(offset), primcount); | 1796 webContext()->drawElementsInstancedANGLE(mode, count, type, static_cast<GLin
tptr>(offset), primcount); |
| 1799 handleTextureCompleteness("drawElementsInstancedANGLE", false); | 1797 handleTextureCompleteness("drawElementsInstancedANGLE", false); |
| 1800 markContextChanged(); | 1798 markContextChanged(); |
| 1801 } | 1799 } |
| 1802 | 1800 |
| 1803 void WebGLRenderingContextBase::enable(GLenum cap) | 1801 void WebGLRenderingContextBase::enable(GLenum cap) |
| 1804 { | 1802 { |
| 1805 if (isContextLost() || !validateCapability("enable", cap)) | 1803 if (isContextLost() || !validateCapability("enable", cap)) |
| 1806 return; | 1804 return; |
| 1807 if (cap == GL_STENCIL_TEST) { | 1805 if (cap == GL_STENCIL_TEST) { |
| 1808 m_stencilEnabled = true; | 1806 m_stencilEnabled = true; |
| 1809 applyStencilTest(); | 1807 applyStencilTest(); |
| 1810 return; | 1808 return; |
| 1811 } | 1809 } |
| 1812 if (cap == GL_SCISSOR_TEST) { | 1810 if (cap == GL_SCISSOR_TEST) { |
| 1813 m_scissorEnabled = true; | 1811 m_scissorEnabled = true; |
| 1814 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); | 1812 m_drawingBuffer->setScissorEnabled(m_scissorEnabled); |
| 1815 } | 1813 } |
| 1816 m_context->enable(cap); | 1814 webContext()->enable(cap); |
| 1817 } | 1815 } |
| 1818 | 1816 |
| 1819 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) | 1817 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) |
| 1820 { | 1818 { |
| 1821 if (isContextLost()) | 1819 if (isContextLost()) |
| 1822 return; | 1820 return; |
| 1823 if (index >= m_maxVertexAttribs) { | 1821 if (index >= m_maxVertexAttribs) { |
| 1824 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); | 1822 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); |
| 1825 return; | 1823 return; |
| 1826 } | 1824 } |
| 1827 | 1825 |
| 1828 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); | 1826 WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObje
ct->getVertexAttribState(index); |
| 1829 state.enabled = true; | 1827 state.enabled = true; |
| 1830 | 1828 |
| 1831 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd
ex); | 1829 m_onePlusMaxEnabledAttribIndex = max(index + 1, m_onePlusMaxEnabledAttribInd
ex); |
| 1832 | 1830 |
| 1833 m_context->enableVertexAttribArray(index); | 1831 webContext()->enableVertexAttribArray(index); |
| 1834 } | 1832 } |
| 1835 | 1833 |
| 1836 void WebGLRenderingContextBase::finish() | 1834 void WebGLRenderingContextBase::finish() |
| 1837 { | 1835 { |
| 1838 if (isContextLost()) | 1836 if (isContextLost()) |
| 1839 return; | 1837 return; |
| 1840 m_context->flush(); // Intentionally a flush, not a finish. | 1838 webContext()->flush(); // Intentionally a flush, not a finish. |
| 1841 } | 1839 } |
| 1842 | 1840 |
| 1843 void WebGLRenderingContextBase::flush() | 1841 void WebGLRenderingContextBase::flush() |
| 1844 { | 1842 { |
| 1845 if (isContextLost()) | 1843 if (isContextLost()) |
| 1846 return; | 1844 return; |
| 1847 m_context->flush(); | 1845 webContext()->flush(); |
| 1848 } | 1846 } |
| 1849 | 1847 |
| 1850 void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at
tachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) | 1848 void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at
tachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) |
| 1851 { | 1849 { |
| 1852 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) | 1850 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) |
| 1853 return; | 1851 return; |
| 1854 if (renderbuffertarget != GL_RENDERBUFFER) { | 1852 if (renderbuffertarget != GL_RENDERBUFFER) { |
| 1855 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); | 1853 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); |
| 1856 return; | 1854 return; |
| 1857 } | 1855 } |
| 1858 if (buffer && !buffer->validate(contextGroup(), this)) { | 1856 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 1859 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b
uffer or buffer not from this context"); | 1857 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b
uffer or buffer not from this context"); |
| 1860 return; | 1858 return; |
| 1861 } | 1859 } |
| 1862 // Don't allow the default framebuffer to be mutated; all current | 1860 // Don't allow the default framebuffer to be mutated; all current |
| 1863 // implementations use an FBO internally in place of the default | 1861 // implementations use an FBO internally in place of the default |
| 1864 // FBO. | 1862 // FBO. |
| 1865 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 1863 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 1866 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); | 1864 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f
ramebuffer bound"); |
| 1867 return; | 1865 return; |
| 1868 } | 1866 } |
| 1869 Platform3DObject bufferObject = objectOrZero(buffer); | 1867 Platform3DObject bufferObject = objectOrZero(buffer); |
| 1870 switch (attachment) { | 1868 switch (attachment) { |
| 1871 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 1869 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
| 1872 if (isDepthStencilSupported() || !buffer) { | 1870 if (isDepthStencilSupported() || !buffer) { |
| 1873 m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rend
erbuffertarget, bufferObject); | 1871 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r
enderbuffertarget, bufferObject); |
| 1874 m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, re
nderbuffertarget, bufferObject); | 1872 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
renderbuffertarget, bufferObject); |
| 1875 } else { | 1873 } else { |
| 1876 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); | 1874 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(renderbuffertarget, buffer); |
| 1877 if (!emulatedStencilBuffer) { | 1875 if (!emulatedStencilBuffer) { |
| 1878 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", "
out of memory"); | 1876 synthesizeGLError(GL_OUT_OF_MEMORY, "framebufferRenderbuffer", "
out of memory"); |
| 1879 return; | 1877 return; |
| 1880 } | 1878 } |
| 1881 m_context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, rend
erbuffertarget, bufferObject); | 1879 webContext()->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, r
enderbuffertarget, bufferObject); |
| 1882 m_context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, re
nderbuffertarget, objectOrZero(emulatedStencilBuffer)); | 1880 webContext()->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
renderbuffertarget, objectOrZero(emulatedStencilBuffer)); |
| 1883 } | 1881 } |
| 1884 break; | 1882 break; |
| 1885 default: | 1883 default: |
| 1886 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge
t, bufferObject); | 1884 webContext()->framebufferRenderbuffer(target, attachment, renderbufferta
rget, bufferObject); |
| 1887 } | 1885 } |
| 1888 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); | 1886 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); |
| 1889 applyStencilTest(); | 1887 applyStencilTest(); |
| 1890 } | 1888 } |
| 1891 | 1889 |
| 1892 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac
hment, GLenum textarget, WebGLTexture* texture, GLint level) | 1890 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac
hment, GLenum textarget, WebGLTexture* texture, GLint level) |
| 1893 { | 1891 { |
| 1894 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) | 1892 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur
e2D", target, attachment)) |
| 1895 return; | 1893 return; |
| 1896 if (level) { | 1894 if (level) { |
| 1897 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0
"); | 1895 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0
"); |
| 1898 return; | 1896 return; |
| 1899 } | 1897 } |
| 1900 if (texture && !texture->validate(contextGroup(), this)) { | 1898 if (texture && !texture->validate(contextGroup(), this)) { |
| 1901 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); | 1899 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text
ure or texture not from this context"); |
| 1902 return; | 1900 return; |
| 1903 } | 1901 } |
| 1904 // Don't allow the default framebuffer to be mutated; all current | 1902 // Don't allow the default framebuffer to be mutated; all current |
| 1905 // implementations use an FBO internally in place of the default | 1903 // implementations use an FBO internally in place of the default |
| 1906 // FBO. | 1904 // FBO. |
| 1907 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 1905 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 1908 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); | 1906 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram
ebuffer bound"); |
| 1909 return; | 1907 return; |
| 1910 } | 1908 } |
| 1911 Platform3DObject textureObject = objectOrZero(texture); | 1909 Platform3DObject textureObject = objectOrZero(texture); |
| 1912 switch (attachment) { | 1910 switch (attachment) { |
| 1913 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: | 1911 case GC3D_DEPTH_STENCIL_ATTACHMENT_WEBGL: |
| 1914 m_context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget,
textureObject, level); | 1912 webContext()->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarge
t, textureObject, level); |
| 1915 m_context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget
, textureObject, level); | 1913 webContext()->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textar
get, textureObject, level); |
| 1916 break; | 1914 break; |
| 1917 case GL_DEPTH_ATTACHMENT: | 1915 case GL_DEPTH_ATTACHMENT: |
| 1918 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 1916 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); |
| 1919 break; | 1917 break; |
| 1920 case GL_STENCIL_ATTACHMENT: | 1918 case GL_STENCIL_ATTACHMENT: |
| 1921 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 1919 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); |
| 1922 break; | 1920 break; |
| 1923 default: | 1921 default: |
| 1924 m_context->framebufferTexture2D(target, attachment, textarget, textureOb
ject, level); | 1922 webContext()->framebufferTexture2D(target, attachment, textarget, textur
eObject, level); |
| 1925 } | 1923 } |
| 1926 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); | 1924 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget
, texture, level); |
| 1927 applyStencilTest(); | 1925 applyStencilTest(); |
| 1928 } | 1926 } |
| 1929 | 1927 |
| 1930 void WebGLRenderingContextBase::frontFace(GLenum mode) | 1928 void WebGLRenderingContextBase::frontFace(GLenum mode) |
| 1931 { | 1929 { |
| 1932 if (isContextLost()) | 1930 if (isContextLost()) |
| 1933 return; | 1931 return; |
| 1934 switch (mode) { | 1932 switch (mode) { |
| 1935 case GL_CW: | 1933 case GL_CW: |
| 1936 case GL_CCW: | 1934 case GL_CCW: |
| 1937 break; | 1935 break; |
| 1938 default: | 1936 default: |
| 1939 synthesizeGLError(GL_INVALID_ENUM, "frontFace", "invalid mode"); | 1937 synthesizeGLError(GL_INVALID_ENUM, "frontFace", "invalid mode"); |
| 1940 return; | 1938 return; |
| 1941 } | 1939 } |
| 1942 m_context->frontFace(mode); | 1940 webContext()->frontFace(mode); |
| 1943 } | 1941 } |
| 1944 | 1942 |
| 1945 void WebGLRenderingContextBase::generateMipmap(GLenum target) | 1943 void WebGLRenderingContextBase::generateMipmap(GLenum target) |
| 1946 { | 1944 { |
| 1947 if (isContextLost()) | 1945 if (isContextLost()) |
| 1948 return; | 1946 return; |
| 1949 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); | 1947 WebGLTexture* tex = validateTextureBinding("generateMipmap", target, false); |
| 1950 if (!tex) | 1948 if (!tex) |
| 1951 return; | 1949 return; |
| 1952 if (!tex->canGenerateMipmaps()) { | 1950 if (!tex->canGenerateMipmaps()) { |
| 1953 synthesizeGLError(GL_INVALID_OPERATION, "generateMipmap", "level 0 not p
ower of 2 or not all the same size"); | 1951 synthesizeGLError(GL_INVALID_OPERATION, "generateMipmap", "level 0 not p
ower of 2 or not all the same size"); |
| 1954 return; | 1952 return; |
| 1955 } | 1953 } |
| 1956 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) | 1954 if (!validateSettableTexFormat("generateMipmap", tex->getInternalFormat(targ
et, 0))) |
| 1957 return; | 1955 return; |
| 1958 | 1956 |
| 1959 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR | 1957 // generateMipmap won't work properly if minFilter is not NEAREST_MIPMAP_LIN
EAR |
| 1960 // on Mac. Remove the hack once this driver bug is fixed. | 1958 // on Mac. Remove the hack once this driver bug is fixed. |
| 1961 #if OS(MACOSX) | 1959 #if OS(MACOSX) |
| 1962 bool needToResetMinFilter = false; | 1960 bool needToResetMinFilter = false; |
| 1963 if (tex->getMinFilter() != GL_NEAREST_MIPMAP_LINEAR) { | 1961 if (tex->getMinFilter() != GL_NEAREST_MIPMAP_LINEAR) { |
| 1964 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMA
P_LINEAR); | 1962 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MI
PMAP_LINEAR); |
| 1965 needToResetMinFilter = true; | 1963 needToResetMinFilter = true; |
| 1966 } | 1964 } |
| 1967 #endif | 1965 #endif |
| 1968 m_context->generateMipmap(target); | 1966 webContext()->generateMipmap(target); |
| 1969 #if OS(MACOSX) | 1967 #if OS(MACOSX) |
| 1970 if (needToResetMinFilter) | 1968 if (needToResetMinFilter) |
| 1971 m_context->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFilte
r()); | 1969 webContext()->texParameteri(target, GL_TEXTURE_MIN_FILTER, tex->getMinFi
lter()); |
| 1972 #endif | 1970 #endif |
| 1973 tex->generateMipmapLevelInfo(); | 1971 tex->generateMipmapLevelInfo(); |
| 1974 } | 1972 } |
| 1975 | 1973 |
| 1976 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg
ram* program, GLuint index) | 1974 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveAttrib(WebGLProg
ram* program, GLuint index) |
| 1977 { | 1975 { |
| 1978 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 1976 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 1979 return nullptr; | 1977 return nullptr; |
| 1980 blink::WebGraphicsContext3D::ActiveInfo info; | 1978 blink::WebGraphicsContext3D::ActiveInfo info; |
| 1981 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) | 1979 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) |
| 1982 return nullptr; | 1980 return nullptr; |
| 1983 return WebGLActiveInfo::create(info.name, info.type, info.size); | 1981 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 1984 } | 1982 } |
| 1985 | 1983 |
| 1986 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLPro
gram* program, GLuint index) | 1984 PassRefPtr<WebGLActiveInfo> WebGLRenderingContextBase::getActiveUniform(WebGLPro
gram* program, GLuint index) |
| 1987 { | 1985 { |
| 1988 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 1986 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) |
| 1989 return nullptr; | 1987 return nullptr; |
| 1990 blink::WebGraphicsContext3D::ActiveInfo info; | 1988 blink::WebGraphicsContext3D::ActiveInfo info; |
| 1991 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) | 1989 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) |
| 1992 return nullptr; | 1990 return nullptr; |
| 1993 return WebGLActiveInfo::create(info.name, info.type, info.size); | 1991 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 1994 } | 1992 } |
| 1995 | 1993 |
| 1996 bool WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program, Vector
<RefPtr<WebGLShader> >& shaderObjects) | 1994 bool WebGLRenderingContextBase::getAttachedShaders(WebGLProgram* program, Vector
<RefPtr<WebGLShader> >& shaderObjects) |
| 1997 { | 1995 { |
| 1998 shaderObjects.clear(); | 1996 shaderObjects.clear(); |
| 1999 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 1997 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
| 2000 return false; | 1998 return false; |
| 2001 | 1999 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2018 if (!validateLocationLength("getAttribLocation", name)) | 2016 if (!validateLocationLength("getAttribLocation", name)) |
| 2019 return -1; | 2017 return -1; |
| 2020 if (!validateString("getAttribLocation", name)) | 2018 if (!validateString("getAttribLocation", name)) |
| 2021 return -1; | 2019 return -1; |
| 2022 if (isPrefixReserved(name)) | 2020 if (isPrefixReserved(name)) |
| 2023 return -1; | 2021 return -1; |
| 2024 if (!program->linkStatus()) { | 2022 if (!program->linkStatus()) { |
| 2025 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); | 2023 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); |
| 2026 return 0; | 2024 return 0; |
| 2027 } | 2025 } |
| 2028 return m_context->getAttribLocation(objectOrZero(program), name.utf8().data(
)); | 2026 return webContext()->getAttribLocation(objectOrZero(program), name.utf8().da
ta()); |
| 2029 } | 2027 } |
| 2030 | 2028 |
| 2031 WebGLGetInfo WebGLRenderingContextBase::getBufferParameter(GLenum target, GLenum
pname) | 2029 WebGLGetInfo WebGLRenderingContextBase::getBufferParameter(GLenum target, GLenum
pname) |
| 2032 { | 2030 { |
| 2033 if (isContextLost()) | 2031 if (isContextLost()) |
| 2034 return WebGLGetInfo(); | 2032 return WebGLGetInfo(); |
| 2035 if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) { | 2033 if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) { |
| 2036 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid target
"); | 2034 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid target
"); |
| 2037 return WebGLGetInfo(); | 2035 return WebGLGetInfo(); |
| 2038 } | 2036 } |
| 2039 | 2037 |
| 2040 if (pname != GL_BUFFER_SIZE && pname != GL_BUFFER_USAGE) { | 2038 if (pname != GL_BUFFER_SIZE && pname != GL_BUFFER_USAGE) { |
| 2041 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame
ter name"); | 2039 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame
ter name"); |
| 2042 return WebGLGetInfo(); | 2040 return WebGLGetInfo(); |
| 2043 } | 2041 } |
| 2044 | 2042 |
| 2045 GLint value = 0; | 2043 GLint value = 0; |
| 2046 m_context->getBufferParameteriv(target, pname, &value); | 2044 webContext()->getBufferParameteriv(target, pname, &value); |
| 2047 if (pname == GL_BUFFER_SIZE) | 2045 if (pname == GL_BUFFER_SIZE) |
| 2048 return WebGLGetInfo(value); | 2046 return WebGLGetInfo(value); |
| 2049 return WebGLGetInfo(static_cast<unsigned>(value)); | 2047 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2050 } | 2048 } |
| 2051 | 2049 |
| 2052 PassRefPtr<WebGLContextAttributes> WebGLRenderingContextBase::getContextAttribut
es() | 2050 PassRefPtr<WebGLContextAttributes> WebGLRenderingContextBase::getContextAttribut
es() |
| 2053 { | 2051 { |
| 2054 if (isContextLost()) | 2052 if (isContextLost()) |
| 2055 return nullptr; | 2053 return nullptr; |
| 2056 // We always need to return a new WebGLContextAttributes object to | 2054 // We always need to return a new WebGLContextAttributes object to |
| 2057 // prevent the user from mutating any cached version. | 2055 // prevent the user from mutating any cached version. |
| 2058 blink::WebGraphicsContext3D::Attributes attrs = m_context->getContextAttribu
tes(); | 2056 blink::WebGraphicsContext3D::Attributes attrs = webContext()->getContextAttr
ibutes(); |
| 2059 RefPtr<WebGLContextAttributes> attributes = m_requestedAttributes->clone(); | 2057 RefPtr<WebGLContextAttributes> attributes = m_requestedAttributes->clone(); |
| 2060 // Some requested attributes may not be honored, so we need to query the und
erlying | 2058 // Some requested attributes may not be honored, so we need to query the und
erlying |
| 2061 // context/drawing buffer and adjust accordingly. | 2059 // context/drawing buffer and adjust accordingly. |
| 2062 if (m_requestedAttributes->depth() && !attrs.depth) | 2060 if (m_requestedAttributes->depth() && !attrs.depth) |
| 2063 attributes->setDepth(false); | 2061 attributes->setDepth(false); |
| 2064 if (m_requestedAttributes->stencil() && !attrs.stencil) | 2062 if (m_requestedAttributes->stencil() && !attrs.stencil) |
| 2065 attributes->setStencil(false); | 2063 attributes->setStencil(false); |
| 2066 attributes->setAntialias(m_drawingBuffer->multisample()); | 2064 attributes->setAntialias(m_drawingBuffer->multisample()); |
| 2067 return attributes.release(); | 2065 return attributes.release(); |
| 2068 } | 2066 } |
| 2069 | 2067 |
| 2070 GLenum WebGLRenderingContextBase::getError() | 2068 GLenum WebGLRenderingContextBase::getError() |
| 2071 { | 2069 { |
| 2072 if (m_lostContextErrors.size()) { | 2070 if (m_lostContextErrors.size()) { |
| 2073 GLenum err = m_lostContextErrors.first(); | 2071 GLenum err = m_lostContextErrors.first(); |
| 2074 m_lostContextErrors.remove(0); | 2072 m_lostContextErrors.remove(0); |
| 2075 return err; | 2073 return err; |
| 2076 } | 2074 } |
| 2077 | 2075 |
| 2078 if (isContextLost()) | 2076 if (isContextLost()) |
| 2079 return GL_NO_ERROR; | 2077 return GL_NO_ERROR; |
| 2080 | 2078 |
| 2081 return m_context->getError(); | 2079 return webContext()->getError(); |
| 2082 } | 2080 } |
| 2083 | 2081 |
| 2084 bool WebGLRenderingContextBase::ExtensionTracker::matchesNameWithPrefixes(const
String& name) const | 2082 bool WebGLRenderingContextBase::ExtensionTracker::matchesNameWithPrefixes(const
String& name) const |
| 2085 { | 2083 { |
| 2086 static const char* const unprefixed[] = { "", 0, }; | 2084 static const char* const unprefixed[] = { "", 0, }; |
| 2087 | 2085 |
| 2088 const char* const* prefixes = m_prefixes ? m_prefixes : unprefixed; | 2086 const char* const* prefixes = m_prefixes ? m_prefixes : unprefixed; |
| 2089 for (; *prefixes; ++prefixes) { | 2087 for (; *prefixes; ++prefixes) { |
| 2090 String prefixedName = String(*prefixes) + extensionName(); | 2088 String prefixedName = String(*prefixes) + extensionName(); |
| 2091 if (equalIgnoringCase(prefixedName, name)) { | 2089 if (equalIgnoringCase(prefixedName, name)) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 if (object->isTexture()) { | 2144 if (object->isTexture()) { |
| 2147 switch (pname) { | 2145 switch (pname) { |
| 2148 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2146 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2149 return WebGLGetInfo(GL_TEXTURE); | 2147 return WebGLGetInfo(GL_TEXTURE); |
| 2150 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2148 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2151 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur
e*>(object))); | 2149 return WebGLGetInfo(PassRefPtr<WebGLTexture>(static_cast<WebGLTextur
e*>(object))); |
| 2152 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | 2150 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2153 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | 2151 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2154 { | 2152 { |
| 2155 GLint value = 0; | 2153 GLint value = 0; |
| 2156 m_context->getFramebufferAttachmentParameteriv(target, attachmen
t, pname, &value); | 2154 webContext()->getFramebufferAttachmentParameteriv(target, attach
ment, pname, &value); |
| 2157 return WebGLGetInfo(value); | 2155 return WebGLGetInfo(value); |
| 2158 } | 2156 } |
| 2159 default: | 2157 default: |
| 2160 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for texture attachment"); | 2158 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for texture attachment"); |
| 2161 return WebGLGetInfo(); | 2159 return WebGLGetInfo(); |
| 2162 } | 2160 } |
| 2163 } else { | 2161 } else { |
| 2164 switch (pname) { | 2162 switch (pname) { |
| 2165 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2163 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2166 return WebGLGetInfo(GL_RENDERBUFFER); | 2164 return WebGLGetInfo(GL_RENDERBUFFER); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 return getBooleanParameter(pname); | 2290 return getBooleanParameter(pname); |
| 2293 case GL_SAMPLE_COVERAGE_VALUE: | 2291 case GL_SAMPLE_COVERAGE_VALUE: |
| 2294 return getFloatParameter(pname); | 2292 return getFloatParameter(pname); |
| 2295 case GL_SAMPLES: | 2293 case GL_SAMPLES: |
| 2296 return getIntParameter(pname); | 2294 return getIntParameter(pname); |
| 2297 case GL_SCISSOR_BOX: | 2295 case GL_SCISSOR_BOX: |
| 2298 return getWebGLIntArrayParameter(pname); | 2296 return getWebGLIntArrayParameter(pname); |
| 2299 case GL_SCISSOR_TEST: | 2297 case GL_SCISSOR_TEST: |
| 2300 return getBooleanParameter(pname); | 2298 return getBooleanParameter(pname); |
| 2301 case GL_SHADING_LANGUAGE_VERSION: | 2299 case GL_SHADING_LANGUAGE_VERSION: |
| 2302 return WebGLGetInfo("WebGL GLSL ES 1.0 (" + String(m_context->getString(
GL_SHADING_LANGUAGE_VERSION)) + ")"); | 2300 return WebGLGetInfo("WebGL GLSL ES 1.0 (" + String(webContext()->getStri
ng(GL_SHADING_LANGUAGE_VERSION)) + ")"); |
| 2303 case GL_STENCIL_BACK_FAIL: | 2301 case GL_STENCIL_BACK_FAIL: |
| 2304 return getUnsignedIntParameter(pname); | 2302 return getUnsignedIntParameter(pname); |
| 2305 case GL_STENCIL_BACK_FUNC: | 2303 case GL_STENCIL_BACK_FUNC: |
| 2306 return getUnsignedIntParameter(pname); | 2304 return getUnsignedIntParameter(pname); |
| 2307 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: | 2305 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: |
| 2308 return getUnsignedIntParameter(pname); | 2306 return getUnsignedIntParameter(pname); |
| 2309 case GL_STENCIL_BACK_PASS_DEPTH_PASS: | 2307 case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
| 2310 return getUnsignedIntParameter(pname); | 2308 return getUnsignedIntParameter(pname); |
| 2311 case GL_STENCIL_BACK_REF: | 2309 case GL_STENCIL_BACK_REF: |
| 2312 return getIntParameter(pname); | 2310 return getIntParameter(pname); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 return getIntParameter(pname); | 2344 return getIntParameter(pname); |
| 2347 case GC3D_UNPACK_FLIP_Y_WEBGL: | 2345 case GC3D_UNPACK_FLIP_Y_WEBGL: |
| 2348 return WebGLGetInfo(m_unpackFlipY); | 2346 return WebGLGetInfo(m_unpackFlipY); |
| 2349 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: | 2347 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: |
| 2350 return WebGLGetInfo(m_unpackPremultiplyAlpha); | 2348 return WebGLGetInfo(m_unpackPremultiplyAlpha); |
| 2351 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: | 2349 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: |
| 2352 return WebGLGetInfo(m_unpackColorspaceConversion); | 2350 return WebGLGetInfo(m_unpackColorspaceConversion); |
| 2353 case GL_VENDOR: | 2351 case GL_VENDOR: |
| 2354 return WebGLGetInfo(String("WebKit")); | 2352 return WebGLGetInfo(String("WebKit")); |
| 2355 case GL_VERSION: | 2353 case GL_VERSION: |
| 2356 return WebGLGetInfo("WebGL 1.0 (" + String(m_context->getString(GL_VERSI
ON)) + ")"); | 2354 return WebGLGetInfo("WebGL 1.0 (" + String(webContext()->getString(GL_VE
RSION)) + ")"); |
| 2357 case GL_VIEWPORT: | 2355 case GL_VIEWPORT: |
| 2358 return getWebGLIntArrayParameter(pname); | 2356 return getWebGLIntArrayParameter(pname); |
| 2359 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives | 2357 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives |
| 2360 if (extensionEnabled(OESStandardDerivativesName)) | 2358 if (extensionEnabled(OESStandardDerivativesName)) |
| 2361 return getUnsignedIntParameter(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OE
S); | 2359 return getUnsignedIntParameter(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OE
S); |
| 2362 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, OES_standard_derivatives not enabled"); | 2360 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, OES_standard_derivatives not enabled"); |
| 2363 return WebGLGetInfo(); | 2361 return WebGLGetInfo(); |
| 2364 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: | 2362 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: |
| 2365 if (extensionEnabled(WebGLDebugRendererInfoName)) | 2363 if (extensionEnabled(WebGLDebugRendererInfoName)) |
| 2366 return WebGLGetInfo(m_context->getString(GL_RENDERER)); | 2364 return WebGLGetInfo(webContext()->getString(GL_RENDERER)); |
| 2367 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_debug_renderer_info not enabled"); | 2365 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_debug_renderer_info not enabled"); |
| 2368 return WebGLGetInfo(); | 2366 return WebGLGetInfo(); |
| 2369 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: | 2367 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: |
| 2370 if (extensionEnabled(WebGLDebugRendererInfoName)) | 2368 if (extensionEnabled(WebGLDebugRendererInfoName)) |
| 2371 return WebGLGetInfo(m_context->getString(GL_VENDOR)); | 2369 return WebGLGetInfo(webContext()->getString(GL_VENDOR)); |
| 2372 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_debug_renderer_info not enabled"); | 2370 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, WEBGL_debug_renderer_info not enabled"); |
| 2373 return WebGLGetInfo(); | 2371 return WebGLGetInfo(); |
| 2374 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object | 2372 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object |
| 2375 if (extensionEnabled(OESVertexArrayObjectName)) { | 2373 if (extensionEnabled(OESVertexArrayObjectName)) { |
| 2376 if (!m_boundVertexArrayObject->isDefaultObject()) | 2374 if (!m_boundVertexArrayObject->isDefaultObject()) |
| 2377 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun
dVertexArrayObject)); | 2375 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun
dVertexArrayObject)); |
| 2378 return WebGLGetInfo(); | 2376 return WebGLGetInfo(); |
| 2379 } | 2377 } |
| 2380 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, OES_vertex_array_object not enabled"); | 2378 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na
me, OES_vertex_array_object not enabled"); |
| 2381 return WebGLGetInfo(); | 2379 return WebGLGetInfo(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2413 WebGLGetInfo WebGLRenderingContextBase::getProgramParameter(WebGLProgram* progra
m, GLenum pname) | 2411 WebGLGetInfo WebGLRenderingContextBase::getProgramParameter(WebGLProgram* progra
m, GLenum pname) |
| 2414 { | 2412 { |
| 2415 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) | 2413 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) |
| 2416 return WebGLGetInfo(); | 2414 return WebGLGetInfo(); |
| 2417 | 2415 |
| 2418 GLint value = 0; | 2416 GLint value = 0; |
| 2419 switch (pname) { | 2417 switch (pname) { |
| 2420 case GL_DELETE_STATUS: | 2418 case GL_DELETE_STATUS: |
| 2421 return WebGLGetInfo(program->isDeleted()); | 2419 return WebGLGetInfo(program->isDeleted()); |
| 2422 case GL_VALIDATE_STATUS: | 2420 case GL_VALIDATE_STATUS: |
| 2423 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2421 webContext()->getProgramiv(objectOrZero(program), pname, &value); |
| 2424 return WebGLGetInfo(static_cast<bool>(value)); | 2422 return WebGLGetInfo(static_cast<bool>(value)); |
| 2425 case GL_LINK_STATUS: | 2423 case GL_LINK_STATUS: |
| 2426 return WebGLGetInfo(program->linkStatus()); | 2424 return WebGLGetInfo(program->linkStatus()); |
| 2427 case GL_ATTACHED_SHADERS: | 2425 case GL_ATTACHED_SHADERS: |
| 2428 case GL_ACTIVE_ATTRIBUTES: | 2426 case GL_ACTIVE_ATTRIBUTES: |
| 2429 case GL_ACTIVE_UNIFORMS: | 2427 case GL_ACTIVE_UNIFORMS: |
| 2430 m_context->getProgramiv(objectOrZero(program), pname, &value); | 2428 webContext()->getProgramiv(objectOrZero(program), pname, &value); |
| 2431 return WebGLGetInfo(value); | 2429 return WebGLGetInfo(value); |
| 2432 default: | 2430 default: |
| 2433 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param
eter name"); | 2431 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param
eter name"); |
| 2434 return WebGLGetInfo(); | 2432 return WebGLGetInfo(); |
| 2435 } | 2433 } |
| 2436 } | 2434 } |
| 2437 | 2435 |
| 2438 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) | 2436 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) |
| 2439 { | 2437 { |
| 2440 if (isContextLost()) | 2438 if (isContextLost()) |
| 2441 return String(); | 2439 return String(); |
| 2442 if (!validateWebGLObject("getProgramInfoLog", program)) | 2440 if (!validateWebGLObject("getProgramInfoLog", program)) |
| 2443 return ""; | 2441 return ""; |
| 2444 return ensureNotNull(m_context->getProgramInfoLog(objectOrZero(program))); | 2442 return ensureNotNull(webContext()->getProgramInfoLog(objectOrZero(program)))
; |
| 2445 } | 2443 } |
| 2446 | 2444 |
| 2447 WebGLGetInfo WebGLRenderingContextBase::getRenderbufferParameter(GLenum target,
GLenum pname) | 2445 WebGLGetInfo WebGLRenderingContextBase::getRenderbufferParameter(GLenum target,
GLenum pname) |
| 2448 { | 2446 { |
| 2449 if (isContextLost()) | 2447 if (isContextLost()) |
| 2450 return WebGLGetInfo(); | 2448 return WebGLGetInfo(); |
| 2451 if (target != GL_RENDERBUFFER) { | 2449 if (target != GL_RENDERBUFFER) { |
| 2452 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
target"); | 2450 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
target"); |
| 2453 return WebGLGetInfo(); | 2451 return WebGLGetInfo(); |
| 2454 } | 2452 } |
| 2455 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { | 2453 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { |
| 2456 synthesizeGLError(GL_INVALID_OPERATION, "getRenderbufferParameter", "no
renderbuffer bound"); | 2454 synthesizeGLError(GL_INVALID_OPERATION, "getRenderbufferParameter", "no
renderbuffer bound"); |
| 2457 return WebGLGetInfo(); | 2455 return WebGLGetInfo(); |
| 2458 } | 2456 } |
| 2459 | 2457 |
| 2460 GLint value = 0; | 2458 GLint value = 0; |
| 2461 switch (pname) { | 2459 switch (pname) { |
| 2462 case GL_RENDERBUFFER_WIDTH: | 2460 case GL_RENDERBUFFER_WIDTH: |
| 2463 case GL_RENDERBUFFER_HEIGHT: | 2461 case GL_RENDERBUFFER_HEIGHT: |
| 2464 case GL_RENDERBUFFER_RED_SIZE: | 2462 case GL_RENDERBUFFER_RED_SIZE: |
| 2465 case GL_RENDERBUFFER_GREEN_SIZE: | 2463 case GL_RENDERBUFFER_GREEN_SIZE: |
| 2466 case GL_RENDERBUFFER_BLUE_SIZE: | 2464 case GL_RENDERBUFFER_BLUE_SIZE: |
| 2467 case GL_RENDERBUFFER_ALPHA_SIZE: | 2465 case GL_RENDERBUFFER_ALPHA_SIZE: |
| 2468 case GL_RENDERBUFFER_DEPTH_SIZE: | 2466 case GL_RENDERBUFFER_DEPTH_SIZE: |
| 2469 m_context->getRenderbufferParameteriv(target, pname, &value); | 2467 webContext()->getRenderbufferParameteriv(target, pname, &value); |
| 2470 return WebGLGetInfo(value); | 2468 return WebGLGetInfo(value); |
| 2471 case GL_RENDERBUFFER_STENCIL_SIZE: | 2469 case GL_RENDERBUFFER_STENCIL_SIZE: |
| 2472 if (m_renderbufferBinding->emulatedStencilBuffer()) { | 2470 if (m_renderbufferBinding->emulatedStencilBuffer()) { |
| 2473 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng->emulatedStencilBuffer())); | 2471 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi
nding->emulatedStencilBuffer())); |
| 2474 m_context->getRenderbufferParameteriv(target, pname, &value); | 2472 webContext()->getRenderbufferParameteriv(target, pname, &value); |
| 2475 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng.get())); | 2473 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi
nding.get())); |
| 2476 } else { | 2474 } else { |
| 2477 m_context->getRenderbufferParameteriv(target, pname, &value); | 2475 webContext()->getRenderbufferParameteriv(target, pname, &value); |
| 2478 } | 2476 } |
| 2479 return WebGLGetInfo(value); | 2477 return WebGLGetInfo(value); |
| 2480 case GL_RENDERBUFFER_INTERNAL_FORMAT: | 2478 case GL_RENDERBUFFER_INTERNAL_FORMAT: |
| 2481 return WebGLGetInfo(m_renderbufferBinding->internalFormat()); | 2479 return WebGLGetInfo(m_renderbufferBinding->internalFormat()); |
| 2482 default: | 2480 default: |
| 2483 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
parameter name"); | 2481 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
parameter name"); |
| 2484 return WebGLGetInfo(); | 2482 return WebGLGetInfo(); |
| 2485 } | 2483 } |
| 2486 } | 2484 } |
| 2487 | 2485 |
| 2488 WebGLGetInfo WebGLRenderingContextBase::getShaderParameter(WebGLShader* shader,
GLenum pname) | 2486 WebGLGetInfo WebGLRenderingContextBase::getShaderParameter(WebGLShader* shader,
GLenum pname) |
| 2489 { | 2487 { |
| 2490 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) | 2488 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) |
| 2491 return WebGLGetInfo(); | 2489 return WebGLGetInfo(); |
| 2492 GLint value = 0; | 2490 GLint value = 0; |
| 2493 switch (pname) { | 2491 switch (pname) { |
| 2494 case GL_DELETE_STATUS: | 2492 case GL_DELETE_STATUS: |
| 2495 return WebGLGetInfo(shader->isDeleted()); | 2493 return WebGLGetInfo(shader->isDeleted()); |
| 2496 case GL_COMPILE_STATUS: | 2494 case GL_COMPILE_STATUS: |
| 2497 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2495 webContext()->getShaderiv(objectOrZero(shader), pname, &value); |
| 2498 return WebGLGetInfo(static_cast<bool>(value)); | 2496 return WebGLGetInfo(static_cast<bool>(value)); |
| 2499 case GL_SHADER_TYPE: | 2497 case GL_SHADER_TYPE: |
| 2500 m_context->getShaderiv(objectOrZero(shader), pname, &value); | 2498 webContext()->getShaderiv(objectOrZero(shader), pname, &value); |
| 2501 return WebGLGetInfo(static_cast<unsigned>(value)); | 2499 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2502 default: | 2500 default: |
| 2503 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame
ter name"); | 2501 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame
ter name"); |
| 2504 return WebGLGetInfo(); | 2502 return WebGLGetInfo(); |
| 2505 } | 2503 } |
| 2506 } | 2504 } |
| 2507 | 2505 |
| 2508 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) | 2506 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) |
| 2509 { | 2507 { |
| 2510 if (isContextLost()) | 2508 if (isContextLost()) |
| 2511 return String(); | 2509 return String(); |
| 2512 if (!validateWebGLObject("getShaderInfoLog", shader)) | 2510 if (!validateWebGLObject("getShaderInfoLog", shader)) |
| 2513 return ""; | 2511 return ""; |
| 2514 return ensureNotNull(m_context->getShaderInfoLog(objectOrZero(shader))); | 2512 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader))); |
| 2515 } | 2513 } |
| 2516 | 2514 |
| 2517 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::getShaderPreci
sionFormat(GLenum shaderType, GLenum precisionType) | 2515 PassRefPtr<WebGLShaderPrecisionFormat> WebGLRenderingContextBase::getShaderPreci
sionFormat(GLenum shaderType, GLenum precisionType) |
| 2518 { | 2516 { |
| 2519 if (isContextLost()) | 2517 if (isContextLost()) |
| 2520 return nullptr; | 2518 return nullptr; |
| 2521 switch (shaderType) { | 2519 switch (shaderType) { |
| 2522 case GL_VERTEX_SHADER: | 2520 case GL_VERTEX_SHADER: |
| 2523 case GL_FRAGMENT_SHADER: | 2521 case GL_FRAGMENT_SHADER: |
| 2524 break; | 2522 break; |
| 2525 default: | 2523 default: |
| 2526 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
shader type"); | 2524 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
shader type"); |
| 2527 return nullptr; | 2525 return nullptr; |
| 2528 } | 2526 } |
| 2529 switch (precisionType) { | 2527 switch (precisionType) { |
| 2530 case GL_LOW_FLOAT: | 2528 case GL_LOW_FLOAT: |
| 2531 case GL_MEDIUM_FLOAT: | 2529 case GL_MEDIUM_FLOAT: |
| 2532 case GL_HIGH_FLOAT: | 2530 case GL_HIGH_FLOAT: |
| 2533 case GL_LOW_INT: | 2531 case GL_LOW_INT: |
| 2534 case GL_MEDIUM_INT: | 2532 case GL_MEDIUM_INT: |
| 2535 case GL_HIGH_INT: | 2533 case GL_HIGH_INT: |
| 2536 break; | 2534 break; |
| 2537 default: | 2535 default: |
| 2538 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); | 2536 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); |
| 2539 return nullptr; | 2537 return nullptr; |
| 2540 } | 2538 } |
| 2541 | 2539 |
| 2542 GLint range[2] = {0, 0}; | 2540 GLint range[2] = {0, 0}; |
| 2543 GLint precision = 0; | 2541 GLint precision = 0; |
| 2544 m_context->getShaderPrecisionFormat(shaderType, precisionType, range, &preci
sion); | 2542 webContext()->getShaderPrecisionFormat(shaderType, precisionType, range, &pr
ecision); |
| 2545 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 2543 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); |
| 2546 } | 2544 } |
| 2547 | 2545 |
| 2548 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) | 2546 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) |
| 2549 { | 2547 { |
| 2550 if (isContextLost()) | 2548 if (isContextLost()) |
| 2551 return String(); | 2549 return String(); |
| 2552 if (!validateWebGLObject("getShaderSource", shader)) | 2550 if (!validateWebGLObject("getShaderSource", shader)) |
| 2553 return ""; | 2551 return ""; |
| 2554 return ensureNotNull(shader->source()); | 2552 return ensureNotNull(shader->source()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2581 return WebGLGetInfo(); | 2579 return WebGLGetInfo(); |
| 2582 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false)
; | 2580 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false)
; |
| 2583 if (!tex) | 2581 if (!tex) |
| 2584 return WebGLGetInfo(); | 2582 return WebGLGetInfo(); |
| 2585 GLint value = 0; | 2583 GLint value = 0; |
| 2586 switch (pname) { | 2584 switch (pname) { |
| 2587 case GL_TEXTURE_MAG_FILTER: | 2585 case GL_TEXTURE_MAG_FILTER: |
| 2588 case GL_TEXTURE_MIN_FILTER: | 2586 case GL_TEXTURE_MIN_FILTER: |
| 2589 case GL_TEXTURE_WRAP_S: | 2587 case GL_TEXTURE_WRAP_S: |
| 2590 case GL_TEXTURE_WRAP_T: | 2588 case GL_TEXTURE_WRAP_T: |
| 2591 m_context->getTexParameteriv(target, pname, &value); | 2589 webContext()->getTexParameteriv(target, pname, &value); |
| 2592 return WebGLGetInfo(static_cast<unsigned>(value)); | 2590 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2593 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic | 2591 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic |
| 2594 if (extensionEnabled(EXTTextureFilterAnisotropicName)) { | 2592 if (extensionEnabled(EXTTextureFilterAnisotropicName)) { |
| 2595 m_context->getTexParameteriv(target, pname, &value); | 2593 webContext()->getTexParameteriv(target, pname, &value); |
| 2596 return WebGLGetInfo(static_cast<unsigned>(value)); | 2594 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 2597 } | 2595 } |
| 2598 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name, EXT_texture_filter_anisotropic not enabled"); | 2596 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name, EXT_texture_filter_anisotropic not enabled"); |
| 2599 return WebGLGetInfo(); | 2597 return WebGLGetInfo(); |
| 2600 default: | 2598 default: |
| 2601 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name"); | 2599 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name"); |
| 2602 return WebGLGetInfo(); | 2600 return WebGLGetInfo(); |
| 2603 } | 2601 } |
| 2604 } | 2602 } |
| 2605 | 2603 |
| 2606 WebGLGetInfo WebGLRenderingContextBase::getUniform(WebGLProgram* program, const
WebGLUniformLocation* uniformLocation) | 2604 WebGLGetInfo WebGLRenderingContextBase::getUniform(WebGLProgram* program, const
WebGLUniformLocation* uniformLocation) |
| 2607 { | 2605 { |
| 2608 if (isContextLost() || !validateWebGLObject("getUniform", program)) | 2606 if (isContextLost() || !validateWebGLObject("getUniform", program)) |
| 2609 return WebGLGetInfo(); | 2607 return WebGLGetInfo(); |
| 2610 if (!uniformLocation || uniformLocation->program() != program) { | 2608 if (!uniformLocation || uniformLocation->program() != program) { |
| 2611 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio
n or not valid for this program"); | 2609 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio
n or not valid for this program"); |
| 2612 return WebGLGetInfo(); | 2610 return WebGLGetInfo(); |
| 2613 } | 2611 } |
| 2614 GLint location = uniformLocation->location(); | 2612 GLint location = uniformLocation->location(); |
| 2615 | 2613 |
| 2616 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it | 2614 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it |
| 2617 GLint activeUniforms = 0; | 2615 GLint activeUniforms = 0; |
| 2618 m_context->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activeUn
iforms); | 2616 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activ
eUniforms); |
| 2619 for (GLint i = 0; i < activeUniforms; i++) { | 2617 for (GLint i = 0; i < activeUniforms; i++) { |
| 2620 blink::WebGraphicsContext3D::ActiveInfo info; | 2618 blink::WebGraphicsContext3D::ActiveInfo info; |
| 2621 if (!m_context->getActiveUniform(objectOrZero(program), i, info)) | 2619 if (!webContext()->getActiveUniform(objectOrZero(program), i, info)) |
| 2622 return WebGLGetInfo(); | 2620 return WebGLGetInfo(); |
| 2623 String name = info.name; | 2621 String name = info.name; |
| 2624 StringBuilder nameBuilder; | 2622 StringBuilder nameBuilder; |
| 2625 // Strip "[0]" from the name if it's an array. | 2623 // Strip "[0]" from the name if it's an array. |
| 2626 if (info.size > 1 && name.endsWith("[0]")) | 2624 if (info.size > 1 && name.endsWith("[0]")) |
| 2627 info.name = name.left(name.length() - 3); | 2625 info.name = name.left(name.length() - 3); |
| 2628 // If it's an array, we need to iterate through each element, appending
"[index]" to the name. | 2626 // If it's an array, we need to iterate through each element, appending
"[index]" to the name. |
| 2629 for (GLint index = 0; index < info.size; ++index) { | 2627 for (GLint index = 0; index < info.size; ++index) { |
| 2630 nameBuilder.clear(); | 2628 nameBuilder.clear(); |
| 2631 nameBuilder.append(info.name); | 2629 nameBuilder.append(info.name); |
| 2632 if (info.size > 1 && index >= 1) { | 2630 if (info.size > 1 && index >= 1) { |
| 2633 nameBuilder.append('['); | 2631 nameBuilder.append('['); |
| 2634 nameBuilder.append(String::number(index)); | 2632 nameBuilder.append(String::number(index)); |
| 2635 nameBuilder.append(']'); | 2633 nameBuilder.append(']'); |
| 2636 } | 2634 } |
| 2637 // Now need to look this up by name again to find its location | 2635 // Now need to look this up by name again to find its location |
| 2638 GLint loc = m_context->getUniformLocation(objectOrZero(program), nam
eBuilder.toString().utf8().data()); | 2636 GLint loc = webContext()->getUniformLocation(objectOrZero(program),
nameBuilder.toString().utf8().data()); |
| 2639 if (loc == location) { | 2637 if (loc == location) { |
| 2640 // Found it. Use the type in the ActiveInfo to determine the ret
urn type. | 2638 // Found it. Use the type in the ActiveInfo to determine the ret
urn type. |
| 2641 GLenum baseType; | 2639 GLenum baseType; |
| 2642 unsigned length; | 2640 unsigned length; |
| 2643 switch (info.type) { | 2641 switch (info.type) { |
| 2644 case GL_BOOL: | 2642 case GL_BOOL: |
| 2645 baseType = GL_BOOL; | 2643 baseType = GL_BOOL; |
| 2646 length = 1; | 2644 length = 1; |
| 2647 break; | 2645 break; |
| 2648 case GL_BOOL_VEC2: | 2646 case GL_BOOL_VEC2: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2707 length = 1; | 2705 length = 1; |
| 2708 break; | 2706 break; |
| 2709 default: | 2707 default: |
| 2710 // Can't handle this type | 2708 // Can't handle this type |
| 2711 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhandled
type"); | 2709 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhandled
type"); |
| 2712 return WebGLGetInfo(); | 2710 return WebGLGetInfo(); |
| 2713 } | 2711 } |
| 2714 switch (baseType) { | 2712 switch (baseType) { |
| 2715 case GL_FLOAT: { | 2713 case GL_FLOAT: { |
| 2716 GLfloat value[16] = {0}; | 2714 GLfloat value[16] = {0}; |
| 2717 m_context->getUniformfv(objectOrZero(program), location, val
ue); | 2715 webContext()->getUniformfv(objectOrZero(program), location,
value); |
| 2718 if (length == 1) | 2716 if (length == 1) |
| 2719 return WebGLGetInfo(value[0]); | 2717 return WebGLGetInfo(value[0]); |
| 2720 return WebGLGetInfo(Float32Array::create(value, length)); | 2718 return WebGLGetInfo(Float32Array::create(value, length)); |
| 2721 } | 2719 } |
| 2722 case GL_INT: { | 2720 case GL_INT: { |
| 2723 GLint value[4] = {0}; | 2721 GLint value[4] = {0}; |
| 2724 m_context->getUniformiv(objectOrZero(program), location, val
ue); | 2722 webContext()->getUniformiv(objectOrZero(program), location,
value); |
| 2725 if (length == 1) | 2723 if (length == 1) |
| 2726 return WebGLGetInfo(value[0]); | 2724 return WebGLGetInfo(value[0]); |
| 2727 return WebGLGetInfo(Int32Array::create(value, length)); | 2725 return WebGLGetInfo(Int32Array::create(value, length)); |
| 2728 } | 2726 } |
| 2729 case GL_BOOL: { | 2727 case GL_BOOL: { |
| 2730 GLint value[4] = {0}; | 2728 GLint value[4] = {0}; |
| 2731 m_context->getUniformiv(objectOrZero(program), location, val
ue); | 2729 webContext()->getUniformiv(objectOrZero(program), location,
value); |
| 2732 if (length > 1) { | 2730 if (length > 1) { |
| 2733 bool boolValue[16] = {0}; | 2731 bool boolValue[16] = {0}; |
| 2734 for (unsigned j = 0; j < length; j++) | 2732 for (unsigned j = 0; j < length; j++) |
| 2735 boolValue[j] = static_cast<bool>(value[j]); | 2733 boolValue[j] = static_cast<bool>(value[j]); |
| 2736 return WebGLGetInfo(boolValue, length); | 2734 return WebGLGetInfo(boolValue, length); |
| 2737 } | 2735 } |
| 2738 return WebGLGetInfo(static_cast<bool>(value[0])); | 2736 return WebGLGetInfo(static_cast<bool>(value[0])); |
| 2739 } | 2737 } |
| 2740 default: | 2738 default: |
| 2741 notImplemented(); | 2739 notImplemented(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2755 if (!validateLocationLength("getUniformLocation", name)) | 2753 if (!validateLocationLength("getUniformLocation", name)) |
| 2756 return nullptr; | 2754 return nullptr; |
| 2757 if (!validateString("getUniformLocation", name)) | 2755 if (!validateString("getUniformLocation", name)) |
| 2758 return nullptr; | 2756 return nullptr; |
| 2759 if (isPrefixReserved(name)) | 2757 if (isPrefixReserved(name)) |
| 2760 return nullptr; | 2758 return nullptr; |
| 2761 if (!program->linkStatus()) { | 2759 if (!program->linkStatus()) { |
| 2762 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); | 2760 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); |
| 2763 return nullptr; | 2761 return nullptr; |
| 2764 } | 2762 } |
| 2765 GLint uniformLocation = m_context->getUniformLocation(objectOrZero(program),
name.utf8().data()); | 2763 GLint uniformLocation = webContext()->getUniformLocation(objectOrZero(progra
m), name.utf8().data()); |
| 2766 if (uniformLocation == -1) | 2764 if (uniformLocation == -1) |
| 2767 return nullptr; | 2765 return nullptr; |
| 2768 return WebGLUniformLocation::create(program, uniformLocation); | 2766 return WebGLUniformLocation::create(program, uniformLocation); |
| 2769 } | 2767 } |
| 2770 | 2768 |
| 2771 WebGLGetInfo WebGLRenderingContextBase::getVertexAttrib(GLuint index, GLenum pna
me) | 2769 WebGLGetInfo WebGLRenderingContextBase::getVertexAttrib(GLuint index, GLenum pna
me) |
| 2772 { | 2770 { |
| 2773 if (isContextLost()) | 2771 if (isContextLost()) |
| 2774 return WebGLGetInfo(); | 2772 return WebGLGetInfo(); |
| 2775 if (index >= m_maxVertexAttribs) { | 2773 if (index >= m_maxVertexAttribs) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2805 } | 2803 } |
| 2806 | 2804 |
| 2807 long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum
pname) | 2805 long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum
pname) |
| 2808 { | 2806 { |
| 2809 if (isContextLost()) | 2807 if (isContextLost()) |
| 2810 return 0; | 2808 return 0; |
| 2811 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) { | 2809 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) { |
| 2812 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid par
ameter name"); | 2810 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid par
ameter name"); |
| 2813 return 0; | 2811 return 0; |
| 2814 } | 2812 } |
| 2815 GLsizeiptr result = m_context->getVertexAttribOffset(index, pname); | 2813 GLsizeiptr result = webContext()->getVertexAttribOffset(index, pname); |
| 2816 return static_cast<long long>(result); | 2814 return static_cast<long long>(result); |
| 2817 } | 2815 } |
| 2818 | 2816 |
| 2819 void WebGLRenderingContextBase::hint(GLenum target, GLenum mode) | 2817 void WebGLRenderingContextBase::hint(GLenum target, GLenum mode) |
| 2820 { | 2818 { |
| 2821 if (isContextLost()) | 2819 if (isContextLost()) |
| 2822 return; | 2820 return; |
| 2823 bool isValid = false; | 2821 bool isValid = false; |
| 2824 switch (target) { | 2822 switch (target) { |
| 2825 case GL_GENERATE_MIPMAP_HINT: | 2823 case GL_GENERATE_MIPMAP_HINT: |
| 2826 isValid = true; | 2824 isValid = true; |
| 2827 break; | 2825 break; |
| 2828 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives | 2826 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives |
| 2829 if (extensionEnabled(OESStandardDerivativesName)) | 2827 if (extensionEnabled(OESStandardDerivativesName)) |
| 2830 isValid = true; | 2828 isValid = true; |
| 2831 break; | 2829 break; |
| 2832 } | 2830 } |
| 2833 if (!isValid) { | 2831 if (!isValid) { |
| 2834 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); | 2832 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); |
| 2835 return; | 2833 return; |
| 2836 } | 2834 } |
| 2837 m_context->hint(target, mode); | 2835 webContext()->hint(target, mode); |
| 2838 } | 2836 } |
| 2839 | 2837 |
| 2840 GLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) | 2838 GLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) |
| 2841 { | 2839 { |
| 2842 if (!buffer || isContextLost()) | 2840 if (!buffer || isContextLost()) |
| 2843 return 0; | 2841 return 0; |
| 2844 | 2842 |
| 2845 if (!buffer->hasEverBeenBound()) | 2843 if (!buffer->hasEverBeenBound()) |
| 2846 return 0; | 2844 return 0; |
| 2847 | 2845 |
| 2848 return m_context->isBuffer(buffer->object()); | 2846 return webContext()->isBuffer(buffer->object()); |
| 2849 } | 2847 } |
| 2850 | 2848 |
| 2851 bool WebGLRenderingContextBase::isContextLost() | 2849 bool WebGLRenderingContextBase::isContextLost() const |
| 2852 { | 2850 { |
| 2853 return m_contextLost; | 2851 return m_contextLost; |
| 2854 } | 2852 } |
| 2855 | 2853 |
| 2856 GLboolean WebGLRenderingContextBase::isEnabled(GLenum cap) | 2854 GLboolean WebGLRenderingContextBase::isEnabled(GLenum cap) |
| 2857 { | 2855 { |
| 2858 if (isContextLost() || !validateCapability("isEnabled", cap)) | 2856 if (isContextLost() || !validateCapability("isEnabled", cap)) |
| 2859 return 0; | 2857 return 0; |
| 2860 if (cap == GL_STENCIL_TEST) | 2858 if (cap == GL_STENCIL_TEST) |
| 2861 return m_stencilEnabled; | 2859 return m_stencilEnabled; |
| 2862 return m_context->isEnabled(cap); | 2860 return webContext()->isEnabled(cap); |
| 2863 } | 2861 } |
| 2864 | 2862 |
| 2865 GLboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuffer
) | 2863 GLboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuffer
) |
| 2866 { | 2864 { |
| 2867 if (!framebuffer || isContextLost()) | 2865 if (!framebuffer || isContextLost()) |
| 2868 return 0; | 2866 return 0; |
| 2869 | 2867 |
| 2870 if (!framebuffer->hasEverBeenBound()) | 2868 if (!framebuffer->hasEverBeenBound()) |
| 2871 return 0; | 2869 return 0; |
| 2872 | 2870 |
| 2873 return m_context->isFramebuffer(framebuffer->object()); | 2871 return webContext()->isFramebuffer(framebuffer->object()); |
| 2874 } | 2872 } |
| 2875 | 2873 |
| 2876 GLboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) | 2874 GLboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) |
| 2877 { | 2875 { |
| 2878 if (!program || isContextLost()) | 2876 if (!program || isContextLost()) |
| 2879 return 0; | 2877 return 0; |
| 2880 | 2878 |
| 2881 return m_context->isProgram(program->object()); | 2879 return webContext()->isProgram(program->object()); |
| 2882 } | 2880 } |
| 2883 | 2881 |
| 2884 GLboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderbuf
fer) | 2882 GLboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderbuf
fer) |
| 2885 { | 2883 { |
| 2886 if (!renderbuffer || isContextLost()) | 2884 if (!renderbuffer || isContextLost()) |
| 2887 return 0; | 2885 return 0; |
| 2888 | 2886 |
| 2889 if (!renderbuffer->hasEverBeenBound()) | 2887 if (!renderbuffer->hasEverBeenBound()) |
| 2890 return 0; | 2888 return 0; |
| 2891 | 2889 |
| 2892 return m_context->isRenderbuffer(renderbuffer->object()); | 2890 return webContext()->isRenderbuffer(renderbuffer->object()); |
| 2893 } | 2891 } |
| 2894 | 2892 |
| 2895 GLboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) | 2893 GLboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) |
| 2896 { | 2894 { |
| 2897 if (!shader || isContextLost()) | 2895 if (!shader || isContextLost()) |
| 2898 return 0; | 2896 return 0; |
| 2899 | 2897 |
| 2900 return m_context->isShader(shader->object()); | 2898 return webContext()->isShader(shader->object()); |
| 2901 } | 2899 } |
| 2902 | 2900 |
| 2903 GLboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) | 2901 GLboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) |
| 2904 { | 2902 { |
| 2905 if (!texture || isContextLost()) | 2903 if (!texture || isContextLost()) |
| 2906 return 0; | 2904 return 0; |
| 2907 | 2905 |
| 2908 if (!texture->hasEverBeenBound()) | 2906 if (!texture->hasEverBeenBound()) |
| 2909 return 0; | 2907 return 0; |
| 2910 | 2908 |
| 2911 return m_context->isTexture(texture->object()); | 2909 return webContext()->isTexture(texture->object()); |
| 2912 } | 2910 } |
| 2913 | 2911 |
| 2914 void WebGLRenderingContextBase::lineWidth(GLfloat width) | 2912 void WebGLRenderingContextBase::lineWidth(GLfloat width) |
| 2915 { | 2913 { |
| 2916 if (isContextLost()) | 2914 if (isContextLost()) |
| 2917 return; | 2915 return; |
| 2918 m_context->lineWidth(width); | 2916 webContext()->lineWidth(width); |
| 2919 } | 2917 } |
| 2920 | 2918 |
| 2921 void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) | 2919 void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) |
| 2922 { | 2920 { |
| 2923 if (isContextLost() || !validateWebGLObject("linkProgram", program)) | 2921 if (isContextLost() || !validateWebGLObject("linkProgram", program)) |
| 2924 return; | 2922 return; |
| 2925 | 2923 |
| 2926 m_context->linkProgram(objectOrZero(program)); | 2924 webContext()->linkProgram(objectOrZero(program)); |
| 2927 program->increaseLinkCount(); | 2925 program->increaseLinkCount(); |
| 2928 } | 2926 } |
| 2929 | 2927 |
| 2930 void WebGLRenderingContextBase::pixelStorei(GLenum pname, GLint param) | 2928 void WebGLRenderingContextBase::pixelStorei(GLenum pname, GLint param) |
| 2931 { | 2929 { |
| 2932 if (isContextLost()) | 2930 if (isContextLost()) |
| 2933 return; | 2931 return; |
| 2934 switch (pname) { | 2932 switch (pname) { |
| 2935 case GC3D_UNPACK_FLIP_Y_WEBGL: | 2933 case GC3D_UNPACK_FLIP_Y_WEBGL: |
| 2936 m_unpackFlipY = param; | 2934 m_unpackFlipY = param; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2948 break; | 2946 break; |
| 2949 case GL_PACK_ALIGNMENT: | 2947 case GL_PACK_ALIGNMENT: |
| 2950 case GL_UNPACK_ALIGNMENT: | 2948 case GL_UNPACK_ALIGNMENT: |
| 2951 if (param == 1 || param == 2 || param == 4 || param == 8) { | 2949 if (param == 1 || param == 2 || param == 4 || param == 8) { |
| 2952 if (pname == GL_PACK_ALIGNMENT) { | 2950 if (pname == GL_PACK_ALIGNMENT) { |
| 2953 m_packAlignment = param; | 2951 m_packAlignment = param; |
| 2954 m_drawingBuffer->setPackAlignment(param); | 2952 m_drawingBuffer->setPackAlignment(param); |
| 2955 } else { // GL_UNPACK_ALIGNMENT: | 2953 } else { // GL_UNPACK_ALIGNMENT: |
| 2956 m_unpackAlignment = param; | 2954 m_unpackAlignment = param; |
| 2957 } | 2955 } |
| 2958 m_context->pixelStorei(pname, param); | 2956 webContext()->pixelStorei(pname, param); |
| 2959 } else { | 2957 } else { |
| 2960 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); | 2958 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); |
| 2961 return; | 2959 return; |
| 2962 } | 2960 } |
| 2963 break; | 2961 break; |
| 2964 default: | 2962 default: |
| 2965 synthesizeGLError(GL_INVALID_ENUM, "pixelStorei", "invalid parameter nam
e"); | 2963 synthesizeGLError(GL_INVALID_ENUM, "pixelStorei", "invalid parameter nam
e"); |
| 2966 return; | 2964 return; |
| 2967 } | 2965 } |
| 2968 } | 2966 } |
| 2969 | 2967 |
| 2970 void WebGLRenderingContextBase::polygonOffset(GLfloat factor, GLfloat units) | 2968 void WebGLRenderingContextBase::polygonOffset(GLfloat factor, GLfloat units) |
| 2971 { | 2969 { |
| 2972 if (isContextLost()) | 2970 if (isContextLost()) |
| 2973 return; | 2971 return; |
| 2974 m_context->polygonOffset(factor, units); | 2972 webContext()->polygonOffset(factor, units); |
| 2975 } | 2973 } |
| 2976 | 2974 |
| 2977 void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi
zei height, GLenum format, GLenum type, ArrayBufferView* pixels) | 2975 void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi
zei height, GLenum format, GLenum type, ArrayBufferView* pixels) |
| 2978 { | 2976 { |
| 2979 if (isContextLost()) | 2977 if (isContextLost()) |
| 2980 return; | 2978 return; |
| 2981 // Due to WebGL's same-origin restrictions, it is not possible to | 2979 // Due to WebGL's same-origin restrictions, it is not possible to |
| 2982 // taint the origin using the WebGL API. | 2980 // taint the origin using the WebGL API. |
| 2983 ASSERT(canvas()->originClean()); | 2981 ASSERT(canvas()->originClean()); |
| 2984 // Validate input parameters. | 2982 // Validate input parameters. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3008 if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) { | 3006 if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) { |
| 3009 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format not RGBA o
r type not UNSIGNED_BYTE"); | 3007 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "format not RGBA o
r type not UNSIGNED_BYTE"); |
| 3010 return; | 3008 return; |
| 3011 } | 3009 } |
| 3012 // Validate array type against pixel type. | 3010 // Validate array type against pixel type. |
| 3013 if (pixels->type() != ArrayBufferView::TypeUint8) { | 3011 if (pixels->type() != ArrayBufferView::TypeUint8) { |
| 3014 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot Uint8Array"); | 3012 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot Uint8Array"); |
| 3015 return; | 3013 return; |
| 3016 } | 3014 } |
| 3017 const char* reason = "framebuffer incomplete"; | 3015 const char* reason = "framebuffer incomplete"; |
| 3018 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 3016 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 3019 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); | 3017 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason
); |
| 3020 return; | 3018 return; |
| 3021 } | 3019 } |
| 3022 // Calculate array size, taking into consideration of PACK_ALIGNMENT. | 3020 // Calculate array size, taking into consideration of PACK_ALIGNMENT. |
| 3023 unsigned totalBytesRequired = 0; | 3021 unsigned totalBytesRequired = 0; |
| 3024 unsigned padding = 0; | 3022 unsigned padding = 0; |
| 3025 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); | 3023 GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, w
idth, height, m_packAlignment, &totalBytesRequired, &padding); |
| 3026 if (error != GL_NO_ERROR) { | 3024 if (error != GL_NO_ERROR) { |
| 3027 synthesizeGLError(error, "readPixels", "invalid dimensions"); | 3025 synthesizeGLError(error, "readPixels", "invalid dimensions"); |
| 3028 return; | 3026 return; |
| 3029 } | 3027 } |
| 3030 if (pixels->byteLength() < totalBytesRequired) { | 3028 if (pixels->byteLength() < totalBytesRequired) { |
| 3031 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); | 3029 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "ArrayBufferView n
ot large enough for dimensions"); |
| 3032 return; | 3030 return; |
| 3033 } | 3031 } |
| 3034 | 3032 |
| 3035 clearIfComposited(); | 3033 clearIfComposited(); |
| 3036 void* data = pixels->baseAddress(); | 3034 void* data = pixels->baseAddress(); |
| 3037 | 3035 |
| 3038 { | 3036 { |
| 3039 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin
ding.get()); | 3037 ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBin
ding.get()); |
| 3040 m_context->readPixels(x, y, width, height, format, type, data); | 3038 webContext()->readPixels(x, y, width, height, format, type, data); |
| 3041 } | 3039 } |
| 3042 | 3040 |
| 3043 #if OS(MACOSX) | 3041 #if OS(MACOSX) |
| 3044 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., | 3042 // FIXME: remove this section when GL driver bug on Mac is fixed, i.e., |
| 3045 // when alpha is off, readPixels should set alpha to 255 instead of 0. | 3043 // when alpha is off, readPixels should set alpha to 255 instead of 0. |
| 3046 if (!m_framebufferBinding && !m_context->getContextAttributes().alpha) { | 3044 if (!m_framebufferBinding && !webContext()->getContextAttributes().alpha) { |
| 3047 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); | 3045 unsigned char* pixels = reinterpret_cast<unsigned char*>(data); |
| 3048 for (GLsizei iy = 0; iy < height; ++iy) { | 3046 for (GLsizei iy = 0; iy < height; ++iy) { |
| 3049 for (GLsizei ix = 0; ix < width; ++ix) { | 3047 for (GLsizei ix = 0; ix < width; ++ix) { |
| 3050 pixels[3] = 255; | 3048 pixels[3] = 255; |
| 3051 pixels += 4; | 3049 pixels += 4; |
| 3052 } | 3050 } |
| 3053 pixels += padding; | 3051 pixels += padding; |
| 3054 } | 3052 } |
| 3055 } | 3053 } |
| 3056 #endif | 3054 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3069 return; | 3067 return; |
| 3070 } | 3068 } |
| 3071 if (!validateSize("renderbufferStorage", width, height)) | 3069 if (!validateSize("renderbufferStorage", width, height)) |
| 3072 return; | 3070 return; |
| 3073 switch (internalformat) { | 3071 switch (internalformat) { |
| 3074 case GL_DEPTH_COMPONENT16: | 3072 case GL_DEPTH_COMPONENT16: |
| 3075 case GL_RGBA4: | 3073 case GL_RGBA4: |
| 3076 case GL_RGB5_A1: | 3074 case GL_RGB5_A1: |
| 3077 case GL_RGB565: | 3075 case GL_RGB565: |
| 3078 case GL_STENCIL_INDEX8: | 3076 case GL_STENCIL_INDEX8: |
| 3079 m_context->renderbufferStorage(target, internalformat, width, height); | 3077 webContext()->renderbufferStorage(target, internalformat, width, height)
; |
| 3080 m_renderbufferBinding->setInternalFormat(internalformat); | 3078 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3081 m_renderbufferBinding->setSize(width, height); | 3079 m_renderbufferBinding->setSize(width, height); |
| 3082 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_context.get()); | 3080 m_renderbufferBinding->deleteEmulatedStencilBuffer(webContext()); |
| 3083 break; | 3081 break; |
| 3084 case GL_DEPTH_STENCIL_OES: | 3082 case GL_DEPTH_STENCIL_OES: |
| 3085 if (isDepthStencilSupported()) { | 3083 if (isDepthStencilSupported()) { |
| 3086 m_context->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, widt
h, height); | 3084 webContext()->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, w
idth, height); |
| 3087 } else { | 3085 } else { |
| 3088 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(target, m_renderbufferBinding.get()); | 3086 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff
er(target, m_renderbufferBinding.get()); |
| 3089 if (!emulatedStencilBuffer) { | 3087 if (!emulatedStencilBuffer) { |
| 3090 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out
of memory"); | 3088 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out
of memory"); |
| 3091 return; | 3089 return; |
| 3092 } | 3090 } |
| 3093 m_context->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width,
height); | 3091 webContext()->renderbufferStorage(target, GL_DEPTH_COMPONENT16, widt
h, height); |
| 3094 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff
er)); | 3092 webContext()->bindRenderbuffer(target, objectOrZero(emulatedStencilB
uffer)); |
| 3095 m_context->renderbufferStorage(target, GL_STENCIL_INDEX8, width, hei
ght); | 3093 webContext()->renderbufferStorage(target, GL_STENCIL_INDEX8, width,
height); |
| 3096 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi
ng.get())); | 3094 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi
nding.get())); |
| 3097 emulatedStencilBuffer->setSize(width, height); | 3095 emulatedStencilBuffer->setSize(width, height); |
| 3098 emulatedStencilBuffer->setInternalFormat(GL_STENCIL_INDEX8); | 3096 emulatedStencilBuffer->setInternalFormat(GL_STENCIL_INDEX8); |
| 3099 } | 3097 } |
| 3100 m_renderbufferBinding->setSize(width, height); | 3098 m_renderbufferBinding->setSize(width, height); |
| 3101 m_renderbufferBinding->setInternalFormat(internalformat); | 3099 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3102 break; | 3100 break; |
| 3103 default: | 3101 default: |
| 3104 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid inter
nalformat"); | 3102 synthesizeGLError(GL_INVALID_ENUM, "renderbufferStorage", "invalid inter
nalformat"); |
| 3105 return; | 3103 return; |
| 3106 } | 3104 } |
| 3107 applyStencilTest(); | 3105 applyStencilTest(); |
| 3108 } | 3106 } |
| 3109 | 3107 |
| 3110 void WebGLRenderingContextBase::sampleCoverage(GLfloat value, GLboolean invert) | 3108 void WebGLRenderingContextBase::sampleCoverage(GLfloat value, GLboolean invert) |
| 3111 { | 3109 { |
| 3112 if (isContextLost()) | 3110 if (isContextLost()) |
| 3113 return; | 3111 return; |
| 3114 m_context->sampleCoverage(value, invert); | 3112 webContext()->sampleCoverage(value, invert); |
| 3115 } | 3113 } |
| 3116 | 3114 |
| 3117 void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei
height) | 3115 void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei
height) |
| 3118 { | 3116 { |
| 3119 if (isContextLost()) | 3117 if (isContextLost()) |
| 3120 return; | 3118 return; |
| 3121 if (!validateSize("scissor", width, height)) | 3119 if (!validateSize("scissor", width, height)) |
| 3122 return; | 3120 return; |
| 3123 m_context->scissor(x, y, width, height); | 3121 webContext()->scissor(x, y, width, height); |
| 3124 } | 3122 } |
| 3125 | 3123 |
| 3126 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String&
string) | 3124 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String&
string) |
| 3127 { | 3125 { |
| 3128 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 3126 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) |
| 3129 return; | 3127 return; |
| 3130 String stringWithoutComments = StripComments(string).result(); | 3128 String stringWithoutComments = StripComments(string).result(); |
| 3131 if (!validateString("shaderSource", stringWithoutComments)) | 3129 if (!validateString("shaderSource", stringWithoutComments)) |
| 3132 return; | 3130 return; |
| 3133 shader->setSource(string); | 3131 shader->setSource(string); |
| 3134 m_context->shaderSource(objectOrZero(shader), stringWithoutComments.utf8().d
ata()); | 3132 webContext()->shaderSource(objectOrZero(shader), stringWithoutComments.utf8(
).data()); |
| 3135 } | 3133 } |
| 3136 | 3134 |
| 3137 void WebGLRenderingContextBase::stencilFunc(GLenum func, GLint ref, GLuint mask) | 3135 void WebGLRenderingContextBase::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 3138 { | 3136 { |
| 3139 if (isContextLost()) | 3137 if (isContextLost()) |
| 3140 return; | 3138 return; |
| 3141 if (!validateStencilOrDepthFunc("stencilFunc", func)) | 3139 if (!validateStencilOrDepthFunc("stencilFunc", func)) |
| 3142 return; | 3140 return; |
| 3143 m_stencilFuncRef = ref; | 3141 m_stencilFuncRef = ref; |
| 3144 m_stencilFuncRefBack = ref; | 3142 m_stencilFuncRefBack = ref; |
| 3145 m_stencilFuncMask = mask; | 3143 m_stencilFuncMask = mask; |
| 3146 m_stencilFuncMaskBack = mask; | 3144 m_stencilFuncMaskBack = mask; |
| 3147 m_context->stencilFunc(func, ref, mask); | 3145 webContext()->stencilFunc(func, ref, mask); |
| 3148 } | 3146 } |
| 3149 | 3147 |
| 3150 void WebGLRenderingContextBase::stencilFuncSeparate(GLenum face, GLenum func, GL
int ref, GLuint mask) | 3148 void WebGLRenderingContextBase::stencilFuncSeparate(GLenum face, GLenum func, GL
int ref, GLuint mask) |
| 3151 { | 3149 { |
| 3152 if (isContextLost()) | 3150 if (isContextLost()) |
| 3153 return; | 3151 return; |
| 3154 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) | 3152 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) |
| 3155 return; | 3153 return; |
| 3156 switch (face) { | 3154 switch (face) { |
| 3157 case GL_FRONT_AND_BACK: | 3155 case GL_FRONT_AND_BACK: |
| 3158 m_stencilFuncRef = ref; | 3156 m_stencilFuncRef = ref; |
| 3159 m_stencilFuncRefBack = ref; | 3157 m_stencilFuncRefBack = ref; |
| 3160 m_stencilFuncMask = mask; | 3158 m_stencilFuncMask = mask; |
| 3161 m_stencilFuncMaskBack = mask; | 3159 m_stencilFuncMaskBack = mask; |
| 3162 break; | 3160 break; |
| 3163 case GL_FRONT: | 3161 case GL_FRONT: |
| 3164 m_stencilFuncRef = ref; | 3162 m_stencilFuncRef = ref; |
| 3165 m_stencilFuncMask = mask; | 3163 m_stencilFuncMask = mask; |
| 3166 break; | 3164 break; |
| 3167 case GL_BACK: | 3165 case GL_BACK: |
| 3168 m_stencilFuncRefBack = ref; | 3166 m_stencilFuncRefBack = ref; |
| 3169 m_stencilFuncMaskBack = mask; | 3167 m_stencilFuncMaskBack = mask; |
| 3170 break; | 3168 break; |
| 3171 default: | 3169 default: |
| 3172 synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face"
); | 3170 synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face"
); |
| 3173 return; | 3171 return; |
| 3174 } | 3172 } |
| 3175 m_context->stencilFuncSeparate(face, func, ref, mask); | 3173 webContext()->stencilFuncSeparate(face, func, ref, mask); |
| 3176 } | 3174 } |
| 3177 | 3175 |
| 3178 void WebGLRenderingContextBase::stencilMask(GLuint mask) | 3176 void WebGLRenderingContextBase::stencilMask(GLuint mask) |
| 3179 { | 3177 { |
| 3180 if (isContextLost()) | 3178 if (isContextLost()) |
| 3181 return; | 3179 return; |
| 3182 m_stencilMask = mask; | 3180 m_stencilMask = mask; |
| 3183 m_stencilMaskBack = mask; | 3181 m_stencilMaskBack = mask; |
| 3184 m_context->stencilMask(mask); | 3182 webContext()->stencilMask(mask); |
| 3185 } | 3183 } |
| 3186 | 3184 |
| 3187 void WebGLRenderingContextBase::stencilMaskSeparate(GLenum face, GLuint mask) | 3185 void WebGLRenderingContextBase::stencilMaskSeparate(GLenum face, GLuint mask) |
| 3188 { | 3186 { |
| 3189 if (isContextLost()) | 3187 if (isContextLost()) |
| 3190 return; | 3188 return; |
| 3191 switch (face) { | 3189 switch (face) { |
| 3192 case GL_FRONT_AND_BACK: | 3190 case GL_FRONT_AND_BACK: |
| 3193 m_stencilMask = mask; | 3191 m_stencilMask = mask; |
| 3194 m_stencilMaskBack = mask; | 3192 m_stencilMaskBack = mask; |
| 3195 break; | 3193 break; |
| 3196 case GL_FRONT: | 3194 case GL_FRONT: |
| 3197 m_stencilMask = mask; | 3195 m_stencilMask = mask; |
| 3198 break; | 3196 break; |
| 3199 case GL_BACK: | 3197 case GL_BACK: |
| 3200 m_stencilMaskBack = mask; | 3198 m_stencilMaskBack = mask; |
| 3201 break; | 3199 break; |
| 3202 default: | 3200 default: |
| 3203 synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face"
); | 3201 synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face"
); |
| 3204 return; | 3202 return; |
| 3205 } | 3203 } |
| 3206 m_context->stencilMaskSeparate(face, mask); | 3204 webContext()->stencilMaskSeparate(face, mask); |
| 3207 } | 3205 } |
| 3208 | 3206 |
| 3209 void WebGLRenderingContextBase::stencilOp(GLenum fail, GLenum zfail, GLenum zpas
s) | 3207 void WebGLRenderingContextBase::stencilOp(GLenum fail, GLenum zfail, GLenum zpas
s) |
| 3210 { | 3208 { |
| 3211 if (isContextLost()) | 3209 if (isContextLost()) |
| 3212 return; | 3210 return; |
| 3213 m_context->stencilOp(fail, zfail, zpass); | 3211 webContext()->stencilOp(fail, zfail, zpass); |
| 3214 } | 3212 } |
| 3215 | 3213 |
| 3216 void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLen
um zfail, GLenum zpass) | 3214 void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLen
um zfail, GLenum zpass) |
| 3217 { | 3215 { |
| 3218 if (isContextLost()) | 3216 if (isContextLost()) |
| 3219 return; | 3217 return; |
| 3220 m_context->stencilOpSeparate(face, fail, zfail, zpass); | 3218 webContext()->stencilOpSeparate(face, fail, zfail, zpass); |
| 3221 } | 3219 } |
| 3222 | 3220 |
| 3223 GLenum WebGLRenderingContextBase::convertTexInternalFormat(GLenum internalformat
, GLenum type) | 3221 GLenum WebGLRenderingContextBase::convertTexInternalFormat(GLenum internalformat
, GLenum type) |
| 3224 { | 3222 { |
| 3225 // Convert to sized internal formats that are renderable with GL_CHROMIUM_co
lor_buffer_float_rgb(a). | 3223 // Convert to sized internal formats that are renderable with GL_CHROMIUM_co
lor_buffer_float_rgb(a). |
| 3226 if (type == GL_FLOAT && internalformat == GL_RGBA | 3224 if (type == GL_FLOAT && internalformat == GL_RGBA |
| 3227 && extensionsUtil()->isExtensionEnabled("GL_CHROMIUM_color_buffer_float_
rgba")) | 3225 && extensionsUtil()->isExtensionEnabled("GL_CHROMIUM_color_buffer_float_
rgba")) |
| 3228 return GL_RGBA32F_EXT; | 3226 return GL_RGBA32F_EXT; |
| 3229 if (type == GL_FLOAT && internalformat == GL_RGB | 3227 if (type == GL_FLOAT && internalformat == GL_RGB |
| 3230 && extensionsUtil()->isExtensionEnabled("GL_CHROMIUM_color_buffer_float_
rgb")) | 3228 && extensionsUtil()->isExtensionEnabled("GL_CHROMIUM_color_buffer_float_
rgb")) |
| 3231 return GL_RGB32F_EXT; | 3229 return GL_RGB32F_EXT; |
| 3232 return internalformat; | 3230 return internalformat; |
| 3233 } | 3231 } |
| 3234 | 3232 |
| 3235 void WebGLRenderingContextBase::texImage2DBase(GLenum target, GLint level, GLenu
m internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GL
enum type, const void* pixels, ExceptionState& exceptionState) | 3233 void WebGLRenderingContextBase::texImage2DBase(GLenum target, GLint level, GLenu
m internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GL
enum type, const void* pixels, ExceptionState& exceptionState) |
| 3236 { | 3234 { |
| 3237 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 3235 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 3238 // FIXME: Handle errors. | 3236 // FIXME: Handle errors. |
| 3239 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); | 3237 WebGLTexture* tex = validateTextureBinding("texImage2D", target, true); |
| 3240 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev
el, internalformat, width, height, border, format, type)); | 3238 ASSERT(validateTexFuncParameters("texImage2D", NotTexSubImage2D, target, lev
el, internalformat, width, height, border, format, type)); |
| 3241 ASSERT(tex); | 3239 ASSERT(tex); |
| 3242 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); | 3240 ASSERT(!level || !WebGLTexture::isNPOT(width, height)); |
| 3243 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); | 3241 ASSERT(!pixels || validateSettableTexFormat("texImage2D", internalformat)); |
| 3244 m_context->texImage2D(target, level, convertTexInternalFormat(internalformat
, type), width, height, border, format, type, pixels); | 3242 webContext()->texImage2D(target, level, convertTexInternalFormat(internalfor
mat, type), width, height, border, format, type, pixels); |
| 3245 tex->setLevelInfo(target, level, internalformat, width, height, type); | 3243 tex->setLevelInfo(target, level, internalformat, width, height, type); |
| 3246 } | 3244 } |
| 3247 | 3245 |
| 3248 void WebGLRenderingContextBase::texImage2DImpl(GLenum target, GLint level, GLenu
m internalformat, GLenum format, GLenum type, Image* image, WebGLImageConversion
::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionStat
e& exceptionState) | 3246 void WebGLRenderingContextBase::texImage2DImpl(GLenum target, GLint level, GLenu
m internalformat, GLenum format, GLenum type, Image* image, WebGLImageConversion
::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, ExceptionStat
e& exceptionState) |
| 3249 { | 3247 { |
| 3250 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 3248 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 3251 Vector<uint8_t> data; | 3249 Vector<uint8_t> data; |
| 3252 WebGLImageConversion::ImageExtractor imageExtractor(image, domSource, premul
tiplyAlpha, m_unpackColorspaceConversion == GL_NONE); | 3250 WebGLImageConversion::ImageExtractor imageExtractor(image, domSource, premul
tiplyAlpha, m_unpackColorspaceConversion == GL_NONE); |
| 3253 if (!imageExtractor.extractSucceeded()) { | 3251 if (!imageExtractor.extractSucceeded()) { |
| 3254 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); | 3252 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); |
| 3255 return; | 3253 return; |
| 3256 } | 3254 } |
| 3257 WebGLImageConversion::DataFormat sourceDataFormat = imageExtractor.imageSour
ceFormat(); | 3255 WebGLImageConversion::DataFormat sourceDataFormat = imageExtractor.imageSour
ceFormat(); |
| 3258 WebGLImageConversion::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); | 3256 WebGLImageConversion::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); |
| 3259 const void* imagePixelData = imageExtractor.imagePixelData(); | 3257 const void* imagePixelData = imageExtractor.imagePixelData(); |
| 3260 | 3258 |
| 3261 bool needConversion = true; | 3259 bool needConversion = true; |
| 3262 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == WebGLImageConversion::Da
taFormatRGBA8 && format == GL_RGBA && alphaOp == WebGLImageConversion::AlphaDoNo
thing && !flipY) | 3260 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == WebGLImageConversion::Da
taFormatRGBA8 && format == GL_RGBA && alphaOp == WebGLImageConversion::AlphaDoNo
thing && !flipY) |
| 3263 needConversion = false; | 3261 needConversion = false; |
| 3264 else { | 3262 else { |
| 3265 if (!WebGLImageConversion::packImageData(image, imagePixelData, format,
type, flipY, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtrac
tor.imageHeight(), imageExtractor.imageSourceUnpackAlignment(), data)) { | 3263 if (!WebGLImageConversion::packImageData(image, imagePixelData, format,
type, flipY, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtrac
tor.imageHeight(), imageExtractor.imageSourceUnpackAlignment(), data)) { |
| 3266 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "packImage error")
; | 3264 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "packImage error")
; |
| 3267 return; | 3265 return; |
| 3268 } | 3266 } |
| 3269 } | 3267 } |
| 3270 | 3268 |
| 3271 if (m_unpackAlignment != 1) | 3269 if (m_unpackAlignment != 1) |
| 3272 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 3270 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3273 texImage2DBase(target, level, internalformat, image->width(), image->height(
), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionStat
e); | 3271 texImage2DBase(target, level, internalformat, image->width(), image->height(
), 0, format, type, needConversion ? data.data() : imagePixelData, exceptionStat
e); |
| 3274 if (m_unpackAlignment != 1) | 3272 if (m_unpackAlignment != 1) |
| 3275 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 3273 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3276 } | 3274 } |
| 3277 | 3275 |
| 3278 bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexFun
cValidationFunctionType functionType, TexFuncValidationSourceType sourceType, GL
enum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset) | 3276 bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexFun
cValidationFunctionType functionType, TexFuncValidationSourceType sourceType, GL
enum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset) |
| 3279 { | 3277 { |
| 3280 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, border, format, type)) | 3278 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, border, format, type)) |
| 3281 return false; | 3279 return false; |
| 3282 | 3280 |
| 3283 WebGLTexture* texture = validateTextureBinding(functionName, target, true); | 3281 WebGLTexture* texture = validateTextureBinding(functionName, target, true); |
| 3284 if (!texture) | 3282 if (!texture) |
| 3285 return false; | 3283 return false; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3343 void* data = pixels ? pixels->baseAddress() : 0; | 3341 void* data = pixels ? pixels->baseAddress() : 0; |
| 3344 Vector<uint8_t> tempData; | 3342 Vector<uint8_t> tempData; |
| 3345 bool changeUnpackAlignment = false; | 3343 bool changeUnpackAlignment = false; |
| 3346 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 3344 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
| 3347 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) | 3345 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) |
| 3348 return; | 3346 return; |
| 3349 data = tempData.data(); | 3347 data = tempData.data(); |
| 3350 changeUnpackAlignment = true; | 3348 changeUnpackAlignment = true; |
| 3351 } | 3349 } |
| 3352 if (changeUnpackAlignment) | 3350 if (changeUnpackAlignment) |
| 3353 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 3351 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3354 texImage2DBase(target, level, internalformat, width, height, border, format,
type, data, exceptionState); | 3352 texImage2DBase(target, level, internalformat, width, height, border, format,
type, data, exceptionState); |
| 3355 if (changeUnpackAlignment) | 3353 if (changeUnpackAlignment) |
| 3356 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 3354 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3357 } | 3355 } |
| 3358 | 3356 |
| 3359 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 3357 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
| 3360 GLenum format, GLenum type, ImageData* pixels, ExceptionState& exceptionStat
e) | 3358 GLenum format, GLenum type, ImageData* pixels, ExceptionState& exceptionStat
e) |
| 3361 { | 3359 { |
| 3362 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm
age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels->
height(), 0, format, type, 0, 0)) | 3360 if (isContextLost() || !pixels || !validateTexFunc("texImage2D", NotTexSubIm
age2D, SourceImageData, target, level, internalformat, pixels->width(), pixels->
height(), 0, format, type, 0, 0)) |
| 3363 return; | 3361 return; |
| 3364 Vector<uint8_t> data; | 3362 Vector<uint8_t> data; |
| 3365 bool needConversion = true; | 3363 bool needConversion = true; |
| 3366 // The data from ImageData is always of format RGBA8. | 3364 // The data from ImageData is always of format RGBA8. |
| 3367 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. | 3365 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. |
| 3368 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GL_RGBA && type
== GL_UNSIGNED_BYTE) | 3366 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GL_RGBA && type
== GL_UNSIGNED_BYTE) |
| 3369 needConversion = false; | 3367 needConversion = false; |
| 3370 else { | 3368 else { |
| 3371 if (!WebGLImageConversion::extractImageData(pixels->data()->data(), pixe
ls->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { | 3369 if (!WebGLImageConversion::extractImageData(pixels->data()->data(), pixe
ls->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { |
| 3372 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); | 3370 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); |
| 3373 return; | 3371 return; |
| 3374 } | 3372 } |
| 3375 } | 3373 } |
| 3376 if (m_unpackAlignment != 1) | 3374 if (m_unpackAlignment != 1) |
| 3377 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 3375 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3378 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh
t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), exc
eptionState); | 3376 texImage2DBase(target, level, internalformat, pixels->width(), pixels->heigh
t(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), exc
eptionState); |
| 3379 if (m_unpackAlignment != 1) | 3377 if (m_unpackAlignment != 1) |
| 3380 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 3378 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3381 } | 3379 } |
| 3382 | 3380 |
| 3383 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 3381 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
| 3384 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) | 3382 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) |
| 3385 { | 3383 { |
| 3386 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except
ionState)) | 3384 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except
ionState)) |
| 3387 return; | 3385 return; |
| 3388 | 3386 |
| 3389 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image-
>renderer()); | 3387 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image-
>renderer()); |
| 3390 if (imageForRender->isSVGImage()) | 3388 if (imageForRender->isSVGImage()) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3401 { | 3399 { |
| 3402 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)) | 3400 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)) |
| 3403 return; | 3401 return; |
| 3404 | 3402 |
| 3405 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3403 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
| 3406 // If possible, copy from the canvas element directly to the texture | 3404 // If possible, copy from the canvas element directly to the texture |
| 3407 // via the GPU, without a read-back to system memory. | 3405 // via the GPU, without a read-back to system memory. |
| 3408 if (GL_TEXTURE_2D == target && texture) { | 3406 if (GL_TEXTURE_2D == target && texture) { |
| 3409 if (!canvas->is3D()) { | 3407 if (!canvas->is3D()) { |
| 3410 ImageBuffer* buffer = canvas->buffer(); | 3408 ImageBuffer* buffer = canvas->buffer(); |
| 3411 if (buffer && buffer->copyToPlatformTexture(m_context.get(), texture
->object(), internalformat, type, | 3409 if (buffer && buffer->copyToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, |
| 3412 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3410 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3413 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3411 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
| 3414 return; | 3412 return; |
| 3415 } | 3413 } |
| 3416 } else { | 3414 } else { |
| 3417 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->
renderingContext()); | 3415 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->
renderingContext()); |
| 3418 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context.get()
, texture->object(), internalformat, type, | 3416 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(webContext(), t
exture->object(), internalformat, type, |
| 3419 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 3417 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3420 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); | 3418 texture->setLevelInfo(target, level, internalformat, canvas->wid
th(), canvas->height(), type); |
| 3421 return; | 3419 return; |
| 3422 } | 3420 } |
| 3423 } | 3421 } |
| 3424 } | 3422 } |
| 3425 | 3423 |
| 3426 RefPtr<ImageData> imageData = canvas->getImageData(); | 3424 RefPtr<ImageData> imageData = canvas->getImageData(); |
| 3427 if (imageData) | 3425 if (imageData) |
| 3428 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); | 3426 texImage2D(target, level, internalformat, format, type, imageData.get(),
exceptionState); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3448 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 3446 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
| 3449 { | 3447 { |
| 3450 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) | 3448 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) |
| 3451 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) | 3449 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0,
format, type, 0, 0)) |
| 3452 return; | 3450 return; |
| 3453 | 3451 |
| 3454 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 3452 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
| 3455 // Otherwise, it will fall back to the normal SW path. | 3453 // Otherwise, it will fall back to the normal SW path. |
| 3456 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 3454 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
| 3457 if (GL_TEXTURE_2D == target && texture) { | 3455 if (GL_TEXTURE_2D == target && texture) { |
| 3458 if (video->copyVideoTextureToPlatformTexture(m_context.get(), texture->o
bject(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY))
{ | 3456 if (video->copyVideoTextureToPlatformTexture(webContext(), texture->obje
ct(), level, type, internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 3459 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), type); | 3457 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), type); |
| 3460 return; | 3458 return; |
| 3461 } | 3459 } |
| 3462 } | 3460 } |
| 3463 | 3461 |
| 3464 // Normal pure SW path. | 3462 // Normal pure SW path. |
| 3465 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e()); | 3463 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod
e()); |
| 3466 if (!image) | 3464 if (!image) |
| 3467 return; | 3465 return; |
| 3468 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, except
ionState); | 3466 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web
GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, except
ionState); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3492 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete
r, EXT_texture_filter_anisotropic not enabled"); | 3490 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete
r, EXT_texture_filter_anisotropic not enabled"); |
| 3493 return; | 3491 return; |
| 3494 } | 3492 } |
| 3495 break; | 3493 break; |
| 3496 default: | 3494 default: |
| 3497 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid parameter na
me"); | 3495 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid parameter na
me"); |
| 3498 return; | 3496 return; |
| 3499 } | 3497 } |
| 3500 if (isFloat) { | 3498 if (isFloat) { |
| 3501 tex->setParameterf(pname, paramf); | 3499 tex->setParameterf(pname, paramf); |
| 3502 m_context->texParameterf(target, pname, paramf); | 3500 webContext()->texParameterf(target, pname, paramf); |
| 3503 } else { | 3501 } else { |
| 3504 tex->setParameteri(pname, parami); | 3502 tex->setParameteri(pname, parami); |
| 3505 m_context->texParameteri(target, pname, parami); | 3503 webContext()->texParameteri(target, pname, parami); |
| 3506 } | 3504 } |
| 3507 } | 3505 } |
| 3508 | 3506 |
| 3509 void WebGLRenderingContextBase::texParameterf(GLenum target, GLenum pname, GLflo
at param) | 3507 void WebGLRenderingContextBase::texParameterf(GLenum target, GLenum pname, GLflo
at param) |
| 3510 { | 3508 { |
| 3511 texParameter(target, pname, param, 0, true); | 3509 texParameter(target, pname, param, 0, true); |
| 3512 } | 3510 } |
| 3513 | 3511 |
| 3514 void WebGLRenderingContextBase::texParameteri(GLenum target, GLenum pname, GLint
param) | 3512 void WebGLRenderingContextBase::texParameteri(GLenum target, GLenum pname, GLint
param) |
| 3515 { | 3513 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3527 if (!tex) { | 3525 if (!tex) { |
| 3528 ASSERT_NOT_REACHED(); | 3526 ASSERT_NOT_REACHED(); |
| 3529 return; | 3527 return; |
| 3530 } | 3528 } |
| 3531 ASSERT((xoffset + width) >= 0); | 3529 ASSERT((xoffset + width) >= 0); |
| 3532 ASSERT((yoffset + height) >= 0); | 3530 ASSERT((yoffset + height) >= 0); |
| 3533 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); | 3531 ASSERT(tex->getWidth(target, level) >= (xoffset + width)); |
| 3534 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); | 3532 ASSERT(tex->getHeight(target, level) >= (yoffset + height)); |
| 3535 ASSERT(tex->getInternalFormat(target, level) == format); | 3533 ASSERT(tex->getInternalFormat(target, level) == format); |
| 3536 ASSERT(tex->getType(target, level) == type); | 3534 ASSERT(tex->getType(target, level) == type); |
| 3537 m_context->texSubImage2D(target, level, xoffset, yoffset, width, height, for
mat, type, pixels); | 3535 webContext()->texSubImage2D(target, level, xoffset, yoffset, width, height,
format, type, pixels); |
| 3538 } | 3536 } |
| 3539 | 3537 |
| 3540 void WebGLRenderingContextBase::texSubImage2DImpl(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLenum format, GLenum type, Image* image, WebGLImage
Conversion::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, Exc
eptionState& exceptionState) | 3538 void WebGLRenderingContextBase::texSubImage2DImpl(GLenum target, GLint level, GL
int xoffset, GLint yoffset, GLenum format, GLenum type, Image* image, WebGLImage
Conversion::ImageHtmlDomSource domSource, bool flipY, bool premultiplyAlpha, Exc
eptionState& exceptionState) |
| 3541 { | 3539 { |
| 3542 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 3540 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 3543 Vector<uint8_t> data; | 3541 Vector<uint8_t> data; |
| 3544 WebGLImageConversion::ImageExtractor imageExtractor(image, domSource, premul
tiplyAlpha, m_unpackColorspaceConversion == GL_NONE); | 3542 WebGLImageConversion::ImageExtractor imageExtractor(image, domSource, premul
tiplyAlpha, m_unpackColorspaceConversion == GL_NONE); |
| 3545 if (!imageExtractor.extractSucceeded()) { | 3543 if (!imageExtractor.extractSucceeded()) { |
| 3546 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "bad image"); | 3544 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "bad image"); |
| 3547 return; | 3545 return; |
| 3548 } | 3546 } |
| 3549 WebGLImageConversion::DataFormat sourceDataFormat = imageExtractor.imageSour
ceFormat(); | 3547 WebGLImageConversion::DataFormat sourceDataFormat = imageExtractor.imageSour
ceFormat(); |
| 3550 WebGLImageConversion::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); | 3548 WebGLImageConversion::AlphaOp alphaOp = imageExtractor.imageAlphaOp(); |
| 3551 const void* imagePixelData = imageExtractor.imagePixelData(); | 3549 const void* imagePixelData = imageExtractor.imagePixelData(); |
| 3552 | 3550 |
| 3553 bool needConversion = true; | 3551 bool needConversion = true; |
| 3554 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == WebGLImageConversion::Da
taFormatRGBA8 && format == GL_RGBA && alphaOp == WebGLImageConversion::AlphaDoNo
thing && !flipY) | 3552 if (type == GL_UNSIGNED_BYTE && sourceDataFormat == WebGLImageConversion::Da
taFormatRGBA8 && format == GL_RGBA && alphaOp == WebGLImageConversion::AlphaDoNo
thing && !flipY) |
| 3555 needConversion = false; | 3553 needConversion = false; |
| 3556 else { | 3554 else { |
| 3557 if (!WebGLImageConversion::packImageData(image, imagePixelData, format,
type, flipY, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtrac
tor.imageHeight(), imageExtractor.imageSourceUnpackAlignment(), data)) { | 3555 if (!WebGLImageConversion::packImageData(image, imagePixelData, format,
type, flipY, alphaOp, sourceDataFormat, imageExtractor.imageWidth(), imageExtrac
tor.imageHeight(), imageExtractor.imageSourceUnpackAlignment(), data)) { |
| 3558 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); | 3556 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "bad image data"); |
| 3559 return; | 3557 return; |
| 3560 } | 3558 } |
| 3561 } | 3559 } |
| 3562 | 3560 |
| 3563 if (m_unpackAlignment != 1) | 3561 if (m_unpackAlignment != 1) |
| 3564 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 3562 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3565 texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->he
ight(), format, type, needConversion ? data.data() : imagePixelData, exceptionS
tate); | 3563 texSubImage2DBase(target, level, xoffset, yoffset, image->width(), image->he
ight(), format, type, needConversion ? data.data() : imagePixelData, exceptionS
tate); |
| 3566 if (m_unpackAlignment != 1) | 3564 if (m_unpackAlignment != 1) |
| 3567 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 3565 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3568 } | 3566 } |
| 3569 | 3567 |
| 3570 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 3568 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
| 3571 GLsizei width, GLsizei height, | 3569 GLsizei width, GLsizei height, |
| 3572 GLenum format, GLenum type, ArrayBufferView* pixels, ExceptionState& excepti
onState) | 3570 GLenum format, GLenum type, ArrayBufferView* pixels, ExceptionState& excepti
onState) |
| 3573 { | 3571 { |
| 3574 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h
eight, format, type, pixels, NullNotAllowed) | 3572 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h
eight, format, type, pixels, NullNotAllowed) |
| 3575 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie
w, target, level, format, width, height, 0, format, type, xoffset, yoffset)) | 3573 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie
w, target, level, format, width, height, 0, format, type, xoffset, yoffset)) |
| 3576 return; | 3574 return; |
| 3577 void* data = pixels->baseAddress(); | 3575 void* data = pixels->baseAddress(); |
| 3578 Vector<uint8_t> tempData; | 3576 Vector<uint8_t> tempData; |
| 3579 bool changeUnpackAlignment = false; | 3577 bool changeUnpackAlignment = false; |
| 3580 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 3578 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
| 3581 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, | 3579 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, |
| 3582 m_unpackAlignment, | 3580 m_unpackAlignment, |
| 3583 m_unpackFlipY, m_unpackPremultiplyAlp
ha, | 3581 m_unpackFlipY, m_unpackPremultiplyAlp
ha, |
| 3584 data, | 3582 data, |
| 3585 tempData)) | 3583 tempData)) |
| 3586 return; | 3584 return; |
| 3587 data = tempData.data(); | 3585 data = tempData.data(); |
| 3588 changeUnpackAlignment = true; | 3586 changeUnpackAlignment = true; |
| 3589 } | 3587 } |
| 3590 if (changeUnpackAlignment) | 3588 if (changeUnpackAlignment) |
| 3591 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 3589 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3592 texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, ty
pe, data, exceptionState); | 3590 texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, ty
pe, data, exceptionState); |
| 3593 if (changeUnpackAlignment) | 3591 if (changeUnpackAlignment) |
| 3594 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 3592 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3595 } | 3593 } |
| 3596 | 3594 |
| 3597 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 3595 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
| 3598 GLenum format, GLenum type, ImageData* pixels, ExceptionState& exceptionStat
e) | 3596 GLenum format, GLenum type, ImageData* pixels, ExceptionState& exceptionStat
e) |
| 3599 { | 3597 { |
| 3600 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm
age2D, SourceImageData, target, level, format, pixels->width(), pixels->height(
), 0, format, type, xoffset, yoffset)) | 3598 if (isContextLost() || !pixels || !validateTexFunc("texSubImage2D", TexSubIm
age2D, SourceImageData, target, level, format, pixels->width(), pixels->height(
), 0, format, type, xoffset, yoffset)) |
| 3601 return; | 3599 return; |
| 3602 | 3600 |
| 3603 Vector<uint8_t> data; | 3601 Vector<uint8_t> data; |
| 3604 bool needConversion = true; | 3602 bool needConversion = true; |
| 3605 // The data from ImageData is always of format RGBA8. | 3603 // The data from ImageData is always of format RGBA8. |
| 3606 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. | 3604 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. |
| 3607 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !m_unpackFlipY && !m_un
packPremultiplyAlpha) | 3605 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !m_unpackFlipY && !m_un
packPremultiplyAlpha) |
| 3608 needConversion = false; | 3606 needConversion = false; |
| 3609 else { | 3607 else { |
| 3610 if (!WebGLImageConversion::extractImageData(pixels->data()->data(), pixe
ls->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { | 3608 if (!WebGLImageConversion::extractImageData(pixels->data()->data(), pixe
ls->size(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { |
| 3611 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "bad image data
"); | 3609 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "bad image data
"); |
| 3612 return; | 3610 return; |
| 3613 } | 3611 } |
| 3614 } | 3612 } |
| 3615 if (m_unpackAlignment != 1) | 3613 if (m_unpackAlignment != 1) |
| 3616 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 3614 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 3617 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->
height(), format, type, needConversion ? data.data() : pixels->data()->data(), e
xceptionState); | 3615 texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->
height(), format, type, needConversion ? data.data() : pixels->data()->data(), e
xceptionState); |
| 3618 if (m_unpackAlignment != 1) | 3616 if (m_unpackAlignment != 1) |
| 3619 m_context->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 3617 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 3620 } | 3618 } |
| 3621 | 3619 |
| 3622 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 3620 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
| 3623 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) | 3621 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) |
| 3624 { | 3622 { |
| 3625 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc
eptionState)) | 3623 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc
eptionState)) |
| 3626 return; | 3624 return; |
| 3627 | 3625 |
| 3628 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image-
>renderer()); | 3626 RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image-
>renderer()); |
| 3629 if (imageForRender->isSVGImage()) | 3627 if (imageForRender->isSVGImage()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3665 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) | 3663 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) |
| 3666 { | 3664 { |
| 3667 if (isContextLost() || !location) | 3665 if (isContextLost() || !location) |
| 3668 return; | 3666 return; |
| 3669 | 3667 |
| 3670 if (location->program() != m_currentProgram) { | 3668 if (location->program() != m_currentProgram) { |
| 3671 synthesizeGLError(GL_INVALID_OPERATION, "uniform1f", "location not for c
urrent program"); | 3669 synthesizeGLError(GL_INVALID_OPERATION, "uniform1f", "location not for c
urrent program"); |
| 3672 return; | 3670 return; |
| 3673 } | 3671 } |
| 3674 | 3672 |
| 3675 m_context->uniform1f(location->location(), x); | 3673 webContext()->uniform1f(location->location(), x); |
| 3676 } | 3674 } |
| 3677 | 3675 |
| 3678 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location,
Float32Array* v) | 3676 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location,
Float32Array* v) |
| 3679 { | 3677 { |
| 3680 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v,
1)) | 3678 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v,
1)) |
| 3681 return; | 3679 return; |
| 3682 | 3680 |
| 3683 m_context->uniform1fv(location->location(), v->length(), v->data()); | 3681 webContext()->uniform1fv(location->location(), v->length(), v->data()); |
| 3684 } | 3682 } |
| 3685 | 3683 |
| 3686 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) | 3684 void WebGLRenderingContextBase::uniform1fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) |
| 3687 { | 3685 { |
| 3688 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v,
size, 1)) | 3686 if (isContextLost() || !validateUniformParameters("uniform1fv", location, v,
size, 1)) |
| 3689 return; | 3687 return; |
| 3690 | 3688 |
| 3691 m_context->uniform1fv(location->location(), size, v); | 3689 webContext()->uniform1fv(location->location(), size, v); |
| 3692 } | 3690 } |
| 3693 | 3691 |
| 3694 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location,
GLint x) | 3692 void WebGLRenderingContextBase::uniform1i(const WebGLUniformLocation* location,
GLint x) |
| 3695 { | 3693 { |
| 3696 if (isContextLost() || !location) | 3694 if (isContextLost() || !location) |
| 3697 return; | 3695 return; |
| 3698 | 3696 |
| 3699 if (location->program() != m_currentProgram) { | 3697 if (location->program() != m_currentProgram) { |
| 3700 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i", "location not for c
urrent program"); | 3698 synthesizeGLError(GL_INVALID_OPERATION, "uniform1i", "location not for c
urrent program"); |
| 3701 return; | 3699 return; |
| 3702 } | 3700 } |
| 3703 | 3701 |
| 3704 m_context->uniform1i(location->location(), x); | 3702 webContext()->uniform1i(location->location(), x); |
| 3705 } | 3703 } |
| 3706 | 3704 |
| 3707 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location,
Int32Array* v) | 3705 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location,
Int32Array* v) |
| 3708 { | 3706 { |
| 3709 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v,
1)) | 3707 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v,
1)) |
| 3710 return; | 3708 return; |
| 3711 | 3709 |
| 3712 m_context->uniform1iv(location->location(), v->length(), v->data()); | 3710 webContext()->uniform1iv(location->location(), v->length(), v->data()); |
| 3713 } | 3711 } |
| 3714 | 3712 |
| 3715 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) | 3713 void WebGLRenderingContextBase::uniform1iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) |
| 3716 { | 3714 { |
| 3717 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v,
size, 1)) | 3715 if (isContextLost() || !validateUniformParameters("uniform1iv", location, v,
size, 1)) |
| 3718 return; | 3716 return; |
| 3719 | 3717 |
| 3720 m_context->uniform1iv(location->location(), size, v); | 3718 webContext()->uniform1iv(location->location(), size, v); |
| 3721 } | 3719 } |
| 3722 | 3720 |
| 3723 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location,
GLfloat x, GLfloat y) | 3721 void WebGLRenderingContextBase::uniform2f(const WebGLUniformLocation* location,
GLfloat x, GLfloat y) |
| 3724 { | 3722 { |
| 3725 if (isContextLost() || !location) | 3723 if (isContextLost() || !location) |
| 3726 return; | 3724 return; |
| 3727 | 3725 |
| 3728 if (location->program() != m_currentProgram) { | 3726 if (location->program() != m_currentProgram) { |
| 3729 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f", "location not for c
urrent program"); | 3727 synthesizeGLError(GL_INVALID_OPERATION, "uniform2f", "location not for c
urrent program"); |
| 3730 return; | 3728 return; |
| 3731 } | 3729 } |
| 3732 | 3730 |
| 3733 m_context->uniform2f(location->location(), x, y); | 3731 webContext()->uniform2f(location->location(), x, y); |
| 3734 } | 3732 } |
| 3735 | 3733 |
| 3736 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location,
Float32Array* v) | 3734 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location,
Float32Array* v) |
| 3737 { | 3735 { |
| 3738 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v,
2)) | 3736 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v,
2)) |
| 3739 return; | 3737 return; |
| 3740 | 3738 |
| 3741 m_context->uniform2fv(location->location(), v->length() / 2, v->data()); | 3739 webContext()->uniform2fv(location->location(), v->length() / 2, v->data()); |
| 3742 } | 3740 } |
| 3743 | 3741 |
| 3744 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) | 3742 void WebGLRenderingContextBase::uniform2fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) |
| 3745 { | 3743 { |
| 3746 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v,
size, 2)) | 3744 if (isContextLost() || !validateUniformParameters("uniform2fv", location, v,
size, 2)) |
| 3747 return; | 3745 return; |
| 3748 | 3746 |
| 3749 m_context->uniform2fv(location->location(), size / 2, v); | 3747 webContext()->uniform2fv(location->location(), size / 2, v); |
| 3750 } | 3748 } |
| 3751 | 3749 |
| 3752 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location,
GLint x, GLint y) | 3750 void WebGLRenderingContextBase::uniform2i(const WebGLUniformLocation* location,
GLint x, GLint y) |
| 3753 { | 3751 { |
| 3754 if (isContextLost() || !location) | 3752 if (isContextLost() || !location) |
| 3755 return; | 3753 return; |
| 3756 | 3754 |
| 3757 if (location->program() != m_currentProgram) { | 3755 if (location->program() != m_currentProgram) { |
| 3758 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i", "location not for c
urrent program"); | 3756 synthesizeGLError(GL_INVALID_OPERATION, "uniform2i", "location not for c
urrent program"); |
| 3759 return; | 3757 return; |
| 3760 } | 3758 } |
| 3761 | 3759 |
| 3762 m_context->uniform2i(location->location(), x, y); | 3760 webContext()->uniform2i(location->location(), x, y); |
| 3763 } | 3761 } |
| 3764 | 3762 |
| 3765 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location,
Int32Array* v) | 3763 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location,
Int32Array* v) |
| 3766 { | 3764 { |
| 3767 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v,
2)) | 3765 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v,
2)) |
| 3768 return; | 3766 return; |
| 3769 | 3767 |
| 3770 m_context->uniform2iv(location->location(), v->length() / 2, v->data()); | 3768 webContext()->uniform2iv(location->location(), v->length() / 2, v->data()); |
| 3771 } | 3769 } |
| 3772 | 3770 |
| 3773 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) | 3771 void WebGLRenderingContextBase::uniform2iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) |
| 3774 { | 3772 { |
| 3775 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v,
size, 2)) | 3773 if (isContextLost() || !validateUniformParameters("uniform2iv", location, v,
size, 2)) |
| 3776 return; | 3774 return; |
| 3777 | 3775 |
| 3778 m_context->uniform2iv(location->location(), size / 2, v); | 3776 webContext()->uniform2iv(location->location(), size / 2, v); |
| 3779 } | 3777 } |
| 3780 | 3778 |
| 3781 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location,
GLfloat x, GLfloat y, GLfloat z) | 3779 void WebGLRenderingContextBase::uniform3f(const WebGLUniformLocation* location,
GLfloat x, GLfloat y, GLfloat z) |
| 3782 { | 3780 { |
| 3783 if (isContextLost() || !location) | 3781 if (isContextLost() || !location) |
| 3784 return; | 3782 return; |
| 3785 | 3783 |
| 3786 if (location->program() != m_currentProgram) { | 3784 if (location->program() != m_currentProgram) { |
| 3787 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f", "location not for c
urrent program"); | 3785 synthesizeGLError(GL_INVALID_OPERATION, "uniform3f", "location not for c
urrent program"); |
| 3788 return; | 3786 return; |
| 3789 } | 3787 } |
| 3790 | 3788 |
| 3791 m_context->uniform3f(location->location(), x, y, z); | 3789 webContext()->uniform3f(location->location(), x, y, z); |
| 3792 } | 3790 } |
| 3793 | 3791 |
| 3794 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location,
Float32Array* v) | 3792 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location,
Float32Array* v) |
| 3795 { | 3793 { |
| 3796 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v,
3)) | 3794 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v,
3)) |
| 3797 return; | 3795 return; |
| 3798 | 3796 |
| 3799 m_context->uniform3fv(location->location(), v->length() / 3, v->data()); | 3797 webContext()->uniform3fv(location->location(), v->length() / 3, v->data()); |
| 3800 } | 3798 } |
| 3801 | 3799 |
| 3802 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) | 3800 void WebGLRenderingContextBase::uniform3fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) |
| 3803 { | 3801 { |
| 3804 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v,
size, 3)) | 3802 if (isContextLost() || !validateUniformParameters("uniform3fv", location, v,
size, 3)) |
| 3805 return; | 3803 return; |
| 3806 | 3804 |
| 3807 m_context->uniform3fv(location->location(), size / 3, v); | 3805 webContext()->uniform3fv(location->location(), size / 3, v); |
| 3808 } | 3806 } |
| 3809 | 3807 |
| 3810 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location,
GLint x, GLint y, GLint z) | 3808 void WebGLRenderingContextBase::uniform3i(const WebGLUniformLocation* location,
GLint x, GLint y, GLint z) |
| 3811 { | 3809 { |
| 3812 if (isContextLost() || !location) | 3810 if (isContextLost() || !location) |
| 3813 return; | 3811 return; |
| 3814 | 3812 |
| 3815 if (location->program() != m_currentProgram) { | 3813 if (location->program() != m_currentProgram) { |
| 3816 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i", "location not for c
urrent program"); | 3814 synthesizeGLError(GL_INVALID_OPERATION, "uniform3i", "location not for c
urrent program"); |
| 3817 return; | 3815 return; |
| 3818 } | 3816 } |
| 3819 | 3817 |
| 3820 m_context->uniform3i(location->location(), x, y, z); | 3818 webContext()->uniform3i(location->location(), x, y, z); |
| 3821 } | 3819 } |
| 3822 | 3820 |
| 3823 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location,
Int32Array* v) | 3821 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location,
Int32Array* v) |
| 3824 { | 3822 { |
| 3825 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v,
3)) | 3823 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v,
3)) |
| 3826 return; | 3824 return; |
| 3827 | 3825 |
| 3828 m_context->uniform3iv(location->location(), v->length() / 3, v->data()); | 3826 webContext()->uniform3iv(location->location(), v->length() / 3, v->data()); |
| 3829 } | 3827 } |
| 3830 | 3828 |
| 3831 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) | 3829 void WebGLRenderingContextBase::uniform3iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) |
| 3832 { | 3830 { |
| 3833 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v,
size, 3)) | 3831 if (isContextLost() || !validateUniformParameters("uniform3iv", location, v,
size, 3)) |
| 3834 return; | 3832 return; |
| 3835 | 3833 |
| 3836 m_context->uniform3iv(location->location(), size / 3, v); | 3834 webContext()->uniform3iv(location->location(), size / 3, v); |
| 3837 } | 3835 } |
| 3838 | 3836 |
| 3839 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location,
GLfloat x, GLfloat y, GLfloat z, GLfloat w) | 3837 void WebGLRenderingContextBase::uniform4f(const WebGLUniformLocation* location,
GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 3840 { | 3838 { |
| 3841 if (isContextLost() || !location) | 3839 if (isContextLost() || !location) |
| 3842 return; | 3840 return; |
| 3843 | 3841 |
| 3844 if (location->program() != m_currentProgram) { | 3842 if (location->program() != m_currentProgram) { |
| 3845 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f", "location not for c
urrent program"); | 3843 synthesizeGLError(GL_INVALID_OPERATION, "uniform4f", "location not for c
urrent program"); |
| 3846 return; | 3844 return; |
| 3847 } | 3845 } |
| 3848 | 3846 |
| 3849 m_context->uniform4f(location->location(), x, y, z, w); | 3847 webContext()->uniform4f(location->location(), x, y, z, w); |
| 3850 } | 3848 } |
| 3851 | 3849 |
| 3852 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location,
Float32Array* v) | 3850 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location,
Float32Array* v) |
| 3853 { | 3851 { |
| 3854 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v,
4)) | 3852 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v,
4)) |
| 3855 return; | 3853 return; |
| 3856 | 3854 |
| 3857 m_context->uniform4fv(location->location(), v->length() / 4, v->data()); | 3855 webContext()->uniform4fv(location->location(), v->length() / 4, v->data()); |
| 3858 } | 3856 } |
| 3859 | 3857 |
| 3860 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) | 3858 void WebGLRenderingContextBase::uniform4fv(const WebGLUniformLocation* location,
GLfloat* v, GLsizei size) |
| 3861 { | 3859 { |
| 3862 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v,
size, 4)) | 3860 if (isContextLost() || !validateUniformParameters("uniform4fv", location, v,
size, 4)) |
| 3863 return; | 3861 return; |
| 3864 | 3862 |
| 3865 m_context->uniform4fv(location->location(), size / 4, v); | 3863 webContext()->uniform4fv(location->location(), size / 4, v); |
| 3866 } | 3864 } |
| 3867 | 3865 |
| 3868 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location,
GLint x, GLint y, GLint z, GLint w) | 3866 void WebGLRenderingContextBase::uniform4i(const WebGLUniformLocation* location,
GLint x, GLint y, GLint z, GLint w) |
| 3869 { | 3867 { |
| 3870 if (isContextLost() || !location) | 3868 if (isContextLost() || !location) |
| 3871 return; | 3869 return; |
| 3872 | 3870 |
| 3873 if (location->program() != m_currentProgram) { | 3871 if (location->program() != m_currentProgram) { |
| 3874 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i", "location not for c
urrent program"); | 3872 synthesizeGLError(GL_INVALID_OPERATION, "uniform4i", "location not for c
urrent program"); |
| 3875 return; | 3873 return; |
| 3876 } | 3874 } |
| 3877 | 3875 |
| 3878 m_context->uniform4i(location->location(), x, y, z, w); | 3876 webContext()->uniform4i(location->location(), x, y, z, w); |
| 3879 } | 3877 } |
| 3880 | 3878 |
| 3881 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location,
Int32Array* v) | 3879 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location,
Int32Array* v) |
| 3882 { | 3880 { |
| 3883 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v,
4)) | 3881 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v,
4)) |
| 3884 return; | 3882 return; |
| 3885 | 3883 |
| 3886 m_context->uniform4iv(location->location(), v->length() / 4, v->data()); | 3884 webContext()->uniform4iv(location->location(), v->length() / 4, v->data()); |
| 3887 } | 3885 } |
| 3888 | 3886 |
| 3889 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) | 3887 void WebGLRenderingContextBase::uniform4iv(const WebGLUniformLocation* location,
GLint* v, GLsizei size) |
| 3890 { | 3888 { |
| 3891 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v,
size, 4)) | 3889 if (isContextLost() || !validateUniformParameters("uniform4iv", location, v,
size, 4)) |
| 3892 return; | 3890 return; |
| 3893 | 3891 |
| 3894 m_context->uniform4iv(location->location(), size / 4, v); | 3892 webContext()->uniform4iv(location->location(), size / 4, v); |
| 3895 } | 3893 } |
| 3896 | 3894 |
| 3897 void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, Float32Array* v) | 3895 void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, Float32Array* v) |
| 3898 { | 3896 { |
| 3899 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv",
location, transpose, v, 4)) | 3897 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv",
location, transpose, v, 4)) |
| 3900 return; | 3898 return; |
| 3901 m_context->uniformMatrix2fv(location->location(), v->length() / 4, transpose
, v->data()); | 3899 webContext()->uniformMatrix2fv(location->location(), v->length() / 4, transp
ose, v->data()); |
| 3902 } | 3900 } |
| 3903 | 3901 |
| 3904 void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, GLfloat* v, GLsizei size) | 3902 void WebGLRenderingContextBase::uniformMatrix2fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, GLfloat* v, GLsizei size) |
| 3905 { | 3903 { |
| 3906 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv",
location, transpose, v, size, 4)) | 3904 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix2fv",
location, transpose, v, size, 4)) |
| 3907 return; | 3905 return; |
| 3908 m_context->uniformMatrix2fv(location->location(), size / 4, transpose, v); | 3906 webContext()->uniformMatrix2fv(location->location(), size / 4, transpose, v)
; |
| 3909 } | 3907 } |
| 3910 | 3908 |
| 3911 void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, Float32Array* v) | 3909 void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, Float32Array* v) |
| 3912 { | 3910 { |
| 3913 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv",
location, transpose, v, 9)) | 3911 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv",
location, transpose, v, 9)) |
| 3914 return; | 3912 return; |
| 3915 m_context->uniformMatrix3fv(location->location(), v->length() / 9, transpose
, v->data()); | 3913 webContext()->uniformMatrix3fv(location->location(), v->length() / 9, transp
ose, v->data()); |
| 3916 } | 3914 } |
| 3917 | 3915 |
| 3918 void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, GLfloat* v, GLsizei size) | 3916 void WebGLRenderingContextBase::uniformMatrix3fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, GLfloat* v, GLsizei size) |
| 3919 { | 3917 { |
| 3920 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv",
location, transpose, v, size, 9)) | 3918 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix3fv",
location, transpose, v, size, 9)) |
| 3921 return; | 3919 return; |
| 3922 m_context->uniformMatrix3fv(location->location(), size / 9, transpose, v); | 3920 webContext()->uniformMatrix3fv(location->location(), size / 9, transpose, v)
; |
| 3923 } | 3921 } |
| 3924 | 3922 |
| 3925 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, Float32Array* v) | 3923 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, Float32Array* v) |
| 3926 { | 3924 { |
| 3927 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv",
location, transpose, v, 16)) | 3925 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv",
location, transpose, v, 16)) |
| 3928 return; | 3926 return; |
| 3929 m_context->uniformMatrix4fv(location->location(), v->length() / 16, transpos
e, v->data()); | 3927 webContext()->uniformMatrix4fv(location->location(), v->length() / 16, trans
pose, v->data()); |
| 3930 } | 3928 } |
| 3931 | 3929 |
| 3932 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, GLfloat* v, GLsizei size) | 3930 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc
ation, GLboolean transpose, GLfloat* v, GLsizei size) |
| 3933 { | 3931 { |
| 3934 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv",
location, transpose, v, size, 16)) | 3932 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv",
location, transpose, v, size, 16)) |
| 3935 return; | 3933 return; |
| 3936 m_context->uniformMatrix4fv(location->location(), size / 16, transpose, v); | 3934 webContext()->uniformMatrix4fv(location->location(), size / 16, transpose, v
); |
| 3937 } | 3935 } |
| 3938 | 3936 |
| 3939 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 3937 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) |
| 3940 { | 3938 { |
| 3941 bool deleted; | 3939 bool deleted; |
| 3942 if (!checkObjectToBeBound("useProgram", program, deleted)) | 3940 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 3943 return; | 3941 return; |
| 3944 if (deleted) | 3942 if (deleted) |
| 3945 program = 0; | 3943 program = 0; |
| 3946 if (program && !program->linkStatus()) { | 3944 if (program && !program->linkStatus()) { |
| 3947 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid
"); | 3945 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid
"); |
| 3948 return; | 3946 return; |
| 3949 } | 3947 } |
| 3950 if (m_currentProgram != program) { | 3948 if (m_currentProgram != program) { |
| 3951 if (m_currentProgram) | 3949 if (m_currentProgram) |
| 3952 m_currentProgram->onDetached(m_context.get()); | 3950 m_currentProgram->onDetached(webContext()); |
| 3953 m_currentProgram = program; | 3951 m_currentProgram = program; |
| 3954 m_context->useProgram(objectOrZero(program)); | 3952 webContext()->useProgram(objectOrZero(program)); |
| 3955 if (program) | 3953 if (program) |
| 3956 program->onAttached(); | 3954 program->onAttached(); |
| 3957 } | 3955 } |
| 3958 } | 3956 } |
| 3959 | 3957 |
| 3960 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) | 3958 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) |
| 3961 { | 3959 { |
| 3962 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 3960 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
| 3963 return; | 3961 return; |
| 3964 m_context->validateProgram(objectOrZero(program)); | 3962 webContext()->validateProgram(objectOrZero(program)); |
| 3965 } | 3963 } |
| 3966 | 3964 |
| 3967 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) | 3965 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) |
| 3968 { | 3966 { |
| 3969 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); | 3967 vertexAttribfImpl("vertexAttrib1f", index, 1, v0, 0.0f, 0.0f, 1.0f); |
| 3970 } | 3968 } |
| 3971 | 3969 |
| 3972 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, Float32Array* v) | 3970 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, Float32Array* v) |
| 3973 { | 3971 { |
| 3974 vertexAttribfvImpl("vertexAttrib1fv", index, v, 1); | 3972 vertexAttribfvImpl("vertexAttrib1fv", index, v, 1); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4057 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribPointer", "invalid type"
); | 4055 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribPointer", "invalid type"
); |
| 4058 return; | 4056 return; |
| 4059 } | 4057 } |
| 4060 if ((stride % typeSize) || (static_cast<GLintptr>(offset) % typeSize)) { | 4058 if ((stride % typeSize) || (static_cast<GLintptr>(offset) % typeSize)) { |
| 4061 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o
r offset not valid for type"); | 4059 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o
r offset not valid for type"); |
| 4062 return; | 4060 return; |
| 4063 } | 4061 } |
| 4064 GLsizei bytesPerElement = size * typeSize; | 4062 GLsizei bytesPerElement = size * typeSize; |
| 4065 | 4063 |
| 4066 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 4064 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); |
| 4067 m_context->vertexAttribPointer(index, size, type, normalized, stride, static
_cast<GLintptr>(offset)); | 4065 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta
tic_cast<GLintptr>(offset)); |
| 4068 } | 4066 } |
| 4069 | 4067 |
| 4070 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di
visor) | 4068 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di
visor) |
| 4071 { | 4069 { |
| 4072 if (isContextLost()) | 4070 if (isContextLost()) |
| 4073 return; | 4071 return; |
| 4074 | 4072 |
| 4075 if (index >= m_maxVertexAttribs) { | 4073 if (index >= m_maxVertexAttribs) { |
| 4076 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o
ut of range"); | 4074 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o
ut of range"); |
| 4077 return; | 4075 return; |
| 4078 } | 4076 } |
| 4079 | 4077 |
| 4080 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); | 4078 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); |
| 4081 m_context->vertexAttribDivisorANGLE(index, divisor); | 4079 webContext()->vertexAttribDivisorANGLE(index, divisor); |
| 4082 } | 4080 } |
| 4083 | 4081 |
| 4084 void WebGLRenderingContextBase::viewport(GLint x, GLint y, GLsizei width, GLsize
i height) | 4082 void WebGLRenderingContextBase::viewport(GLint x, GLint y, GLsizei width, GLsize
i height) |
| 4085 { | 4083 { |
| 4086 if (isContextLost()) | 4084 if (isContextLost()) |
| 4087 return; | 4085 return; |
| 4088 if (!validateSize("viewport", width, height)) | 4086 if (!validateSize("viewport", width, height)) |
| 4089 return; | 4087 return; |
| 4090 m_context->viewport(x, y, width, height); | 4088 webContext()->viewport(x, y, width, height); |
| 4091 } | 4089 } |
| 4092 | 4090 |
| 4093 void WebGLRenderingContextBase::forceLostContext(WebGLRenderingContextBase::Lost
ContextMode mode) | 4091 void WebGLRenderingContextBase::forceLostContext(WebGLRenderingContextBase::Lost
ContextMode mode) |
| 4094 { | 4092 { |
| 4095 if (isContextLost()) { | 4093 if (isContextLost()) { |
| 4096 synthesizeGLError(GL_INVALID_OPERATION, "loseContext", "context already
lost"); | 4094 synthesizeGLError(GL_INVALID_OPERATION, "loseContext", "context already
lost"); |
| 4097 return; | 4095 return; |
| 4098 } | 4096 } |
| 4099 | 4097 |
| 4100 m_contextGroup->loseContextGroup(mode); | 4098 m_contextGroup->loseContextGroup(mode); |
| 4101 } | 4099 } |
| 4102 | 4100 |
| 4103 void WebGLRenderingContextBase::loseContextImpl(WebGLRenderingContextBase::LostC
ontextMode mode) | 4101 void WebGLRenderingContextBase::loseContextImpl(WebGLRenderingContextBase::LostC
ontextMode mode) |
| 4104 { | 4102 { |
| 4105 if (isContextLost()) | 4103 if (isContextLost()) |
| 4106 return; | 4104 return; |
| 4107 | 4105 |
| 4108 m_contextLost = true; | 4106 m_contextLost = true; |
| 4109 m_contextLostMode = mode; | 4107 m_contextLostMode = mode; |
| 4110 | 4108 |
| 4111 if (mode == RealLostContext) { | 4109 if (mode == RealLostContext) { |
| 4112 // Inform the embedder that a lost context was received. In response, th
e embedder might | 4110 // Inform the embedder that a lost context was received. In response, th
e embedder might |
| 4113 // decide to take action such as asking the user for permission to use W
ebGL again. | 4111 // decide to take action such as asking the user for permission to use W
ebGL again. |
| 4114 if (LocalFrame* frame = canvas()->document().frame()) | 4112 if (LocalFrame* frame = canvas()->document().frame()) |
| 4115 frame->loader().client()->didLoseWebGLContext(m_context->getGraphics
ResetStatusARB()); | 4113 frame->loader().client()->didLoseWebGLContext(webContext()->getGraph
icsResetStatusARB()); |
| 4116 } | 4114 } |
| 4117 | 4115 |
| 4118 // Make absolutely sure we do not refer to an already-deleted texture or fra
mebuffer. | 4116 // Make absolutely sure we do not refer to an already-deleted texture or fra
mebuffer. |
| 4119 m_drawingBuffer->setTexture2DBinding(0); | 4117 m_drawingBuffer->setTexture2DBinding(0); |
| 4120 m_drawingBuffer->setFramebufferBinding(0); | 4118 m_drawingBuffer->setFramebufferBinding(0); |
| 4121 | 4119 |
| 4122 detachAndRemoveAllObjects(); | 4120 detachAndRemoveAllObjects(); |
| 4123 | 4121 |
| 4124 // Lose all the extensions. | 4122 // Lose all the extensions. |
| 4125 for (size_t i = 0; i < m_extensions.size(); ++i) { | 4123 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4159 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); | 4157 synthesizeGLError(GL_INVALID_OPERATION, "restoreContext", "context r
estoration not allowed"); |
| 4160 return; | 4158 return; |
| 4161 } | 4159 } |
| 4162 | 4160 |
| 4163 if (!m_restoreTimer.isActive()) | 4161 if (!m_restoreTimer.isActive()) |
| 4164 m_restoreTimer.startOneShot(0); | 4162 m_restoreTimer.startOneShot(0); |
| 4165 } | 4163 } |
| 4166 | 4164 |
| 4167 blink::WebLayer* WebGLRenderingContextBase::platformLayer() const | 4165 blink::WebLayer* WebGLRenderingContextBase::platformLayer() const |
| 4168 { | 4166 { |
| 4169 return m_drawingBuffer->platformLayer(); | 4167 return isContextLost() ? 0 : m_drawingBuffer->platformLayer(); |
| 4170 } | 4168 } |
| 4171 | 4169 |
| 4172 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() | 4170 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() |
| 4173 { | 4171 { |
| 4172 ASSERT(!isContextLost()); |
| 4174 if (!m_extensionsUtil) | 4173 if (!m_extensionsUtil) |
| 4175 m_extensionsUtil = adoptPtr(new Extensions3DUtil(m_context.get())); | 4174 m_extensionsUtil = adoptPtr(new Extensions3DUtil(webContext())); |
| 4176 return m_extensionsUtil.get(); | 4175 return m_extensionsUtil.get(); |
| 4177 } | 4176 } |
| 4178 | 4177 |
| 4179 void WebGLRenderingContextBase::removeSharedObject(WebGLSharedObject* object) | 4178 void WebGLRenderingContextBase::removeSharedObject(WebGLSharedObject* object) |
| 4180 { | 4179 { |
| 4181 m_contextGroup->removeObject(object); | 4180 m_contextGroup->removeObject(object); |
| 4182 } | 4181 } |
| 4183 | 4182 |
| 4184 void WebGLRenderingContextBase::addSharedObject(WebGLSharedObject* object) | 4183 void WebGLRenderingContextBase::addSharedObject(WebGLSharedObject* object) |
| 4185 { | 4184 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4216 if (!isContextLost()) { | 4215 if (!isContextLost()) { |
| 4217 forceLostContext(SyntheticLostContext); | 4216 forceLostContext(SyntheticLostContext); |
| 4218 destroyContext(); | 4217 destroyContext(); |
| 4219 } | 4218 } |
| 4220 } | 4219 } |
| 4221 | 4220 |
| 4222 WebGLGetInfo WebGLRenderingContextBase::getBooleanParameter(GLenum pname) | 4221 WebGLGetInfo WebGLRenderingContextBase::getBooleanParameter(GLenum pname) |
| 4223 { | 4222 { |
| 4224 GLboolean value = 0; | 4223 GLboolean value = 0; |
| 4225 if (!isContextLost()) | 4224 if (!isContextLost()) |
| 4226 m_context->getBooleanv(pname, &value); | 4225 webContext()->getBooleanv(pname, &value); |
| 4227 return WebGLGetInfo(static_cast<bool>(value)); | 4226 return WebGLGetInfo(static_cast<bool>(value)); |
| 4228 } | 4227 } |
| 4229 | 4228 |
| 4230 WebGLGetInfo WebGLRenderingContextBase::getBooleanArrayParameter(GLenum pname) | 4229 WebGLGetInfo WebGLRenderingContextBase::getBooleanArrayParameter(GLenum pname) |
| 4231 { | 4230 { |
| 4232 if (pname != GL_COLOR_WRITEMASK) { | 4231 if (pname != GL_COLOR_WRITEMASK) { |
| 4233 notImplemented(); | 4232 notImplemented(); |
| 4234 return WebGLGetInfo(0, 0); | 4233 return WebGLGetInfo(0, 0); |
| 4235 } | 4234 } |
| 4236 GLboolean value[4] = {0}; | 4235 GLboolean value[4] = {0}; |
| 4237 if (!isContextLost()) | 4236 if (!isContextLost()) |
| 4238 m_context->getBooleanv(pname, value); | 4237 webContext()->getBooleanv(pname, value); |
| 4239 bool boolValue[4]; | 4238 bool boolValue[4]; |
| 4240 for (int ii = 0; ii < 4; ++ii) | 4239 for (int ii = 0; ii < 4; ++ii) |
| 4241 boolValue[ii] = static_cast<bool>(value[ii]); | 4240 boolValue[ii] = static_cast<bool>(value[ii]); |
| 4242 return WebGLGetInfo(boolValue, 4); | 4241 return WebGLGetInfo(boolValue, 4); |
| 4243 } | 4242 } |
| 4244 | 4243 |
| 4245 WebGLGetInfo WebGLRenderingContextBase::getFloatParameter(GLenum pname) | 4244 WebGLGetInfo WebGLRenderingContextBase::getFloatParameter(GLenum pname) |
| 4246 { | 4245 { |
| 4247 GLfloat value = 0; | 4246 GLfloat value = 0; |
| 4248 if (!isContextLost()) | 4247 if (!isContextLost()) |
| 4249 m_context->getFloatv(pname, &value); | 4248 webContext()->getFloatv(pname, &value); |
| 4250 return WebGLGetInfo(value); | 4249 return WebGLGetInfo(value); |
| 4251 } | 4250 } |
| 4252 | 4251 |
| 4253 WebGLGetInfo WebGLRenderingContextBase::getIntParameter(GLenum pname) | 4252 WebGLGetInfo WebGLRenderingContextBase::getIntParameter(GLenum pname) |
| 4254 { | 4253 { |
| 4255 GLint value = 0; | 4254 GLint value = 0; |
| 4256 if (!isContextLost()) | 4255 if (!isContextLost()) |
| 4257 m_context->getIntegerv(pname, &value); | 4256 webContext()->getIntegerv(pname, &value); |
| 4258 return WebGLGetInfo(value); | 4257 return WebGLGetInfo(value); |
| 4259 } | 4258 } |
| 4260 | 4259 |
| 4261 WebGLGetInfo WebGLRenderingContextBase::getUnsignedIntParameter(GLenum pname) | 4260 WebGLGetInfo WebGLRenderingContextBase::getUnsignedIntParameter(GLenum pname) |
| 4262 { | 4261 { |
| 4263 GLint value = 0; | 4262 GLint value = 0; |
| 4264 if (!isContextLost()) | 4263 if (!isContextLost()) |
| 4265 m_context->getIntegerv(pname, &value); | 4264 webContext()->getIntegerv(pname, &value); |
| 4266 return WebGLGetInfo(static_cast<unsigned>(value)); | 4265 return WebGLGetInfo(static_cast<unsigned>(value)); |
| 4267 } | 4266 } |
| 4268 | 4267 |
| 4269 WebGLGetInfo WebGLRenderingContextBase::getWebGLFloatArrayParameter(GLenum pname
) | 4268 WebGLGetInfo WebGLRenderingContextBase::getWebGLFloatArrayParameter(GLenum pname
) |
| 4270 { | 4269 { |
| 4271 GLfloat value[4] = {0}; | 4270 GLfloat value[4] = {0}; |
| 4272 if (!isContextLost()) | 4271 if (!isContextLost()) |
| 4273 m_context->getFloatv(pname, value); | 4272 webContext()->getFloatv(pname, value); |
| 4274 unsigned length = 0; | 4273 unsigned length = 0; |
| 4275 switch (pname) { | 4274 switch (pname) { |
| 4276 case GL_ALIASED_POINT_SIZE_RANGE: | 4275 case GL_ALIASED_POINT_SIZE_RANGE: |
| 4277 case GL_ALIASED_LINE_WIDTH_RANGE: | 4276 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 4278 case GL_DEPTH_RANGE: | 4277 case GL_DEPTH_RANGE: |
| 4279 length = 2; | 4278 length = 2; |
| 4280 break; | 4279 break; |
| 4281 case GL_BLEND_COLOR: | 4280 case GL_BLEND_COLOR: |
| 4282 case GL_COLOR_CLEAR_VALUE: | 4281 case GL_COLOR_CLEAR_VALUE: |
| 4283 length = 4; | 4282 length = 4; |
| 4284 break; | 4283 break; |
| 4285 default: | 4284 default: |
| 4286 notImplemented(); | 4285 notImplemented(); |
| 4287 } | 4286 } |
| 4288 return WebGLGetInfo(Float32Array::create(value, length)); | 4287 return WebGLGetInfo(Float32Array::create(value, length)); |
| 4289 } | 4288 } |
| 4290 | 4289 |
| 4291 WebGLGetInfo WebGLRenderingContextBase::getWebGLIntArrayParameter(GLenum pname) | 4290 WebGLGetInfo WebGLRenderingContextBase::getWebGLIntArrayParameter(GLenum pname) |
| 4292 { | 4291 { |
| 4293 GLint value[4] = {0}; | 4292 GLint value[4] = {0}; |
| 4294 if (!isContextLost()) | 4293 if (!isContextLost()) |
| 4295 m_context->getIntegerv(pname, value); | 4294 webContext()->getIntegerv(pname, value); |
| 4296 unsigned length = 0; | 4295 unsigned length = 0; |
| 4297 switch (pname) { | 4296 switch (pname) { |
| 4298 case GL_MAX_VIEWPORT_DIMS: | 4297 case GL_MAX_VIEWPORT_DIMS: |
| 4299 length = 2; | 4298 length = 2; |
| 4300 break; | 4299 break; |
| 4301 case GL_SCISSOR_BOX: | 4300 case GL_SCISSOR_BOX: |
| 4302 case GL_VIEWPORT: | 4301 case GL_VIEWPORT: |
| 4303 length = 4; | 4302 length = 4; |
| 4304 break; | 4303 break; |
| 4305 default: | 4304 default: |
| 4306 notImplemented(); | 4305 notImplemented(); |
| 4307 } | 4306 } |
| 4308 return WebGLGetInfo(Int32Array::create(value, length)); | 4307 return WebGLGetInfo(Int32Array::create(value, length)); |
| 4309 } | 4308 } |
| 4310 | 4309 |
| 4311 void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
me, bool prepareToDraw) | 4310 void WebGLRenderingContextBase::handleTextureCompleteness(const char* functionNa
me, bool prepareToDraw) |
| 4312 { | 4311 { |
| 4313 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 4312 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 4314 bool resetActiveUnit = false; | 4313 bool resetActiveUnit = false; |
| 4315 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE
xtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::Textu
reFloatLinearExtensionEnabled : 0) | 4314 WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureE
xtensionFlag>((extensionEnabled(OESTextureFloatLinearName) ? WebGLTexture::Textu
reFloatLinearExtensionEnabled : 0) |
| 4316 | (extensionEnabled(OESTextureHalfFloatLinearName) ? WebGLTexture::Textu
reHalfFloatLinearExtensionEnabled : 0)); | 4315 | (extensionEnabled(OESTextureHalfFloatLinearName) ? WebGLTexture::Textu
reHalfFloatLinearExtensionEnabled : 0)); |
| 4317 for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { | 4316 for (unsigned ii = 0; ii < m_onePlusMaxNonDefaultTextureUnit; ++ii) { |
| 4318 if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m
_texture2DBinding->needToUseBlackTexture(flag)) | 4317 if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m
_texture2DBinding->needToUseBlackTexture(flag)) |
| 4319 || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUni
ts[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) { | 4318 || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUni
ts[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) { |
| 4320 if (ii != m_activeTextureUnit) { | 4319 if (ii != m_activeTextureUnit) { |
| 4321 m_context->activeTexture(ii); | 4320 webContext()->activeTexture(ii); |
| 4322 resetActiveUnit = true; | 4321 resetActiveUnit = true; |
| 4323 } else if (resetActiveUnit) { | 4322 } else if (resetActiveUnit) { |
| 4324 m_context->activeTexture(ii); | 4323 webContext()->activeTexture(ii); |
| 4325 resetActiveUnit = false; | 4324 resetActiveUnit = false; |
| 4326 } | 4325 } |
| 4327 WebGLTexture* tex2D; | 4326 WebGLTexture* tex2D; |
| 4328 WebGLTexture* texCubeMap; | 4327 WebGLTexture* texCubeMap; |
| 4329 if (prepareToDraw) { | 4328 if (prepareToDraw) { |
| 4330 String msg(String("texture bound to texture unit ") + String::nu
mber(ii) | 4329 String msg(String("texture bound to texture unit ") + String::nu
mber(ii) |
| 4331 + " is not renderable. It maybe non-power-of-2 and have inco
mpatible texture filtering or is not 'texture complete'." | 4330 + " is not renderable. It maybe non-power-of-2 and have inco
mpatible texture filtering or is not 'texture complete'." |
| 4332 + " Or the texture is Float or Half Float type with linear f
iltering while OES_float_linear or OES_half_float_linear extension is not enable
d."); | 4331 + " Or the texture is Float or Half Float type with linear f
iltering while OES_float_linear or OES_half_float_linear extension is not enable
d."); |
| 4333 emitGLWarning(functionName, msg.utf8().data()); | 4332 emitGLWarning(functionName, msg.utf8().data()); |
| 4334 tex2D = m_blackTexture2D.get(); | 4333 tex2D = m_blackTexture2D.get(); |
| 4335 texCubeMap = m_blackTextureCubeMap.get(); | 4334 texCubeMap = m_blackTextureCubeMap.get(); |
| 4336 } else { | 4335 } else { |
| 4337 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); | 4336 tex2D = m_textureUnits[ii].m_texture2DBinding.get(); |
| 4338 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); | 4337 texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get(); |
| 4339 } | 4338 } |
| 4340 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te
xture2DBinding->needToUseBlackTexture(flag)) | 4339 if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_te
xture2DBinding->needToUseBlackTexture(flag)) |
| 4341 m_context->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); | 4340 webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(tex2D)); |
| 4342 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii]
.m_textureCubeMapBinding->needToUseBlackTexture(flag)) | 4341 if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii]
.m_textureCubeMapBinding->needToUseBlackTexture(flag)) |
| 4343 m_context->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texCube
Map)); | 4342 webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, objectOrZero(texC
ubeMap)); |
| 4344 } | 4343 } |
| 4345 } | 4344 } |
| 4346 if (resetActiveUnit) | 4345 if (resetActiveUnit) |
| 4347 m_context->activeTexture(m_activeTextureUnit); | 4346 webContext()->activeTexture(m_activeTextureUnit); |
| 4348 } | 4347 } |
| 4349 | 4348 |
| 4350 void WebGLRenderingContextBase::createFallbackBlackTextures1x1() | 4349 void WebGLRenderingContextBase::createFallbackBlackTextures1x1() |
| 4351 { | 4350 { |
| 4352 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. | 4351 // All calling functions check isContextLost, so a duplicate check is not ne
eded here. |
| 4353 unsigned char black[] = {0, 0, 0, 255}; | 4352 unsigned char black[] = {0, 0, 0, 255}; |
| 4354 m_blackTexture2D = createTexture(); | 4353 m_blackTexture2D = createTexture(); |
| 4355 m_context->bindTexture(GL_TEXTURE_2D, m_blackTexture2D->object()); | 4354 webContext()->bindTexture(GL_TEXTURE_2D, m_blackTexture2D->object()); |
| 4356 m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, | 4355 webContext()->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, |
| 4357 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4356 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4358 m_context->bindTexture(GL_TEXTURE_2D, 0); | 4357 webContext()->bindTexture(GL_TEXTURE_2D, 0); |
| 4359 m_blackTextureCubeMap = createTexture(); | 4358 m_blackTextureCubeMap = createTexture(); |
| 4360 m_context->bindTexture(GL_TEXTURE_CUBE_MAP, m_blackTextureCubeMap->object())
; | 4359 webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, m_blackTextureCubeMap->object
()); |
| 4361 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 1, 1, | 4360 webContext()->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 1, 1, |
| 4362 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4361 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4363 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 1, 1, | 4362 webContext()->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 1, 1, |
| 4364 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4363 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4365 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 1, 1, | 4364 webContext()->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 1, 1, |
| 4366 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4365 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4367 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 1, 1, | 4366 webContext()->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 1, 1, |
| 4368 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4367 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4369 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 1, 1, | 4368 webContext()->texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 1, 1, |
| 4370 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4369 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4371 m_context->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 1, 1, | 4370 webContext()->texImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 1, 1, |
| 4372 0, GL_RGBA, GL_UNSIGNED_BYTE, black); | 4371 0, GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 4373 m_context->bindTexture(GL_TEXTURE_CUBE_MAP, 0); | 4372 webContext()->bindTexture(GL_TEXTURE_CUBE_MAP, 0); |
| 4374 } | 4373 } |
| 4375 | 4374 |
| 4376 bool WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid(G
Lenum texInternalFormat, GLenum colorBufferFormat) | 4375 bool WebGLRenderingContextBase::isTexInternalFormatColorBufferCombinationValid(G
Lenum texInternalFormat, GLenum colorBufferFormat) |
| 4377 { | 4376 { |
| 4378 unsigned need = WebGLImageConversion::getChannelBitsByFormat(texInternalForm
at); | 4377 unsigned need = WebGLImageConversion::getChannelBitsByFormat(texInternalForm
at); |
| 4379 unsigned have = WebGLImageConversion::getChannelBitsByFormat(colorBufferForm
at); | 4378 unsigned have = WebGLImageConversion::getChannelBitsByFormat(colorBufferForm
at); |
| 4380 return (need & have) == need; | 4379 return (need & have) == need; |
| 4381 } | 4380 } |
| 4382 | 4381 |
| 4383 GLenum WebGLRenderingContextBase::boundFramebufferColorFormat() | 4382 GLenum WebGLRenderingContextBase::boundFramebufferColorFormat() |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5140 if (!count) { | 5139 if (!count) { |
| 5141 markContextChanged(); | 5140 markContextChanged(); |
| 5142 return false; | 5141 return false; |
| 5143 } | 5142 } |
| 5144 | 5143 |
| 5145 if (!validateRenderingState(functionName)) { | 5144 if (!validateRenderingState(functionName)) { |
| 5146 return false; | 5145 return false; |
| 5147 } | 5146 } |
| 5148 | 5147 |
| 5149 const char* reason = "framebuffer incomplete"; | 5148 const char* reason = "framebuffer incomplete"; |
| 5150 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 5149 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 5151 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); | 5150 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); |
| 5152 return false; | 5151 return false; |
| 5153 } | 5152 } |
| 5154 | 5153 |
| 5155 return true; | 5154 return true; |
| 5156 } | 5155 } |
| 5157 | 5156 |
| 5158 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G
Lenum mode, GLsizei count, GLenum type, long long offset) | 5157 bool WebGLRenderingContextBase::validateDrawElements(const char* functionName, G
Lenum mode, GLsizei count, GLenum type, long long offset) |
| 5159 { | 5158 { |
| 5160 if (isContextLost() || !validateDrawMode(functionName, mode)) | 5159 if (isContextLost() || !validateDrawMode(functionName, mode)) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5190 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { | 5189 if (!m_boundVertexArrayObject->boundElementArrayBuffer()) { |
| 5191 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_
BUFFER bound"); | 5190 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_
BUFFER bound"); |
| 5192 return false; | 5191 return false; |
| 5193 } | 5192 } |
| 5194 | 5193 |
| 5195 if (!validateRenderingState(functionName)) { | 5194 if (!validateRenderingState(functionName)) { |
| 5196 return false; | 5195 return false; |
| 5197 } | 5196 } |
| 5198 | 5197 |
| 5199 const char* reason = "framebuffer incomplete"; | 5198 const char* reason = "framebuffer incomplete"; |
| 5200 if (m_framebufferBinding && !m_framebufferBinding->onAccess(m_context.get(),
&reason)) { | 5199 if (m_framebufferBinding && !m_framebufferBinding->onAccess(webContext(), &r
eason)) { |
| 5201 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); | 5200 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason
); |
| 5202 return false; | 5201 return false; |
| 5203 } | 5202 } |
| 5204 | 5203 |
| 5205 return true; | 5204 return true; |
| 5206 } | 5205 } |
| 5207 | 5206 |
| 5208 // Helper function to validate draw*Instanced calls | 5207 // Helper function to validate draw*Instanced calls |
| 5209 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName,
GLsizei primcount) | 5208 bool WebGLRenderingContextBase::validateDrawInstanced(const char* functionName,
GLsizei primcount) |
| 5210 { | 5209 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5228 { | 5227 { |
| 5229 if (isContextLost()) | 5228 if (isContextLost()) |
| 5230 return; | 5229 return; |
| 5231 if (index >= m_maxVertexAttribs) { | 5230 if (index >= m_maxVertexAttribs) { |
| 5232 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); | 5231 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); |
| 5233 return; | 5232 return; |
| 5234 } | 5233 } |
| 5235 // In GL, we skip setting vertexAttrib0 values. | 5234 // In GL, we skip setting vertexAttrib0 values. |
| 5236 switch (expectedSize) { | 5235 switch (expectedSize) { |
| 5237 case 1: | 5236 case 1: |
| 5238 m_context->vertexAttrib1f(index, v0); | 5237 webContext()->vertexAttrib1f(index, v0); |
| 5239 break; | 5238 break; |
| 5240 case 2: | 5239 case 2: |
| 5241 m_context->vertexAttrib2f(index, v0, v1); | 5240 webContext()->vertexAttrib2f(index, v0, v1); |
| 5242 break; | 5241 break; |
| 5243 case 3: | 5242 case 3: |
| 5244 m_context->vertexAttrib3f(index, v0, v1, v2); | 5243 webContext()->vertexAttrib3f(index, v0, v1, v2); |
| 5245 break; | 5244 break; |
| 5246 case 4: | 5245 case 4: |
| 5247 m_context->vertexAttrib4f(index, v0, v1, v2, v3); | 5246 webContext()->vertexAttrib4f(index, v0, v1, v2, v3); |
| 5248 break; | 5247 break; |
| 5249 } | 5248 } |
| 5250 VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 5249 VertexAttribValue& attribValue = m_vertexAttribValue[index]; |
| 5251 attribValue.value[0] = v0; | 5250 attribValue.value[0] = v0; |
| 5252 attribValue.value[1] = v1; | 5251 attribValue.value[1] = v1; |
| 5253 attribValue.value[2] = v2; | 5252 attribValue.value[2] = v2; |
| 5254 attribValue.value[3] = v3; | 5253 attribValue.value[3] = v3; |
| 5255 } | 5254 } |
| 5256 | 5255 |
| 5257 void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GLu
int index, Float32Array* v, GLsizei expectedSize) | 5256 void WebGLRenderingContextBase::vertexAttribfvImpl(const char* functionName, GLu
int index, Float32Array* v, GLsizei expectedSize) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5277 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); | 5276 synthesizeGLError(GL_INVALID_VALUE, functionName, "invalid size"); |
| 5278 return; | 5277 return; |
| 5279 } | 5278 } |
| 5280 if (index >= m_maxVertexAttribs) { | 5279 if (index >= m_maxVertexAttribs) { |
| 5281 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); | 5280 synthesizeGLError(GL_INVALID_VALUE, functionName, "index out of range"); |
| 5282 return; | 5281 return; |
| 5283 } | 5282 } |
| 5284 // In GL, we skip setting vertexAttrib0 values. | 5283 // In GL, we skip setting vertexAttrib0 values. |
| 5285 switch (expectedSize) { | 5284 switch (expectedSize) { |
| 5286 case 1: | 5285 case 1: |
| 5287 m_context->vertexAttrib1fv(index, v); | 5286 webContext()->vertexAttrib1fv(index, v); |
| 5288 break; | 5287 break; |
| 5289 case 2: | 5288 case 2: |
| 5290 m_context->vertexAttrib2fv(index, v); | 5289 webContext()->vertexAttrib2fv(index, v); |
| 5291 break; | 5290 break; |
| 5292 case 3: | 5291 case 3: |
| 5293 m_context->vertexAttrib3fv(index, v); | 5292 webContext()->vertexAttrib3fv(index, v); |
| 5294 break; | 5293 break; |
| 5295 case 4: | 5294 case 4: |
| 5296 m_context->vertexAttrib4fv(index, v); | 5295 webContext()->vertexAttrib4fv(index, v); |
| 5297 break; | 5296 break; |
| 5298 } | 5297 } |
| 5299 VertexAttribValue& attribValue = m_vertexAttribValue[index]; | 5298 VertexAttribValue& attribValue = m_vertexAttribValue[index]; |
| 5300 attribValue.initValue(); | 5299 attribValue.initValue(); |
| 5301 for (int ii = 0; ii < expectedSize; ++ii) | 5300 for (int ii = 0; ii < expectedSize; ++ii) |
| 5302 attribValue.value[ii] = v[ii]; | 5301 attribValue.value[ii] = v[ii]; |
| 5303 } | 5302 } |
| 5304 | 5303 |
| 5305 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) | 5304 void WebGLRenderingContextBase::dispatchContextLostEvent(Timer<WebGLRenderingCon
textBase>*) |
| 5306 { | 5305 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5329 if (!frame) | 5328 if (!frame) |
| 5330 return; | 5329 return; |
| 5331 | 5330 |
| 5332 Settings* settings = frame->settings(); | 5331 Settings* settings = frame->settings(); |
| 5333 | 5332 |
| 5334 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) | 5333 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled
())) |
| 5335 return; | 5334 return; |
| 5336 | 5335 |
| 5337 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings); | 5336 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings); |
| 5338 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes)); | 5337 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes)); |
| 5339 if (!context) { | 5338 |
| 5339 ASSERT(!m_drawingBuffer); |
| 5340 if (context) { |
| 5341 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = ad
optRef(new WebGLRenderingContextEvictionManager()); |
| 5342 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->p
reserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
| 5343 m_drawingBuffer = DrawingBuffer::create(context.release(), clampedCanvas
Size(), preserve, contextEvictionManager.release()); |
| 5344 } |
| 5345 |
| 5346 bool failToRestore = !m_drawingBuffer; |
| 5347 if (failToRestore) { |
| 5340 if (m_contextLostMode == RealLostContext) { | 5348 if (m_contextLostMode == RealLostContext) { |
| 5341 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); | 5349 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts); |
| 5342 } else { | 5350 } else { |
| 5343 // This likely shouldn't happen but is the best way to report it to
the WebGL app. | 5351 // This likely shouldn't happen but is the best way to report it to
the WebGL app. |
| 5344 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); | 5352 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context
"); |
| 5345 } | 5353 } |
| 5346 return; | 5354 return; |
| 5347 } | 5355 } |
| 5348 | 5356 |
| 5349 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | |
| 5350 | |
| 5351 // Construct a new drawing buffer with the new WebGraphicsContext3D. | |
| 5352 m_drawingBuffer->releaseResources(); | |
| 5353 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->prese
rveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | |
| 5354 m_drawingBuffer = DrawingBuffer::create(context.get(), clampedCanvasSize(),
preserve, contextEvictionManager.release()); | |
| 5355 | |
| 5356 if (m_drawingBuffer->isZeroSized()) | |
| 5357 return; | |
| 5358 | |
| 5359 m_drawingBuffer->bind(); | 5357 m_drawingBuffer->bind(); |
| 5360 | |
| 5361 m_lostContextErrors.clear(); | 5358 m_lostContextErrors.clear(); |
| 5362 | |
| 5363 m_context = context.release(); | |
| 5364 m_contextLost = false; | 5359 m_contextLost = false; |
| 5365 | 5360 |
| 5366 setupFlags(); | 5361 setupFlags(); |
| 5367 initializeNewContext(); | 5362 initializeNewContext(); |
| 5368 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte
xtrestored, false, true, "")); | 5363 canvas()->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglconte
xtrestored, false, true, "")); |
| 5369 } | 5364 } |
| 5370 | 5365 |
| 5371 String WebGLRenderingContextBase::ensureNotNull(const String& text) const | 5366 String WebGLRenderingContextBase::ensureNotNull(const String& text) const |
| 5372 { | 5367 { |
| 5373 if (text.isNull()) | 5368 if (text.isNull()) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5436 } // namespace anonymous | 5431 } // namespace anonymous |
| 5437 | 5432 |
| 5438 void WebGLRenderingContextBase::synthesizeGLError(GLenum error, const char* func
tionName, const char* description, ConsoleDisplayPreference display) | 5433 void WebGLRenderingContextBase::synthesizeGLError(GLenum error, const char* func
tionName, const char* description, ConsoleDisplayPreference display) |
| 5439 { | 5434 { |
| 5440 String errorType = GetErrorString(error); | 5435 String errorType = GetErrorString(error); |
| 5441 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { | 5436 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { |
| 5442 String message = String("WebGL: ") + errorType + ": " + String(function
Name) + ": " + String(description); | 5437 String message = String("WebGL: ") + errorType + ": " + String(function
Name) + ": " + String(description); |
| 5443 printGLErrorToConsole(message); | 5438 printGLErrorToConsole(message); |
| 5444 } | 5439 } |
| 5445 if (!isContextLost()) | 5440 if (!isContextLost()) |
| 5446 m_context->synthesizeGLError(error); | 5441 webContext()->synthesizeGLError(error); |
| 5447 else { | 5442 else { |
| 5448 if (m_lostContextErrors.find(error) == WTF::kNotFound) | 5443 if (m_lostContextErrors.find(error) == WTF::kNotFound) |
| 5449 m_lostContextErrors.append(error); | 5444 m_lostContextErrors.append(error); |
| 5450 } | 5445 } |
| 5451 InspectorInstrumentation::didFireWebGLError(canvas(), errorType); | 5446 InspectorInstrumentation::didFireWebGLError(canvas(), errorType); |
| 5452 } | 5447 } |
| 5453 | 5448 |
| 5454 void WebGLRenderingContextBase::emitGLWarning(const char* functionName, const ch
ar* description) | 5449 void WebGLRenderingContextBase::emitGLWarning(const char* functionName, const ch
ar* description) |
| 5455 { | 5450 { |
| 5456 if (m_synthesizedErrorsToConsole) { | 5451 if (m_synthesizedErrorsToConsole) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5472 } | 5467 } |
| 5473 enableOrDisable(GL_STENCIL_TEST, | 5468 enableOrDisable(GL_STENCIL_TEST, |
| 5474 m_stencilEnabled && haveStencilBuffer); | 5469 m_stencilEnabled && haveStencilBuffer); |
| 5475 } | 5470 } |
| 5476 | 5471 |
| 5477 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 5472 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) |
| 5478 { | 5473 { |
| 5479 if (isContextLost()) | 5474 if (isContextLost()) |
| 5480 return; | 5475 return; |
| 5481 if (enable) | 5476 if (enable) |
| 5482 m_context->enable(capability); | 5477 webContext()->enable(capability); |
| 5483 else | 5478 else |
| 5484 m_context->disable(capability); | 5479 webContext()->disable(capability); |
| 5485 } | 5480 } |
| 5486 | 5481 |
| 5487 IntSize WebGLRenderingContextBase::clampedCanvasSize() | 5482 IntSize WebGLRenderingContextBase::clampedCanvasSize() |
| 5488 { | 5483 { |
| 5489 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), | 5484 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), |
| 5490 clamp(canvas()->height(), 1, m_maxViewportDims[1])); | 5485 clamp(canvas()->height(), 1, m_maxViewportDims[1])); |
| 5491 } | 5486 } |
| 5492 | 5487 |
| 5493 GLint WebGLRenderingContextBase::maxDrawBuffers() | 5488 GLint WebGLRenderingContextBase::maxDrawBuffers() |
| 5494 { | 5489 { |
| 5495 if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) | 5490 if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) |
| 5496 return 0; | 5491 return 0; |
| 5497 if (!m_maxDrawBuffers) | 5492 if (!m_maxDrawBuffers) |
| 5498 m_context->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers); | 5493 webContext()->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers); |
| 5499 if (!m_maxColorAttachments) | 5494 if (!m_maxColorAttachments) |
| 5500 m_context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachme
nts); | 5495 webContext()->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttac
hments); |
| 5501 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. | 5496 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. |
| 5502 return std::min(m_maxDrawBuffers, m_maxColorAttachments); | 5497 return std::min(m_maxDrawBuffers, m_maxColorAttachments); |
| 5503 } | 5498 } |
| 5504 | 5499 |
| 5505 GLint WebGLRenderingContextBase::maxColorAttachments() | 5500 GLint WebGLRenderingContextBase::maxColorAttachments() |
| 5506 { | 5501 { |
| 5507 if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) | 5502 if (isContextLost() || !extensionEnabled(WebGLDrawBuffersName)) |
| 5508 return 0; | 5503 return 0; |
| 5509 if (!m_maxColorAttachments) | 5504 if (!m_maxColorAttachments) |
| 5510 m_context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachme
nts); | 5505 webContext()->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttac
hments); |
| 5511 return m_maxColorAttachments; | 5506 return m_maxColorAttachments; |
| 5512 } | 5507 } |
| 5513 | 5508 |
| 5514 void WebGLRenderingContextBase::setBackDrawBuffer(GLenum buf) | 5509 void WebGLRenderingContextBase::setBackDrawBuffer(GLenum buf) |
| 5515 { | 5510 { |
| 5516 m_backDrawBuffer = buf; | 5511 m_backDrawBuffer = buf; |
| 5517 } | 5512 } |
| 5518 | 5513 |
| 5519 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 5514 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| 5520 { | 5515 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5555 if (m_textureUnits[i].m_texture2DBinding | 5550 if (m_textureUnits[i].m_texture2DBinding |
| 5556 || m_textureUnits[i].m_textureCubeMapBinding) { | 5551 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 5557 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5552 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 5558 return; | 5553 return; |
| 5559 } | 5554 } |
| 5560 } | 5555 } |
| 5561 m_onePlusMaxNonDefaultTextureUnit = 0; | 5556 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 5562 } | 5557 } |
| 5563 | 5558 |
| 5564 } // namespace WebCore | 5559 } // namespace WebCore |
| OLD | NEW |