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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "gpu/command_buffer/service/framebuffer_manager.h" | 41 #include "gpu/command_buffer/service/framebuffer_manager.h" |
42 #include "gpu/command_buffer/service/gl_utils.h" | 42 #include "gpu/command_buffer/service/gl_utils.h" |
43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
44 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 44 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
45 #include "gpu/command_buffer/service/gpu_state_tracer.h" | 45 #include "gpu/command_buffer/service/gpu_state_tracer.h" |
46 #include "gpu/command_buffer/service/gpu_switches.h" | 46 #include "gpu/command_buffer/service/gpu_switches.h" |
47 #include "gpu/command_buffer/service/gpu_tracer.h" | 47 #include "gpu/command_buffer/service/gpu_tracer.h" |
48 #include "gpu/command_buffer/service/image_manager.h" | 48 #include "gpu/command_buffer/service/image_manager.h" |
49 #include "gpu/command_buffer/service/mailbox_manager.h" | 49 #include "gpu/command_buffer/service/mailbox_manager.h" |
50 #include "gpu/command_buffer/service/memory_tracking.h" | 50 #include "gpu/command_buffer/service/memory_tracking.h" |
| 51 #include "gpu/command_buffer/service/path_manager.h" |
51 #include "gpu/command_buffer/service/program_manager.h" | 52 #include "gpu/command_buffer/service/program_manager.h" |
52 #include "gpu/command_buffer/service/query_manager.h" | 53 #include "gpu/command_buffer/service/query_manager.h" |
53 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 54 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
54 #include "gpu/command_buffer/service/shader_manager.h" | 55 #include "gpu/command_buffer/service/shader_manager.h" |
55 #include "gpu/command_buffer/service/shader_translator.h" | 56 #include "gpu/command_buffer/service/shader_translator.h" |
56 #include "gpu/command_buffer/service/shader_translator_cache.h" | 57 #include "gpu/command_buffer/service/shader_translator_cache.h" |
57 #include "gpu/command_buffer/service/texture_manager.h" | 58 #include "gpu/command_buffer/service/texture_manager.h" |
58 #include "gpu/command_buffer/service/vertex_array_manager.h" | 59 #include "gpu/command_buffer/service/vertex_array_manager.h" |
59 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 60 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
60 #include "ui/gl/gl_bindings.h" | 61 #include "ui/gl/gl_bindings.h" |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); | 733 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); |
733 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); | 734 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); |
734 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 735 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
735 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 736 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
736 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 737 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
737 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 738 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
738 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 739 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
739 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 740 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
740 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 741 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
741 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 742 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
| 743 bool GenPathsCHROMIUMHelper(GLsizei range, const GLuint* client_ids); |
| 744 void DeletePathsCHROMIUMHelper(GLuint path, GLsizei range); |
742 | 745 |
743 // Helper for async upload token completion notification callback. | 746 // Helper for async upload token completion notification callback. |
744 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, | 747 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, |
745 uint32 sync_data_shm_id, | 748 uint32 sync_data_shm_id, |
746 uint32 sync_data_shm_offset); | 749 uint32 sync_data_shm_offset); |
747 | 750 |
748 | 751 |
749 | 752 |
750 // Workarounds | 753 // Workarounds |
751 void OnFboChanged() const; | 754 void OnFboChanged() const; |
752 void OnUseFramebuffer() const; | 755 void OnUseFramebuffer() const; |
753 | 756 |
754 // TODO(gman): Cache these pointers? | 757 // TODO(gman): Cache these pointers? |
755 BufferManager* buffer_manager() { | 758 BufferManager* buffer_manager() { |
756 return group_->buffer_manager(); | 759 return group_->buffer_manager(); |
757 } | 760 } |
758 | 761 |
759 RenderbufferManager* renderbuffer_manager() { | 762 RenderbufferManager* renderbuffer_manager() { |
760 return group_->renderbuffer_manager(); | 763 return group_->renderbuffer_manager(); |
761 } | 764 } |
762 | 765 |
763 FramebufferManager* framebuffer_manager() { | 766 FramebufferManager* framebuffer_manager() { |
764 return group_->framebuffer_manager(); | 767 return group_->framebuffer_manager(); |
765 } | 768 } |
766 | 769 |
| 770 PathManager* path_manager() { return group_->path_manager(); } |
| 771 |
767 ProgramManager* program_manager() { | 772 ProgramManager* program_manager() { |
768 return group_->program_manager(); | 773 return group_->program_manager(); |
769 } | 774 } |
770 | 775 |
771 ShaderManager* shader_manager() { | 776 ShaderManager* shader_manager() { |
772 return group_->shader_manager(); | 777 return group_->shader_manager(); |
773 } | 778 } |
774 | 779 |
775 ShaderTranslatorCache* shader_translator_cache() { | 780 ShaderTranslatorCache* shader_translator_cache() { |
776 return group_->shader_translator_cache(); | 781 return group_->shader_translator_cache(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 // Gets the texture info for the given texture. Returns NULL if none exists. | 826 // Gets the texture info for the given texture. Returns NULL if none exists. |
822 TextureRef* GetTexture(GLuint client_id) const { | 827 TextureRef* GetTexture(GLuint client_id) const { |
823 return texture_manager()->GetTexture(client_id); | 828 return texture_manager()->GetTexture(client_id); |
824 } | 829 } |
825 | 830 |
826 // Deletes the texture info for the given texture. | 831 // Deletes the texture info for the given texture. |
827 void RemoveTexture(GLuint client_id) { | 832 void RemoveTexture(GLuint client_id) { |
828 texture_manager()->RemoveTexture(client_id); | 833 texture_manager()->RemoveTexture(client_id); |
829 } | 834 } |
830 | 835 |
| 836 GLuint GetPath(GLuint client_id, error::Error* path_error); |
| 837 |
831 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 838 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
832 // or regular back buffer). | 839 // or regular back buffer). |
833 gfx::Size GetBoundReadFrameBufferSize(); | 840 gfx::Size GetBoundReadFrameBufferSize(); |
834 | 841 |
835 // Get the format of the currently bound frame buffer (either FBO or regular | 842 // Get the format of the currently bound frame buffer (either FBO or regular |
836 // back buffer) | 843 // back buffer) |
837 GLenum GetBoundReadFrameBufferTextureType(); | 844 GLenum GetBoundReadFrameBufferTextureType(); |
838 GLenum GetBoundReadFrameBufferInternalFormat(); | 845 GLenum GetBoundReadFrameBufferInternalFormat(); |
839 GLenum GetBoundDrawFrameBufferInternalFormat(); | 846 GLenum GetBoundDrawFrameBufferInternalFormat(); |
840 | 847 |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 if (!offscreen_target_frame_buffer_.get() && | 1628 if (!offscreen_target_frame_buffer_.get() && |
1622 !framebuffer_state_.bound_read_framebuffer.get() && | 1629 !framebuffer_state_.bound_read_framebuffer.get() && |
1623 !surface_->SetBackbufferAllocation(true)) | 1630 !surface_->SetBackbufferAllocation(true)) |
1624 return error::kLostContext; | 1631 return error::kLostContext; |
1625 return error::kNoError; | 1632 return error::kNoError; |
1626 } | 1633 } |
1627 | 1634 |
1628 void ProcessPendingReadPixels(); | 1635 void ProcessPendingReadPixels(); |
1629 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); | 1636 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); |
1630 | 1637 |
| 1638 error::Error PrepareInstancedPathCommand(uint32 num_paths, |
| 1639 uint32 paths_shm_id, |
| 1640 uint32 paths_shm_offset, |
| 1641 GLuint path_base, |
| 1642 GLenum transform_type, |
| 1643 uint32 transforms_shm_id, |
| 1644 uint32 transforms_shm_offset, |
| 1645 GLuint** out_paths, |
| 1646 const GLfloat** out_transforms); |
| 1647 |
1631 // Generate a member function prototype for each command in an automated and | 1648 // Generate a member function prototype for each command in an automated and |
1632 // typesafe way. | 1649 // typesafe way. |
1633 #define GLES2_CMD_OP(name) \ | 1650 #define GLES2_CMD_OP(name) \ |
1634 Error Handle ## name( \ | 1651 Error Handle ## name( \ |
1635 uint32 immediate_data_size, \ | 1652 uint32 immediate_data_size, \ |
1636 const cmds::name& args); \ | 1653 const cmds::name& args); \ |
1637 | 1654 |
1638 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1655 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1639 | 1656 |
1640 #undef GLES2_CMD_OP | 1657 #undef GLES2_CMD_OP |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 features().arb_texture_rectangle ? 1 : 0; | 2768 features().arb_texture_rectangle ? 1 : 0; |
2752 resources.OES_EGL_image_external = | 2769 resources.OES_EGL_image_external = |
2753 features().oes_egl_image_external ? 1 : 0; | 2770 features().oes_egl_image_external ? 1 : 0; |
2754 resources.EXT_draw_buffers = | 2771 resources.EXT_draw_buffers = |
2755 features().ext_draw_buffers ? 1 : 0; | 2772 features().ext_draw_buffers ? 1 : 0; |
2756 resources.EXT_frag_depth = | 2773 resources.EXT_frag_depth = |
2757 features().ext_frag_depth ? 1 : 0; | 2774 features().ext_frag_depth ? 1 : 0; |
2758 #if (ANGLE_SH_VERSION >= 123) | 2775 #if (ANGLE_SH_VERSION >= 123) |
2759 resources.EXT_shader_texture_lod = | 2776 resources.EXT_shader_texture_lod = |
2760 features().ext_shader_texture_lod ? 1 : 0; | 2777 features().ext_shader_texture_lod ? 1 : 0; |
| 2778 #if (ANGLE_SH_VERSION >= 124) |
| 2779 if (features().chromium_path_rendering) { |
| 2780 resources.CHROMIUM_path_rendering = 1; |
| 2781 GLint value = 0; |
| 2782 glGetIntegerv(GL_MAX_TEXTURE_COORDS, &value); |
| 2783 resources.MaxTextureCoords = value; |
| 2784 } |
| 2785 #endif |
2761 #endif | 2786 #endif |
2762 } | 2787 } |
2763 | 2788 |
2764 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC | 2789 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC |
2765 : SH_GLES2_SPEC; | 2790 : SH_GLES2_SPEC; |
2766 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) | 2791 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) |
2767 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | 2792 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |
2768 resources.HashFunction = &CityHashForAngle; | 2793 resources.HashFunction = &CityHashForAngle; |
2769 #else | 2794 #else |
2770 resources.HashFunction = &CityHash64; | 2795 resources.HashFunction = &CityHash64; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 } | 2888 } |
2864 } | 2889 } |
2865 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 2890 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
2866 glGenTextures(n, service_ids.get()); | 2891 glGenTextures(n, service_ids.get()); |
2867 for (GLsizei ii = 0; ii < n; ++ii) { | 2892 for (GLsizei ii = 0; ii < n; ++ii) { |
2868 CreateTexture(client_ids[ii], service_ids[ii]); | 2893 CreateTexture(client_ids[ii], service_ids[ii]); |
2869 } | 2894 } |
2870 return true; | 2895 return true; |
2871 } | 2896 } |
2872 | 2897 |
| 2898 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLsizei range, |
| 2899 const GLuint* client_ids) { |
| 2900 for (GLsizei ii = 0; ii < range; ++ii) { |
| 2901 if (path_manager()->GetPath(client_ids[ii])) { |
| 2902 return false; |
| 2903 } |
| 2904 } |
| 2905 |
| 2906 GLuint n = glGenPathsNV(range); |
| 2907 for (GLsizei ii = 0; ii < range; ++ii) { |
| 2908 path_manager()->CreatePath(client_ids[ii], n + ii); |
| 2909 } |
| 2910 return true; |
| 2911 } |
| 2912 |
| 2913 void GLES2DecoderImpl::DeletePathsCHROMIUMHelper(GLuint path, GLsizei range) { |
| 2914 path_manager()->RemovePaths(path, range); |
| 2915 } |
| 2916 |
2873 void GLES2DecoderImpl::DeleteBuffersHelper( | 2917 void GLES2DecoderImpl::DeleteBuffersHelper( |
2874 GLsizei n, const GLuint* client_ids) { | 2918 GLsizei n, const GLuint* client_ids) { |
2875 for (GLsizei ii = 0; ii < n; ++ii) { | 2919 for (GLsizei ii = 0; ii < n; ++ii) { |
2876 Buffer* buffer = GetBuffer(client_ids[ii]); | 2920 Buffer* buffer = GetBuffer(client_ids[ii]); |
2877 if (buffer && !buffer->IsDeleted()) { | 2921 if (buffer && !buffer->IsDeleted()) { |
2878 state_.vertex_attrib_manager->Unbind(buffer); | 2922 state_.vertex_attrib_manager->Unbind(buffer); |
2879 if (state_.bound_array_buffer.get() == buffer) { | 2923 if (state_.bound_array_buffer.get() == buffer) { |
2880 state_.bound_array_buffer = NULL; | 2924 state_.bound_array_buffer = NULL; |
2881 } | 2925 } |
2882 RemoveBuffer(client_ids[ii]); | 2926 RemoveBuffer(client_ids[ii]); |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4335 if (params) { | 4379 if (params) { |
4336 params[0] = renderbuffer_manager()->max_samples(); | 4380 params[0] = renderbuffer_manager()->max_samples(); |
4337 } | 4381 } |
4338 return true; | 4382 return true; |
4339 case GL_MAX_RENDERBUFFER_SIZE: | 4383 case GL_MAX_RENDERBUFFER_SIZE: |
4340 *num_written = 1; | 4384 *num_written = 1; |
4341 if (params) { | 4385 if (params) { |
4342 params[0] = renderbuffer_manager()->max_renderbuffer_size(); | 4386 params[0] = renderbuffer_manager()->max_renderbuffer_size(); |
4343 } | 4387 } |
4344 return true; | 4388 return true; |
| 4389 case GL_MAX_TEXTURE_COORDS: |
| 4390 *num_written = 1; |
| 4391 if (params) { |
| 4392 glGetIntegerv(GL_MAX_TEXTURE_COORDS, params); |
| 4393 } |
| 4394 return true; |
4345 case GL_MAX_TEXTURE_SIZE: | 4395 case GL_MAX_TEXTURE_SIZE: |
4346 *num_written = 1; | 4396 *num_written = 1; |
4347 if (params) { | 4397 if (params) { |
4348 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); | 4398 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); |
4349 } | 4399 } |
4350 return true; | 4400 return true; |
4351 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 4401 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
4352 *num_written = 1; | 4402 *num_written = 1; |
4353 if (params) { | 4403 if (params) { |
4354 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); | 4404 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); |
(...skipping 6423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10778 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10828 DoDidUseTexImageIfNeeded(texture, texture->target()); |
10779 } | 10829 } |
10780 | 10830 |
10781 void GLES2DecoderImpl::OnOutOfMemoryError() { | 10831 void GLES2DecoderImpl::OnOutOfMemoryError() { |
10782 if (lose_context_when_out_of_memory_) { | 10832 if (lose_context_when_out_of_memory_) { |
10783 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10833 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); |
10784 LoseContext(GL_GUILTY_CONTEXT_RESET_ARB); | 10834 LoseContext(GL_GUILTY_CONTEXT_RESET_ARB); |
10785 } | 10835 } |
10786 } | 10836 } |
10787 | 10837 |
| 10838 GLuint GLES2DecoderImpl::GetPath(GLuint client_id, error::Error* path_error) { |
| 10839 GLuint service_id = 0; |
| 10840 // FIXME: currently we do not create paths if they are not present. |
| 10841 if (!path_manager()->GetPath(client_id, &service_id)) { |
| 10842 *path_error = error::kInvalidArguments; |
| 10843 return 0; |
| 10844 } |
| 10845 return service_id; |
| 10846 } |
| 10847 |
| 10848 error::Error GLES2DecoderImpl::HandleGenPathsCHROMIUM( |
| 10849 uint32 immediate_data_size, |
| 10850 const gles2::cmds::GenPathsCHROMIUM& c) { |
| 10851 GLsizei range = static_cast<GLsizei>(c.range); |
| 10852 uint32 data_size; |
| 10853 if (!SafeMultiplyUint32(range, sizeof(GLuint), &data_size)) { |
| 10854 return error::kOutOfBounds; |
| 10855 } |
| 10856 GLuint* client_ids = GetSharedMemoryAs<GLuint*>( |
| 10857 c.client_ids_shm_id, c.client_ids_shm_offset, data_size); |
| 10858 if (client_ids == NULL) { |
| 10859 return error::kOutOfBounds; |
| 10860 } |
| 10861 if (!GenPathsCHROMIUMHelper(range, client_ids)) { |
| 10862 return error::kInvalidArguments; |
| 10863 } |
| 10864 return error::kNoError; |
| 10865 } |
| 10866 |
| 10867 error::Error GLES2DecoderImpl::HandlePathCommandsCHROMIUM( |
| 10868 uint32 immediate_data_size, |
| 10869 const cmds::PathCommandsCHROMIUM& c) { |
| 10870 error::Error path_error = error::kNoError; |
| 10871 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 10872 if (path_error != error::kNoError) { |
| 10873 return path_error; |
| 10874 } |
| 10875 |
| 10876 GLsizei numCommands = static_cast<GLsizei>(c.numCommands); |
| 10877 uint32 commands_shm_id = static_cast<uint32>(c.commands_shm_id); |
| 10878 uint32 commands_shm_offset = static_cast<uint32>(c.commands_shm_offset); |
| 10879 |
| 10880 const GLubyte* commands = NULL; |
| 10881 if (commands_shm_id != 0 || commands_shm_offset != 0) { |
| 10882 commands = GetSharedMemoryAs<const GLubyte*>( |
| 10883 commands_shm_id, commands_shm_offset, numCommands); |
| 10884 if (!commands) { |
| 10885 return error::kOutOfBounds; |
| 10886 } |
| 10887 } |
| 10888 |
| 10889 GLenum coordType = static_cast<GLenum>(c.coordType); |
| 10890 GLsizei numCoords = static_cast<GLsizei>(c.numCoords); |
| 10891 uint32 coords_shm_id = static_cast<uint32>(c.coords_shm_id); |
| 10892 uint32 coords_shm_offset = static_cast<uint32>(c.coords_shm_offset); |
| 10893 uint32 coords_size = |
| 10894 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(coordType) * numCoords; |
| 10895 |
| 10896 const void* coords = NULL; |
| 10897 if (coords_shm_id != 0 || coords_shm_offset != 0) { |
| 10898 coords = GetSharedMemoryAs<const void*>( |
| 10899 coords_shm_id, coords_shm_offset, coords_size); |
| 10900 if (!coords) { |
| 10901 return error::kOutOfBounds; |
| 10902 } |
| 10903 } |
| 10904 |
| 10905 glPathCommandsNV( |
| 10906 service_id, numCommands, commands, numCoords, coordType, coords); |
| 10907 |
| 10908 return error::kNoError; |
| 10909 } |
| 10910 |
| 10911 error::Error GLES2DecoderImpl::HandlePathParameterfCHROMIUM( |
| 10912 uint32 immediate_data_size, |
| 10913 const gles2::cmds::PathParameterfCHROMIUM& c) { |
| 10914 error::Error path_error = error::kNoError; |
| 10915 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 10916 if (path_error != error::kNoError) { |
| 10917 return path_error; |
| 10918 } |
| 10919 GLenum pname = static_cast<GLenum>(c.pname); |
| 10920 GLfloat value = static_cast<GLfloat>(c.value); |
| 10921 glPathParameterfNV(service_id, pname, value); |
| 10922 return error::kNoError; |
| 10923 } |
| 10924 |
| 10925 error::Error GLES2DecoderImpl::HandlePathParameteriCHROMIUM( |
| 10926 uint32 immediate_data_size, |
| 10927 const gles2::cmds::PathParameteriCHROMIUM& c) { |
| 10928 error::Error path_error = error::kNoError; |
| 10929 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 10930 if (path_error != error::kNoError) { |
| 10931 return path_error; |
| 10932 } |
| 10933 GLenum pname = static_cast<GLenum>(c.pname); |
| 10934 GLint value = static_cast<GLint>(c.value); |
| 10935 glPathParameteriNV(service_id, pname, value); |
| 10936 return error::kNoError; |
| 10937 } |
| 10938 |
| 10939 error::Error GLES2DecoderImpl::HandleStencilFillPathCHROMIUM( |
| 10940 uint32 immediate_data_size, |
| 10941 const gles2::cmds::StencilFillPathCHROMIUM& c) { |
| 10942 error::Error path_error = error::kNoError; |
| 10943 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 10944 if (path_error != error::kNoError) { |
| 10945 return path_error; |
| 10946 } |
| 10947 GLenum fillMode = static_cast<GLenum>(c.fillMode); |
| 10948 GLuint mask = static_cast<GLuint>(c.mask); |
| 10949 ApplyDirtyState(); |
| 10950 glStencilFillPathNV(service_id, fillMode, mask); |
| 10951 return error::kNoError; |
| 10952 } |
| 10953 |
| 10954 error::Error GLES2DecoderImpl::PrepareInstancedPathCommand( |
| 10955 uint32 num_paths, |
| 10956 uint32 paths_shm_id, |
| 10957 uint32 paths_shm_offset, |
| 10958 GLuint path_base, |
| 10959 GLenum transform_type, |
| 10960 uint32 transforms_shm_id, |
| 10961 uint32 transforms_shm_offset, |
| 10962 GLuint** out_paths, |
| 10963 const GLfloat** out_transforms) { |
| 10964 GLuint* paths = NULL; |
| 10965 if (paths_shm_id != 0 || paths_shm_offset != 0) { |
| 10966 paths = GetSharedMemoryAs<GLuint*>( |
| 10967 paths_shm_id, paths_shm_offset, sizeof(GLuint) * num_paths); |
| 10968 } |
| 10969 if (!paths) { |
| 10970 return error::kOutOfBounds; |
| 10971 } |
| 10972 |
| 10973 uint32 num_transform_elements = |
| 10974 GLES2Util::GetComponentCountForGLTransformType(transform_type) * |
| 10975 num_paths; |
| 10976 |
| 10977 const GLfloat* transforms = NULL; |
| 10978 if (transforms_shm_id != 0 || transforms_shm_offset != 0) { |
| 10979 transforms = GetSharedMemoryAs<const GLfloat*>( |
| 10980 transforms_shm_id, |
| 10981 transforms_shm_offset, |
| 10982 sizeof(GLfloat) * num_transform_elements); |
| 10983 } |
| 10984 if (!transforms) { |
| 10985 return error::kOutOfBounds; |
| 10986 } |
| 10987 |
| 10988 for (uint32_t i = 0; i < num_paths; ++i) { |
| 10989 error::Error path_error; |
| 10990 GLuint service_id = GetPath(paths[i] + path_base, &path_error); |
| 10991 // Will use path 0 if the path is not found. This is in line |
| 10992 // of the spec: missing paths will produce nothing, but does |
| 10993 // not stop the instanced draw. |
| 10994 paths[i] = service_id; |
| 10995 } |
| 10996 |
| 10997 DCHECK((reinterpret_cast<uintptr_t>(paths) & 0x3) == 0); |
| 10998 DCHECK((reinterpret_cast<uintptr_t>(transforms) & 0x3) == 0); |
| 10999 |
| 11000 *out_paths = paths; |
| 11001 *out_transforms = transforms; |
| 11002 return error::kNoError; |
| 11003 } |
| 11004 |
| 11005 error::Error GLES2DecoderImpl::HandleStencilFillPathInstancedCHROMIUM( |
| 11006 uint32 immediate_data_size, |
| 11007 const gles2::cmds::StencilFillPathInstancedCHROMIUM& c) { |
| 11008 TRACE_EVENT0("gpu", |
| 11009 "GLES2DecoderImpl::HandleStencilFillPathInstancedCHROMIUM"); |
| 11010 |
| 11011 GLsizei numPaths = static_cast<GLsizei>(c.numPaths); |
| 11012 GLenum pathNameType = static_cast<GLenum>(c.pathNameType); |
| 11013 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 11014 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 11015 GLuint pathBase = static_cast<GLuint>(c.pathBase); |
| 11016 GLenum fillMode = static_cast<GLenum>(c.fillMode); |
| 11017 GLuint mask = static_cast<GLuint>(c.mask); |
| 11018 GLenum transformType = static_cast<GLenum>(c.transformType); |
| 11019 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 11020 uint32 transforms_shm_offset = |
| 11021 static_cast<uint32>(c.transformValues_shm_offset); |
| 11022 |
| 11023 DCHECK(pathNameType == GL_UNSIGNED_INT); |
| 11024 |
| 11025 GLuint* paths; |
| 11026 const GLfloat* transforms; |
| 11027 |
| 11028 error::Error prepare_error = |
| 11029 PrepareInstancedPathCommand(static_cast<uint32_t>(numPaths), |
| 11030 paths_shm_id, |
| 11031 paths_shm_offset, |
| 11032 pathBase, |
| 11033 transformType, |
| 11034 transforms_shm_id, |
| 11035 transforms_shm_offset, |
| 11036 &paths, |
| 11037 &transforms); |
| 11038 |
| 11039 if (prepare_error != error::kNoError) { |
| 11040 return prepare_error; |
| 11041 } |
| 11042 |
| 11043 ApplyDirtyState(); |
| 11044 glStencilFillPathInstancedNV(numPaths, |
| 11045 GL_UNSIGNED_INT, |
| 11046 paths, |
| 11047 0, |
| 11048 fillMode, |
| 11049 mask, |
| 11050 transformType, |
| 11051 transforms); |
| 11052 |
| 11053 return error::kNoError; |
| 11054 } |
| 11055 |
| 11056 error::Error GLES2DecoderImpl::HandleStencilStrokePathCHROMIUM( |
| 11057 uint32 immediate_data_size, |
| 11058 const gles2::cmds::StencilStrokePathCHROMIUM& c) { |
| 11059 error::Error path_error = error::kNoError; |
| 11060 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 11061 if (path_error != error::kNoError) { |
| 11062 return path_error; |
| 11063 } |
| 11064 GLint reference = static_cast<GLint>(c.reference); |
| 11065 GLuint mask = static_cast<GLuint>(c.mask); |
| 11066 ApplyDirtyState(); |
| 11067 glStencilStrokePathNV(service_id, reference, mask); |
| 11068 return error::kNoError; |
| 11069 } |
| 11070 |
| 11071 error::Error GLES2DecoderImpl::HandleStencilStrokePathInstancedCHROMIUM( |
| 11072 uint32 immediate_data_size, |
| 11073 const gles2::cmds::StencilStrokePathInstancedCHROMIUM& c) { |
| 11074 TRACE_EVENT0("gpu", |
| 11075 "GLES2DecoderImpl::HandleStencilStrokePathInstancedCHROMIUM"); |
| 11076 |
| 11077 GLsizei numPaths = static_cast<GLsizei>(c.numPaths); |
| 11078 GLenum pathNameType = static_cast<GLenum>(c.pathNameType); |
| 11079 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 11080 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 11081 GLuint pathBase = static_cast<GLuint>(c.pathBase); |
| 11082 GLuint ref = static_cast<GLuint>(c.ref); |
| 11083 GLuint mask = static_cast<GLuint>(c.mask); |
| 11084 GLenum transformType = static_cast<GLenum>(c.transformType); |
| 11085 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 11086 uint32 transforms_shm_offset = |
| 11087 static_cast<uint32>(c.transformValues_shm_offset); |
| 11088 |
| 11089 DCHECK(pathNameType == GL_UNSIGNED_INT); |
| 11090 |
| 11091 GLuint* paths; |
| 11092 const GLfloat* transforms; |
| 11093 |
| 11094 error::Error prepare_error = |
| 11095 PrepareInstancedPathCommand(static_cast<uint32_t>(numPaths), |
| 11096 paths_shm_id, |
| 11097 paths_shm_offset, |
| 11098 pathBase, |
| 11099 transformType, |
| 11100 transforms_shm_id, |
| 11101 transforms_shm_offset, |
| 11102 &paths, |
| 11103 &transforms); |
| 11104 |
| 11105 if (prepare_error != error::kNoError) { |
| 11106 return prepare_error; |
| 11107 } |
| 11108 |
| 11109 ApplyDirtyState(); |
| 11110 glStencilStrokePathInstancedNV(numPaths, |
| 11111 GL_UNSIGNED_INT, |
| 11112 paths, |
| 11113 0, |
| 11114 ref, |
| 11115 mask, |
| 11116 transformType, |
| 11117 transforms); |
| 11118 |
| 11119 return error::kNoError; |
| 11120 } |
| 11121 |
| 11122 error::Error GLES2DecoderImpl::HandlePathTexGenCHROMIUM( |
| 11123 uint32 immediate_data_size, |
| 11124 const gles2::cmds::PathTexGenCHROMIUM& c) { |
| 11125 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePathTexGenCHROMIUM"); |
| 11126 GLenum texCoordSet = static_cast<GLenum>(c.texCoordSet); |
| 11127 GLenum genMode = static_cast<GLenum>(c.genMode); |
| 11128 GLint components = static_cast<GLint>(c.components); |
| 11129 uint32 buffer_shm_id = static_cast<uint32>(c.coeffs_shm_id); |
| 11130 uint32 buffer_shm_offset = static_cast<uint32>(c.coeffs_shm_offset); |
| 11131 |
| 11132 uint32 coeffs_size = |
| 11133 sizeof(GLfloat) * components * (genMode == GL_EYE_LINEAR ? 4 : 3); |
| 11134 |
| 11135 if (coeffs_size < 0) { |
| 11136 return error::kOutOfBounds; |
| 11137 } |
| 11138 const GLfloat* coeffs = NULL; |
| 11139 if (buffer_shm_id != 0 || buffer_shm_offset != 0) { |
| 11140 coeffs = GetSharedMemoryAs<const GLfloat*>( |
| 11141 buffer_shm_id, buffer_shm_offset, coeffs_size); |
| 11142 if (!coeffs) { |
| 11143 return error::kOutOfBounds; |
| 11144 } |
| 11145 } |
| 11146 glPathTexGenNV(texCoordSet, genMode, components, coeffs); |
| 11147 return error::kNoError; |
| 11148 } |
| 11149 |
| 11150 error::Error GLES2DecoderImpl::HandleCoverFillPathCHROMIUM( |
| 11151 uint32 immediate_data_size, |
| 11152 const gles2::cmds::CoverFillPathCHROMIUM& c) { |
| 11153 error::Error path_error = error::kNoError; |
| 11154 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 11155 if (path_error != error::kNoError) { |
| 11156 return path_error; |
| 11157 } |
| 11158 GLenum coverMode = static_cast<GLenum>(c.coverMode); |
| 11159 ApplyDirtyState(); |
| 11160 glCoverFillPathNV(service_id, coverMode); |
| 11161 return error::kNoError; |
| 11162 } |
| 11163 |
| 11164 error::Error GLES2DecoderImpl::HandleCoverFillPathInstancedCHROMIUM( |
| 11165 uint32 immediate_data_size, |
| 11166 const gles2::cmds::CoverFillPathInstancedCHROMIUM& c) { |
| 11167 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleCoverFillPathInstancedCHROMIUM"); |
| 11168 |
| 11169 GLsizei numPaths = static_cast<GLsizei>(c.numPaths); |
| 11170 GLenum pathNameType = static_cast<GLenum>(c.pathNameType); |
| 11171 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 11172 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 11173 GLuint pathBase = static_cast<GLuint>(c.pathBase); |
| 11174 GLenum coverMode = static_cast<GLuint>(c.coverMode); |
| 11175 GLenum transformType = static_cast<GLenum>(c.transformType); |
| 11176 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 11177 uint32 transforms_shm_offset = |
| 11178 static_cast<uint32>(c.transformValues_shm_offset); |
| 11179 |
| 11180 DCHECK(pathNameType == GL_UNSIGNED_INT); |
| 11181 |
| 11182 GLuint* paths; |
| 11183 const GLfloat* transforms; |
| 11184 |
| 11185 error::Error prepare_error = |
| 11186 PrepareInstancedPathCommand(static_cast<uint32_t>(numPaths), |
| 11187 paths_shm_id, |
| 11188 paths_shm_offset, |
| 11189 pathBase, |
| 11190 transformType, |
| 11191 transforms_shm_id, |
| 11192 transforms_shm_offset, |
| 11193 &paths, |
| 11194 &transforms); |
| 11195 |
| 11196 if (prepare_error != error::kNoError) { |
| 11197 return prepare_error; |
| 11198 } |
| 11199 |
| 11200 ApplyDirtyState(); |
| 11201 glCoverFillPathInstancedNV(numPaths, |
| 11202 GL_UNSIGNED_INT, |
| 11203 paths, |
| 11204 0, |
| 11205 coverMode, |
| 11206 transformType, |
| 11207 transforms); |
| 11208 |
| 11209 return error::kNoError; |
| 11210 } |
| 11211 |
| 11212 error::Error GLES2DecoderImpl::HandleCoverStrokePathCHROMIUM( |
| 11213 uint32 immediate_data_size, |
| 11214 const gles2::cmds::CoverStrokePathCHROMIUM& c) { |
| 11215 error::Error path_error = error::kNoError; |
| 11216 GLuint service_id = GetPath(static_cast<GLuint>(c.path), &path_error); |
| 11217 if (path_error != error::kNoError) { |
| 11218 return path_error; |
| 11219 } |
| 11220 GLenum coverMode = static_cast<GLenum>(c.coverMode); |
| 11221 ApplyDirtyState(); |
| 11222 glCoverStrokePathNV(service_id, coverMode); |
| 11223 return error::kNoError; |
| 11224 } |
| 11225 |
| 11226 error::Error GLES2DecoderImpl::HandleCoverStrokePathInstancedCHROMIUM( |
| 11227 uint32 immediate_data_size, |
| 11228 const gles2::cmds::CoverStrokePathInstancedCHROMIUM& c) { |
| 11229 TRACE_EVENT0("gpu", |
| 11230 "GLES2DecoderImpl::HandleCoverStrokePathInstancedCHROMIUM"); |
| 11231 |
| 11232 GLsizei numPaths = static_cast<GLsizei>(c.numPaths); |
| 11233 GLenum pathNameType = static_cast<GLenum>(c.pathNameType); |
| 11234 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 11235 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 11236 GLuint pathBase = static_cast<GLuint>(c.pathBase); |
| 11237 GLenum coverMode = static_cast<GLuint>(c.coverMode); |
| 11238 GLenum transformType = static_cast<GLenum>(c.transformType); |
| 11239 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 11240 uint32 transforms_shm_offset = |
| 11241 static_cast<uint32>(c.transformValues_shm_offset); |
| 11242 |
| 11243 DCHECK(pathNameType == GL_UNSIGNED_INT); |
| 11244 |
| 11245 GLuint* paths; |
| 11246 const GLfloat* transforms; |
| 11247 |
| 11248 error::Error prepare_error = |
| 11249 PrepareInstancedPathCommand(static_cast<uint32_t>(numPaths), |
| 11250 paths_shm_id, |
| 11251 paths_shm_offset, |
| 11252 pathBase, |
| 11253 transformType, |
| 11254 transforms_shm_id, |
| 11255 transforms_shm_offset, |
| 11256 &paths, |
| 11257 &transforms); |
| 11258 |
| 11259 if (prepare_error != error::kNoError) { |
| 11260 return prepare_error; |
| 11261 } |
| 11262 |
| 11263 ApplyDirtyState(); |
| 11264 glCoverStrokePathInstancedNV(numPaths, |
| 11265 GL_UNSIGNED_INT, |
| 11266 paths, |
| 11267 0, |
| 11268 coverMode, |
| 11269 transformType, |
| 11270 transforms); |
| 11271 return error::kNoError; |
| 11272 } |
| 11273 |
10788 // Include the auto-generated part of this file. We split this because it means | 11274 // Include the auto-generated part of this file. We split this because it means |
10789 // we can easily edit the non-auto generated parts right here in this file | 11275 // we can easily edit the non-auto generated parts right here in this file |
10790 // instead of having to edit some template or the code generator. | 11276 // instead of having to edit some template or the code generator. |
10791 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11277 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10792 | 11278 |
10793 } // namespace gles2 | 11279 } // namespace gles2 |
10794 } // namespace gpu | 11280 } // namespace gpu |
OLD | NEW |