Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 795833004: Use dictionaries for context creation attributes. Eliminate custom bindings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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
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
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 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 if (!program->linkStatus()) { 2090 if (!program->linkStatus()) {
2085 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no t linked"); 2091 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no t linked");
2086 return 0; 2092 return 0;
2087 } 2093 }
2088 return webContext()->getAttribLocation(objectOrZero(program), name.utf8().da ta()); 2094 return webContext()->getAttribLocation(objectOrZero(program), name.utf8().da ta());
2089 } 2095 }
2090 2096
2091 ScriptValue WebGLRenderingContextBase::getBufferParameter(ScriptState* scriptSta te, GLenum target, GLenum pname) 2097 ScriptValue WebGLRenderingContextBase::getBufferParameter(ScriptState* scriptSta te, GLenum target, GLenum pname)
2092 { 2098 {
2093 if (isContextLost()) 2099 if (isContextLost())
2094 return WebGLAny(scriptState); 2100 return ScriptValue::createNull(scriptState);
2095 if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) { 2101 if (target != GL_ARRAY_BUFFER && target != GL_ELEMENT_ARRAY_BUFFER) {
2096 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid target "); 2102 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid target ");
2097 return WebGLAny(scriptState); 2103 return ScriptValue::createNull(scriptState);
2098 } 2104 }
2099 2105
2100 if (pname != GL_BUFFER_SIZE && pname != GL_BUFFER_USAGE) { 2106 if (pname != GL_BUFFER_SIZE && pname != GL_BUFFER_USAGE) {
2101 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame ter name"); 2107 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame ter name");
2102 return WebGLAny(scriptState); 2108 return ScriptValue::createNull(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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 return extension.release(); 2189 return extension.release();
2187 } 2190 }
2188 } 2191 }
2189 2192
2190 return nullptr; 2193 return nullptr;
2191 } 2194 }
2192 2195
2193 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) 2196 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname)
2194 { 2197 {
2195 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) 2198 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment))
2196 return WebGLAny(scriptState); 2199 return ScriptValue::createNull(scriptState);
2197 2200
2198 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2201 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2199 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); 2202 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound");
2200 return WebGLAny(scriptState); 2203 return ScriptValue::createNull(scriptState);
2201 } 2204 }
2202 2205
2203 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); 2206 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment);
2204 if (!object) { 2207 if (!object) {
2205 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) 2208 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)
2206 return WebGLAny(scriptState, GL_NONE); 2209 return WebGLAny(scriptState, GL_NONE);
2207 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL 2210 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL
2208 // specifies INVALID_OPERATION. 2211 // specifies INVALID_OPERATION.
2209 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); 2212 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
2210 return WebGLAny(scriptState); 2213 return ScriptValue::createNull(scriptState);
2211 } 2214 }
2212 2215
2213 ASSERT(object->isTexture() || object->isRenderbuffer()); 2216 ASSERT(object->isTexture() || object->isRenderbuffer());
2214 if (object->isTexture()) { 2217 if (object->isTexture()) {
2215 switch (pname) { 2218 switch (pname) {
2216 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2219 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2217 return WebGLAny(scriptState, GL_TEXTURE); 2220 return WebGLAny(scriptState, GL_TEXTURE);
2218 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2221 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2219 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2222 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect));
2220 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 2223 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2221 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 2224 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2222 { 2225 {
2223 GLint value = 0; 2226 GLint value = 0;
2224 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2227 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2225 return WebGLAny(scriptState, value); 2228 return WebGLAny(scriptState, value);
2226 } 2229 }
2227 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2230 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2228 if (extensionEnabled(EXTsRGBName)) { 2231 if (extensionEnabled(EXTsRGBName)) {
2229 GLint value = 0; 2232 GLint value = 0;
2230 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2233 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2231 return WebGLAny(scriptState, value); 2234 return WebGLAny(scriptState, value);
2232 } 2235 }
2233 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2236 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2234 return WebGLAny(scriptState); 2237 return ScriptValue::createNull(scriptState);
2235 default: 2238 default:
2236 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); 2239 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment");
2237 return WebGLAny(scriptState); 2240 return ScriptValue::createNull(scriptState);
2238 } 2241 }
2239 } else { 2242 } else {
2240 switch (pname) { 2243 switch (pname) {
2241 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2244 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2242 return WebGLAny(scriptState, GL_RENDERBUFFER); 2245 return WebGLAny(scriptState, GL_RENDERBUFFER);
2243 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2246 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2244 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2247 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect));
2245 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2248 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2246 if (extensionEnabled(EXTsRGBName)) { 2249 if (extensionEnabled(EXTsRGBName)) {
2247 GLint value = 0; 2250 GLint value = 0;
2248 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2251 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2249 return WebGLAny(scriptState, value); 2252 return WebGLAny(scriptState, value);
2250 } 2253 }
2251 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2254 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2252 return WebGLAny(scriptState); 2255 return ScriptValue::createNull(scriptState);
2253 default: 2256 default:
2254 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2257 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2255 return WebGLAny(scriptState); 2258 return ScriptValue::createNull(scriptState);
2256 } 2259 }
2257 } 2260 }
2258 } 2261 }
2259 2262
2260 ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* scriptState, GL enum pname) 2263 ScriptValue WebGLRenderingContextBase::getParameter(ScriptState* scriptState, GL enum pname)
2261 { 2264 {
2262 if (isContextLost()) 2265 if (isContextLost())
2263 return WebGLAny(scriptState); 2266 return ScriptValue::createNull(scriptState);
2264 const int intZero = 0; 2267 const int intZero = 0;
2265 switch (pname) { 2268 switch (pname) {
2266 case GL_ACTIVE_TEXTURE: 2269 case GL_ACTIVE_TEXTURE:
2267 return getUnsignedIntParameter(scriptState, pname); 2270 return getUnsignedIntParameter(scriptState, pname);
2268 case GL_ALIASED_LINE_WIDTH_RANGE: 2271 case GL_ALIASED_LINE_WIDTH_RANGE:
2269 return getWebGLFloatArrayParameter(scriptState, pname); 2272 return getWebGLFloatArrayParameter(scriptState, pname);
2270 case GL_ALIASED_POINT_SIZE_RANGE: 2273 case GL_ALIASED_POINT_SIZE_RANGE:
2271 return getWebGLFloatArrayParameter(scriptState, pname); 2274 return getWebGLFloatArrayParameter(scriptState, pname);
2272 case GL_ALPHA_BITS: 2275 case GL_ALPHA_BITS:
2273 return getIntParameter(scriptState, pname); 2276 return getIntParameter(scriptState, pname);
(...skipping 23 matching lines...) Expand all
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
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 24 matching lines...) Expand all
2441 case GL_VENDOR: 2444 case GL_VENDOR:
2442 return WebGLAny(scriptState, String("WebKit")); 2445 return WebGLAny(scriptState, String("WebKit"));
2443 case GL_VERSION: 2446 case GL_VERSION:
2444 return WebGLAny(scriptState, "WebGL 1.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")"); 2447 return WebGLAny(scriptState, "WebGL 1.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")");
2445 case GL_VIEWPORT: 2448 case GL_VIEWPORT:
2446 return getWebGLIntArrayParameter(scriptState, pname); 2449 return getWebGLIntArrayParameter(scriptState, pname);
2447 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives 2450 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives
2448 if (extensionEnabled(OESStandardDerivativesName)) 2451 if (extensionEnabled(OESStandardDerivativesName))
2449 return getUnsignedIntParameter(scriptState, GL_FRAGMENT_SHADER_DERIV ATIVE_HINT_OES); 2452 return getUnsignedIntParameter(scriptState, GL_FRAGMENT_SHADER_DERIV ATIVE_HINT_OES);
2450 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_standard_derivatives not enabled"); 2453 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_standard_derivatives not enabled");
2451 return WebGLAny(scriptState); 2454 return ScriptValue::createNull(scriptState);
2452 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: 2455 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
2453 if (extensionEnabled(WebGLDebugRendererInfoName)) 2456 if (extensionEnabled(WebGLDebugRendererInfoName))
2454 return WebGLAny(scriptState, webContext()->getString(GL_RENDERER)); 2457 return WebGLAny(scriptState, webContext()->getString(GL_RENDERER));
2455 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); 2458 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2456 return WebGLAny(scriptState); 2459 return ScriptValue::createNull(scriptState);
2457 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: 2460 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL:
2458 if (extensionEnabled(WebGLDebugRendererInfoName)) 2461 if (extensionEnabled(WebGLDebugRendererInfoName))
2459 return WebGLAny(scriptState, webContext()->getString(GL_VENDOR)); 2462 return WebGLAny(scriptState, webContext()->getString(GL_VENDOR));
2460 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); 2463 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2461 return WebGLAny(scriptState); 2464 return ScriptValue::createNull(scriptState);
2462 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object 2465 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
2463 if (extensionEnabled(OESVertexArrayObjectName)) { 2466 if (extensionEnabled(OESVertexArrayObjectName)) {
2464 if (!m_boundVertexArrayObject->isDefaultObject()) 2467 if (!m_boundVertexArrayObject->isDefaultObject())
2465 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject> (m_boundVertexArrayObject.get())); 2468 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject> (m_boundVertexArrayObject.get()));
2466 return WebGLAny(scriptState); 2469 return ScriptValue::createNull(scriptState);
2467 } 2470 }
2468 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled"); 2471 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled");
2469 return WebGLAny(scriptState); 2472 return ScriptValue::createNull(scriptState);
2470 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic 2473 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic
2471 if (extensionEnabled(EXTTextureFilterAnisotropicName)) 2474 if (extensionEnabled(EXTTextureFilterAnisotropicName))
2472 return getUnsignedIntParameter(scriptState, GL_MAX_TEXTURE_MAX_ANISO TROPY_EXT); 2475 return getUnsignedIntParameter(scriptState, GL_MAX_TEXTURE_MAX_ANISO TROPY_EXT);
2473 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled"); 2476 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled");
2474 return WebGLAny(scriptState); 2477 return ScriptValue::createNull(scriptState);
2475 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN 2478 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN
2476 if (extensionEnabled(WebGLDrawBuffersName)) 2479 if (extensionEnabled(WebGLDrawBuffersName))
2477 return WebGLAny(scriptState, maxColorAttachments()); 2480 return WebGLAny(scriptState, maxColorAttachments());
2478 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled"); 2481 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled");
2479 return WebGLAny(scriptState); 2482 return ScriptValue::createNull(scriptState);
2480 case GL_MAX_DRAW_BUFFERS_EXT: 2483 case GL_MAX_DRAW_BUFFERS_EXT:
2481 if (extensionEnabled(WebGLDrawBuffersName)) 2484 if (extensionEnabled(WebGLDrawBuffersName))
2482 return WebGLAny(scriptState, maxDrawBuffers()); 2485 return WebGLAny(scriptState, maxDrawBuffers());
2483 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled"); 2486 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled");
2484 return WebGLAny(scriptState); 2487 return ScriptValue::createNull(scriptState);
2485 default: 2488 default:
2486 if (extensionEnabled(WebGLDrawBuffersName) 2489 if (extensionEnabled(WebGLDrawBuffersName)
2487 && pname >= GL_DRAW_BUFFER0_EXT 2490 && pname >= GL_DRAW_BUFFER0_EXT
2488 && pname < static_cast<GLenum>(GL_DRAW_BUFFER0_EXT + maxDrawBuffers( ))) { 2491 && pname < static_cast<GLenum>(GL_DRAW_BUFFER0_EXT + maxDrawBuffers( ))) {
2489 GLint value = GL_NONE; 2492 GLint value = GL_NONE;
2490 if (m_framebufferBinding) 2493 if (m_framebufferBinding)
2491 value = m_framebufferBinding->getDrawBuffer(pname); 2494 value = m_framebufferBinding->getDrawBuffer(pname);
2492 else // emulated backbuffer 2495 else // emulated backbuffer
2493 value = m_backDrawBuffer; 2496 value = m_backDrawBuffer;
2494 return WebGLAny(scriptState, value); 2497 return WebGLAny(scriptState, value);
2495 } 2498 }
2496 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me"); 2499 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me");
2497 return WebGLAny(scriptState); 2500 return ScriptValue::createNull(scriptState);
2498 } 2501 }
2499 } 2502 }
2500 2503
2501 ScriptValue WebGLRenderingContextBase::getProgramParameter(ScriptState* scriptSt ate, WebGLProgram* program, GLenum pname) 2504 ScriptValue WebGLRenderingContextBase::getProgramParameter(ScriptState* scriptSt ate, WebGLProgram* program, GLenum pname)
2502 { 2505 {
2503 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) 2506 if (isContextLost() || !validateWebGLObject("getProgramParameter", program))
2504 return WebGLAny(scriptState); 2507 return ScriptValue::createNull(scriptState);
2505 2508
2506 GLint value = 0; 2509 GLint value = 0;
2507 switch (pname) { 2510 switch (pname) {
2508 case GL_DELETE_STATUS: 2511 case GL_DELETE_STATUS:
2509 return WebGLAny(scriptState, program->isDeleted()); 2512 return WebGLAny(scriptState, program->isDeleted());
2510 case GL_VALIDATE_STATUS: 2513 case GL_VALIDATE_STATUS:
2511 webContext()->getProgramiv(objectOrZero(program), pname, &value); 2514 webContext()->getProgramiv(objectOrZero(program), pname, &value);
2512 return WebGLAny(scriptState, static_cast<bool>(value)); 2515 return WebGLAny(scriptState, static_cast<bool>(value));
2513 case GL_LINK_STATUS: 2516 case GL_LINK_STATUS:
2514 return WebGLAny(scriptState, program->linkStatus()); 2517 return WebGLAny(scriptState, program->linkStatus());
2515 case GL_ATTACHED_SHADERS: 2518 case GL_ATTACHED_SHADERS:
2516 case GL_ACTIVE_ATTRIBUTES: 2519 case GL_ACTIVE_ATTRIBUTES:
2517 case GL_ACTIVE_UNIFORMS: 2520 case GL_ACTIVE_UNIFORMS:
2518 webContext()->getProgramiv(objectOrZero(program), pname, &value); 2521 webContext()->getProgramiv(objectOrZero(program), pname, &value);
2519 return WebGLAny(scriptState, value); 2522 return WebGLAny(scriptState, value);
2520 default: 2523 default:
2521 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param eter name"); 2524 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param eter name");
2522 return WebGLAny(scriptState); 2525 return ScriptValue::createNull(scriptState);
2523 } 2526 }
2524 } 2527 }
2525 2528
2526 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) 2529 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program)
2527 { 2530 {
2528 if (isContextLost()) 2531 if (isContextLost())
2529 return String(); 2532 return String();
2530 if (!validateWebGLObject("getProgramInfoLog", program)) 2533 if (!validateWebGLObject("getProgramInfoLog", program))
2531 return ""; 2534 return "";
2532 return ensureNotNull(webContext()->getProgramInfoLog(objectOrZero(program))) ; 2535 return ensureNotNull(webContext()->getProgramInfoLog(objectOrZero(program))) ;
2533 } 2536 }
2534 2537
2535 ScriptValue WebGLRenderingContextBase::getRenderbufferParameter(ScriptState* scr iptState, GLenum target, GLenum pname) 2538 ScriptValue WebGLRenderingContextBase::getRenderbufferParameter(ScriptState* scr iptState, GLenum target, GLenum pname)
2536 { 2539 {
2537 if (isContextLost()) 2540 if (isContextLost())
2538 return WebGLAny(scriptState); 2541 return ScriptValue::createNull(scriptState);
2539 if (target != GL_RENDERBUFFER) { 2542 if (target != GL_RENDERBUFFER) {
2540 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid target"); 2543 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid target");
2541 return WebGLAny(scriptState); 2544 return ScriptValue::createNull(scriptState);
2542 } 2545 }
2543 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) { 2546 if (!m_renderbufferBinding || !m_renderbufferBinding->object()) {
2544 synthesizeGLError(GL_INVALID_OPERATION, "getRenderbufferParameter", "no renderbuffer bound"); 2547 synthesizeGLError(GL_INVALID_OPERATION, "getRenderbufferParameter", "no renderbuffer bound");
2545 return WebGLAny(scriptState); 2548 return ScriptValue::createNull(scriptState);
2546 } 2549 }
2547 2550
2548 GLint value = 0; 2551 GLint value = 0;
2549 switch (pname) { 2552 switch (pname) {
2550 case GL_RENDERBUFFER_WIDTH: 2553 case GL_RENDERBUFFER_WIDTH:
2551 case GL_RENDERBUFFER_HEIGHT: 2554 case GL_RENDERBUFFER_HEIGHT:
2552 case GL_RENDERBUFFER_RED_SIZE: 2555 case GL_RENDERBUFFER_RED_SIZE:
2553 case GL_RENDERBUFFER_GREEN_SIZE: 2556 case GL_RENDERBUFFER_GREEN_SIZE:
2554 case GL_RENDERBUFFER_BLUE_SIZE: 2557 case GL_RENDERBUFFER_BLUE_SIZE:
2555 case GL_RENDERBUFFER_ALPHA_SIZE: 2558 case GL_RENDERBUFFER_ALPHA_SIZE:
2556 case GL_RENDERBUFFER_DEPTH_SIZE: 2559 case GL_RENDERBUFFER_DEPTH_SIZE:
2557 webContext()->getRenderbufferParameteriv(target, pname, &value); 2560 webContext()->getRenderbufferParameteriv(target, pname, &value);
2558 return WebGLAny(scriptState, value); 2561 return WebGLAny(scriptState, value);
2559 case GL_RENDERBUFFER_STENCIL_SIZE: 2562 case GL_RENDERBUFFER_STENCIL_SIZE:
2560 if (m_renderbufferBinding->emulatedStencilBuffer()) { 2563 if (m_renderbufferBinding->emulatedStencilBuffer()) {
2561 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi nding->emulatedStencilBuffer())); 2564 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi nding->emulatedStencilBuffer()));
2562 webContext()->getRenderbufferParameteriv(target, pname, &value); 2565 webContext()->getRenderbufferParameteriv(target, pname, &value);
2563 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi nding.get())); 2566 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBi nding.get()));
2564 } else { 2567 } else {
2565 webContext()->getRenderbufferParameteriv(target, pname, &value); 2568 webContext()->getRenderbufferParameteriv(target, pname, &value);
2566 } 2569 }
2567 return WebGLAny(scriptState, value); 2570 return WebGLAny(scriptState, value);
2568 case GL_RENDERBUFFER_INTERNAL_FORMAT: 2571 case GL_RENDERBUFFER_INTERNAL_FORMAT:
2569 return WebGLAny(scriptState, m_renderbufferBinding->internalFormat()); 2572 return WebGLAny(scriptState, m_renderbufferBinding->internalFormat());
2570 default: 2573 default:
2571 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name"); 2574 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid parameter name");
2572 return WebGLAny(scriptState); 2575 return ScriptValue::createNull(scriptState);
2573 } 2576 }
2574 } 2577 }
2575 2578
2576 ScriptValue WebGLRenderingContextBase::getShaderParameter(ScriptState* scriptSta te, WebGLShader* shader, GLenum pname) 2579 ScriptValue WebGLRenderingContextBase::getShaderParameter(ScriptState* scriptSta te, WebGLShader* shader, GLenum pname)
2577 { 2580 {
2578 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) 2581 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader))
2579 return WebGLAny(scriptState); 2582 return ScriptValue::createNull(scriptState);
2580 GLint value = 0; 2583 GLint value = 0;
2581 switch (pname) { 2584 switch (pname) {
2582 case GL_DELETE_STATUS: 2585 case GL_DELETE_STATUS:
2583 return WebGLAny(scriptState, shader->isDeleted()); 2586 return WebGLAny(scriptState, shader->isDeleted());
2584 case GL_COMPILE_STATUS: 2587 case GL_COMPILE_STATUS:
2585 webContext()->getShaderiv(objectOrZero(shader), pname, &value); 2588 webContext()->getShaderiv(objectOrZero(shader), pname, &value);
2586 return WebGLAny(scriptState, static_cast<bool>(value)); 2589 return WebGLAny(scriptState, static_cast<bool>(value));
2587 case GL_SHADER_TYPE: 2590 case GL_SHADER_TYPE:
2588 webContext()->getShaderiv(objectOrZero(shader), pname, &value); 2591 webContext()->getShaderiv(objectOrZero(shader), pname, &value);
2589 return WebGLAny(scriptState, static_cast<unsigned>(value)); 2592 return WebGLAny(scriptState, static_cast<unsigned>(value));
2590 default: 2593 default:
2591 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame ter name"); 2594 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame ter name");
2592 return WebGLAny(scriptState); 2595 return ScriptValue::createNull(scriptState);
2593 } 2596 }
2594 } 2597 }
2595 2598
2596 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) 2599 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader)
2597 { 2600 {
2598 if (isContextLost()) 2601 if (isContextLost())
2599 return String(); 2602 return String();
2600 if (!validateWebGLObject("getShaderInfoLog", shader)) 2603 if (!validateWebGLObject("getShaderInfoLog", shader))
2601 return ""; 2604 return "";
2602 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader))); 2605 return ensureNotNull(webContext()->getShaderInfoLog(objectOrZero(shader)));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 } 2662 }
2660 } 2663 }
2661 } 2664 }
2662 2665
2663 return result; 2666 return result;
2664 } 2667 }
2665 2668
2666 ScriptValue WebGLRenderingContextBase::getTexParameter(ScriptState* scriptState, GLenum target, GLenum pname) 2669 ScriptValue WebGLRenderingContextBase::getTexParameter(ScriptState* scriptState, GLenum target, GLenum pname)
2667 { 2670 {
2668 if (isContextLost()) 2671 if (isContextLost())
2669 return WebGLAny(scriptState); 2672 return ScriptValue::createNull(scriptState);
2670 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ; 2673 WebGLTexture* tex = validateTextureBinding("getTexParameter", target, false) ;
2671 if (!tex) 2674 if (!tex)
2672 return WebGLAny(scriptState); 2675 return ScriptValue::createNull(scriptState);
2673 switch (pname) { 2676 switch (pname) {
2674 case GL_TEXTURE_MAG_FILTER: 2677 case GL_TEXTURE_MAG_FILTER:
2675 case GL_TEXTURE_MIN_FILTER: 2678 case GL_TEXTURE_MIN_FILTER:
2676 case GL_TEXTURE_WRAP_S: 2679 case GL_TEXTURE_WRAP_S:
2677 case GL_TEXTURE_WRAP_T: 2680 case GL_TEXTURE_WRAP_T:
2678 { 2681 {
2679 GLint value = 0; 2682 GLint value = 0;
2680 webContext()->getTexParameteriv(target, pname, &value); 2683 webContext()->getTexParameteriv(target, pname, &value);
2681 return WebGLAny(scriptState, static_cast<unsigned>(value)); 2684 return WebGLAny(scriptState, static_cast<unsigned>(value));
2682 } 2685 }
2683 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic 2686 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic
2684 if (extensionEnabled(EXTTextureFilterAnisotropicName)) { 2687 if (extensionEnabled(EXTTextureFilterAnisotropicName)) {
2685 GLfloat value = 0.f; 2688 GLfloat value = 0.f;
2686 webContext()->getTexParameterfv(target, pname, &value); 2689 webContext()->getTexParameterfv(target, pname, &value);
2687 return WebGLAny(scriptState, value); 2690 return WebGLAny(scriptState, value);
2688 } 2691 }
2689 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled"); 2692 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled");
2690 return WebGLAny(scriptState); 2693 return ScriptValue::createNull(scriptState);
2691 default: 2694 default:
2692 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name"); 2695 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name");
2693 return WebGLAny(scriptState); 2696 return ScriptValue::createNull(scriptState);
2694 } 2697 }
2695 } 2698 }
2696 2699
2697 ScriptValue WebGLRenderingContextBase::getUniform(ScriptState* scriptState, WebG LProgram* program, const WebGLUniformLocation* uniformLocation) 2700 ScriptValue WebGLRenderingContextBase::getUniform(ScriptState* scriptState, WebG LProgram* program, const WebGLUniformLocation* uniformLocation)
2698 { 2701 {
2699 if (isContextLost() || !validateWebGLObject("getUniform", program)) 2702 if (isContextLost() || !validateWebGLObject("getUniform", program))
2700 return WebGLAny(scriptState); 2703 return ScriptValue::createNull(scriptState);
2701 if (!uniformLocation || uniformLocation->program() != program) { 2704 if (!uniformLocation || uniformLocation->program() != program) {
2702 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio n or not valid for this program"); 2705 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio n or not valid for this program");
2703 return WebGLAny(scriptState); 2706 return ScriptValue::createNull(scriptState);
2704 } 2707 }
2705 GLint location = uniformLocation->location(); 2708 GLint location = uniformLocation->location();
2706 2709
2707 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it 2710 // FIXME: make this more efficient using WebGLUniformLocation and caching ty pes in it
2708 GLint activeUniforms = 0; 2711 GLint activeUniforms = 0;
2709 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activ eUniforms); 2712 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activ eUniforms);
2710 for (GLint i = 0; i < activeUniforms; i++) { 2713 for (GLint i = 0; i < activeUniforms; i++) {
2711 blink::WebGraphicsContext3D::ActiveInfo info; 2714 blink::WebGraphicsContext3D::ActiveInfo info;
2712 if (!webContext()->getActiveUniform(objectOrZero(program), i, info)) 2715 if (!webContext()->getActiveUniform(objectOrZero(program), i, info))
2713 return WebGLAny(scriptState); 2716 return ScriptValue::createNull(scriptState);
2714 String name = info.name; 2717 String name = info.name;
2715 StringBuilder nameBuilder; 2718 StringBuilder nameBuilder;
2716 // Strip "[0]" from the name if it's an array. 2719 // Strip "[0]" from the name if it's an array.
2717 if (info.size > 1 && name.endsWith("[0]")) 2720 if (info.size > 1 && name.endsWith("[0]"))
2718 info.name = name.left(name.length() - 3); 2721 info.name = name.left(name.length() - 3);
2719 // If it's an array, we need to iterate through each element, appending "[index]" to the name. 2722 // If it's an array, we need to iterate through each element, appending "[index]" to the name.
2720 for (GLint index = 0; index < info.size; ++index) { 2723 for (GLint index = 0; index < info.size; ++index) {
2721 nameBuilder.clear(); 2724 nameBuilder.clear();
2722 nameBuilder.append(info.name); 2725 nameBuilder.append(info.name);
2723 if (info.size > 1 && index >= 1) { 2726 if (info.size > 1 && index >= 1) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 length = 16; 2796 length = 16;
2794 break; 2797 break;
2795 case GL_SAMPLER_2D: 2798 case GL_SAMPLER_2D:
2796 case GL_SAMPLER_CUBE: 2799 case GL_SAMPLER_CUBE:
2797 baseType = GL_INT; 2800 baseType = GL_INT;
2798 length = 1; 2801 length = 1;
2799 break; 2802 break;
2800 default: 2803 default:
2801 // Can't handle this type 2804 // Can't handle this type
2802 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhandled type"); 2805 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhandled type");
2803 return WebGLAny(scriptState); 2806 return ScriptValue::createNull(scriptState);
2804 } 2807 }
2805 switch (baseType) { 2808 switch (baseType) {
2806 case GL_FLOAT: { 2809 case GL_FLOAT: {
2807 GLfloat value[16] = {0}; 2810 GLfloat value[16] = {0};
2808 webContext()->getUniformfv(objectOrZero(program), location, value); 2811 webContext()->getUniformfv(objectOrZero(program), location, value);
2809 if (length == 1) 2812 if (length == 1)
2810 return WebGLAny(scriptState, value[0]); 2813 return WebGLAny(scriptState, value[0]);
2811 return WebGLAny(scriptState, DOMFloat32Array::create(value, length)); 2814 return WebGLAny(scriptState, DOMFloat32Array::create(value, length));
2812 } 2815 }
2813 case GL_INT: { 2816 case GL_INT: {
(...skipping 15 matching lines...) Expand all
2829 return WebGLAny(scriptState, static_cast<bool>(value[0])); 2832 return WebGLAny(scriptState, static_cast<bool>(value[0]));
2830 } 2833 }
2831 default: 2834 default:
2832 notImplemented(); 2835 notImplemented();
2833 } 2836 }
2834 } 2837 }
2835 } 2838 }
2836 } 2839 }
2837 // If we get here, something went wrong in our unfortunately complex logic a bove 2840 // If we get here, something went wrong in our unfortunately complex logic a bove
2838 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error"); 2841 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unknown error");
2839 return WebGLAny(scriptState); 2842 return ScriptValue::createNull(scriptState);
2840 } 2843 }
2841 2844
2842 PassRefPtrWillBeRawPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUnifo rmLocation(WebGLProgram* program, const String& name) 2845 PassRefPtrWillBeRawPtr<WebGLUniformLocation> WebGLRenderingContextBase::getUnifo rmLocation(WebGLProgram* program, const String& name)
2843 { 2846 {
2844 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) 2847 if (isContextLost() || !validateWebGLObject("getUniformLocation", program))
2845 return nullptr; 2848 return nullptr;
2846 if (!validateLocationLength("getUniformLocation", name)) 2849 if (!validateLocationLength("getUniformLocation", name))
2847 return nullptr; 2850 return nullptr;
2848 if (!validateString("getUniformLocation", name)) 2851 if (!validateString("getUniformLocation", name))
2849 return nullptr; 2852 return nullptr;
2850 if (isPrefixReserved(name)) 2853 if (isPrefixReserved(name))
2851 return nullptr; 2854 return nullptr;
2852 if (!program->linkStatus()) { 2855 if (!program->linkStatus()) {
2853 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n ot linked"); 2856 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n ot linked");
2854 return nullptr; 2857 return nullptr;
2855 } 2858 }
2856 GLint uniformLocation = webContext()->getUniformLocation(objectOrZero(progra m), name.utf8().data()); 2859 GLint uniformLocation = webContext()->getUniformLocation(objectOrZero(progra m), name.utf8().data());
2857 if (uniformLocation == -1) 2860 if (uniformLocation == -1)
2858 return nullptr; 2861 return nullptr;
2859 return WebGLUniformLocation::create(program, uniformLocation); 2862 return WebGLUniformLocation::create(program, uniformLocation);
2860 } 2863 }
2861 2864
2862 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState, GLuint index, GLenum pname) 2865 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState, GLuint index, GLenum pname)
2863 { 2866 {
2864 if (isContextLost()) 2867 if (isContextLost())
2865 return WebGLAny(scriptState); 2868 return ScriptValue::createNull(scriptState);
2866 if (index >= m_maxVertexAttribs) { 2869 if (index >= m_maxVertexAttribs) {
2867 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge"); 2870 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge");
2868 return WebGLAny(scriptState); 2871 return ScriptValue::createNull(scriptState);
2869 } 2872 }
2870 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); 2873 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index);
2871 2874
2872 if (extensionEnabled(ANGLEInstancedArraysName) && pname == GL_VERTEX_ATTRIB_ ARRAY_DIVISOR_ANGLE) 2875 if (extensionEnabled(ANGLEInstancedArraysName) && pname == GL_VERTEX_ATTRIB_ ARRAY_DIVISOR_ANGLE)
2873 return WebGLAny(scriptState, state.divisor); 2876 return WebGLAny(scriptState, state.divisor);
2874 2877
2875 switch (pname) { 2878 switch (pname) {
2876 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 2879 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
2877 if (!state.bufferBinding || !state.bufferBinding->object()) 2880 if (!state.bufferBinding || !state.bufferBinding->object())
2878 return WebGLAny(scriptState); 2881 return ScriptValue::createNull(scriptState);
2879 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(state.b ufferBinding.get())); 2882 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(state.b ufferBinding.get()));
2880 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: 2883 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
2881 return WebGLAny(scriptState, state.enabled); 2884 return WebGLAny(scriptState, state.enabled);
2882 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: 2885 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
2883 return WebGLAny(scriptState, state.normalized); 2886 return WebGLAny(scriptState, state.normalized);
2884 case GL_VERTEX_ATTRIB_ARRAY_SIZE: 2887 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
2885 return WebGLAny(scriptState, state.size); 2888 return WebGLAny(scriptState, state.size);
2886 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: 2889 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
2887 return WebGLAny(scriptState, state.originalStride); 2890 return WebGLAny(scriptState, state.originalStride);
2888 case GL_VERTEX_ATTRIB_ARRAY_TYPE: 2891 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
2889 return WebGLAny(scriptState, state.type); 2892 return WebGLAny(scriptState, state.type);
2890 case GL_CURRENT_VERTEX_ATTRIB: 2893 case GL_CURRENT_VERTEX_ATTRIB:
2891 return WebGLAny(scriptState, DOMFloat32Array::create(m_vertexAttribValue [index].value, 4)); 2894 return WebGLAny(scriptState, DOMFloat32Array::create(m_vertexAttribValue [index].value, 4));
2892 default: 2895 default:
2893 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttrib", "invalid parameter name"); 2896 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttrib", "invalid parameter name");
2894 return WebGLAny(scriptState); 2897 return ScriptValue::createNull(scriptState);
2895 } 2898 }
2896 } 2899 }
2897 2900
2898 long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum pname) 2901 long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum pname)
2899 { 2902 {
2900 if (isContextLost()) 2903 if (isContextLost())
2901 return 0; 2904 return 0;
2902 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) { 2905 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) {
2903 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid par ameter name"); 2906 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttribOffset", "invalid par ameter name");
2904 return 0; 2907 return 0;
(...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | Source/core/html/canvas/WebGLRenderingContextBase.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698