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 <stdio.h> | 8 #include <stdio.h> |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 index = index * 10 + digit; | 708 index = index * 10 + digit; |
709 } | 709 } |
710 getting_array_location = true; | 710 getting_array_location = true; |
711 } | 711 } |
712 *getting_array = getting_array_location; | 712 *getting_array = getting_array_location; |
713 *element_index = index; | 713 *element_index = index; |
714 *array_pos = open_pos; | 714 *array_pos = open_pos; |
715 return true; | 715 return true; |
716 } | 716 } |
717 | 717 |
718 ContextCreationAttribParser::ContextCreationAttribParser() | 718 namespace { |
| 719 |
| 720 // From <EGL/egl.h>. |
| 721 const int32 kAlphaSize = 0x3021; // EGL_ALPHA_SIZE |
| 722 const int32 kBlueSize = 0x3022; // EGL_BLUE_SIZE |
| 723 const int32 kGreenSize = 0x3023; // EGL_GREEN_SIZE |
| 724 const int32 kRedSize = 0x3024; // EGL_RED_SIZE |
| 725 const int32 kDepthSize = 0x3025; // EGL_DEPTH_SIZE |
| 726 const int32 kStencilSize = 0x3026; // EGL_STENCIL_SIZE |
| 727 const int32 kSamples = 0x3031; // EGL_SAMPLES |
| 728 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
| 729 const int32 kNone = 0x3038; // EGL_NONE |
| 730 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
| 731 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
| 732 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
| 733 |
| 734 // Chromium only. |
| 735 const int32 kShareResources = 0x10000; |
| 736 const int32 kBindGeneratesResource = 0x10001; |
| 737 |
| 738 } // namespace |
| 739 |
| 740 ContextCreationAttribHelper::ContextCreationAttribHelper() |
719 : alpha_size_(-1), | 741 : alpha_size_(-1), |
720 blue_size_(-1), | 742 blue_size_(-1), |
721 green_size_(-1), | 743 green_size_(-1), |
722 red_size_(-1), | 744 red_size_(-1), |
723 depth_size_(-1), | 745 depth_size_(-1), |
724 stencil_size_(-1), | 746 stencil_size_(-1), |
725 samples_(-1), | 747 samples_(-1), |
726 sample_buffers_(-1), | 748 sample_buffers_(-1), |
727 buffer_preserved_(true), | 749 buffer_preserved_(true), |
728 share_resources_(false), | 750 share_resources_(false), |
729 bind_generates_resource_(true) { | 751 bind_generates_resource_(true) { |
730 } | 752 } |
731 | 753 |
732 bool ContextCreationAttribParser::Parse(const std::vector<int32>& attribs) { | 754 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { |
733 // From <EGL/egl.h>. | 755 if (alpha_size_ != -1) { |
734 const int32 EGL_ALPHA_SIZE = 0x3021; | 756 attribs->push_back(kAlphaSize); |
735 const int32 EGL_BLUE_SIZE = 0x3022; | 757 attribs->push_back(alpha_size_); |
736 const int32 EGL_GREEN_SIZE = 0x3023; | 758 } |
737 const int32 EGL_RED_SIZE = 0x3024; | 759 if (blue_size_ != -1) { |
738 const int32 EGL_DEPTH_SIZE = 0x3025; | 760 attribs->push_back(kBlueSize); |
739 const int32 EGL_STENCIL_SIZE = 0x3026; | 761 attribs->push_back(blue_size_); |
740 const int32 EGL_SAMPLES = 0x3031; | 762 } |
741 const int32 EGL_SAMPLE_BUFFERS = 0x3032; | 763 if (green_size_ != -1) { |
742 const int32 EGL_NONE = 0x3038; | 764 attribs->push_back(kGreenSize); |
743 const int32 EGL_SWAP_BEHAVIOR = 0x3093; | 765 attribs->push_back(green_size_); |
744 const int32 EGL_BUFFER_PRESERVED = 0x3094; | 766 } |
| 767 if (red_size_ != -1) { |
| 768 attribs->push_back(kRedSize); |
| 769 attribs->push_back(red_size_); |
| 770 } |
| 771 if (depth_size_ != -1) { |
| 772 attribs->push_back(kDepthSize); |
| 773 attribs->push_back(depth_size_); |
| 774 } |
| 775 if (stencil_size_ != -1) { |
| 776 attribs->push_back(kStencilSize); |
| 777 attribs->push_back(stencil_size_); |
| 778 } |
| 779 if (samples_ != -1) { |
| 780 attribs->push_back(kSamples); |
| 781 attribs->push_back(samples_); |
| 782 } |
| 783 if (sample_buffers_ != -1) { |
| 784 attribs->push_back(kSampleBuffers); |
| 785 attribs->push_back(sample_buffers_); |
| 786 } |
| 787 attribs->push_back(kSwapBehavior); |
| 788 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); |
| 789 attribs->push_back(kShareResources); |
| 790 attribs->push_back(share_resources_ ? 1 : 0); |
| 791 attribs->push_back(kBindGeneratesResource); |
| 792 attribs->push_back(bind_generates_resource_ ? 1 : 0); |
| 793 attribs->push_back(kNone); |
| 794 } |
745 | 795 |
746 // Chromium only. | 796 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
747 const int32 SHARE_RESOURCES = 0x10000; | |
748 const int32 BIND_GENERATES_RESOURCES = 0x10001; | |
749 | |
750 for (size_t i = 0; i < attribs.size(); i += 2) { | 797 for (size_t i = 0; i < attribs.size(); i += 2) { |
751 const int32 attrib = attribs[i]; | 798 const int32 attrib = attribs[i]; |
752 if (i + 1 >= attribs.size()) { | 799 if (i + 1 >= attribs.size()) { |
753 if (attrib == EGL_NONE) { | 800 if (attrib == kNone) { |
754 return true; | 801 return true; |
755 } | 802 } |
756 | 803 |
757 GPU_DLOG(ERROR) << "Missing value after context creation attribute: " | 804 GPU_DLOG(ERROR) << "Missing value after context creation attribute: " |
758 << attrib; | 805 << attrib; |
759 return false; | 806 return false; |
760 } | 807 } |
761 | 808 |
762 const int32 value = attribs[i+1]; | 809 const int32 value = attribs[i+1]; |
763 switch (attrib) { | 810 switch (attrib) { |
764 case EGL_ALPHA_SIZE: | 811 case kAlphaSize: |
765 alpha_size_ = value; | 812 alpha_size_ = value; |
766 break; | 813 break; |
767 case EGL_BLUE_SIZE: | 814 case kBlueSize: |
768 blue_size_ = value; | 815 blue_size_ = value; |
769 break; | 816 break; |
770 case EGL_GREEN_SIZE: | 817 case kGreenSize: |
771 green_size_ = value; | 818 green_size_ = value; |
772 break; | 819 break; |
773 case EGL_RED_SIZE: | 820 case kRedSize: |
774 red_size_ = value; | 821 red_size_ = value; |
775 break; | 822 break; |
776 case EGL_DEPTH_SIZE: | 823 case kDepthSize: |
777 depth_size_ = value; | 824 depth_size_ = value; |
778 break; | 825 break; |
779 case EGL_STENCIL_SIZE: | 826 case kStencilSize: |
780 stencil_size_ = value; | 827 stencil_size_ = value; |
781 break; | 828 break; |
782 case EGL_SAMPLES: | 829 case kSamples: |
783 samples_ = value; | 830 samples_ = value; |
784 break; | 831 break; |
785 case EGL_SAMPLE_BUFFERS: | 832 case kSampleBuffers: |
786 sample_buffers_ = value; | 833 sample_buffers_ = value; |
787 break; | 834 break; |
788 case EGL_SWAP_BEHAVIOR: | 835 case kSwapBehavior: |
789 buffer_preserved_ = value == EGL_BUFFER_PRESERVED; | 836 buffer_preserved_ = value == kBufferPreserved; |
790 break; | 837 break; |
791 case SHARE_RESOURCES: | 838 case kShareResources: |
792 share_resources_ = value != 0; | 839 share_resources_ = value != 0; |
793 break; | 840 break; |
794 case BIND_GENERATES_RESOURCES: | 841 case kBindGeneratesResource: |
795 bind_generates_resource_ = value != 0; | 842 bind_generates_resource_ = value != 0; |
796 break; | 843 break; |
797 case EGL_NONE: | 844 case kNone: |
798 // Terminate list, even if more attributes. | 845 // Terminate list, even if more attributes. |
799 return true; | 846 return true; |
800 default: | 847 default: |
801 GPU_DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 848 GPU_DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
802 return false; | 849 return false; |
803 } | 850 } |
804 } | 851 } |
805 | 852 |
806 return true; | 853 return true; |
807 } | 854 } |
808 | 855 |
809 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 856 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
810 | 857 |
811 } // namespace gles2 | 858 } // namespace gles2 |
812 } // namespace gpu | 859 } // namespace gpu |
813 | 860 |
OLD | NEW |