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

Side by Side Diff: Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1300583002: Improve samplerParameter[if] in WebGL2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « Source/modules/webgl/WebGL2RenderingContextBase.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/webgl/WebGL2RenderingContextBase.h" 6 #include "modules/webgl/WebGL2RenderingContextBase.h"
7 7
8 #include "bindings/modules/v8/WebGLAny.h" 8 #include "bindings/modules/v8/WebGLAny.h"
9 #include "core/html/HTMLCanvasElement.h" 9 #include "core/html/HTMLCanvasElement.h"
10 #include "core/html/HTMLImageElement.h" 10 #include "core/html/HTMLImageElement.h"
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 { 1287 {
1288 if (isContextLost()) 1288 if (isContextLost())
1289 return nullptr; 1289 return nullptr;
1290 WebGLSampler* o = WebGLSampler::create(this); 1290 WebGLSampler* o = WebGLSampler::create(this);
1291 addSharedObject(o); 1291 addSharedObject(o);
1292 return o; 1292 return o;
1293 } 1293 }
1294 1294
1295 void WebGL2RenderingContextBase::deleteSampler(WebGLSampler* sampler) 1295 void WebGL2RenderingContextBase::deleteSampler(WebGLSampler* sampler)
1296 { 1296 {
1297 if (isContextLost())
1298 return;
1299
1297 for (size_t i = 0; i < m_samplerUnits.size(); ++i) { 1300 for (size_t i = 0; i < m_samplerUnits.size(); ++i) {
1298 if (sampler == m_samplerUnits[i]) { 1301 if (sampler == m_samplerUnits[i]) {
1299 m_samplerUnits[i] = nullptr; 1302 m_samplerUnits[i] = nullptr;
1300 webContext()->bindSampler(i, 0); 1303 webContext()->bindSampler(i, 0);
1301 } 1304 }
1302 } 1305 }
1303 1306
1304 deleteObject(sampler); 1307 deleteObject(sampler);
1305 } 1308 }
1306 1309
1307 GLboolean WebGL2RenderingContextBase::isSampler(WebGLSampler* sampler) 1310 GLboolean WebGL2RenderingContextBase::isSampler(WebGLSampler* sampler)
1308 { 1311 {
1309 if (isContextLost() || !sampler) 1312 if (isContextLost() || !sampler)
1310 return 0; 1313 return 0;
1311 1314
1312 return webContext()->isSampler(sampler->object()); 1315 return webContext()->isSampler(sampler->object());
1313 } 1316 }
1314 1317
1315 void WebGL2RenderingContextBase::bindSampler(GLuint unit, WebGLSampler* sampler) 1318 void WebGL2RenderingContextBase::bindSampler(GLuint unit, WebGLSampler* sampler)
1316 { 1319 {
1320 if (isContextLost())
1321 return;
1322
1317 bool deleted; 1323 bool deleted;
1318 if (!checkObjectToBeBound("bindSampler", sampler, deleted)) 1324 if (!checkObjectToBeBound("bindSampler", sampler, deleted))
1319 return; 1325 return;
1320 if (deleted) { 1326 if (deleted) {
1321 synthesizeGLError(GL_INVALID_OPERATION, "bindSampler", "attempted to bin d a deleted sampler"); 1327 synthesizeGLError(GL_INVALID_OPERATION, "bindSampler", "attempted to bin d a deleted sampler");
1322 return; 1328 return;
1323 } 1329 }
1324 1330
1325 if (unit >= m_samplerUnits.size()) { 1331 if (unit >= m_samplerUnits.size()) {
1326 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", "texture unit out of range"); 1332 synthesizeGLError(GL_INVALID_VALUE, "bindSampler", "texture unit out of range");
1327 return; 1333 return;
1328 } 1334 }
1329 1335
1330 m_samplerUnits[unit] = sampler; 1336 m_samplerUnits[unit] = sampler;
1331 1337
1332 webContext()->bindSampler(unit, objectOrZero(sampler)); 1338 webContext()->bindSampler(unit, objectOrZero(sampler));
1333 } 1339 }
1334 1340
1341 void WebGL2RenderingContextBase::samplerParameter(WebGLSampler* sampler, GLenum pname, GLfloat paramf, GLint parami, bool isFloat)
1342 {
1343 if (isContextLost() || !validateWebGLObject("samplerParameter", sampler))
1344 return;
1345
1346 switch (pname) {
1347 case GL_TEXTURE_COMPARE_FUNC:
1348 case GL_TEXTURE_COMPARE_MODE:
1349 case GL_TEXTURE_MAG_FILTER:
1350 case GL_TEXTURE_MIN_FILTER:
1351 case GL_TEXTURE_WRAP_R:
1352 case GL_TEXTURE_WRAP_S:
1353 case GL_TEXTURE_WRAP_T:
1354 case GL_TEXTURE_MAX_LOD:
1355 case GL_TEXTURE_MIN_LOD:
1356 break;
1357 default:
1358 synthesizeGLError(GL_INVALID_ENUM, "samplerParameter", "invalid paramete r name");
1359 return;
1360 }
1361
1362 if (isFloat) {
1363 webContext()->samplerParameterf(objectOrZero(sampler), pname, paramf);
1364 } else {
1365 webContext()->samplerParameteri(objectOrZero(sampler), pname, parami);
1366 }
1367 }
1368
1335 void WebGL2RenderingContextBase::samplerParameteri(WebGLSampler* sampler, GLenum pname, GLint param) 1369 void WebGL2RenderingContextBase::samplerParameteri(WebGLSampler* sampler, GLenum pname, GLint param)
1336 { 1370 {
1337 if (isContextLost() || !validateWebGLObject("samplerParameteri", sampler)) 1371 samplerParameter(sampler, pname, 0, param, false);
1338 return;
1339
1340 webContext()->samplerParameteri(objectOrZero(sampler), pname, param);
1341 } 1372 }
1342 1373
1343 void WebGL2RenderingContextBase::samplerParameterf(WebGLSampler* sampler, GLenum pname, GLfloat param) 1374 void WebGL2RenderingContextBase::samplerParameterf(WebGLSampler* sampler, GLenum pname, GLfloat param)
1344 { 1375 {
1345 if (isContextLost() || !validateWebGLObject("samplerParameterf", sampler)) 1376 samplerParameter(sampler, pname, param, 0, true);
1346 return;
1347
1348 webContext()->samplerParameterf(objectOrZero(sampler), pname, param);
1349 } 1377 }
1350 1378
1351 ScriptValue WebGL2RenderingContextBase::getSamplerParameter(ScriptState* scriptS tate, WebGLSampler* sampler, GLenum pname) 1379 ScriptValue WebGL2RenderingContextBase::getSamplerParameter(ScriptState* scriptS tate, WebGLSampler* sampler, GLenum pname)
1352 { 1380 {
1353 if (isContextLost() || !validateWebGLObject("getSamplerParameter", sampler)) 1381 if (isContextLost() || !validateWebGLObject("getSamplerParameter", sampler))
1354 return ScriptValue::createNull(scriptState); 1382 return ScriptValue::createNull(scriptState);
1355 1383
1356 switch (pname) { 1384 switch (pname) {
1357 case GL_TEXTURE_COMPARE_FUNC: 1385 case GL_TEXTURE_COMPARE_FUNC:
1358 case GL_TEXTURE_COMPARE_MODE: 1386 case GL_TEXTURE_COMPARE_MODE:
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 2471 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2444 { 2472 {
2445 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 2473 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2446 return m_readFramebufferBinding->colorBufferFormat(); 2474 return m_readFramebufferBinding->colorBufferFormat();
2447 if (m_requestedAttributes.alpha()) 2475 if (m_requestedAttributes.alpha())
2448 return GL_RGBA; 2476 return GL_RGBA;
2449 return GL_RGB; 2477 return GL_RGB;
2450 } 2478 }
2451 2479
2452 } // namespace blink 2480 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webgl/WebGL2RenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698