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 24 matching lines...) Expand all Loading... |
35 #include "core/fetch/ImageResource.h" | 35 #include "core/fetch/ImageResource.h" |
36 #include "core/frame/LocalFrame.h" | 36 #include "core/frame/LocalFrame.h" |
37 #include "core/frame/Settings.h" | 37 #include "core/frame/Settings.h" |
38 #include "core/html/HTMLCanvasElement.h" | 38 #include "core/html/HTMLCanvasElement.h" |
39 #include "core/html/HTMLImageElement.h" | 39 #include "core/html/HTMLImageElement.h" |
40 #include "core/html/HTMLVideoElement.h" | 40 #include "core/html/HTMLVideoElement.h" |
41 #include "core/html/ImageData.h" | 41 #include "core/html/ImageData.h" |
42 #include "core/html/canvas/ANGLEInstancedArrays.h" | 42 #include "core/html/canvas/ANGLEInstancedArrays.h" |
43 #include "core/html/canvas/CHROMIUMSubscribeUniform.h" | 43 #include "core/html/canvas/CHROMIUMSubscribeUniform.h" |
44 #include "core/html/canvas/CHROMIUMValuebuffer.h" | 44 #include "core/html/canvas/CHROMIUMValuebuffer.h" |
| 45 #include "core/html/canvas/ContextAttributeHelpers.h" |
45 #include "core/html/canvas/EXTBlendMinMax.h" | 46 #include "core/html/canvas/EXTBlendMinMax.h" |
46 #include "core/html/canvas/EXTFragDepth.h" | 47 #include "core/html/canvas/EXTFragDepth.h" |
47 #include "core/html/canvas/EXTShaderTextureLOD.h" | 48 #include "core/html/canvas/EXTShaderTextureLOD.h" |
48 #include "core/html/canvas/EXTTextureFilterAnisotropic.h" | 49 #include "core/html/canvas/EXTTextureFilterAnisotropic.h" |
49 #include "core/html/canvas/OESElementIndexUint.h" | 50 #include "core/html/canvas/OESElementIndexUint.h" |
50 #include "core/html/canvas/OESStandardDerivatives.h" | 51 #include "core/html/canvas/OESStandardDerivatives.h" |
51 #include "core/html/canvas/OESTextureFloat.h" | 52 #include "core/html/canvas/OESTextureFloat.h" |
52 #include "core/html/canvas/OESTextureFloatLinear.h" | 53 #include "core/html/canvas/OESTextureFloatLinear.h" |
53 #include "core/html/canvas/OESTextureHalfFloat.h" | 54 #include "core/html/canvas/OESTextureHalfFloat.h" |
54 #include "core/html/canvas/OESTextureHalfFloatLinear.h" | 55 #include "core/html/canvas/OESTextureHalfFloatLinear.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 visitor->trace(m_context); | 552 visitor->trace(m_context); |
552 } | 553 } |
553 | 554 |
554 private: | 555 private: |
555 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase
* context) | 556 explicit WebGLRenderingContextErrorMessageCallback(WebGLRenderingContextBase
* context) |
556 : m_context(context) { } | 557 : m_context(context) { } |
557 | 558 |
558 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; | 559 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; |
559 }; | 560 }; |
560 | 561 |
561 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
nvas, PassOwnPtr<blink::WebGraphicsContext3D> context, WebGLContextAttributes* r
equestedAttributes) | 562 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
nvas, PassOwnPtr<blink::WebGraphicsContext3D> context, const WebGLContextAttribu
tes& requestedAttributes) |
562 : CanvasRenderingContext(passedCanvas) | 563 : CanvasRenderingContext(passedCanvas) |
563 , ActiveDOMObject(&passedCanvas->document()) | 564 , ActiveDOMObject(&passedCanvas->document()) |
564 , m_contextLostMode(NotLostContext) | 565 , m_contextLostMode(NotLostContext) |
565 , m_autoRecoveryMethod(Manual) | 566 , m_autoRecoveryMethod(Manual) |
566 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch
ContextLostEvent) | 567 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch
ContextLostEvent) |
567 , m_restoreAllowed(false) | 568 , m_restoreAllowed(false) |
568 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 569 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
569 , m_generatedImageCache(4) | 570 , m_generatedImageCache(4) |
570 , m_requestedAttributes(requestedAttributes->clone()) | 571 , m_requestedAttributes(requestedAttributes) |
571 , m_synthesizedErrorsToConsole(true) | 572 , m_synthesizedErrorsToConsole(true) |
572 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 573 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
573 , m_multisamplingAllowed(false) | 574 , m_multisamplingAllowed(false) |
574 , m_multisamplingObserverRegistered(false) | 575 , m_multisamplingObserverRegistered(false) |
575 , m_onePlusMaxNonDefaultTextureUnit(0) | 576 , m_onePlusMaxNonDefaultTextureUnit(0) |
576 { | 577 { |
577 ASSERT(context); | 578 ASSERT(context); |
578 | 579 |
579 m_contextGroup = WebGLContextGroup::create(); | 580 m_contextGroup = WebGLContextGroup::create(); |
580 m_contextGroup->addContext(this); | 581 m_contextGroup->addContext(this); |
(...skipping 14 matching lines...) Expand all Loading... |
595 drawingBuffer()->bind(); | 596 drawingBuffer()->bind(); |
596 setupFlags(); | 597 setupFlags(); |
597 initializeNewContext(); | 598 initializeNewContext(); |
598 } | 599 } |
599 | 600 |
600 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn
Ptr<blink::WebGraphicsContext3D> context) | 601 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn
Ptr<blink::WebGraphicsContext3D> context) |
601 { | 602 { |
602 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); | 603 RefPtr<WebGLRenderingContextEvictionManager> contextEvictionManager = adoptR
ef(new WebGLRenderingContextEvictionManager()); |
603 | 604 |
604 blink::WebGraphicsContext3D::Attributes attrs; | 605 blink::WebGraphicsContext3D::Attributes attrs; |
605 attrs.alpha = m_requestedAttributes->alpha(); | 606 attrs.alpha = m_requestedAttributes.alpha(); |
606 attrs.depth = m_requestedAttributes->depth(); | 607 attrs.depth = m_requestedAttributes.depth(); |
607 attrs.stencil = m_requestedAttributes->stencil(); | 608 attrs.stencil = m_requestedAttributes.stencil(); |
608 attrs.antialias = m_requestedAttributes->antialias(); | 609 attrs.antialias = m_requestedAttributes.antialias(); |
609 attrs.premultipliedAlpha = m_requestedAttributes->premultipliedAlpha(); | 610 attrs.premultipliedAlpha = m_requestedAttributes.premultipliedAlpha(); |
610 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes->prese
rveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 611 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes.preser
veDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
611 return DrawingBuffer::create(context, clampedCanvasSize(), preserve, attrs,
contextEvictionManager.release()); | 612 return DrawingBuffer::create(context, clampedCanvasSize(), preserve, attrs,
contextEvictionManager.release()); |
612 } | 613 } |
613 | 614 |
614 void WebGLRenderingContextBase::initializeNewContext() | 615 void WebGLRenderingContextBase::initializeNewContext() |
615 { | 616 { |
616 ASSERT(!isContextLost()); | 617 ASSERT(!isContextLost()); |
617 m_markedCanvasDirty = false; | 618 m_markedCanvasDirty = false; |
618 m_activeTextureUnit = 0; | 619 m_activeTextureUnit = 0; |
619 m_packAlignment = 4; | 620 m_packAlignment = 4; |
620 m_unpackAlignment = 4; | 621 m_unpackAlignment = 4; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 | 692 |
692 activateContext(this); | 693 activateContext(this); |
693 } | 694 } |
694 | 695 |
695 void WebGLRenderingContextBase::setupFlags() | 696 void WebGLRenderingContextBase::setupFlags() |
696 { | 697 { |
697 ASSERT(drawingBuffer()); | 698 ASSERT(drawingBuffer()); |
698 if (Page* p = canvas()->document().page()) { | 699 if (Page* p = canvas()->document().page()) { |
699 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled
(); | 700 m_synthesizedErrorsToConsole = p->settings().webGLErrorsToConsoleEnabled
(); |
700 | 701 |
701 if (!m_multisamplingObserverRegistered && m_requestedAttributes->antiali
as()) { | 702 if (!m_multisamplingObserverRegistered && m_requestedAttributes.antialia
s()) { |
702 m_multisamplingAllowed = drawingBuffer()->multisample(); | 703 m_multisamplingAllowed = drawingBuffer()->multisample(); |
703 p->addMultisamplingChangedObserver(this); | 704 p->addMultisamplingChangedObserver(this); |
704 m_multisamplingObserverRegistered = true; | 705 m_multisamplingObserverRegistered = true; |
705 } | 706 } |
706 } | 707 } |
707 | 708 |
708 m_isGLES2NPOTStrict = !extensionsUtil()->isExtensionEnabled("GL_OES_texture_
npot"); | 709 m_isGLES2NPOTStrict = !extensionsUtil()->isExtensionEnabled("GL_OES_texture_
npot"); |
709 m_isDepthStencilSupported = extensionsUtil()->isExtensionEnabled("GL_OES_pac
ked_depth_stencil"); | 710 m_isDepthStencilSupported = extensionsUtil()->isExtensionEnabled("GL_OES_pac
ked_depth_stencil"); |
710 } | 711 } |
711 | 712 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 } | 817 } |
817 | 818 |
818 WebGLRenderingContextBase::HowToClear WebGLRenderingContextBase::clearIfComposit
ed(GLbitfield mask) | 819 WebGLRenderingContextBase::HowToClear WebGLRenderingContextBase::clearIfComposit
ed(GLbitfield mask) |
819 { | 820 { |
820 if (isContextLost()) | 821 if (isContextLost()) |
821 return Skipped; | 822 return Skipped; |
822 | 823 |
823 if (!drawingBuffer()->bufferClearNeeded() || (mask && m_framebufferBinding)) | 824 if (!drawingBuffer()->bufferClearNeeded() || (mask && m_framebufferBinding)) |
824 return Skipped; | 825 return Skipped; |
825 | 826 |
826 RefPtrWillBeRawPtr<WebGLContextAttributes> contextAttributes = getContextAtt
ributes(); | 827 Nullable<WebGLContextAttributes> contextAttributes; |
| 828 getContextAttributes(contextAttributes); |
| 829 if (contextAttributes.isNull()) { |
| 830 // Unlikely, but context was lost. |
| 831 return Skipped; |
| 832 } |
827 | 833 |
828 // Determine if it's possible to combine the clear the user asked for and th
is clear. | 834 // Determine if it's possible to combine the clear the user asked for and th
is clear. |
829 bool combinedClear = mask && !m_scissorEnabled; | 835 bool combinedClear = mask && !m_scissorEnabled; |
830 | 836 |
831 webContext()->disable(GL_SCISSOR_TEST); | 837 webContext()->disable(GL_SCISSOR_TEST); |
832 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { | 838 if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { |
833 webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, | 839 webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, |
834 m_colorMask[1] ? m_clearColor[1] : 0, | 840 m_colorMask[1] ? m_clearColor[1] : 0, |
835 m_colorMask[2] ? m_clearColor[2] : 0, | 841 m_colorMask[2] ? m_clearColor[2] : 0, |
836 m_colorMask[3] ? m_clearColor[3] : 0); | 842 m_colorMask[3] ? m_clearColor[3] : 0); |
837 } else { | 843 } else { |
838 webContext()->clearColor(0, 0, 0, 0); | 844 webContext()->clearColor(0, 0, 0, 0); |
839 } | 845 } |
840 webContext()->colorMask(true, true, true, true); | 846 webContext()->colorMask(true, true, true, true); |
841 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 847 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; |
842 if (contextAttributes->depth()) { | 848 if (contextAttributes.get().depth()) { |
843 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) | 849 if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) |
844 webContext()->clearDepth(1.0f); | 850 webContext()->clearDepth(1.0f); |
845 clearMask |= GL_DEPTH_BUFFER_BIT; | 851 clearMask |= GL_DEPTH_BUFFER_BIT; |
846 webContext()->depthMask(true); | 852 webContext()->depthMask(true); |
847 } | 853 } |
848 if (contextAttributes->stencil()) { | 854 if (contextAttributes.get().stencil()) { |
849 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 855 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
850 webContext()->clearStencil(m_clearStencil & m_stencilMask); | 856 webContext()->clearStencil(m_clearStencil & m_stencilMask); |
851 else | 857 else |
852 webContext()->clearStencil(0); | 858 webContext()->clearStencil(0); |
853 clearMask |= GL_STENCIL_BUFFER_BIT; | 859 clearMask |= GL_STENCIL_BUFFER_BIT; |
854 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 860 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
855 } | 861 } |
856 | 862 |
857 drawingBuffer()->clearFramebuffers(clearMask); | 863 drawingBuffer()->clearFramebuffers(clearMask); |
858 | 864 |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 return WebGLAny(scriptState); | 2108 return WebGLAny(scriptState); |
2103 } | 2109 } |
2104 | 2110 |
2105 GLint value = 0; | 2111 GLint value = 0; |
2106 webContext()->getBufferParameteriv(target, pname, &value); | 2112 webContext()->getBufferParameteriv(target, pname, &value); |
2107 if (pname == GL_BUFFER_SIZE) | 2113 if (pname == GL_BUFFER_SIZE) |
2108 return WebGLAny(scriptState, value); | 2114 return WebGLAny(scriptState, value); |
2109 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2115 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
2110 } | 2116 } |
2111 | 2117 |
2112 PassRefPtrWillBeRawPtr<WebGLContextAttributes> WebGLRenderingContextBase::getCon
textAttributes() | 2118 void WebGLRenderingContextBase::getContextAttributes(Nullable<WebGLContextAttrib
utes>& result) |
2113 { | 2119 { |
2114 if (isContextLost()) | 2120 if (isContextLost()) |
2115 return nullptr; | 2121 return; |
2116 // We always need to return a new WebGLContextAttributes object to | 2122 result.set(m_requestedAttributes); |
2117 // prevent the user from mutating any cached version. | |
2118 blink::WebGraphicsContext3D::Attributes attrs = drawingBuffer()->getActualAt
tributes(); | |
2119 RefPtrWillBeRawPtr<WebGLContextAttributes> attributes = m_requestedAttribute
s->clone(); | |
2120 // Some requested attributes may not be honored, so we need to query the und
erlying | 2123 // Some requested attributes may not be honored, so we need to query the und
erlying |
2121 // context/drawing buffer and adjust accordingly. | 2124 // context/drawing buffer and adjust accordingly. |
2122 if (m_requestedAttributes->depth() && !attrs.depth) | 2125 blink::WebGraphicsContext3D::Attributes attrs = drawingBuffer()->getActualAt
tributes(); |
2123 attributes->setDepth(false); | 2126 if (m_requestedAttributes.depth() && !attrs.depth) |
2124 if (m_requestedAttributes->stencil() && !attrs.stencil) | 2127 result.get().setDepth(false); |
2125 attributes->setStencil(false); | 2128 if (m_requestedAttributes.stencil() && !attrs.stencil) |
2126 attributes->setAntialias(drawingBuffer()->multisample()); | 2129 result.get().setStencil(false); |
2127 return attributes.release(); | 2130 result.get().setAntialias(drawingBuffer()->multisample()); |
2128 } | 2131 } |
2129 | 2132 |
2130 GLenum WebGLRenderingContextBase::getError() | 2133 GLenum WebGLRenderingContextBase::getError() |
2131 { | 2134 { |
2132 if (m_lostContextErrors.size()) { | 2135 if (m_lostContextErrors.size()) { |
2133 GLenum err = m_lostContextErrors.first(); | 2136 GLenum err = m_lostContextErrors.first(); |
2134 m_lostContextErrors.remove(0); | 2137 m_lostContextErrors.remove(0); |
2135 return err; | 2138 return err; |
2136 } | 2139 } |
2137 | 2140 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 return getBooleanArrayParameter(scriptState, pname); | 2300 return getBooleanArrayParameter(scriptState, pname); |
2298 case GL_COMPRESSED_TEXTURE_FORMATS: | 2301 case GL_COMPRESSED_TEXTURE_FORMATS: |
2299 return WebGLAny(scriptState, DOMUint32Array::create(m_compressedTextureF
ormats.data(), m_compressedTextureFormats.size())); | 2302 return WebGLAny(scriptState, DOMUint32Array::create(m_compressedTextureF
ormats.data(), m_compressedTextureFormats.size())); |
2300 case GL_CULL_FACE: | 2303 case GL_CULL_FACE: |
2301 return getBooleanParameter(scriptState, pname); | 2304 return getBooleanParameter(scriptState, pname); |
2302 case GL_CULL_FACE_MODE: | 2305 case GL_CULL_FACE_MODE: |
2303 return getUnsignedIntParameter(scriptState, pname); | 2306 return getUnsignedIntParameter(scriptState, pname); |
2304 case GL_CURRENT_PROGRAM: | 2307 case GL_CURRENT_PROGRAM: |
2305 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_curre
ntProgram.get())); | 2308 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_curre
ntProgram.get())); |
2306 case GL_DEPTH_BITS: | 2309 case GL_DEPTH_BITS: |
2307 if (!m_framebufferBinding && !m_requestedAttributes->depth()) | 2310 if (!m_framebufferBinding && !m_requestedAttributes.depth()) |
2308 return WebGLAny(scriptState, intZero); | 2311 return WebGLAny(scriptState, intZero); |
2309 return getIntParameter(scriptState, pname); | 2312 return getIntParameter(scriptState, pname); |
2310 case GL_DEPTH_CLEAR_VALUE: | 2313 case GL_DEPTH_CLEAR_VALUE: |
2311 return getFloatParameter(scriptState, pname); | 2314 return getFloatParameter(scriptState, pname); |
2312 case GL_DEPTH_FUNC: | 2315 case GL_DEPTH_FUNC: |
2313 return getUnsignedIntParameter(scriptState, pname); | 2316 return getUnsignedIntParameter(scriptState, pname); |
2314 case GL_DEPTH_RANGE: | 2317 case GL_DEPTH_RANGE: |
2315 return getWebGLFloatArrayParameter(scriptState, pname); | 2318 return getWebGLFloatArrayParameter(scriptState, pname); |
2316 case GL_DEPTH_TEST: | 2319 case GL_DEPTH_TEST: |
2317 return getBooleanParameter(scriptState, pname); | 2320 return getBooleanParameter(scriptState, pname); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 return getUnsignedIntParameter(scriptState, pname); | 2399 return getUnsignedIntParameter(scriptState, pname); |
2397 case GL_STENCIL_BACK_PASS_DEPTH_PASS: | 2400 case GL_STENCIL_BACK_PASS_DEPTH_PASS: |
2398 return getUnsignedIntParameter(scriptState, pname); | 2401 return getUnsignedIntParameter(scriptState, pname); |
2399 case GL_STENCIL_BACK_REF: | 2402 case GL_STENCIL_BACK_REF: |
2400 return getIntParameter(scriptState, pname); | 2403 return getIntParameter(scriptState, pname); |
2401 case GL_STENCIL_BACK_VALUE_MASK: | 2404 case GL_STENCIL_BACK_VALUE_MASK: |
2402 return getUnsignedIntParameter(scriptState, pname); | 2405 return getUnsignedIntParameter(scriptState, pname); |
2403 case GL_STENCIL_BACK_WRITEMASK: | 2406 case GL_STENCIL_BACK_WRITEMASK: |
2404 return getUnsignedIntParameter(scriptState, pname); | 2407 return getUnsignedIntParameter(scriptState, pname); |
2405 case GL_STENCIL_BITS: | 2408 case GL_STENCIL_BITS: |
2406 if (!m_framebufferBinding && !m_requestedAttributes->stencil()) | 2409 if (!m_framebufferBinding && !m_requestedAttributes.stencil()) |
2407 return WebGLAny(scriptState, intZero); | 2410 return WebGLAny(scriptState, intZero); |
2408 return getIntParameter(scriptState, pname); | 2411 return getIntParameter(scriptState, pname); |
2409 case GL_STENCIL_CLEAR_VALUE: | 2412 case GL_STENCIL_CLEAR_VALUE: |
2410 return getIntParameter(scriptState, pname); | 2413 return getIntParameter(scriptState, pname); |
2411 case GL_STENCIL_FAIL: | 2414 case GL_STENCIL_FAIL: |
2412 return getUnsignedIntParameter(scriptState, pname); | 2415 return getUnsignedIntParameter(scriptState, pname); |
2413 case GL_STENCIL_FUNC: | 2416 case GL_STENCIL_FUNC: |
2414 return getUnsignedIntParameter(scriptState, pname); | 2417 return getUnsignedIntParameter(scriptState, pname); |
2415 case GL_STENCIL_PASS_DEPTH_FAIL: | 2418 case GL_STENCIL_PASS_DEPTH_FAIL: |
2416 return getUnsignedIntParameter(scriptState, pname); | 2419 return getUnsignedIntParameter(scriptState, pname); |
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4589 { | 4592 { |
4590 unsigned need = WebGLImageConversion::getChannelBitsByFormat(texInternalForm
at); | 4593 unsigned need = WebGLImageConversion::getChannelBitsByFormat(texInternalForm
at); |
4591 unsigned have = WebGLImageConversion::getChannelBitsByFormat(colorBufferForm
at); | 4594 unsigned have = WebGLImageConversion::getChannelBitsByFormat(colorBufferForm
at); |
4592 return (need & have) == need; | 4595 return (need & have) == need; |
4593 } | 4596 } |
4594 | 4597 |
4595 GLenum WebGLRenderingContextBase::boundFramebufferColorFormat() | 4598 GLenum WebGLRenderingContextBase::boundFramebufferColorFormat() |
4596 { | 4599 { |
4597 if (m_framebufferBinding && m_framebufferBinding->object()) | 4600 if (m_framebufferBinding && m_framebufferBinding->object()) |
4598 return m_framebufferBinding->colorBufferFormat(); | 4601 return m_framebufferBinding->colorBufferFormat(); |
4599 if (m_requestedAttributes->alpha()) | 4602 if (m_requestedAttributes.alpha()) |
4600 return GL_RGBA; | 4603 return GL_RGBA; |
4601 return GL_RGB; | 4604 return GL_RGB; |
4602 } | 4605 } |
4603 | 4606 |
4604 WebGLTexture* WebGLRenderingContextBase::validateTextureBinding(const char* func
tionName, GLenum target, bool useSixEnumsForCubeMap) | 4607 WebGLTexture* WebGLRenderingContextBase::validateTextureBinding(const char* func
tionName, GLenum target, bool useSixEnumsForCubeMap) |
4605 { | 4608 { |
4606 WebGLTexture* tex = nullptr; | 4609 WebGLTexture* tex = nullptr; |
4607 switch (target) { | 4610 switch (target) { |
4608 case GL_TEXTURE_2D: | 4611 case GL_TEXTURE_2D: |
4609 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); | 4612 tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get(); |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5596 // If the context was lost due to RealLostContext, we need to destroy the ol
d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou
gh. | 5599 // If the context was lost due to RealLostContext, we need to destroy the ol
d DrawingBuffer before creating new DrawingBuffer to ensure resource budget enou
gh. |
5597 if (drawingBuffer()) { | 5600 if (drawingBuffer()) { |
5598 #if ENABLE(OILPAN) | 5601 #if ENABLE(OILPAN) |
5599 m_sharedWebGraphicsContext3D->dispose(); | 5602 m_sharedWebGraphicsContext3D->dispose(); |
5600 #else | 5603 #else |
5601 m_drawingBuffer->beginDestruction(); | 5604 m_drawingBuffer->beginDestruction(); |
5602 m_drawingBuffer.clear(); | 5605 m_drawingBuffer.clear(); |
5603 #endif | 5606 #endif |
5604 } | 5607 } |
5605 | 5608 |
5606 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes->
attributes(canvas()->document().topDocument().url().string(), settings, version(
)); | 5609 blink::WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DA
ttributes(m_requestedAttributes, canvas()->document().topDocument().url().string
(), settings, version()); |
5607 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes, 0)); | 5610 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr
ent()->createOffscreenGraphicsContext3D(attributes, 0)); |
5608 RefPtr<DrawingBuffer> buffer; | 5611 RefPtr<DrawingBuffer> buffer; |
5609 if (context) { | 5612 if (context) { |
5610 // Construct a new drawing buffer with the new WebGraphicsContext3D. | 5613 // Construct a new drawing buffer with the new WebGraphicsContext3D. |
5611 buffer = createDrawingBuffer(context.release()); | 5614 buffer = createDrawingBuffer(context.release()); |
5612 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. | 5615 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| i
s set to null. |
5613 } | 5616 } |
5614 if (!buffer) { | 5617 if (!buffer) { |
5615 if (m_contextLostMode == RealLostContext) { | 5618 if (m_contextLostMode == RealLostContext) { |
5616 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE
); | 5619 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE
); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5735 InspectorInstrumentation::didFireWebGLWarning(canvas()); | 5738 InspectorInstrumentation::didFireWebGLWarning(canvas()); |
5736 } | 5739 } |
5737 | 5740 |
5738 void WebGLRenderingContextBase::applyStencilTest() | 5741 void WebGLRenderingContextBase::applyStencilTest() |
5739 { | 5742 { |
5740 bool haveStencilBuffer = false; | 5743 bool haveStencilBuffer = false; |
5741 | 5744 |
5742 if (m_framebufferBinding) | 5745 if (m_framebufferBinding) |
5743 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); | 5746 haveStencilBuffer = m_framebufferBinding->hasStencilBuffer(); |
5744 else { | 5747 else { |
5745 RefPtrWillBeRawPtr<WebGLContextAttributes> attributes = getContextAttrib
utes(); | 5748 Nullable<WebGLContextAttributes> attributes; |
5746 haveStencilBuffer = attributes->stencil(); | 5749 getContextAttributes(attributes); |
| 5750 haveStencilBuffer = !attributes.isNull() && attributes.get().stencil(); |
5747 } | 5751 } |
5748 enableOrDisable(GL_STENCIL_TEST, | 5752 enableOrDisable(GL_STENCIL_TEST, |
5749 m_stencilEnabled && haveStencilBuffer); | 5753 m_stencilEnabled && haveStencilBuffer); |
5750 } | 5754 } |
5751 | 5755 |
5752 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) | 5756 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) |
5753 { | 5757 { |
5754 if (isContextLost()) | 5758 if (isContextLost()) |
5755 return; | 5759 return; |
5756 if (enable) | 5760 if (enable) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5863 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; | 5867 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB
uffer() : 0; |
5864 } | 5868 } |
5865 #else | 5869 #else |
5866 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 5870 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
5867 { | 5871 { |
5868 return m_drawingBuffer.get(); | 5872 return m_drawingBuffer.get(); |
5869 } | 5873 } |
5870 #endif | 5874 #endif |
5871 | 5875 |
5872 } // namespace blink | 5876 } // namespace blink |
OLD | NEW |