| 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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 887 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
| 888 const int32 kNone = 0x3038; // EGL_NONE | 888 const int32 kNone = 0x3038; // EGL_NONE |
| 889 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 889 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
| 890 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 890 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
| 891 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 891 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
| 892 | 892 |
| 893 // Chromium only. | 893 // Chromium only. |
| 894 const int32 kBindGeneratesResource = 0x10000; | 894 const int32 kBindGeneratesResource = 0x10000; |
| 895 const int32 kFailIfMajorPerfCaveat = 0x10001; | 895 const int32 kFailIfMajorPerfCaveat = 0x10001; |
| 896 const int32 kLoseContextWhenOutOfMemory = 0x10002; | 896 const int32 kLoseContextWhenOutOfMemory = 0x10002; |
| 897 const int32 kES3ContextRequired = 0x10003; |
| 897 | 898 |
| 898 } // namespace | 899 } // namespace |
| 899 | 900 |
| 900 ContextCreationAttribHelper::ContextCreationAttribHelper() | 901 ContextCreationAttribHelper::ContextCreationAttribHelper() |
| 901 : alpha_size(-1), | 902 : alpha_size(-1), |
| 902 blue_size(-1), | 903 blue_size(-1), |
| 903 green_size(-1), | 904 green_size(-1), |
| 904 red_size(-1), | 905 red_size(-1), |
| 905 depth_size(-1), | 906 depth_size(-1), |
| 906 stencil_size(-1), | 907 stencil_size(-1), |
| 907 samples(-1), | 908 samples(-1), |
| 908 sample_buffers(-1), | 909 sample_buffers(-1), |
| 909 buffer_preserved(true), | 910 buffer_preserved(true), |
| 910 bind_generates_resource(true), | 911 bind_generates_resource(true), |
| 911 fail_if_major_perf_caveat(false), | 912 fail_if_major_perf_caveat(false), |
| 912 lose_context_when_out_of_memory(false) {} | 913 lose_context_when_out_of_memory(false), |
| 914 es3_context_required(false) {} |
| 913 | 915 |
| 914 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { | 916 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { |
| 915 if (alpha_size != -1) { | 917 if (alpha_size != -1) { |
| 916 attribs->push_back(kAlphaSize); | 918 attribs->push_back(kAlphaSize); |
| 917 attribs->push_back(alpha_size); | 919 attribs->push_back(alpha_size); |
| 918 } | 920 } |
| 919 if (blue_size != -1) { | 921 if (blue_size != -1) { |
| 920 attribs->push_back(kBlueSize); | 922 attribs->push_back(kBlueSize); |
| 921 attribs->push_back(blue_size); | 923 attribs->push_back(blue_size); |
| 922 } | 924 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 945 attribs->push_back(sample_buffers); | 947 attribs->push_back(sample_buffers); |
| 946 } | 948 } |
| 947 attribs->push_back(kSwapBehavior); | 949 attribs->push_back(kSwapBehavior); |
| 948 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); | 950 attribs->push_back(buffer_preserved ? kBufferPreserved : kBufferDestroyed); |
| 949 attribs->push_back(kBindGeneratesResource); | 951 attribs->push_back(kBindGeneratesResource); |
| 950 attribs->push_back(bind_generates_resource ? 1 : 0); | 952 attribs->push_back(bind_generates_resource ? 1 : 0); |
| 951 attribs->push_back(kFailIfMajorPerfCaveat); | 953 attribs->push_back(kFailIfMajorPerfCaveat); |
| 952 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); | 954 attribs->push_back(fail_if_major_perf_caveat ? 1 : 0); |
| 953 attribs->push_back(kLoseContextWhenOutOfMemory); | 955 attribs->push_back(kLoseContextWhenOutOfMemory); |
| 954 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); | 956 attribs->push_back(lose_context_when_out_of_memory ? 1 : 0); |
| 957 attribs->push_back(kES3ContextRequired); |
| 958 attribs->push_back(es3_context_required ? 1 : 0); |
| 955 attribs->push_back(kNone); | 959 attribs->push_back(kNone); |
| 956 } | 960 } |
| 957 | 961 |
| 958 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 962 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
| 959 for (size_t i = 0; i < attribs.size(); i += 2) { | 963 for (size_t i = 0; i < attribs.size(); i += 2) { |
| 960 const int32 attrib = attribs[i]; | 964 const int32 attrib = attribs[i]; |
| 961 if (i + 1 >= attribs.size()) { | 965 if (i + 1 >= attribs.size()) { |
| 962 if (attrib == kNone) { | 966 if (attrib == kNone) { |
| 963 return true; | 967 return true; |
| 964 } | 968 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 break; | 1003 break; |
| 1000 case kBindGeneratesResource: | 1004 case kBindGeneratesResource: |
| 1001 bind_generates_resource = value != 0; | 1005 bind_generates_resource = value != 0; |
| 1002 break; | 1006 break; |
| 1003 case kFailIfMajorPerfCaveat: | 1007 case kFailIfMajorPerfCaveat: |
| 1004 fail_if_major_perf_caveat = value != 0; | 1008 fail_if_major_perf_caveat = value != 0; |
| 1005 break; | 1009 break; |
| 1006 case kLoseContextWhenOutOfMemory: | 1010 case kLoseContextWhenOutOfMemory: |
| 1007 lose_context_when_out_of_memory = value != 0; | 1011 lose_context_when_out_of_memory = value != 0; |
| 1008 break; | 1012 break; |
| 1013 case kES3ContextRequired: |
| 1014 es3_context_required = value != 0; |
| 1015 break; |
| 1009 case kNone: | 1016 case kNone: |
| 1010 // Terminate list, even if more attributes. | 1017 // Terminate list, even if more attributes. |
| 1011 return true; | 1018 return true; |
| 1012 default: | 1019 default: |
| 1013 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 1020 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
| 1014 return false; | 1021 return false; |
| 1015 } | 1022 } |
| 1016 } | 1023 } |
| 1017 | 1024 |
| 1018 return true; | 1025 return true; |
| 1019 } | 1026 } |
| 1020 | 1027 |
| 1021 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1028 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
| 1022 | 1029 |
| 1023 } // namespace gles2 | 1030 } // namespace gles2 |
| 1024 } // namespace gpu | 1031 } // namespace gpu |
| 1025 | 1032 |
| OLD | NEW |