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