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

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

Issue 1157983002: Update WebGLVertexArrayObjectOES to WebGLVertexArrayObject for WebGL2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed bajones' comments Created 5 years, 6 months 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
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "core/html/canvas/WebGLDrawBuffers.h" 69 #include "core/html/canvas/WebGLDrawBuffers.h"
70 #include "core/html/canvas/WebGLFramebuffer.h" 70 #include "core/html/canvas/WebGLFramebuffer.h"
71 #include "core/html/canvas/WebGLLoseContext.h" 71 #include "core/html/canvas/WebGLLoseContext.h"
72 #include "core/html/canvas/WebGLProgram.h" 72 #include "core/html/canvas/WebGLProgram.h"
73 #include "core/html/canvas/WebGLRenderbuffer.h" 73 #include "core/html/canvas/WebGLRenderbuffer.h"
74 #include "core/html/canvas/WebGLShader.h" 74 #include "core/html/canvas/WebGLShader.h"
75 #include "core/html/canvas/WebGLShaderPrecisionFormat.h" 75 #include "core/html/canvas/WebGLShaderPrecisionFormat.h"
76 #include "core/html/canvas/WebGLSharedWebGraphicsContext3D.h" 76 #include "core/html/canvas/WebGLSharedWebGraphicsContext3D.h"
77 #include "core/html/canvas/WebGLTexture.h" 77 #include "core/html/canvas/WebGLTexture.h"
78 #include "core/html/canvas/WebGLUniformLocation.h" 78 #include "core/html/canvas/WebGLUniformLocation.h"
79 #include "core/html/canvas/WebGLVertexArrayObjectOES.h"
79 #include "core/inspector/ConsoleMessage.h" 80 #include "core/inspector/ConsoleMessage.h"
80 #include "core/inspector/InspectorInstrumentation.h" 81 #include "core/inspector/InspectorInstrumentation.h"
81 #include "core/layout/LayoutBox.h" 82 #include "core/layout/LayoutBox.h"
82 #include "core/loader/FrameLoader.h" 83 #include "core/loader/FrameLoader.h"
83 #include "core/loader/FrameLoaderClient.h" 84 #include "core/loader/FrameLoaderClient.h"
84 #include "platform/CheckedInt.h" 85 #include "platform/CheckedInt.h"
85 #include "platform/NotImplemented.h" 86 #include "platform/NotImplemented.h"
86 #include "platform/RuntimeEnabledFeatures.h" 87 #include "platform/RuntimeEnabledFeatures.h"
87 #include "platform/geometry/IntSize.h" 88 #include "platform/geometry/IntSize.h"
88 #include "platform/graphics/GraphicsContext.h" 89 #include "platform/graphics/GraphicsContext.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 m_scissorEnabled = false; 698 m_scissorEnabled = false;
698 m_clearDepth = 1; 699 m_clearDepth = 1;
699 m_clearStencil = 0; 700 m_clearStencil = 0;
700 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; 701 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true;
701 702
702 GLint numCombinedTextureImageUnits = 0; 703 GLint numCombinedTextureImageUnits = 0;
703 webContext()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedT extureImageUnits); 704 webContext()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedT extureImageUnits);
704 m_textureUnits.clear(); 705 m_textureUnits.clear();
705 m_textureUnits.resize(numCombinedTextureImageUnits); 706 m_textureUnits.resize(numCombinedTextureImageUnits);
706 707
707 GLint numVertexAttribs = 0;
708 webContext()->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
709 m_maxVertexAttribs = numVertexAttribs;
710
711 m_maxTextureSize = 0; 708 m_maxTextureSize = 0;
712 webContext()->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); 709 webContext()->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
713 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT extureSize, 1); 710 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT extureSize, 1);
714 m_maxCubeMapTextureSize = 0; 711 m_maxCubeMapTextureSize = 0;
715 webContext()->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTexture Size); 712 webContext()->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTexture Size);
716 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu reSize, m_maxCubeMapTextureSize, 1); 713 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu reSize, m_maxCubeMapTextureSize, 1);
717 m_maxRenderbufferSize = 0; 714 m_maxRenderbufferSize = 0;
718 webContext()->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); 715 webContext()->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize);
719 716
720 // These two values from EXT_draw_buffers are lazily queried. 717 // These two values from EXT_draw_buffers are lazily queried.
721 m_maxDrawBuffers = 0; 718 m_maxDrawBuffers = 0;
722 m_maxColorAttachments = 0; 719 m_maxColorAttachments = 0;
723 720
724 m_backDrawBuffer = GL_BACK; 721 m_backDrawBuffer = GL_BACK;
725 722
726 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, WebGLVe rtexArrayObjectOES::VaoTypeDefault); 723 if (!m_defaultVertexArrayObject) {
727 addContextObject(m_defaultVertexArrayObject.get()); 724 GLint numVertexAttribs = 0;
728 m_boundVertexArrayObject = m_defaultVertexArrayObject; 725 webContext()->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs);
726 m_maxVertexAttribs = numVertexAttribs;
legend 2015/05/27 02:05:46 The initialization of m_maxVertexAttribs is moved
727
728 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, Web GLVertexArrayObjectBase::VaoTypeDefault);
729 addContextObject(m_defaultVertexArrayObject.get());
730 m_boundVertexArrayObject = m_defaultVertexArrayObject;
731 }
729 732
730 m_vertexAttribValue.resize(m_maxVertexAttribs); 733 m_vertexAttribValue.resize(m_maxVertexAttribs);
731 734
732 createFallbackBlackTextures1x1(); 735 createFallbackBlackTextures1x1();
733 736
734 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); 737 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight());
735 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); 738 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight());
736 739
737 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); 740 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s);
738 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this); 741 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c reate(this);
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 1865
1863 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) 1866 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index)
1864 { 1867 {
1865 if (isContextLost()) 1868 if (isContextLost())
1866 return; 1869 return;
1867 if (index >= m_maxVertexAttribs) { 1870 if (index >= m_maxVertexAttribs) {
1868 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o ut of range"); 1871 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o ut of range");
1869 return; 1872 return;
1870 } 1873 }
1871 1874
1872 WebGLVertexArrayObjectOES::VertexAttribState* state = m_boundVertexArrayObje ct->getVertexAttribState(index); 1875 WebGLVertexArrayObjectBase::VertexAttribState* state = m_boundVertexArrayObj ect->getVertexAttribState(index);
1873 state->enabled = false; 1876 state->enabled = false;
1874 1877
1875 webContext()->disableVertexAttribArray(index); 1878 webContext()->disableVertexAttribArray(index);
1876 } 1879 }
1877 1880
1878 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) 1881 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName)
1879 { 1882 {
1880 if (!m_currentProgram) { 1883 if (!m_currentProgram) {
1881 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p rogram in use"); 1884 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p rogram in use");
1882 return false; 1885 return false;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 1977
1975 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) 1978 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index)
1976 { 1979 {
1977 if (isContextLost()) 1980 if (isContextLost())
1978 return; 1981 return;
1979 if (index >= m_maxVertexAttribs) { 1982 if (index >= m_maxVertexAttribs) {
1980 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou t of range"); 1983 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou t of range");
1981 return; 1984 return;
1982 } 1985 }
1983 1986
1984 WebGLVertexArrayObjectOES::VertexAttribState* state = m_boundVertexArrayObje ct->getVertexAttribState(index); 1987 WebGLVertexArrayObjectBase::VertexAttribState* state = m_boundVertexArrayObj ect->getVertexAttribState(index);
1985 state->enabled = true; 1988 state->enabled = true;
1986 1989
1987 webContext()->enableVertexAttribArray(index); 1990 webContext()->enableVertexAttribArray(index);
1988 } 1991 }
1989 1992
1990 void WebGLRenderingContextBase::finish() 1993 void WebGLRenderingContextBase::finish()
1991 { 1994 {
1992 if (isContextLost()) 1995 if (isContextLost())
1993 return; 1996 return;
1994 webContext()->flush(); // Intentionally a flush, not a finish. 1997 webContext()->flush(); // Intentionally a flush, not a finish.
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3045 } 3048 }
3046 3049
3047 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState, GLuint index, GLenum pname) 3050 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState, GLuint index, GLenum pname)
3048 { 3051 {
3049 if (isContextLost()) 3052 if (isContextLost())
3050 return ScriptValue::createNull(scriptState); 3053 return ScriptValue::createNull(scriptState);
3051 if (index >= m_maxVertexAttribs) { 3054 if (index >= m_maxVertexAttribs) {
3052 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge"); 3055 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge");
3053 return ScriptValue::createNull(scriptState); 3056 return ScriptValue::createNull(scriptState);
3054 } 3057 }
3055 const WebGLVertexArrayObjectOES::VertexAttribState* state = m_boundVertexArr ayObject->getVertexAttribState(index); 3058 const WebGLVertexArrayObjectBase::VertexAttribState* state = m_boundVertexAr rayObject->getVertexAttribState(index);
3056 3059
3057 if ((extensionEnabled(ANGLEInstancedArraysName) || isWebGL2OrHigher()) 3060 if ((extensionEnabled(ANGLEInstancedArraysName) || isWebGL2OrHigher())
3058 && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE) 3061 && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)
3059 return WebGLAny(scriptState, state->divisor); 3062 return WebGLAny(scriptState, state->divisor);
3060 3063
3061 switch (pname) { 3064 switch (pname) {
3062 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 3065 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
3063 if (!state->bufferBinding || !state->bufferBinding->object()) 3066 if (!state->bufferBinding || !state->bufferBinding->object())
3064 return ScriptValue::createNull(scriptState); 3067 return ScriptValue::createNull(scriptState);
3065 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(state-> bufferBinding.get())); 3068 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(state-> bufferBinding.get()));
(...skipping 3158 matching lines...) Expand 10 before | Expand all | Expand 10 after
6224 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6227 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6225 } 6228 }
6226 #else 6229 #else
6227 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6230 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6228 { 6231 {
6229 return m_drawingBuffer.get(); 6232 return m_drawingBuffer.get();
6230 } 6233 }
6231 #endif 6234 #endif
6232 6235
6233 } // namespace blink 6236 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | Source/core/html/canvas/WebGLVertexArrayObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698