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

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

Issue 106503003: Changed GL enums from GraphicsContext3D to standard versions (Take 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
« no previous file with comments | « Source/core/html/canvas/WebGLObject.h ('k') | Source/core/html/canvas/WebGLRenderbuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void WebGLProgram::increaseLinkCount() 103 void WebGLProgram::increaseLinkCount()
104 { 104 {
105 ++m_linkCount; 105 ++m_linkCount;
106 m_infoValid = false; 106 m_infoValid = false;
107 } 107 }
108 108
109 WebGLShader* WebGLProgram::getAttachedShader(GC3Denum type) 109 WebGLShader* WebGLProgram::getAttachedShader(GC3Denum type)
110 { 110 {
111 switch (type) { 111 switch (type) {
112 case GraphicsContext3D::VERTEX_SHADER: 112 case GL_VERTEX_SHADER:
113 return m_vertexShader.get(); 113 return m_vertexShader.get();
114 case GraphicsContext3D::FRAGMENT_SHADER: 114 case GL_FRAGMENT_SHADER:
115 return m_fragmentShader.get(); 115 return m_fragmentShader.get();
116 default: 116 default:
117 return 0; 117 return 0;
118 } 118 }
119 } 119 }
120 120
121 bool WebGLProgram::attachShader(WebGLShader* shader) 121 bool WebGLProgram::attachShader(WebGLShader* shader)
122 { 122 {
123 if (!shader || !shader->object()) 123 if (!shader || !shader->object())
124 return false; 124 return false;
125 switch (shader->type()) { 125 switch (shader->type()) {
126 case GraphicsContext3D::VERTEX_SHADER: 126 case GL_VERTEX_SHADER:
127 if (m_vertexShader) 127 if (m_vertexShader)
128 return false; 128 return false;
129 m_vertexShader = shader; 129 m_vertexShader = shader;
130 return true; 130 return true;
131 case GraphicsContext3D::FRAGMENT_SHADER: 131 case GL_FRAGMENT_SHADER:
132 if (m_fragmentShader) 132 if (m_fragmentShader)
133 return false; 133 return false;
134 m_fragmentShader = shader; 134 m_fragmentShader = shader;
135 return true; 135 return true;
136 default: 136 default:
137 return false; 137 return false;
138 } 138 }
139 } 139 }
140 140
141 bool WebGLProgram::detachShader(WebGLShader* shader) 141 bool WebGLProgram::detachShader(WebGLShader* shader)
142 { 142 {
143 if (!shader || !shader->object()) 143 if (!shader || !shader->object())
144 return false; 144 return false;
145 switch (shader->type()) { 145 switch (shader->type()) {
146 case GraphicsContext3D::VERTEX_SHADER: 146 case GL_VERTEX_SHADER:
147 if (m_vertexShader != shader) 147 if (m_vertexShader != shader)
148 return false; 148 return false;
149 m_vertexShader = 0; 149 m_vertexShader = 0;
150 return true; 150 return true;
151 case GraphicsContext3D::FRAGMENT_SHADER: 151 case GL_FRAGMENT_SHADER:
152 if (m_fragmentShader != shader) 152 if (m_fragmentShader != shader)
153 return false; 153 return false;
154 m_fragmentShader = 0; 154 m_fragmentShader = 0;
155 return true; 155 return true;
156 default: 156 default:
157 return false; 157 return false;
158 } 158 }
159 } 159 }
160 160
161 void WebGLProgram::cacheActiveAttribLocations(GraphicsContext3D* context3d) 161 void WebGLProgram::cacheActiveAttribLocations(GraphicsContext3D* context3d)
162 { 162 {
163 m_activeAttribLocations.clear(); 163 m_activeAttribLocations.clear();
164 164
165 GC3Dint numAttribs = 0; 165 GC3Dint numAttribs = 0;
166 context3d->getProgramiv(object(), GraphicsContext3D::ACTIVE_ATTRIBUTES, &num Attribs); 166 context3d->getProgramiv(object(), GL_ACTIVE_ATTRIBUTES, &numAttribs);
167 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs)); 167 m_activeAttribLocations.resize(static_cast<size_t>(numAttribs));
168 for (int i = 0; i < numAttribs; ++i) { 168 for (int i = 0; i < numAttribs; ++i) {
169 ActiveInfo info; 169 ActiveInfo info;
170 context3d->getActiveAttrib(object(), i, info); 170 context3d->getActiveAttrib(object(), i, info);
171 m_activeAttribLocations[i] = context3d->getAttribLocation(object(), info .name); 171 m_activeAttribLocations[i] = context3d->getAttribLocation(object(), info .name);
172 } 172 }
173 } 173 }
174 174
175 void WebGLProgram::cacheInfoIfNeeded() 175 void WebGLProgram::cacheInfoIfNeeded()
176 { 176 {
177 if (m_infoValid) 177 if (m_infoValid)
178 return; 178 return;
179 179
180 if (!object()) 180 if (!object())
181 return; 181 return;
182 182
183 GraphicsContext3D* context = getAGraphicsContext3D(); 183 GraphicsContext3D* context = getAGraphicsContext3D();
184 if (!context) 184 if (!context)
185 return; 185 return;
186 GC3Dint linkStatus = 0; 186 GC3Dint linkStatus = 0;
187 context->getProgramiv(object(), GraphicsContext3D::LINK_STATUS, &linkStatus) ; 187 context->getProgramiv(object(), GL_LINK_STATUS, &linkStatus);
188 m_linkStatus = linkStatus; 188 m_linkStatus = linkStatus;
189 if (m_linkStatus) 189 if (m_linkStatus)
190 cacheActiveAttribLocations(context); 190 cacheActiveAttribLocations(context);
191 m_infoValid = true; 191 m_infoValid = true;
192 } 192 }
193 193
194 } 194 }
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLObject.h ('k') | Source/core/html/canvas/WebGLRenderbuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698