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 <cmath> | 10 #include <cmath> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "gpu/command_buffer/service/gl_utils.h" | 44 #include "gpu/command_buffer/service/gl_utils.h" |
45 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" | 45 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" |
46 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 46 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
47 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 47 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
48 #include "gpu/command_buffer/service/gpu_state_tracer.h" | 48 #include "gpu/command_buffer/service/gpu_state_tracer.h" |
49 #include "gpu/command_buffer/service/gpu_switches.h" | 49 #include "gpu/command_buffer/service/gpu_switches.h" |
50 #include "gpu/command_buffer/service/gpu_tracer.h" | 50 #include "gpu/command_buffer/service/gpu_tracer.h" |
51 #include "gpu/command_buffer/service/image_manager.h" | 51 #include "gpu/command_buffer/service/image_manager.h" |
52 #include "gpu/command_buffer/service/mailbox_manager.h" | 52 #include "gpu/command_buffer/service/mailbox_manager.h" |
53 #include "gpu/command_buffer/service/memory_tracking.h" | 53 #include "gpu/command_buffer/service/memory_tracking.h" |
| 54 #include "gpu/command_buffer/service/path_manager.h" |
54 #include "gpu/command_buffer/service/program_manager.h" | 55 #include "gpu/command_buffer/service/program_manager.h" |
55 #include "gpu/command_buffer/service/query_manager.h" | 56 #include "gpu/command_buffer/service/query_manager.h" |
56 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 57 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
57 #include "gpu/command_buffer/service/shader_manager.h" | 58 #include "gpu/command_buffer/service/shader_manager.h" |
58 #include "gpu/command_buffer/service/shader_translator.h" | 59 #include "gpu/command_buffer/service/shader_translator.h" |
59 #include "gpu/command_buffer/service/shader_translator_cache.h" | 60 #include "gpu/command_buffer/service/shader_translator_cache.h" |
60 #include "gpu/command_buffer/service/texture_manager.h" | 61 #include "gpu/command_buffer/service/texture_manager.h" |
61 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 62 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
62 #include "gpu/command_buffer/service/vertex_array_manager.h" | 63 #include "gpu/command_buffer/service/vertex_array_manager.h" |
63 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 64 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 784 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
784 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); | 785 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids); |
785 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 786 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
786 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 787 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
787 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 788 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
788 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 789 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
789 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 790 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
790 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 791 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
791 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 792 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
792 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 793 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
| 794 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
| 795 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
793 | 796 |
794 // Helper for async upload token completion notification callback. | 797 // Helper for async upload token completion notification callback. |
795 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, | 798 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, |
796 uint32 sync_data_shm_id, | 799 uint32 sync_data_shm_id, |
797 uint32 sync_data_shm_offset); | 800 uint32 sync_data_shm_offset); |
798 | 801 |
799 | 802 |
800 | 803 |
801 // Workarounds | 804 // Workarounds |
802 void OnFboChanged() const; | 805 void OnFboChanged() const; |
(...skipping 12 matching lines...) Expand all Loading... |
815 } | 818 } |
816 | 819 |
817 FramebufferManager* framebuffer_manager() { | 820 FramebufferManager* framebuffer_manager() { |
818 return group_->framebuffer_manager(); | 821 return group_->framebuffer_manager(); |
819 } | 822 } |
820 | 823 |
821 ValuebufferManager* valuebuffer_manager() { | 824 ValuebufferManager* valuebuffer_manager() { |
822 return group_->valuebuffer_manager(); | 825 return group_->valuebuffer_manager(); |
823 } | 826 } |
824 | 827 |
| 828 PathManager* path_manager() { return group_->path_manager(); } |
| 829 |
825 ProgramManager* program_manager() { | 830 ProgramManager* program_manager() { |
826 return group_->program_manager(); | 831 return group_->program_manager(); |
827 } | 832 } |
828 | 833 |
829 ShaderManager* shader_manager() { | 834 ShaderManager* shader_manager() { |
830 return group_->shader_manager(); | 835 return group_->shader_manager(); |
831 } | 836 } |
832 | 837 |
833 ShaderTranslatorCache* shader_translator_cache() { | 838 ShaderTranslatorCache* shader_translator_cache() { |
834 return group_->shader_translator_cache(); | 839 return group_->shader_translator_cache(); |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 | 1554 |
1550 // Wrappers for glIsXXX functions. | 1555 // Wrappers for glIsXXX functions. |
1551 bool DoIsEnabled(GLenum cap); | 1556 bool DoIsEnabled(GLenum cap); |
1552 bool DoIsBuffer(GLuint client_id); | 1557 bool DoIsBuffer(GLuint client_id); |
1553 bool DoIsFramebuffer(GLuint client_id); | 1558 bool DoIsFramebuffer(GLuint client_id); |
1554 bool DoIsProgram(GLuint client_id); | 1559 bool DoIsProgram(GLuint client_id); |
1555 bool DoIsRenderbuffer(GLuint client_id); | 1560 bool DoIsRenderbuffer(GLuint client_id); |
1556 bool DoIsShader(GLuint client_id); | 1561 bool DoIsShader(GLuint client_id); |
1557 bool DoIsTexture(GLuint client_id); | 1562 bool DoIsTexture(GLuint client_id); |
1558 bool DoIsVertexArrayOES(GLuint client_id); | 1563 bool DoIsVertexArrayOES(GLuint client_id); |
| 1564 bool DoIsPathCHROMIUM(GLuint client_id); |
1559 | 1565 |
1560 // Wrapper for glLinkProgram | 1566 // Wrapper for glLinkProgram |
1561 void DoLinkProgram(GLuint program); | 1567 void DoLinkProgram(GLuint program); |
1562 | 1568 |
1563 // Wrapper for glRenderbufferStorage. | 1569 // Wrapper for glRenderbufferStorage. |
1564 void DoRenderbufferStorage( | 1570 void DoRenderbufferStorage( |
1565 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); | 1571 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); |
1566 | 1572 |
1567 // Handler for glRenderbufferStorageMultisampleCHROMIUM. | 1573 // Handler for glRenderbufferStorageMultisampleCHROMIUM. |
1568 void DoRenderbufferStorageMultisampleCHROMIUM( | 1574 void DoRenderbufferStorageMultisampleCHROMIUM( |
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3342 } | 3348 } |
3343 } | 3349 } |
3344 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 3350 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
3345 glGenTextures(n, service_ids.get()); | 3351 glGenTextures(n, service_ids.get()); |
3346 for (GLsizei ii = 0; ii < n; ++ii) { | 3352 for (GLsizei ii = 0; ii < n; ++ii) { |
3347 CreateTexture(client_ids[ii], service_ids[ii]); | 3353 CreateTexture(client_ids[ii], service_ids[ii]); |
3348 } | 3354 } |
3349 return true; | 3355 return true; |
3350 } | 3356 } |
3351 | 3357 |
| 3358 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, |
| 3359 GLsizei range) { |
| 3360 GLuint last_client_id; |
| 3361 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) |
| 3362 return false; |
| 3363 |
| 3364 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) |
| 3365 return false; |
| 3366 |
| 3367 GLuint first_service_id = glGenPathsNV(range); |
| 3368 if (first_service_id == 0) { |
| 3369 // We have to fail the connection here, because client has already |
| 3370 // succeeded in allocating the ids. This happens if we allocate |
| 3371 // the whole path id space (two allocations of 0x7FFFFFFF paths, for |
| 3372 // example). |
| 3373 return false; |
| 3374 } |
| 3375 // GenPathsNV does not wrap. |
| 3376 DCHECK(first_service_id + range - 1 >= first_service_id); |
| 3377 |
| 3378 path_manager()->CreatePathRange(first_client_id, last_client_id, |
| 3379 first_service_id); |
| 3380 |
| 3381 return true; |
| 3382 } |
| 3383 |
| 3384 bool GLES2DecoderImpl::DeletePathsCHROMIUMHelper(GLuint first_client_id, |
| 3385 GLsizei range) { |
| 3386 GLuint last_client_id; |
| 3387 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) |
| 3388 return false; |
| 3389 |
| 3390 path_manager()->RemovePaths(first_client_id, last_client_id); |
| 3391 return true; |
| 3392 } |
| 3393 |
3352 void GLES2DecoderImpl::DeleteBuffersHelper( | 3394 void GLES2DecoderImpl::DeleteBuffersHelper( |
3353 GLsizei n, const GLuint* client_ids) { | 3395 GLsizei n, const GLuint* client_ids) { |
3354 for (GLsizei ii = 0; ii < n; ++ii) { | 3396 for (GLsizei ii = 0; ii < n; ++ii) { |
3355 Buffer* buffer = GetBuffer(client_ids[ii]); | 3397 Buffer* buffer = GetBuffer(client_ids[ii]); |
3356 if (buffer && !buffer->IsDeleted()) { | 3398 if (buffer && !buffer->IsDeleted()) { |
3357 buffer->RemoveMappedRange(); | 3399 buffer->RemoveMappedRange(); |
3358 state_.RemoveBoundBuffer(buffer); | 3400 state_.RemoveBoundBuffer(buffer); |
3359 RemoveBuffer(client_ids[ii]); | 3401 RemoveBuffer(client_ids[ii]); |
3360 } | 3402 } |
3361 } | 3403 } |
(...skipping 8389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11751 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, | 11793 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, |
11752 element_array_buffer ? element_array_buffer->service_id() : 0); | 11794 element_array_buffer ? element_array_buffer->service_id() : 0); |
11753 } | 11795 } |
11754 | 11796 |
11755 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { | 11797 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { |
11756 const VertexAttribManager* vao = | 11798 const VertexAttribManager* vao = |
11757 GetVertexAttribManager(client_id); | 11799 GetVertexAttribManager(client_id); |
11758 return vao && vao->IsValid() && !vao->IsDeleted(); | 11800 return vao && vao->IsValid() && !vao->IsDeleted(); |
11759 } | 11801 } |
11760 | 11802 |
| 11803 bool GLES2DecoderImpl::DoIsPathCHROMIUM(GLuint client_id) { |
| 11804 GLuint service_id = 0; |
| 11805 if (!path_manager()->GetPath(client_id, &service_id)) |
| 11806 return false; |
| 11807 |
| 11808 return glIsPathNV(service_id); |
| 11809 } |
| 11810 |
11761 #if defined(OS_MACOSX) | 11811 #if defined(OS_MACOSX) |
11762 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) { | 11812 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) { |
11763 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find( | 11813 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find( |
11764 texture_id); | 11814 texture_id); |
11765 if (it != texture_to_io_surface_map_.end()) { | 11815 if (it != texture_to_io_surface_map_.end()) { |
11766 // Found a previous IOSurface bound to this texture; release it. | 11816 // Found a previous IOSurface bound to this texture; release it. |
11767 IOSurfaceRef surface = it->second; | 11817 IOSurfaceRef surface = it->second; |
11768 CFRelease(surface); | 11818 CFRelease(surface); |
11769 texture_to_io_surface_map_.erase(it); | 11819 texture_to_io_surface_map_.erase(it); |
11770 } | 11820 } |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13698 if (CheckResetStatus()) { | 13748 if (CheckResetStatus()) { |
13699 other = error::kUnknown; | 13749 other = error::kUnknown; |
13700 } else { | 13750 } else { |
13701 // Need to lose current context before broadcasting! | 13751 // Need to lose current context before broadcasting! |
13702 MarkContextLost(error::kOutOfMemory); | 13752 MarkContextLost(error::kOutOfMemory); |
13703 } | 13753 } |
13704 group_->LoseContexts(other); | 13754 group_->LoseContexts(other); |
13705 } | 13755 } |
13706 } | 13756 } |
13707 | 13757 |
| 13758 error::Error GLES2DecoderImpl::HandleGenPathsCHROMIUM( |
| 13759 uint32 immediate_data_size, |
| 13760 const void* cmd_data) { |
| 13761 static const char kFunctionName[] = "glGenPathsCHROMIUM"; |
| 13762 const gles2::cmds::GenPathsCHROMIUM& c = |
| 13763 *static_cast<const gles2::cmds::GenPathsCHROMIUM*>(cmd_data); |
| 13764 if (!features().chromium_path_rendering) { |
| 13765 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13766 "function not available"); |
| 13767 return error::kNoError; |
| 13768 } |
| 13769 |
| 13770 GLsizei range = static_cast<GLsizei>(c.range); |
| 13771 if (range < 0) { |
| 13772 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "range < 0"); |
| 13773 return error::kNoError; |
| 13774 } |
| 13775 |
| 13776 GLuint first_client_id = static_cast<GLuint>(c.first_client_id); |
| 13777 if (first_client_id == 0) |
| 13778 return error::kInvalidArguments; |
| 13779 |
| 13780 if (range == 0) |
| 13781 return error::kNoError; |
| 13782 |
| 13783 if (!GenPathsCHROMIUMHelper(first_client_id, range)) |
| 13784 return error::kInvalidArguments; |
| 13785 |
| 13786 return error::kNoError; |
| 13787 } |
| 13788 error::Error GLES2DecoderImpl::HandleDeletePathsCHROMIUM( |
| 13789 uint32_t immediate_data_size, |
| 13790 const void* cmd_data) { |
| 13791 static const char kFunctionName[] = "glDeletePathsCHROMIUM"; |
| 13792 const gles2::cmds::DeletePathsCHROMIUM& c = |
| 13793 *static_cast<const gles2::cmds::DeletePathsCHROMIUM*>(cmd_data); |
| 13794 if (!features().chromium_path_rendering) { |
| 13795 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13796 "function not available"); |
| 13797 return error::kNoError; |
| 13798 } |
| 13799 |
| 13800 GLsizei range = static_cast<GLsizei>(c.range); |
| 13801 if (range < 0) { |
| 13802 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "range < 0"); |
| 13803 return error::kNoError; |
| 13804 } |
| 13805 |
| 13806 if (range == 0) |
| 13807 return error::kNoError; |
| 13808 |
| 13809 GLuint first_client_id = c.first_client_id; |
| 13810 // first_client_id can be 0, because non-existing path ids are skipped. |
| 13811 |
| 13812 if (!DeletePathsCHROMIUMHelper(first_client_id, range)) |
| 13813 return error::kInvalidArguments; |
| 13814 |
| 13815 return error::kNoError; |
| 13816 } |
| 13817 |
| 13818 error::Error GLES2DecoderImpl::HandlePathCommandsCHROMIUM( |
| 13819 uint32 immediate_data_size, |
| 13820 const void* cmd_data) { |
| 13821 static const char kFunctionName[] = "glPathCommandsCHROMIUM"; |
| 13822 const gles2::cmds::PathCommandsCHROMIUM& c = |
| 13823 *static_cast<const gles2::cmds::PathCommandsCHROMIUM*>(cmd_data); |
| 13824 if (!features().chromium_path_rendering) { |
| 13825 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13826 "function not available"); |
| 13827 return error::kNoError; |
| 13828 } |
| 13829 |
| 13830 GLuint service_id = 0; |
| 13831 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { |
| 13832 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13833 "invalid path name"); |
| 13834 return error::kNoError; |
| 13835 } |
| 13836 |
| 13837 GLsizei num_commands = static_cast<GLsizei>(c.numCommands); |
| 13838 if (num_commands < 0) { |
| 13839 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numCommands < 0"); |
| 13840 return error::kNoError; |
| 13841 } |
| 13842 |
| 13843 GLsizei num_coords = static_cast<uint32>(c.numCoords); |
| 13844 if (num_coords < 0) { |
| 13845 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numCoords < 0"); |
| 13846 return error::kNoError; |
| 13847 } |
| 13848 |
| 13849 GLenum coord_type = static_cast<uint32>(c.coordType); |
| 13850 if (!validators_->path_coord_type.IsValid(static_cast<GLint>(coord_type))) { |
| 13851 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, kFunctionName, "invalid coordType"); |
| 13852 return error::kNoError; |
| 13853 } |
| 13854 |
| 13855 const GLubyte* commands = NULL; |
| 13856 base::CheckedNumeric<GLsizei> num_coords_expected = 0; |
| 13857 |
| 13858 if (num_commands > 0) { |
| 13859 uint32 commands_shm_id = static_cast<uint32>(c.commands_shm_id); |
| 13860 uint32 commands_shm_offset = static_cast<uint32>(c.commands_shm_offset); |
| 13861 if (commands_shm_id != 0 || commands_shm_offset != 0) |
| 13862 commands = GetSharedMemoryAs<const GLubyte*>( |
| 13863 commands_shm_id, commands_shm_offset, num_commands); |
| 13864 |
| 13865 if (!commands) |
| 13866 return error::kOutOfBounds; |
| 13867 |
| 13868 for (GLsizei i = 0; i < num_commands; ++i) { |
| 13869 switch (commands[i]) { |
| 13870 case GL_CLOSE_PATH_CHROMIUM: |
| 13871 // Close has no coords. |
| 13872 break; |
| 13873 case GL_MOVE_TO_CHROMIUM: |
| 13874 // Fallthrough. |
| 13875 case GL_LINE_TO_CHROMIUM: |
| 13876 num_coords_expected += 2; |
| 13877 break; |
| 13878 case GL_QUADRATIC_CURVE_TO_CHROMIUM: |
| 13879 num_coords_expected += 4; |
| 13880 break; |
| 13881 case GL_CUBIC_CURVE_TO_CHROMIUM: |
| 13882 num_coords_expected += 6; |
| 13883 break; |
| 13884 case GL_CONIC_CURVE_TO_CHROMIUM: |
| 13885 num_coords_expected += 5; |
| 13886 break; |
| 13887 default: |
| 13888 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, kFunctionName, "invalid command"); |
| 13889 return error::kNoError; |
| 13890 } |
| 13891 } |
| 13892 } |
| 13893 |
| 13894 if (!num_coords_expected.IsValid() || |
| 13895 num_coords != num_coords_expected.ValueOrDie()) { |
| 13896 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13897 "numCoords does not match commands"); |
| 13898 return error::kNoError; |
| 13899 } |
| 13900 |
| 13901 const void* coords = NULL; |
| 13902 |
| 13903 if (num_coords > 0) { |
| 13904 uint32 coords_size = 0; |
| 13905 uint32 coord_type_size = |
| 13906 GLES2Util::GetGLTypeSizeForPathCoordType(coord_type); |
| 13907 if (!SafeMultiplyUint32(num_coords, coord_type_size, &coords_size)) |
| 13908 return error::kOutOfBounds; |
| 13909 |
| 13910 uint32 coords_shm_id = static_cast<uint32>(c.coords_shm_id); |
| 13911 uint32 coords_shm_offset = static_cast<uint32>(c.coords_shm_offset); |
| 13912 if (coords_shm_id != 0 || coords_shm_offset != 0) |
| 13913 coords = GetSharedMemoryAs<const void*>(coords_shm_id, coords_shm_offset, |
| 13914 coords_size); |
| 13915 |
| 13916 if (!coords) |
| 13917 return error::kOutOfBounds; |
| 13918 } |
| 13919 |
| 13920 glPathCommandsNV(service_id, num_commands, commands, num_coords, coord_type, |
| 13921 coords); |
| 13922 |
| 13923 return error::kNoError; |
| 13924 } |
| 13925 |
| 13926 error::Error GLES2DecoderImpl::HandlePathParameterfCHROMIUM( |
| 13927 uint32 immediate_data_size, |
| 13928 const void* cmd_data) { |
| 13929 static const char kFunctionName[] = "glPathParameterfCHROMIUM"; |
| 13930 const gles2::cmds::PathParameterfCHROMIUM& c = |
| 13931 *static_cast<const gles2::cmds::PathParameterfCHROMIUM*>(cmd_data); |
| 13932 if (!features().chromium_path_rendering) { |
| 13933 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13934 "function not available"); |
| 13935 return error::kNoError; |
| 13936 } |
| 13937 GLuint service_id = 0; |
| 13938 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { |
| 13939 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13940 "invalid path name"); |
| 13941 return error::kNoError; |
| 13942 } |
| 13943 |
| 13944 GLenum pname = static_cast<GLenum>(c.pname); |
| 13945 GLfloat value = static_cast<GLfloat>(c.value); |
| 13946 bool hasValueError = false; |
| 13947 |
| 13948 switch (pname) { |
| 13949 case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 13950 case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 13951 hasValueError = std::isnan(value) || !std::isfinite(value) || value < 0; |
| 13952 break; |
| 13953 case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 13954 value = std::max(std::min(1.0f, value), 0.0f); |
| 13955 break; |
| 13956 case GL_PATH_END_CAPS_CHROMIUM: |
| 13957 hasValueError = !validators_->path_parameter_cap_values.IsValid( |
| 13958 static_cast<GLint>(value)); |
| 13959 break; |
| 13960 case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 13961 hasValueError = !validators_->path_parameter_join_values.IsValid( |
| 13962 static_cast<GLint>(value)); |
| 13963 break; |
| 13964 default: |
| 13965 DCHECK(!validators_->path_parameter.IsValid(pname)); |
| 13966 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, pname, "pname"); |
| 13967 return error::kNoError; |
| 13968 } |
| 13969 DCHECK(validators_->path_parameter.IsValid(pname)); |
| 13970 |
| 13971 if (hasValueError) { |
| 13972 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "value not correct"); |
| 13973 return error::kNoError; |
| 13974 } |
| 13975 |
| 13976 glPathParameterfNV(service_id, pname, value); |
| 13977 return error::kNoError; |
| 13978 } |
| 13979 |
| 13980 error::Error GLES2DecoderImpl::HandlePathParameteriCHROMIUM( |
| 13981 uint32 immediate_data_size, |
| 13982 const void* cmd_data) { |
| 13983 static const char kFunctionName[] = "glPathParameteriCHROMIUM"; |
| 13984 const gles2::cmds::PathParameteriCHROMIUM& c = |
| 13985 *static_cast<const gles2::cmds::PathParameteriCHROMIUM*>(cmd_data); |
| 13986 if (!features().chromium_path_rendering) { |
| 13987 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13988 "function not available"); |
| 13989 return error::kNoError; |
| 13990 } |
| 13991 GLuint service_id = 0; |
| 13992 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { |
| 13993 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 13994 "invalid path name"); |
| 13995 return error::kNoError; |
| 13996 } |
| 13997 |
| 13998 GLenum pname = static_cast<GLenum>(c.pname); |
| 13999 GLint value = static_cast<GLint>(c.value); |
| 14000 bool hasValueError = false; |
| 14001 |
| 14002 switch (pname) { |
| 14003 case GL_PATH_STROKE_WIDTH_CHROMIUM: |
| 14004 case GL_PATH_MITER_LIMIT_CHROMIUM: |
| 14005 hasValueError = value < 0; |
| 14006 break; |
| 14007 case GL_PATH_STROKE_BOUND_CHROMIUM: |
| 14008 value = std::max(std::min(1, value), 0); |
| 14009 break; |
| 14010 case GL_PATH_END_CAPS_CHROMIUM: |
| 14011 hasValueError = !validators_->path_parameter_cap_values.IsValid(value); |
| 14012 break; |
| 14013 case GL_PATH_JOIN_STYLE_CHROMIUM: |
| 14014 hasValueError = !validators_->path_parameter_join_values.IsValid(value); |
| 14015 break; |
| 14016 default: |
| 14017 DCHECK(!validators_->path_parameter.IsValid(pname)); |
| 14018 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, pname, "pname"); |
| 14019 return error::kNoError; |
| 14020 } |
| 14021 DCHECK(validators_->path_parameter.IsValid(pname)); |
| 14022 |
| 14023 if (hasValueError) { |
| 14024 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "value not correct"); |
| 14025 return error::kNoError; |
| 14026 } |
| 14027 |
| 14028 glPathParameteriNV(service_id, pname, value); |
| 14029 return error::kNoError; |
| 14030 } |
| 14031 |
| 14032 error::Error GLES2DecoderImpl::HandleStencilFillPathCHROMIUM( |
| 14033 uint32 immediate_data_size, |
| 14034 const void* cmd_data) { |
| 14035 static const char kFunctionName[] = "glStencilFillPathCHROMIUM"; |
| 14036 const gles2::cmds::StencilFillPathCHROMIUM& c = |
| 14037 *static_cast<const gles2::cmds::StencilFillPathCHROMIUM*>(cmd_data); |
| 14038 if (!features().chromium_path_rendering) { |
| 14039 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14040 "function not available"); |
| 14041 return error::kNoError; |
| 14042 } |
| 14043 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 14044 if (!validators_->path_fill_mode.IsValid(fill_mode)) { |
| 14045 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); |
| 14046 return error::kNoError; |
| 14047 } |
| 14048 GLuint mask = static_cast<GLuint>(c.mask); |
| 14049 if ((fill_mode == GL_COUNT_UP_CHROMIUM || |
| 14050 fill_mode == GL_COUNT_DOWN_CHROMIUM) && |
| 14051 GLES2Util::IsNPOT(mask + 1)) { |
| 14052 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
| 14053 "mask + 1 is not power of two"); |
| 14054 return error::kNoError; |
| 14055 } |
| 14056 GLuint service_id = 0; |
| 14057 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { |
| 14058 // "If /path/ does not name an existing path object, the command does |
| 14059 // nothing (and no error is generated)." |
| 14060 // This holds for other rendering functions, too. |
| 14061 return error::kNoError; |
| 14062 } |
| 14063 ApplyDirtyState(); |
| 14064 glStencilFillPathNV(service_id, fill_mode, mask); |
| 14065 return error::kNoError; |
| 14066 } |
| 14067 |
| 14068 error::Error GLES2DecoderImpl::HandleStencilStrokePathCHROMIUM( |
| 14069 uint32 immediate_data_size, |
| 14070 const void* cmd_data) { |
| 14071 static const char kFunctionName[] = "glStencilStrokePathCHROMIUM"; |
| 14072 const gles2::cmds::StencilStrokePathCHROMIUM& c = |
| 14073 *static_cast<const gles2::cmds::StencilStrokePathCHROMIUM*>(cmd_data); |
| 14074 if (!features().chromium_path_rendering) { |
| 14075 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14076 "function not available"); |
| 14077 return error::kNoError; |
| 14078 } |
| 14079 GLuint service_id = 0; |
| 14080 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { |
| 14081 return error::kNoError; |
| 14082 } |
| 14083 GLint reference = static_cast<GLint>(c.reference); |
| 14084 GLuint mask = static_cast<GLuint>(c.mask); |
| 14085 ApplyDirtyState(); |
| 14086 glStencilStrokePathNV(service_id, reference, mask); |
| 14087 return error::kNoError; |
| 14088 } |
| 14089 |
| 14090 error::Error GLES2DecoderImpl::HandleCoverFillPathCHROMIUM( |
| 14091 uint32 immediate_data_size, |
| 14092 const void* cmd_data) { |
| 14093 static const char kFunctionName[] = "glCoverFillPathCHROMIUM"; |
| 14094 const gles2::cmds::CoverFillPathCHROMIUM& c = |
| 14095 *static_cast<const gles2::cmds::CoverFillPathCHROMIUM*>(cmd_data); |
| 14096 if (!features().chromium_path_rendering) { |
| 14097 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14098 "function not available"); |
| 14099 return error::kNoError; |
| 14100 } |
| 14101 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 14102 if (!validators_->path_cover_mode.IsValid(cover_mode)) { |
| 14103 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 14104 return error::kNoError; |
| 14105 } |
| 14106 GLuint service_id = 0; |
| 14107 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) |
| 14108 return error::kNoError; |
| 14109 |
| 14110 ApplyDirtyState(); |
| 14111 glCoverFillPathNV(service_id, cover_mode); |
| 14112 return error::kNoError; |
| 14113 } |
| 14114 |
| 14115 error::Error GLES2DecoderImpl::HandleCoverStrokePathCHROMIUM( |
| 14116 uint32 immediate_data_size, |
| 14117 const void* cmd_data) { |
| 14118 static const char kFunctionName[] = "glCoverStrokePathCHROMIUM"; |
| 14119 const gles2::cmds::CoverStrokePathCHROMIUM& c = |
| 14120 *static_cast<const gles2::cmds::CoverStrokePathCHROMIUM*>(cmd_data); |
| 14121 if (!features().chromium_path_rendering) { |
| 14122 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14123 "function not available"); |
| 14124 return error::kNoError; |
| 14125 } |
| 14126 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 14127 if (!validators_->path_cover_mode.IsValid(cover_mode)) { |
| 14128 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 14129 return error::kNoError; |
| 14130 } |
| 14131 GLuint service_id = 0; |
| 14132 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) |
| 14133 return error::kNoError; |
| 14134 |
| 14135 ApplyDirtyState(); |
| 14136 glCoverStrokePathNV(service_id, cover_mode); |
| 14137 return error::kNoError; |
| 14138 } |
| 14139 |
| 14140 error::Error GLES2DecoderImpl::HandleStencilThenCoverFillPathCHROMIUM( |
| 14141 uint32 immediate_data_size, |
| 14142 const void* cmd_data) { |
| 14143 static const char kFunctionName[] = "glStencilThenCoverFillPathCHROMIUM"; |
| 14144 const gles2::cmds::StencilThenCoverFillPathCHROMIUM& c = |
| 14145 *static_cast<const gles2::cmds::StencilThenCoverFillPathCHROMIUM*>( |
| 14146 cmd_data); |
| 14147 if (!features().chromium_path_rendering) { |
| 14148 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14149 "function not available"); |
| 14150 return error::kNoError; |
| 14151 } |
| 14152 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 14153 if (!validators_->path_fill_mode.IsValid(fill_mode)) { |
| 14154 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); |
| 14155 return error::kNoError; |
| 14156 } |
| 14157 GLuint mask = static_cast<GLuint>(c.mask); |
| 14158 if ((fill_mode == GL_COUNT_UP_CHROMIUM || |
| 14159 fill_mode == GL_COUNT_DOWN_CHROMIUM) && |
| 14160 GLES2Util::IsNPOT(mask + 1)) { |
| 14161 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
| 14162 "mask + 1 is not power of two"); |
| 14163 return error::kNoError; |
| 14164 } |
| 14165 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 14166 if (!validators_->path_cover_mode.IsValid(cover_mode)) { |
| 14167 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 14168 return error::kNoError; |
| 14169 } |
| 14170 GLuint service_id = 0; |
| 14171 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) |
| 14172 return error::kNoError; |
| 14173 |
| 14174 ApplyDirtyState(); |
| 14175 glStencilThenCoverFillPathNV(service_id, fill_mode, mask, cover_mode); |
| 14176 return error::kNoError; |
| 14177 } |
| 14178 |
| 14179 error::Error GLES2DecoderImpl::HandleStencilThenCoverStrokePathCHROMIUM( |
| 14180 uint32 immediate_data_size, |
| 14181 const void* cmd_data) { |
| 14182 static const char kFunctionName[] = "glStencilThenCoverStrokePathCHROMIUM"; |
| 14183 const gles2::cmds::StencilThenCoverStrokePathCHROMIUM& c = |
| 14184 *static_cast<const gles2::cmds::StencilThenCoverStrokePathCHROMIUM*>( |
| 14185 cmd_data); |
| 14186 if (!features().chromium_path_rendering) { |
| 14187 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14188 "function not available"); |
| 14189 return error::kNoError; |
| 14190 } |
| 14191 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 14192 if (!validators_->path_cover_mode.IsValid(cover_mode)) { |
| 14193 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 14194 return error::kNoError; |
| 14195 } |
| 14196 GLuint service_id = 0; |
| 14197 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) |
| 14198 return error::kNoError; |
| 14199 |
| 14200 GLint reference = static_cast<GLint>(c.reference); |
| 14201 GLuint mask = static_cast<GLuint>(c.mask); |
| 14202 ApplyDirtyState(); |
| 14203 glStencilThenCoverStrokePathNV(service_id, reference, mask, cover_mode); |
| 14204 return error::kNoError; |
| 14205 } |
| 14206 |
13708 // Include the auto-generated part of this file. We split this because it means | 14207 // Include the auto-generated part of this file. We split this because it means |
13709 // we can easily edit the non-auto generated parts right here in this file | 14208 // we can easily edit the non-auto generated parts right here in this file |
13710 // instead of having to edit some template or the code generator. | 14209 // instead of having to edit some template or the code generator. |
13711 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 14210 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
13712 | 14211 |
13713 } // namespace gles2 | 14212 } // namespace gles2 |
13714 } // namespace gpu | 14213 } // namespace gpu |
OLD | NEW |