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

Side by Side Diff: gpu/command_buffer/common/gles2_cmd_utils.cc

Issue 1325433003: command_buffer: Add support for creating non-WebGL ES 3 contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file is here so other GLES2 related files can have a common set of 5 // This file is here so other GLES2 related files can have a common set of
6 // includes where appropriate. 6 // includes where appropriate.
7 7
8 #include <sstream> 8 #include <sstream>
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS 1232 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS
1233 const int32 kNone = 0x3038; // EGL_NONE 1233 const int32 kNone = 0x3038; // EGL_NONE
1234 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR 1234 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR
1235 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED 1235 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED
1236 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED 1236 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED
1237 1237
1238 // Chromium only. 1238 // Chromium only.
1239 const int32 kBindGeneratesResource = 0x10000; 1239 const int32 kBindGeneratesResource = 0x10000;
1240 const int32 kFailIfMajorPerfCaveat = 0x10001; 1240 const int32 kFailIfMajorPerfCaveat = 0x10001;
1241 const int32 kLoseContextWhenOutOfMemory = 0x10002; 1241 const int32 kLoseContextWhenOutOfMemory = 0x10002;
1242 const int32 kWebGLVersion = 0x10003; 1242 const int32 kContextType = 0x10003;
1243 1243
1244 } // namespace 1244 } // namespace
1245 1245
1246 ContextCreationAttribHelper::ContextCreationAttribHelper() 1246 ContextCreationAttribHelper::ContextCreationAttribHelper()
1247 : alpha_size(-1), 1247 : alpha_size(-1),
1248 blue_size(-1), 1248 blue_size(-1),
1249 green_size(-1), 1249 green_size(-1),
1250 red_size(-1), 1250 red_size(-1),
1251 depth_size(-1), 1251 depth_size(-1),
1252 stencil_size(-1), 1252 stencil_size(-1),
1253 samples(-1), 1253 samples(-1),
1254 sample_buffers(-1), 1254 sample_buffers(-1),
1255 buffer_preserved(true), 1255 buffer_preserved(true),
1256 bind_generates_resource(true), 1256 bind_generates_resource(true),
1257 fail_if_major_perf_caveat(false), 1257 fail_if_major_perf_caveat(false),
1258 lose_context_when_out_of_memory(false), 1258 lose_context_when_out_of_memory(false),
1259 webgl_version(0) { 1259 context_type(CONTEXT_TYPE_OPENGLES2) {}
1260 }
1261 1260
1262 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { 1261 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const {
1263 if (alpha_size != -1) { 1262 if (alpha_size != -1) {
1264 attribs->push_back(kAlphaSize); 1263 attribs->push_back(kAlphaSize);
1265 attribs->push_back(alpha_size); 1264 attribs->push_back(alpha_size);
1266 } 1265 }
1267 if (blue_size != -1) { 1266 if (blue_size != -1) {
1268 attribs->push_back(kBlueSize); 1267 attribs->push_back(kBlueSize);
1269 attribs->push_back(blue_size); 1268 attribs->push_back(blue_size);
1270 } 1269 }
(...skipping 22 matching lines...) Expand all
1293 attribs->push_back(sample_buffers); 1292 attribs->push_back(sample_buffers);
1294 } 1293 }
1295 attribs->push_back(kSwapBehavior); 1294 attribs->push_back(kSwapBehavior);
1296 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); 1295 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed);
1297 attribs->push_back(kBindGeneratesResource); 1296 attribs->push_back(kBindGeneratesResource);
1298 attribs->push_back(bind_generates_resource ? 1 : 0); 1297 attribs->push_back(bind_generates_resource ? 1 : 0);
1299 attribs->push_back(kFailIfMajorPerfCaveat); 1298 attribs->push_back(kFailIfMajorPerfCaveat);
1300 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); 1299 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0);
1301 attribs->push_back(kLoseContextWhenOutOfMemory); 1300 attribs->push_back(kLoseContextWhenOutOfMemory);
1302 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); 1301 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0);
1303 attribs->push_back(kWebGLVersion); 1302 attribs->push_back(kContextType);
1304 attribs->push_back(webgl_version); 1303 attribs->push_back(context_type);
1305 attribs->push_back(kNone); 1304 attribs->push_back(kNone);
1306 } 1305 }
1307 1306
1308 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { 1307 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) {
1309 for (size_t i = 0; i < attribs.size(); i += 2) { 1308 for (size_t i = 0; i < attribs.size(); i += 2) {
1310 const int32 attrib = attribs[i]; 1309 const int32 attrib = attribs[i];
1311 if (i + 1 >= attribs.size()) { 1310 if (i + 1 >= attribs.size()) {
1312 if (attrib == kNone) { 1311 if (attrib == kNone) {
1313 return true; 1312 return true;
1314 } 1313 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 break; 1348 break;
1350 case kBindGeneratesResource: 1349 case kBindGeneratesResource:
1351 bind_generates_resource = value != 0; 1350 bind_generates_resource = value != 0;
1352 break; 1351 break;
1353 case kFailIfMajorPerfCaveat: 1352 case kFailIfMajorPerfCaveat:
1354 fail_if_major_perf_caveat = value != 0; 1353 fail_if_major_perf_caveat = value != 0;
1355 break; 1354 break;
1356 case kLoseContextWhenOutOfMemory: 1355 case kLoseContextWhenOutOfMemory:
1357 lose_context_when_out_of_memory = value != 0; 1356 lose_context_when_out_of_memory = value != 0;
1358 break; 1357 break;
1359 case kWebGLVersion: 1358 case kContextType:
1360 webgl_version = value; 1359 context_type = static_cast<ContextType>(value);
1361 break; 1360 break;
1362 case kNone: 1361 case kNone:
1363 // Terminate list, even if more attributes. 1362 // Terminate list, even if more attributes.
1364 return true; 1363 return true;
1365 default: 1364 default:
1366 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; 1365 DLOG(ERROR) << "Invalid context creation attribute: " << attrib;
1367 return false; 1366 return false;
1368 } 1367 }
1369 } 1368 }
1370 1369
1371 return true; 1370 return true;
1372 } 1371 }
1373 1372
1374 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" 1373 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h"
1375 1374
1376 } // namespace gles2 1375 } // namespace gles2
1377 } // namespace gpu 1376 } // namespace gpu
1378 1377
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698