Chromium Code Reviews| 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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 727 const int32 kSamples = 0x3031; // EGL_SAMPLES | 727 const int32 kSamples = 0x3031; // EGL_SAMPLES |
| 728 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS | 728 const int32 kSampleBuffers = 0x3032; // EGL_SAMPLE_BUFFERS |
| 729 const int32 kNone = 0x3038; // EGL_NONE | 729 const int32 kNone = 0x3038; // EGL_NONE |
| 730 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR | 730 const int32 kSwapBehavior = 0x3093; // EGL_SWAP_BEHAVIOR |
| 731 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED | 731 const int32 kBufferPreserved = 0x3094; // EGL_BUFFER_PRESERVED |
| 732 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED | 732 const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED |
| 733 | 733 |
| 734 // Chromium only. | 734 // Chromium only. |
| 735 const int32 kShareResources = 0x10000; | 735 const int32 kShareResources = 0x10000; |
| 736 const int32 kBindGeneratesResource = 0x10001; | 736 const int32 kBindGeneratesResource = 0x10001; |
| 737 const int32 kFailIfMajorPerfCaveat = 0x10002; | |
|
Ken Russell (switch to Gerrit)
2013/11/20 22:39:02
This duplication of constants is really unfortunat
| |
| 737 | 738 |
| 738 } // namespace | 739 } // namespace |
| 739 | 740 |
| 740 ContextCreationAttribHelper::ContextCreationAttribHelper() | 741 ContextCreationAttribHelper::ContextCreationAttribHelper() |
| 741 : alpha_size_(-1), | 742 : alpha_size_(-1), |
| 742 blue_size_(-1), | 743 blue_size_(-1), |
| 743 green_size_(-1), | 744 green_size_(-1), |
| 744 red_size_(-1), | 745 red_size_(-1), |
| 745 depth_size_(-1), | 746 depth_size_(-1), |
| 746 stencil_size_(-1), | 747 stencil_size_(-1), |
| 747 samples_(-1), | 748 samples_(-1), |
| 748 sample_buffers_(-1), | 749 sample_buffers_(-1), |
| 749 buffer_preserved_(true), | 750 buffer_preserved_(true), |
| 750 share_resources_(false), | 751 share_resources_(false), |
| 751 bind_generates_resource_(true) { | 752 bind_generates_resource_(true), |
| 753 fail_if_major_perf_caveat_(false) { | |
| 752 } | 754 } |
| 753 | 755 |
| 754 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { | 756 void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { |
| 755 if (alpha_size_ != -1) { | 757 if (alpha_size_ != -1) { |
| 756 attribs->push_back(kAlphaSize); | 758 attribs->push_back(kAlphaSize); |
| 757 attribs->push_back(alpha_size_); | 759 attribs->push_back(alpha_size_); |
| 758 } | 760 } |
| 759 if (blue_size_ != -1) { | 761 if (blue_size_ != -1) { |
| 760 attribs->push_back(kBlueSize); | 762 attribs->push_back(kBlueSize); |
| 761 attribs->push_back(blue_size_); | 763 attribs->push_back(blue_size_); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 783 if (sample_buffers_ != -1) { | 785 if (sample_buffers_ != -1) { |
| 784 attribs->push_back(kSampleBuffers); | 786 attribs->push_back(kSampleBuffers); |
| 785 attribs->push_back(sample_buffers_); | 787 attribs->push_back(sample_buffers_); |
| 786 } | 788 } |
| 787 attribs->push_back(kSwapBehavior); | 789 attribs->push_back(kSwapBehavior); |
| 788 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); | 790 attribs->push_back(buffer_preserved_ ? kBufferPreserved : kBufferDestroyed); |
| 789 attribs->push_back(kShareResources); | 791 attribs->push_back(kShareResources); |
| 790 attribs->push_back(share_resources_ ? 1 : 0); | 792 attribs->push_back(share_resources_ ? 1 : 0); |
| 791 attribs->push_back(kBindGeneratesResource); | 793 attribs->push_back(kBindGeneratesResource); |
| 792 attribs->push_back(bind_generates_resource_ ? 1 : 0); | 794 attribs->push_back(bind_generates_resource_ ? 1 : 0); |
| 795 attribs->push_back(kFailIfMajorPerfCaveat); | |
| 796 attribs->push_back(fail_if_major_perf_caveat_ ? 1 : 0); | |
| 793 attribs->push_back(kNone); | 797 attribs->push_back(kNone); |
| 794 } | 798 } |
| 795 | 799 |
| 796 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { | 800 bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { |
| 797 for (size_t i = 0; i < attribs.size(); i += 2) { | 801 for (size_t i = 0; i < attribs.size(); i += 2) { |
| 798 const int32 attrib = attribs[i]; | 802 const int32 attrib = attribs[i]; |
| 799 if (i + 1 >= attribs.size()) { | 803 if (i + 1 >= attribs.size()) { |
| 800 if (attrib == kNone) { | 804 if (attrib == kNone) { |
| 801 return true; | 805 return true; |
| 802 } | 806 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 break; | 838 break; |
| 835 case kSwapBehavior: | 839 case kSwapBehavior: |
| 836 buffer_preserved_ = value == kBufferPreserved; | 840 buffer_preserved_ = value == kBufferPreserved; |
| 837 break; | 841 break; |
| 838 case kShareResources: | 842 case kShareResources: |
| 839 share_resources_ = value != 0; | 843 share_resources_ = value != 0; |
| 840 break; | 844 break; |
| 841 case kBindGeneratesResource: | 845 case kBindGeneratesResource: |
| 842 bind_generates_resource_ = value != 0; | 846 bind_generates_resource_ = value != 0; |
| 843 break; | 847 break; |
| 848 case kFailIfMajorPerfCaveat: | |
| 849 fail_if_major_perf_caveat_ = value != 0; | |
| 850 break; | |
| 844 case kNone: | 851 case kNone: |
| 845 // Terminate list, even if more attributes. | 852 // Terminate list, even if more attributes. |
| 846 return true; | 853 return true; |
| 847 default: | 854 default: |
| 848 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; | 855 DLOG(ERROR) << "Invalid context creation attribute: " << attrib; |
| 849 return false; | 856 return false; |
| 850 } | 857 } |
| 851 } | 858 } |
| 852 | 859 |
| 853 return true; | 860 return true; |
| 854 } | 861 } |
| 855 | 862 |
| 856 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 863 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
| 857 | 864 |
| 858 } // namespace gles2 | 865 } // namespace gles2 |
| 859 } // namespace gpu | 866 } // namespace gpu |
| 860 | 867 |
| OLD | NEW |