| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 return true; | 797 return true; |
| 798 case GL_MAX_VERTEX_ATTRIBS: | 798 case GL_MAX_VERTEX_ATTRIBS: |
| 799 *params = capabilities_.max_vertex_attribs; | 799 *params = capabilities_.max_vertex_attribs; |
| 800 return true; | 800 return true; |
| 801 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: | 801 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 802 *params = capabilities_.max_vertex_texture_image_units; | 802 *params = capabilities_.max_vertex_texture_image_units; |
| 803 return true; | 803 return true; |
| 804 case GL_MAX_VERTEX_UNIFORM_VECTORS: | 804 case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 805 *params = capabilities_.max_vertex_uniform_vectors; | 805 *params = capabilities_.max_vertex_uniform_vectors; |
| 806 return true; | 806 return true; |
| 807 case GL_MAX_VIEWPORT_DIMS: |
| 808 params[0] = capabilities_.max_viewport_width; |
| 809 params[1] = capabilities_.max_viewport_height; |
| 810 return true; |
| 807 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: | 811 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 808 *params = capabilities_.num_compressed_texture_formats; | 812 *params = capabilities_.num_compressed_texture_formats; |
| 809 return true; | 813 return true; |
| 810 case GL_NUM_SHADER_BINARY_FORMATS: | 814 case GL_NUM_SHADER_BINARY_FORMATS: |
| 811 *params = capabilities_.num_shader_binary_formats; | 815 *params = capabilities_.num_shader_binary_formats; |
| 812 return true; | 816 return true; |
| 813 case GL_RENDERBUFFER_BINDING: | 817 case GL_RENDERBUFFER_BINDING: |
| 814 *params = bound_renderbuffer_; | 818 *params = bound_renderbuffer_; |
| 815 return true; | 819 return true; |
| 816 case GL_TEXTURE_BINDING_2D: | 820 case GL_TEXTURE_BINDING_2D: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 840 case GL_TIMESTAMP_EXT: | 844 case GL_TIMESTAMP_EXT: |
| 841 // We convert all GPU timestamps to CPU time. | 845 // We convert all GPU timestamps to CPU time. |
| 842 *params = base::saturated_cast<GLint>( | 846 *params = base::saturated_cast<GLint>( |
| 843 (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() | 847 (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds() |
| 844 * base::Time::kNanosecondsPerMicrosecond); | 848 * base::Time::kNanosecondsPerMicrosecond); |
| 845 return true; | 849 return true; |
| 846 case GL_GPU_DISJOINT_EXT: | 850 case GL_GPU_DISJOINT_EXT: |
| 847 *params = static_cast<GLint>(query_tracker_->CheckAndResetDisjoint()); | 851 *params = static_cast<GLint>(query_tracker_->CheckAndResetDisjoint()); |
| 848 return true; | 852 return true; |
| 849 | 853 |
| 854 case GL_VIEWPORT: |
| 855 if (state_.viewport_width > 0 || state_.viewport_height > 0) { |
| 856 params[0] = state_.viewport_x; |
| 857 params[1] = state_.viewport_y; |
| 858 params[2] = std::min(state_.viewport_width, |
| 859 capabilities_.max_viewport_width); |
| 860 params[3] = std::min(state_.viewport_height, |
| 861 capabilities_.max_viewport_height); |
| 862 return true; |
| 863 } |
| 864 // If they haven't been cached on the client side, go to service side |
| 865 // to query the underlying driver. |
| 866 return false; |
| 867 |
| 850 // Non-cached parameters. | 868 // Non-cached parameters. |
| 851 case GL_ALIASED_LINE_WIDTH_RANGE: | 869 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 852 case GL_ALIASED_POINT_SIZE_RANGE: | 870 case GL_ALIASED_POINT_SIZE_RANGE: |
| 853 case GL_ALPHA_BITS: | 871 case GL_ALPHA_BITS: |
| 854 case GL_BLEND: | 872 case GL_BLEND: |
| 855 case GL_BLEND_COLOR: | 873 case GL_BLEND_COLOR: |
| 856 case GL_BLEND_DST_ALPHA: | 874 case GL_BLEND_DST_ALPHA: |
| 857 case GL_BLEND_DST_RGB: | 875 case GL_BLEND_DST_RGB: |
| 858 case GL_BLEND_EQUATION_ALPHA: | 876 case GL_BLEND_EQUATION_ALPHA: |
| 859 case GL_BLEND_EQUATION_RGB: | 877 case GL_BLEND_EQUATION_RGB: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 872 case GL_DEPTH_RANGE: | 890 case GL_DEPTH_RANGE: |
| 873 case GL_DEPTH_TEST: | 891 case GL_DEPTH_TEST: |
| 874 case GL_DEPTH_WRITEMASK: | 892 case GL_DEPTH_WRITEMASK: |
| 875 case GL_DITHER: | 893 case GL_DITHER: |
| 876 case GL_FRONT_FACE: | 894 case GL_FRONT_FACE: |
| 877 case GL_GENERATE_MIPMAP_HINT: | 895 case GL_GENERATE_MIPMAP_HINT: |
| 878 case GL_GREEN_BITS: | 896 case GL_GREEN_BITS: |
| 879 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: | 897 case GL_IMPLEMENTATION_COLOR_READ_FORMAT: |
| 880 case GL_IMPLEMENTATION_COLOR_READ_TYPE: | 898 case GL_IMPLEMENTATION_COLOR_READ_TYPE: |
| 881 case GL_LINE_WIDTH: | 899 case GL_LINE_WIDTH: |
| 882 case GL_MAX_VIEWPORT_DIMS: | |
| 883 case GL_PACK_ALIGNMENT: | 900 case GL_PACK_ALIGNMENT: |
| 884 case GL_POLYGON_OFFSET_FACTOR: | 901 case GL_POLYGON_OFFSET_FACTOR: |
| 885 case GL_POLYGON_OFFSET_FILL: | 902 case GL_POLYGON_OFFSET_FILL: |
| 886 case GL_POLYGON_OFFSET_UNITS: | 903 case GL_POLYGON_OFFSET_UNITS: |
| 887 case GL_RED_BITS: | 904 case GL_RED_BITS: |
| 888 case GL_SAMPLE_ALPHA_TO_COVERAGE: | 905 case GL_SAMPLE_ALPHA_TO_COVERAGE: |
| 889 case GL_SAMPLE_BUFFERS: | 906 case GL_SAMPLE_BUFFERS: |
| 890 case GL_SAMPLE_COVERAGE: | 907 case GL_SAMPLE_COVERAGE: |
| 891 case GL_SAMPLE_COVERAGE_INVERT: | 908 case GL_SAMPLE_COVERAGE_INVERT: |
| 892 case GL_SAMPLE_COVERAGE_VALUE: | 909 case GL_SAMPLE_COVERAGE_VALUE: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 907 case GL_STENCIL_FAIL: | 924 case GL_STENCIL_FAIL: |
| 908 case GL_STENCIL_FUNC: | 925 case GL_STENCIL_FUNC: |
| 909 case GL_STENCIL_PASS_DEPTH_FAIL: | 926 case GL_STENCIL_PASS_DEPTH_FAIL: |
| 910 case GL_STENCIL_PASS_DEPTH_PASS: | 927 case GL_STENCIL_PASS_DEPTH_PASS: |
| 911 case GL_STENCIL_REF: | 928 case GL_STENCIL_REF: |
| 912 case GL_STENCIL_TEST: | 929 case GL_STENCIL_TEST: |
| 913 case GL_STENCIL_VALUE_MASK: | 930 case GL_STENCIL_VALUE_MASK: |
| 914 case GL_STENCIL_WRITEMASK: | 931 case GL_STENCIL_WRITEMASK: |
| 915 case GL_SUBPIXEL_BITS: | 932 case GL_SUBPIXEL_BITS: |
| 916 case GL_UNPACK_ALIGNMENT: | 933 case GL_UNPACK_ALIGNMENT: |
| 917 case GL_VIEWPORT: | |
| 918 return false; | 934 return false; |
| 919 default: | 935 default: |
| 920 break; | 936 break; |
| 921 } | 937 } |
| 922 | 938 |
| 923 if (capabilities_.major_version < 3) { | 939 if (capabilities_.major_version < 3) { |
| 924 return false; | 940 return false; |
| 925 } | 941 } |
| 926 | 942 |
| 927 // ES3 parameters. | 943 // ES3 parameters. |
| (...skipping 6095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7023 return; | 7039 return; |
| 7024 } | 7040 } |
| 7025 GetStringHelper(GL_EXTENSIONS); | 7041 GetStringHelper(GL_EXTENSIONS); |
| 7026 } | 7042 } |
| 7027 | 7043 |
| 7028 void GLES2Implementation::InvalidateCachedExtensions() { | 7044 void GLES2Implementation::InvalidateCachedExtensions() { |
| 7029 cached_extension_string_ = nullptr; | 7045 cached_extension_string_ = nullptr; |
| 7030 cached_extensions_.clear(); | 7046 cached_extensions_.clear(); |
| 7031 } | 7047 } |
| 7032 | 7048 |
| 7049 void GLES2Implementation::Viewport(GLint x, |
| 7050 GLint y, |
| 7051 GLsizei width, |
| 7052 GLsizei height) { |
| 7053 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 7054 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glViewport(" << x << ", " << y |
| 7055 << ", " << width << ", " << height << ")"); |
| 7056 if (width < 0 || height < 0) { |
| 7057 SetGLError(GL_INVALID_VALUE, "glViewport", "negative width/height"); |
| 7058 return; |
| 7059 } |
| 7060 state_.SetViewport(x, y, width, height); |
| 7061 helper_->Viewport(x, y, width, height); |
| 7062 CheckGLError(); |
| 7063 } |
| 7064 |
| 7033 // Include the auto-generated part of this file. We split this because it means | 7065 // Include the auto-generated part of this file. We split this because it means |
| 7034 // we can easily edit the non-auto generated parts right here in this file | 7066 // we can easily edit the non-auto generated parts right here in this file |
| 7035 // instead of having to edit some template or the code generator. | 7067 // instead of having to edit some template or the code generator. |
| 7036 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 7068 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 7037 | 7069 |
| 7038 } // namespace gles2 | 7070 } // namespace gles2 |
| 7039 } // namespace gpu | 7071 } // namespace gpu |
| OLD | NEW |