Attachment #676065: Two different solutions for bug #801986

View | Details | Raw Unified | Return to bug 801986
Collapse All | Expand All

(-)a/content/canvas/src/WebGLContext.h (-8 / +40 lines)
Line     Link Here 
 Lines 2861-2880   public: Link Here 
2861
            if (attachment != LOCAL_GL_COLOR_ATTACHMENT0)
2861
            if (attachment != LOCAL_GL_COLOR_ATTACHMENT0)
2862
                return mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: attachment", attachment);
2862
                return mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: attachment", attachment);
2863
2863
2864
            mColorAttachment.SetRenderbuffer(wrb);
2864
            mColorAttachment.SetRenderbuffer(wrb);
2865
            break;
2865
            break;
2866
        }
2866
        }
2867
2867
2868
        mContext->MakeContextCurrent();
2868
        mContext->MakeContextCurrent();
2869
        WebGLuint renderbuffername = wrb ? wrb->GLName() : 0;
2869
2870
        WebGLuint renderbuffername = wrb ? wrb->GLName() : 
2871
            ((attachment == LOCAL_GL_DEPTH_ATTACHMENT || attachment == LOCAL_GL_STENCIL_ATTACHMENT) 
2872
             && mDepthStencilAttachment.Renderbuffer()) ? 
2873
            mDepthStencilAttachment.Renderbuffer()->GLName() : 0;
2874
2875
        WebGLuint depthbuffername = wrb ? renderbuffername : 
2876
            (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT && mDepthAttachment.Renderbuffer()) ? 
2877
            mDepthAttachment.Renderbuffer()->GLName() : 0;
2878
2879
        WebGLuint stencilbuffername = wrb ? renderbuffername :
2880
            (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT && mStencilAttachment.Renderbuffer()) ? 
2881
            mStencilAttachment.Renderbuffer()->GLName() : 0;
2882
2870
        if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
2883
        if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
2871
            mContext->gl->fFramebufferRenderbuffer(target, LOCAL_GL_DEPTH_ATTACHMENT, rbtarget, renderbuffername);
2884
            mContext->gl->fFramebufferRenderbuffer(target, LOCAL_GL_DEPTH_ATTACHMENT, rbtarget, depthbuffername);
2872
            mContext->gl->fFramebufferRenderbuffer(target, LOCAL_GL_STENCIL_ATTACHMENT, rbtarget, renderbuffername);
2885
            mContext->gl->fFramebufferRenderbuffer(target, LOCAL_GL_STENCIL_ATTACHMENT, rbtarget, stencilbuffername);
2873
        } else {
2886
        } else {
2874
            mContext->gl->fFramebufferRenderbuffer(target, attachment, rbtarget, renderbuffername);
2887
            mContext->gl->fFramebufferRenderbuffer(target, attachment, rbtarget, renderbuffername);
2875
        }
2888
        }
2876
    }
2889
    }
2877
2890
2878
    void FramebufferTexture2D(WebGLenum target,
2891
    void FramebufferTexture2D(WebGLenum target,
2879
                              WebGLenum attachment,
2892
                              WebGLenum attachment,
2880
                              WebGLenum textarget,
2893
                              WebGLenum textarget,
 Lines 2914-2934   public: Link Here 
2914
                return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: attachment", attachment);
2927
                return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: attachment", attachment);
2915
2928
2916
            mColorAttachment.SetTexture(wtex, level, face);
2929
            mColorAttachment.SetTexture(wtex, level, face);
2917
            break;
2930
            break;
2918
        }
2931
        }
2919
2932
2920
        mContext->MakeContextCurrent();
2933
        mContext->MakeContextCurrent();
2921
        WebGLuint texturename = wtex ? wtex->GLName() : 0;
2934
        WebGLuint texturename = wtex ? wtex->GLName() : 0;
2922
        if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
2935
        if(wtex) {
2923
            mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_DEPTH_ATTACHMENT, textarget, texturename, level);
2936
            if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
2924
            mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_STENCIL_ATTACHMENT, textarget, texturename, level);
2937
                mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_DEPTH_ATTACHMENT, textarget, texturename, level);
2925
        } else {
2938
                mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_STENCIL_ATTACHMENT, textarget, texturename, level);
2926
            mContext->gl->fFramebufferTexture2D(target, attachment, textarget, texturename, level);
2939
            } else {
2940
                mContext->gl->fFramebufferTexture2D(target, attachment, textarget, texturename, level);
2941
            }
2942
        }
2943
        // If we are detaching a texture, we should restore any textures that require restoration.
2944
        else { 
2945
            if (attachment == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
2946
                WebGLuint depthtexturename = mDepthAttachment.Texture() ? mDepthAttachment.Texture()->GLName() : 0;
2947
                mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_DEPTH_ATTACHMENT, textarget, depthtexturename, level);
2948
2949
                WebGLuint stenciltexturename = mStencilAttachment.Texture() ? mStencilAttachment.Texture()->GLName() : 0;
2950
                mContext->gl->fFramebufferTexture2D(target, LOCAL_GL_STENCIL_ATTACHMENT, textarget, stenciltexturename, level);
2951
            }
2952
            else if (attachment == LOCAL_GL_DEPTH_ATTACHMENT || attachment == LOCAL_GL_STENCIL_ATTACHMENT){
2953
                WebGLuint depthstenciltexturename = mDepthStencilAttachment.Texture() ? mDepthStencilAttachment.Texture()->GLName() : 0;
2954
                mContext->gl->fFramebufferTexture2D(target, attachment, textarget, depthstenciltexturename, level);
2955
            }
2956
            else{
2957
                mContext->gl->fFramebufferTexture2D(target, attachment, textarget, texturename, level);
2958
            }
2927
        }
2959
        }
2928
2960
2929
        return;
2961
        return;
2930
    }
2962
    }
2931
2963
2932
    bool HasIncompleteAttachment() const {
2964
    bool HasIncompleteAttachment() const {
2933
        return (mColorAttachment.IsDefined() && !mColorAttachment.IsComplete()) ||
2965
        return (mColorAttachment.IsDefined() && !mColorAttachment.IsComplete()) ||
2934
               (mDepthAttachment.IsDefined() && !mDepthAttachment.IsComplete()) ||
2966
               (mDepthAttachment.IsDefined() && !mDepthAttachment.IsComplete()) ||

Return to bug 801986