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