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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 767 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
768 const int32 kNone = 0x3038; // EGL_NONE | 768 const int32 kNone = 0x3038; // EGL_NONE |
769 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 769 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
770 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 770 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
771 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 771 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
772 | 772 |
773 // Chromium only. | 773 // Chromium only. |
774 const int32 kShareResources = 0x10000; | 774 const int32 kShareResources = 0x10000; |
775 const int32 kBindGeneratesResource = 0x10001; | 775 const int32 kBindGeneratesResource = 0x10001; |
776 const int32 kFailIfMajorPerfCaveat = 0x10002; | 776 const int32 kFailIfMajorPerfCaveat = 0x10002; |
777 const int32 kLoseContextWhenOutOfMemory = 0x10003; | |
778 | 777 |
779 } // namespace | 778 } // namespace |
780 | 779 |
781 ContextCreationAttribHelper::ContextCreationAttribHelper() | 780 ContextCreationAttribHelper::ContextCreationAttribHelper() |
782 : alpha_size_(-1), | 781 : alpha_size_(-1), |
783 blue_size_(-1), | 782 blue_size_(-1), |
784 green_size_(-1), | 783 green_size_(-1), |
785 red_size_(-1), | 784 red_size_(-1), |
786 depth_size_(-1), | 785 depth_size_(-1), |
787 stencil_size_(-1), | 786 stencil_size_(-1), |
788 samples_(-1), | 787 samples_(-1), |
789 sample_buffers_(-1), | 788 sample_buffers_(-1), |
790 buffer_preserved_(true), | 789 buffer_preserved_(true), |
791 share_resources_(false), | 790 share_resources_(false), |
792 bind_generates_resource_(true), | 791 bind_generates_resource_(true), |
793 fail_if_major_perf_caveat_(false), | 792 fail_if_major_perf_caveat_(false) { |
794 lose_context_when_out_of_memory_(false) {} | 793 } |
795 | 794 |
796 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { | 795 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { |
797 if (alpha_size_ != -1) { | 796 if (alpha_size_ != -1) { |
798 attribs->push_back(kAlphaSize); | 797 attribs->push_back(kAlphaSize); |
799 attribs->push_back(alpha_size_); | 798 attribs->push_back(alpha_size_); |
800 } | 799 } |
801 if (blue_size_ != -1) { | 800 if (blue_size_ != -1) { |
802 attribs->push_back(kBlueSize); | 801 attribs->push_back(kBlueSize); |
803 attribs->push_back(blue_size_); | 802 attribs->push_back(blue_size_); |
804 } | 803 } |
(...skipping 22 matching lines...) Expand all Loading... |
827 attribs->push_back(sample_buffers_); | 826 attribs->push_back(sample_buffers_); |
828 } | 827 } |
829 attribs->push_back(kSwapBehavior); | 828 attribs->push_back(kSwapBehavior); |
830 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); | 829 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); |
831 attribs->push_back(kShareResources); | 830 attribs->push_back(kShareResources); |
832 attribs->push_back(share_resources_ ? 1 : 0); | 831 attribs->push_back(share_resources_ ? 1 : 0); |
833 attribs->push_back(kBindGeneratesResource); | 832 attribs->push_back(kBindGeneratesResource); |
834 attribs->push_back(bind_generates_resource_ ? 1 : 0); | 833 attribs->push_back(bind_generates_resource_ ? 1 : 0); |
835 attribs->push_back(kFailIfMajorPerfCaveat); | 834 attribs->push_back(kFailIfMajorPerfCaveat); |
836 attribs->push_back(fail_if_major_perf_caveat_ ? 1 : 0); | 835 attribs->push_back(fail_if_major_perf_caveat_ ? 1 : 0); |
837 attribs->push_back(kLoseContextWhenOutOfMemory); | |
838 attribs->push_back(lose_context_when_out_of_memory_ ? 1 : 0); | |
839 attribs->push_back(kNone); | 836 attribs->push_back(kNone); |
840 } | 837 } |
841 | 838 |
842 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 839 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
843 for (size_t i = 0; i < attribs.size(); i += 2) { | 840 for (size_t i = 0; i < attribs.size(); i += 2) { |
844 const int32 attrib = attribs[i]; | 841 const int32 attrib = attribs[i]; |
845 if (i + 1 >= attribs.size()) { | 842 if (i + 1 >= attribs.size()) { |
846 if (attrib == kNone) { | 843 if (attrib == kNone) { |
847 return true; | 844 return true; |
848 } | 845 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 break; | 880 break; |
884 case kShareResources: | 881 case kShareResources: |
885 share_resources_ = value != 0; | 882 share_resources_ = value != 0; |
886 break; | 883 break; |
887 case kBindGeneratesResource: | 884 case kBindGeneratesResource: |
888 bind_generates_resource_ = value != 0; | 885 bind_generates_resource_ = value != 0; |
889 break; | 886 break; |
890 case kFailIfMajorPerfCaveat: | 887 case kFailIfMajorPerfCaveat: |
891 fail_if_major_perf_caveat_ = value != 0; | 888 fail_if_major_perf_caveat_ = value != 0; |
892 break; | 889 break; |
893 case kLoseContextWhenOutOfMemory: | |
894 lose_context_when_out_of_memory_ = value != 0; | |
895 break; | |
896 case kNone: | 890 case kNone: |
897 // Terminate list, even if more attributes. | 891 // Terminate list, even if more attributes. |
898 return true; | 892 return true; |
899 default: | 893 default: |
900 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 894 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
901 return false; | 895 return false; |
902 } | 896 } |
903 } | 897 } |
904 | 898 |
905 return true; | 899 return true; |
906 } | 900 } |
907 | 901 |
908 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 902 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
909 | 903 |
910 } // namespace gles2 | 904 } // namespace gles2 |
911 } // namespace gpu | 905 } // namespace gpu |
912 | 906 |
OLD | NEW |