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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 getting_array_location = true; | 777 getting_array_location = true; |
778 } | 778 } |
779 *getting_array = getting_array_location; | 779 *getting_array = getting_array_location; |
780 *element_index = index; | 780 *element_index = index; |
781 *array_pos = open_pos; | 781 *array_pos = open_pos; |
782 return true; | 782 return true; |
783 } | 783 } |
784 | 784 |
785 namespace { | 785 namespace { |
786 | 786 |
787 // WebGraphicsContext3DCommandBufferImpl configuration attributes. Those in | |
788 // the 16-bit range are the same as used by EGL. Those outside the 16-bit range | |
789 // are unique to Chromium. Attributes are matched using a closest fit algorithm. | |
790 | |
787 // From <EGL/egl.h>. | 791 // From <EGL/egl.h>. |
788 const int32 kAlphaSize = 0x3021; // EGL_ALPHA_SIZE | 792 const int32 kAlphaSize = 0x3021; // EGL_ALPHA_SIZE |
789 const int32 kBlueSize = 0x3022; // EGL_BLUE_SIZE | 793 const int32 kBlueSize = 0x3022; // EGL_BLUE_SIZE |
790 const int32 kGreenSize = 0x3023; // EGL_GREEN_SIZE | 794 const int32 kGreenSize = 0x3023; // EGL_GREEN_SIZE |
791 const int32 kRedSize = 0x3024; // EGL_RED_SIZE | 795 const int32 kRedSize = 0x3024; // EGL_RED_SIZE |
792 const int32 kDepthSize = 0x3025; // EGL_DEPTH_SIZE | 796 const int32 kDepthSize = 0x3025; // EGL_DEPTH_SIZE |
793 const int32 kStencilSize = 0x3026; // EGL_STENCIL_SIZE | 797 const int32 kStencilSize = 0x3026; // EGL_STENCIL_SIZE |
794 const int32 kSamples = 0x3031; // EGL_SAMPLES | 798 const int32 kSamples = 0x3031; // EGL_SAMPLES |
795 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 799 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
796 const int32 kNone = 0x3038; // EGL_NONE | 800 const int32 kNone = 0x3038; // EGL_NONE |
797 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 801 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
798 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 802 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
799 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 803 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
800 | 804 |
801 // Chromium only. | 805 // Chromium only. |
802 const int32 kShareResources = 0x10000; | |
Zhenyao Mo
2014/08/09 00:42:25
nit: move the below three values one up. It's wei
| |
803 const int32 kBindGeneratesResource = 0x10001; | 806 const int32 kBindGeneratesResource = 0x10001; |
804 const int32 kFailIfMajorPerfCaveat = 0x10002; | 807 const int32 kFailIfMajorPerfCaveat = 0x10002; |
805 const int32 kLoseContextWhenOutOfMemory = 0x10003; | 808 const int32 kLoseContextWhenOutOfMemory = 0x10003; |
806 | 809 |
807 } // namespace | 810 } // namespace |
808 | 811 |
809 ContextCreationAttribHelper::ContextCreationAttribHelper() | 812 ContextCreationAttribHelper::ContextCreationAttribHelper() |
810 : alpha_size_(-1), | 813 : alpha_size_(-1), |
811 blue_size_(-1), | 814 blue_size_(-1), |
812 green_size_(-1), | 815 green_size_(-1), |
813 red_size_(-1), | 816 red_size_(-1), |
814 depth_size_(-1), | 817 depth_size_(-1), |
815 stencil_size_(-1), | 818 stencil_size_(-1), |
816 samples_(-1), | 819 samples_(-1), |
817 sample_buffers_(-1), | 820 sample_buffers_(-1), |
818 buffer_preserved_(true), | 821 buffer_preserved_(true), |
819 share_resources_(false), | |
820 bind_generates_resource_(true), | 822 bind_generates_resource_(true), |
821 fail_if_major_perf_caveat_(false), | 823 fail_if_major_perf_caveat_(false), |
822 lose_context_when_out_of_memory_(false) {} | 824 lose_context_when_out_of_memory_(false) {} |
823 | 825 |
824 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { | 826 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) const { |
825 if (alpha_size_ != -1) { | 827 if (alpha_size_ != -1) { |
826 attribs->push_back(kAlphaSize); | 828 attribs->push_back(kAlphaSize); |
827 attribs->push_back(alpha_size_); | 829 attribs->push_back(alpha_size_); |
828 } | 830 } |
829 if (blue_size_ != -1) { | 831 if (blue_size_ != -1) { |
830 attribs->push_back(kBlueSize); | 832 attribs->push_back(kBlueSize); |
831 attribs->push_back(blue_size_); | 833 attribs->push_back(blue_size_); |
832 } | 834 } |
833 if (green_size_ != -1) { | 835 if (green_size_ != -1) { |
834 attribs->push_back(kGreenSize); | 836 attribs->push_back(kGreenSize); |
(...skipping 14 matching lines...) Expand all Loading... | |
849 if (samples_ != -1) { | 851 if (samples_ != -1) { |
850 attribs->push_back(kSamples); | 852 attribs->push_back(kSamples); |
851 attribs->push_back(samples_); | 853 attribs->push_back(samples_); |
852 } | 854 } |
853 if (sample_buffers_ != -1) { | 855 if (sample_buffers_ != -1) { |
854 attribs->push_back(kSampleBuffers); | 856 attribs->push_back(kSampleBuffers); |
855 attribs->push_back(sample_buffers_); | 857 attribs->push_back(sample_buffers_); |
856 } | 858 } |
857 attribs->push_back(kSwapBehavior); | 859 attribs->push_back(kSwapBehavior); |
858 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); | 860 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); |
859 attribs->push_back(kShareResources); | |
860 attribs->push_back(share_resources_ ? 1 : 0); | |
861 attribs->push_back(kBindGeneratesResource); | 861 attribs->push_back(kBindGeneratesResource); |
862 attribs->push_back(bind_generates_resource_ ? 1 : 0); | 862 attribs->push_back(bind_generates_resource_ ? 1 : 0); |
863 attribs->push_back(kFailIfMajorPerfCaveat); | 863 attribs->push_back(kFailIfMajorPerfCaveat); |
864 attribs->push_back(fail_if_major_perf_caveat_ ? 1 : 0); | 864 attribs->push_back(fail_if_major_perf_caveat_ ? 1 : 0); |
865 attribs->push_back(kLoseContextWhenOutOfMemory); | 865 attribs->push_back(kLoseContextWhenOutOfMemory); |
866 attribs->push_back(lose_context_when_out_of_memory_ ? 1 : 0); | 866 attribs->push_back(lose_context_when_out_of_memory_ ? 1 : 0); |
867 attribs->push_back(kNone); | 867 attribs->push_back(kNone); |
868 } | 868 } |
869 | 869 |
870 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 870 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 break; | 902 break; |
903 case kSamples: | 903 case kSamples: |
904 samples_ = value; | 904 samples_ = value; |
905 break; | 905 break; |
906 case kSampleBuffers: | 906 case kSampleBuffers: |
907 sample_buffers_ = value; | 907 sample_buffers_ = value; |
908 break; | 908 break; |
909 case kSwapBehavior: | 909 case kSwapBehavior: |
910 buffer_preserved_ = value == kBufferPreserved; | 910 buffer_preserved_ = value == kBufferPreserved; |
911 break; | 911 break; |
912 case kShareResources: | |
913 share_resources_ = value != 0; | |
914 break; | |
915 case kBindGeneratesResource: | 912 case kBindGeneratesResource: |
916 bind_generates_resource_ = value != 0; | 913 bind_generates_resource_ = value != 0; |
917 break; | 914 break; |
918 case kFailIfMajorPerfCaveat: | 915 case kFailIfMajorPerfCaveat: |
919 fail_if_major_perf_caveat_ = value != 0; | 916 fail_if_major_perf_caveat_ = value != 0; |
920 break; | 917 break; |
921 case kLoseContextWhenOutOfMemory: | 918 case kLoseContextWhenOutOfMemory: |
922 lose_context_when_out_of_memory_ = value != 0; | 919 lose_context_when_out_of_memory_ = value != 0; |
923 break; | 920 break; |
924 case kNone: | 921 case kNone: |
925 // Terminate list, even if more attributes. | 922 // Terminate list, even if more attributes. |
926 return true; | 923 return true; |
927 default: | 924 default: |
928 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 925 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
929 return false; | 926 return false; |
930 } | 927 } |
931 } | 928 } |
932 | 929 |
933 return true; | 930 return true; |
934 } | 931 } |
935 | 932 |
936 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 933 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
937 | 934 |
938 } // namespace gles2 | 935 } // namespace gles2 |
939 } // namespace gpu | 936 } // namespace gpu |
940 | 937 |
OLD | NEW |