OLD | NEW |
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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 1228 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
1229 const int32 kNone = 0x3038; // EGL_NONE | 1229 const int32 kNone = 0x3038; // EGL_NONE |
1230 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 1230 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
1231 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 1231 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
1232 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 1232 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
1233 | 1233 |
1234 // Chromium only. | 1234 // Chromium only. |
1235 const int32 kBindGeneratesResource = 0x10000; | 1235 const int32 kBindGeneratesResource = 0x10000; |
1236 const int32 kFailIfMajorPerfCaveat = 0x10001; | 1236 const int32 kFailIfMajorPerfCaveat = 0x10001; |
1237 const int32 kLoseContextWhenOutOfMemory = 0x10002; | 1237 const int32 kLoseContextWhenOutOfMemory = 0x10002; |
1238 const int32 kWebGLVersion = 0x10003; | 1238 const int32 kContextType = 0x10003; |
1239 | 1239 |
1240 } // namespace | 1240 } // namespace |
1241 | 1241 |
1242 ContextCreationAttribHelper::ContextCreationAttribHelper() | 1242 ContextCreationAttribHelper::ContextCreationAttribHelper() |
1243 : alpha_size(-1), | 1243 : alpha_size(-1), |
1244 blue_size(-1), | 1244 blue_size(-1), |
1245 green_size(-1), | 1245 green_size(-1), |
1246 red_size(-1), | 1246 red_size(-1), |
1247 depth_size(-1), | 1247 depth_size(-1), |
1248 stencil_size(-1), | 1248 stencil_size(-1), |
1249 samples(-1), | 1249 samples(-1), |
1250 sample_buffers(-1), | 1250 sample_buffers(-1), |
1251 buffer_preserved(true), | 1251 buffer_preserved(true), |
1252 bind_generates_resource(true), | 1252 bind_generates_resource(true), |
1253 fail_if_major_perf_caveat(false), | 1253 fail_if_major_perf_caveat(false), |
1254 lose_context_when_out_of_memory(false), | 1254 lose_context_when_out_of_memory(false), |
1255 webgl_version(0) { | 1255 context_type(CONTEXT_TYPE_OPENGLES2) {} |
1256 } | |
1257 | 1256 |
1258 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { | 1257 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { |
1259 if (alpha_size != -1) { | 1258 if (alpha_size != -1) { |
1260 attribs->push_back(kAlphaSize); | 1259 attribs->push_back(kAlphaSize); |
1261 attribs->push_back(alpha_size); | 1260 attribs->push_back(alpha_size); |
1262 } | 1261 } |
1263 if (blue_size != -1) { | 1262 if (blue_size != -1) { |
1264 attribs->push_back(kBlueSize); | 1263 attribs->push_back(kBlueSize); |
1265 attribs->push_back(blue_size); | 1264 attribs->push_back(blue_size); |
1266 } | 1265 } |
(...skipping 22 matching lines...) Expand all Loading... |
1289 attribs->push_back(sample_buffers); | 1288 attribs->push_back(sample_buffers); |
1290 } | 1289 } |
1291 attribs->push_back(kSwapBehavior); | 1290 attribs->push_back(kSwapBehavior); |
1292 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); | 1291 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); |
1293 attribs->push_back(kBindGeneratesResource); | 1292 attribs->push_back(kBindGeneratesResource); |
1294 attribs->push_back(bind_generates_resource ? 1 : 0); | 1293 attribs->push_back(bind_generates_resource ? 1 : 0); |
1295 attribs->push_back(kFailIfMajorPerfCaveat); | 1294 attribs->push_back(kFailIfMajorPerfCaveat); |
1296 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); | 1295 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); |
1297 attribs->push_back(kLoseContextWhenOutOfMemory); | 1296 attribs->push_back(kLoseContextWhenOutOfMemory); |
1298 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); | 1297 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); |
1299 attribs->push_back(kWebGLVersion); | 1298 attribs->push_back(kContextType); |
1300 attribs->push_back(webgl_version); | 1299 attribs->push_back(context_type); |
1301 attribs->push_back(kNone); | 1300 attribs->push_back(kNone); |
1302 } | 1301 } |
1303 | 1302 |
1304 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 1303 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
1305 for (size_t i = 0; i < attribs.size(); i += 2) { | 1304 for (size_t i = 0; i < attribs.size(); i += 2) { |
1306 const int32 attrib = attribs[i]; | 1305 const int32 attrib = attribs[i]; |
1307 if (i + 1 >= attribs.size()) { | 1306 if (i + 1 >= attribs.size()) { |
1308 if (attrib == kNone) { | 1307 if (attrib == kNone) { |
1309 return true; | 1308 return true; |
1310 } | 1309 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 break; | 1344 break; |
1346 case kBindGeneratesResource: | 1345 case kBindGeneratesResource: |
1347 bind_generates_resource = value != 0; | 1346 bind_generates_resource = value != 0; |
1348 break; | 1347 break; |
1349 case kFailIfMajorPerfCaveat: | 1348 case kFailIfMajorPerfCaveat: |
1350 fail_if_major_perf_caveat = value != 0; | 1349 fail_if_major_perf_caveat = value != 0; |
1351 break; | 1350 break; |
1352 case kLoseContextWhenOutOfMemory: | 1351 case kLoseContextWhenOutOfMemory: |
1353 lose_context_when_out_of_memory = value != 0; | 1352 lose_context_when_out_of_memory = value != 0; |
1354 break; | 1353 break; |
1355 case kWebGLVersion: | 1354 case kContextType: |
1356 webgl_version = value; | 1355 context_type = static_cast<ContextType>(value); |
1357 break; | 1356 break; |
1358 case kNone: | 1357 case kNone: |
1359 // Terminate list, even if more attributes. | 1358 // Terminate list, even if more attributes. |
1360 return true; | 1359 return true; |
1361 default: | 1360 default: |
1362 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 1361 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
1363 return false; | 1362 return false; |
1364 } | 1363 } |
1365 } | 1364 } |
1366 | 1365 |
1367 return true; | 1366 return true; |
1368 } | 1367 } |
1369 | 1368 |
1370 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1369 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
1371 | 1370 |
1372 } // namespace gles2 | 1371 } // namespace gles2 |
1373 } // namespace gpu | 1372 } // namespace gpu |
1374 | 1373 |
OLD | NEW |