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 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 1264 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
1265 const int32 kNone = 0x3038; // EGL_NONE | 1265 const int32 kNone = 0x3038; // EGL_NONE |
1266 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 1266 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
1267 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 1267 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
1268 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 1268 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
1269 | 1269 |
1270 // Chromium only. | 1270 // Chromium only. |
1271 const int32 kBindGeneratesResource = 0x10000; | 1271 const int32 kBindGeneratesResource = 0x10000; |
1272 const int32 kFailIfMajorPerfCaveat = 0x10001; | 1272 const int32 kFailIfMajorPerfCaveat = 0x10001; |
1273 const int32 kLoseContextWhenOutOfMemory = 0x10002; | 1273 const int32 kLoseContextWhenOutOfMemory = 0x10002; |
1274 const int32 kWebGLVersion = 0x10003; | 1274 const int32 kContextType = 0x10003; |
1275 | 1275 |
1276 } // namespace | 1276 } // namespace |
1277 | 1277 |
1278 ContextCreationAttribHelper::ContextCreationAttribHelper() | 1278 ContextCreationAttribHelper::ContextCreationAttribHelper() |
1279 : alpha_size(-1), | 1279 : alpha_size(-1), |
1280 blue_size(-1), | 1280 blue_size(-1), |
1281 green_size(-1), | 1281 green_size(-1), |
1282 red_size(-1), | 1282 red_size(-1), |
1283 depth_size(-1), | 1283 depth_size(-1), |
1284 stencil_size(-1), | 1284 stencil_size(-1), |
1285 samples(-1), | 1285 samples(-1), |
1286 sample_buffers(-1), | 1286 sample_buffers(-1), |
1287 buffer_preserved(true), | 1287 buffer_preserved(true), |
1288 bind_generates_resource(true), | 1288 bind_generates_resource(true), |
1289 fail_if_major_perf_caveat(false), | 1289 fail_if_major_perf_caveat(false), |
1290 lose_context_when_out_of_memory(false), | 1290 lose_context_when_out_of_memory(false), |
1291 webgl_version(0) { | 1291 context_type(CONTEXT_TYPE_OPENGLES2) {} |
1292 } | |
1293 | 1292 |
1294 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { | 1293 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { |
1295 if (alpha_size != -1) { | 1294 if (alpha_size != -1) { |
1296 attribs->push_back(kAlphaSize); | 1295 attribs->push_back(kAlphaSize); |
1297 attribs->push_back(alpha_size); | 1296 attribs->push_back(alpha_size); |
1298 } | 1297 } |
1299 if (blue_size != -1) { | 1298 if (blue_size != -1) { |
1300 attribs->push_back(kBlueSize); | 1299 attribs->push_back(kBlueSize); |
1301 attribs->push_back(blue_size); | 1300 attribs->push_back(blue_size); |
1302 } | 1301 } |
(...skipping 22 matching lines...) Expand all Loading... |
1325 attribs->push_back(sample_buffers); | 1324 attribs->push_back(sample_buffers); |
1326 } | 1325 } |
1327 attribs->push_back(kSwapBehavior); | 1326 attribs->push_back(kSwapBehavior); |
1328 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); | 1327 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); |
1329 attribs->push_back(kBindGeneratesResource); | 1328 attribs->push_back(kBindGeneratesResource); |
1330 attribs->push_back(bind_generates_resource ? 1 : 0); | 1329 attribs->push_back(bind_generates_resource ? 1 : 0); |
1331 attribs->push_back(kFailIfMajorPerfCaveat); | 1330 attribs->push_back(kFailIfMajorPerfCaveat); |
1332 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); | 1331 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); |
1333 attribs->push_back(kLoseContextWhenOutOfMemory); | 1332 attribs->push_back(kLoseContextWhenOutOfMemory); |
1334 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); | 1333 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); |
1335 attribs->push_back(kWebGLVersion); | 1334 attribs->push_back(kContextType); |
1336 attribs->push_back(webgl_version); | 1335 attribs->push_back(context_type); |
1337 attribs->push_back(kNone); | 1336 attribs->push_back(kNone); |
1338 } | 1337 } |
1339 | 1338 |
1340 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 1339 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
1341 for (size_t i = 0; i < attribs.size(); i += 2) { | 1340 for (size_t i = 0; i < attribs.size(); i += 2) { |
1342 const int32 attrib = attribs[i]; | 1341 const int32 attrib = attribs[i]; |
1343 if (i + 1 >= attribs.size()) { | 1342 if (i + 1 >= attribs.size()) { |
1344 if (attrib == kNone) { | 1343 if (attrib == kNone) { |
1345 return true; | 1344 return true; |
1346 } | 1345 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 break; | 1380 break; |
1382 case kBindGeneratesResource: | 1381 case kBindGeneratesResource: |
1383 bind_generates_resource = value != 0; | 1382 bind_generates_resource = value != 0; |
1384 break; | 1383 break; |
1385 case kFailIfMajorPerfCaveat: | 1384 case kFailIfMajorPerfCaveat: |
1386 fail_if_major_perf_caveat = value != 0; | 1385 fail_if_major_perf_caveat = value != 0; |
1387 break; | 1386 break; |
1388 case kLoseContextWhenOutOfMemory: | 1387 case kLoseContextWhenOutOfMemory: |
1389 lose_context_when_out_of_memory = value != 0; | 1388 lose_context_when_out_of_memory = value != 0; |
1390 break; | 1389 break; |
1391 case kWebGLVersion: | 1390 case kContextType: |
1392 webgl_version = value; | 1391 context_type = static_cast<ContextType>(value); |
1393 break; | 1392 break; |
1394 case kNone: | 1393 case kNone: |
1395 // Terminate list, even if more attributes. | 1394 // Terminate list, even if more attributes. |
1396 return true; | 1395 return true; |
1397 default: | 1396 default: |
1398 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 1397 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
1399 return false; | 1398 return false; |
1400 } | 1399 } |
1401 } | 1400 } |
1402 | 1401 |
1403 return true; | 1402 return true; |
1404 } | 1403 } |
1405 | 1404 |
1406 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1405 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
1407 | 1406 |
1408 } // namespace gles2 | 1407 } // namespace gles2 |
1409 } // namespace gpu | 1408 } // namespace gpu |
1410 | 1409 |
OLD | NEW |