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 #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) { | |
|
piman
2015/06/24 03:27:44
Is it guaranteed tha first_service_id + range does
Kimmo Kinnunen
2015/06/24 12:49:02
Yes.
| |
| 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 | |
| 3376 path_manager()->CreatePathRange(first_client_id, last_client_id, | |
| 3377 first_service_id); | |
| 3378 | |
| 3379 return true; | |
| 3380 } | |
| 3381 | |
| 3382 bool GLES2DecoderImpl::DeletePathsCHROMIUMHelper(GLuint first_client_id, | |
| 3383 GLsizei range) { | |
| 3384 GLuint last_client_id; | |
| 3385 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) | |
| 3386 return false; | |
| 3387 | |
| 3388 path_manager()->RemovePaths(first_client_id, last_client_id); | |
| 3389 return true; | |
| 3390 } | |
| 3391 | |
| 3352 void GLES2DecoderImpl::DeleteBuffersHelper( | 3392 void GLES2DecoderImpl::DeleteBuffersHelper( |
| 3353 GLsizei n, const GLuint* client_ids) { | 3393 GLsizei n, const GLuint* client_ids) { |
| 3354 for (GLsizei ii = 0; ii < n; ++ii) { | 3394 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3355 Buffer* buffer = GetBuffer(client_ids[ii]); | 3395 Buffer* buffer = GetBuffer(client_ids[ii]); |
| 3356 if (buffer && !buffer->IsDeleted()) { | 3396 if (buffer && !buffer->IsDeleted()) { |
| 3357 buffer->RemoveMappedRange(); | 3397 buffer->RemoveMappedRange(); |
| 3358 state_.RemoveBoundBuffer(buffer); | 3398 state_.RemoveBoundBuffer(buffer); |
| 3359 RemoveBuffer(client_ids[ii]); | 3399 RemoveBuffer(client_ids[ii]); |
| 3360 } | 3400 } |
| 3361 } | 3401 } |
| (...skipping 8389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11751 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, | 11791 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, |
| 11752 element_array_buffer ? element_array_buffer->service_id() : 0); | 11792 element_array_buffer ? element_array_buffer->service_id() : 0); |
| 11753 } | 11793 } |
| 11754 | 11794 |
| 11755 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { | 11795 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { |
| 11756 const VertexAttribManager* vao = | 11796 const VertexAttribManager* vao = |
| 11757 GetVertexAttribManager(client_id); | 11797 GetVertexAttribManager(client_id); |
| 11758 return vao && vao->IsValid() && !vao->IsDeleted(); | 11798 return vao && vao->IsValid() && !vao->IsDeleted(); |
| 11759 } | 11799 } |
| 11760 | 11800 |
| 11801 bool GLES2DecoderImpl::DoIsPathCHROMIUM(GLuint client_id) { | |
| 11802 GLuint service_id = 0; | |
| 11803 if (!path_manager()->GetPath(client_id, &service_id)) | |
| 11804 return false; | |
| 11805 | |
| 11806 return glIsPathNV(service_id); | |
| 11807 } | |
| 11808 | |
| 11761 #if defined(OS_MACOSX) | 11809 #if defined(OS_MACOSX) |
| 11762 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) { | 11810 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) { |
| 11763 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find( | 11811 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find( |
| 11764 texture_id); | 11812 texture_id); |
| 11765 if (it != texture_to_io_surface_map_.end()) { | 11813 if (it != texture_to_io_surface_map_.end()) { |
| 11766 // Found a previous IOSurface bound to this texture; release it. | 11814 // Found a previous IOSurface bound to this texture; release it. |
| 11767 IOSurfaceRef surface = it->second; | 11815 IOSurfaceRef surface = it->second; |
| 11768 CFRelease(surface); | 11816 CFRelease(surface); |
| 11769 texture_to_io_surface_map_.erase(it); | 11817 texture_to_io_surface_map_.erase(it); |
| 11770 } | 11818 } |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13698 if (CheckResetStatus()) { | 13746 if (CheckResetStatus()) { |
| 13699 other = error::kUnknown; | 13747 other = error::kUnknown; |
| 13700 } else { | 13748 } else { |
| 13701 // Need to lose current context before broadcasting! | 13749 // Need to lose current context before broadcasting! |
| 13702 MarkContextLost(error::kOutOfMemory); | 13750 MarkContextLost(error::kOutOfMemory); |
| 13703 } | 13751 } |
| 13704 group_->LoseContexts(other); | 13752 group_->LoseContexts(other); |
| 13705 } | 13753 } |
| 13706 } | 13754 } |
| 13707 | 13755 |
| 13756 error::Error GLES2DecoderImpl::HandleGenPathsCHROMIUM( | |
| 13757 uint32 immediate_data_size, | |
| 13758 const void* cmd_data) { | |
| 13759 static const char kFunctionName[] = "glGenPathsCHROMIUM"; | |
| 13760 const gles2::cmds::GenPathsCHROMIUM& c = | |
| 13761 *static_cast<const gles2::cmds::GenPathsCHROMIUM*>(cmd_data); | |
| 13762 if (!features().chromium_path_rendering) { | |
| 13763 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13764 "function not available"); | |
| 13765 return error::kNoError; | |
| 13766 } | |
| 13767 | |
| 13768 GLsizei range = static_cast<GLsizei>(c.range); | |
| 13769 if (range < 0) { | |
| 13770 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "range < 0"); | |
| 13771 return error::kNoError; | |
| 13772 } | |
| 13773 | |
| 13774 GLuint first_client_id = static_cast<GLuint>(c.first_client_id); | |
| 13775 if (first_client_id == 0) | |
| 13776 return error::kInvalidArguments; | |
| 13777 | |
| 13778 if (range == 0) | |
| 13779 return error::kNoError; | |
| 13780 | |
| 13781 if (!GenPathsCHROMIUMHelper(first_client_id, range)) | |
| 13782 return error::kInvalidArguments; | |
| 13783 | |
| 13784 return error::kNoError; | |
| 13785 } | |
| 13786 error::Error GLES2DecoderImpl::HandleDeletePathsCHROMIUM( | |
| 13787 uint32_t immediate_data_size, | |
| 13788 const void* cmd_data) { | |
| 13789 static const char kFunctionName[] = "glDeletePathsCHROMIUM"; | |
| 13790 const gles2::cmds::DeletePathsCHROMIUM& c = | |
| 13791 *static_cast<const gles2::cmds::DeletePathsCHROMIUM*>(cmd_data); | |
| 13792 if (!features().chromium_path_rendering) { | |
| 13793 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13794 "function not available"); | |
| 13795 return error::kNoError; | |
| 13796 } | |
| 13797 | |
| 13798 GLsizei range = static_cast<GLsizei>(c.range); | |
| 13799 if (range < 0) { | |
| 13800 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "range < 0"); | |
| 13801 return error::kNoError; | |
| 13802 } | |
| 13803 | |
| 13804 if (range == 0) | |
| 13805 return error::kNoError; | |
| 13806 | |
| 13807 GLuint first_client_id = c.first_client_id; | |
| 13808 // first_client_id can be 0, because non-existing path ids are skipped. | |
| 13809 | |
| 13810 if (!DeletePathsCHROMIUMHelper(first_client_id, range)) | |
| 13811 return error::kInvalidArguments; | |
| 13812 | |
| 13813 return error::kNoError; | |
| 13814 } | |
| 13815 | |
| 13816 error::Error GLES2DecoderImpl::HandlePathCommandsCHROMIUM( | |
| 13817 uint32 immediate_data_size, | |
| 13818 const void* cmd_data) { | |
| 13819 static const char kFunctionName[] = "glPathCommandsCHROMIUM"; | |
| 13820 const gles2::cmds::PathCommandsCHROMIUM& c = | |
| 13821 *static_cast<const gles2::cmds::PathCommandsCHROMIUM*>(cmd_data); | |
| 13822 if (!features().chromium_path_rendering) { | |
| 13823 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13824 "function not available"); | |
| 13825 return error::kNoError; | |
| 13826 } | |
| 13827 | |
| 13828 GLuint service_id = 0; | |
| 13829 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { | |
| 13830 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13831 "invalid path name"); | |
| 13832 return error::kNoError; | |
| 13833 } | |
| 13834 | |
| 13835 GLsizei num_commands = static_cast<GLsizei>(c.numCommands); | |
| 13836 if (num_commands < 0) { | |
| 13837 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numCommands < 0"); | |
| 13838 return error::kNoError; | |
| 13839 } | |
| 13840 | |
| 13841 GLsizei num_coords = static_cast<uint32>(c.numCoords); | |
| 13842 if (num_coords < 0) { | |
| 13843 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numCoords < 0"); | |
| 13844 return error::kNoError; | |
| 13845 } | |
| 13846 | |
| 13847 GLenum coord_type = static_cast<uint32>(c.coordType); | |
| 13848 if (!validators_->path_coord_type.IsValid(static_cast<GLint>(coord_type))) { | |
| 13849 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, kFunctionName, "invalid coordType"); | |
| 13850 return error::kNoError; | |
| 13851 } | |
| 13852 | |
| 13853 const GLubyte* commands = NULL; | |
| 13854 GLsizei num_coords_expected = 0; | |
|
piman
2015/06/24 03:27:44
You may need a CheckedNumeric<GLsizei> to detect /
Kimmo Kinnunen
2015/06/24 12:49:01
Done.
| |
| 13855 | |
| 13856 if (num_commands > 0) { | |
| 13857 uint32 commands_shm_id = static_cast<uint32>(c.commands_shm_id); | |
| 13858 uint32 commands_shm_offset = static_cast<uint32>(c.commands_shm_offset); | |
| 13859 if (commands_shm_id != 0 || commands_shm_offset != 0) | |
| 13860 commands = GetSharedMemoryAs<const GLubyte*>( | |
| 13861 commands_shm_id, commands_shm_offset, num_commands); | |
| 13862 | |
| 13863 if (!commands) | |
| 13864 return error::kOutOfBounds; | |
| 13865 | |
| 13866 for (GLsizei i = 0; i < num_commands; ++i) { | |
| 13867 switch (commands[i]) { | |
| 13868 case GL_CLOSE_PATH_CHROMIUM: | |
| 13869 // Close has no coords. | |
| 13870 break; | |
| 13871 case GL_MOVE_TO_CHROMIUM: | |
| 13872 // Fallthrough. | |
| 13873 case GL_LINE_TO_CHROMIUM: | |
| 13874 num_coords_expected += 2; | |
| 13875 break; | |
| 13876 case GL_QUADRATIC_CURVE_TO_CHROMIUM: | |
| 13877 num_coords_expected += 4; | |
| 13878 break; | |
| 13879 case GL_CUBIC_CURVE_TO_CHROMIUM: | |
| 13880 num_coords_expected += 6; | |
| 13881 break; | |
| 13882 case GL_CONIC_CURVE_TO_CHROMIUM: | |
| 13883 num_coords_expected += 5; | |
| 13884 break; | |
| 13885 default: | |
| 13886 LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, kFunctionName, "invalid command"); | |
| 13887 return error::kNoError; | |
| 13888 } | |
| 13889 } | |
| 13890 } | |
| 13891 | |
| 13892 if (num_coords != num_coords_expected) { | |
| 13893 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13894 "numCoords does not match commands"); | |
| 13895 return error::kNoError; | |
| 13896 } | |
| 13897 | |
| 13898 const void* coords = NULL; | |
| 13899 | |
| 13900 if (num_coords > 0) { | |
| 13901 uint32 coords_size = 0; | |
| 13902 uint32 coord_type_size = | |
| 13903 GLES2Util::GetGLTypeSizeForPathCoordType(coord_type); | |
| 13904 if (!SafeMultiplyUint32(num_coords, coord_type_size, &coords_size)) | |
| 13905 return error::kOutOfBounds; | |
| 13906 | |
| 13907 uint32 coords_shm_id = static_cast<uint32>(c.coords_shm_id); | |
| 13908 uint32 coords_shm_offset = static_cast<uint32>(c.coords_shm_offset); | |
| 13909 if (coords_shm_id != 0 || coords_shm_offset != 0) | |
| 13910 coords = GetSharedMemoryAs<const void*>(coords_shm_id, coords_shm_offset, | |
| 13911 coords_size); | |
| 13912 | |
| 13913 if (!coords) | |
| 13914 return error::kOutOfBounds; | |
| 13915 } | |
| 13916 | |
| 13917 glPathCommandsNV(service_id, num_commands, commands, num_coords, coord_type, | |
| 13918 coords); | |
| 13919 | |
| 13920 return error::kNoError; | |
| 13921 } | |
| 13922 | |
| 13923 error::Error GLES2DecoderImpl::HandlePathParameterfCHROMIUM( | |
| 13924 uint32 immediate_data_size, | |
| 13925 const void* cmd_data) { | |
| 13926 static const char kFunctionName[] = "glPathParameterfCHROMIUM"; | |
| 13927 const gles2::cmds::PathParameterfCHROMIUM& c = | |
| 13928 *static_cast<const gles2::cmds::PathParameterfCHROMIUM*>(cmd_data); | |
| 13929 if (!features().chromium_path_rendering) { | |
| 13930 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13931 "function not available"); | |
| 13932 return error::kNoError; | |
| 13933 } | |
| 13934 GLuint service_id = 0; | |
| 13935 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { | |
| 13936 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13937 "invalid path name"); | |
| 13938 return error::kNoError; | |
| 13939 } | |
| 13940 | |
| 13941 GLenum pname = static_cast<GLenum>(c.pname); | |
| 13942 GLfloat value = static_cast<GLfloat>(c.value); | |
| 13943 bool hasValueError = false; | |
| 13944 | |
| 13945 switch (pname) { | |
| 13946 case GL_PATH_STROKE_WIDTH_CHROMIUM: | |
| 13947 case GL_PATH_MITER_LIMIT_CHROMIUM: | |
| 13948 hasValueError = std::isnan(value) || !std::isfinite(value) || value < 0; | |
| 13949 break; | |
| 13950 case GL_PATH_STROKE_BOUND_CHROMIUM: | |
| 13951 value = std::max(std::min(1.0f, value), 0.0f); | |
| 13952 break; | |
| 13953 case GL_PATH_END_CAPS_CHROMIUM: | |
| 13954 hasValueError = !validators_->path_parameter_cap_values.IsValid( | |
| 13955 static_cast<GLint>(value)); | |
| 13956 break; | |
| 13957 case GL_PATH_JOIN_STYLE_CHROMIUM: | |
| 13958 hasValueError = !validators_->path_parameter_join_values.IsValid( | |
| 13959 static_cast<GLint>(value)); | |
| 13960 break; | |
| 13961 default: | |
| 13962 DCHECK(!validators_->path_parameter.IsValid(pname)); | |
| 13963 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, pname, "pname"); | |
| 13964 return error::kNoError; | |
| 13965 } | |
| 13966 DCHECK(validators_->path_parameter.IsValid(pname)); | |
| 13967 | |
| 13968 if (hasValueError) { | |
| 13969 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "value not correct"); | |
| 13970 return error::kNoError; | |
| 13971 } | |
| 13972 | |
| 13973 glPathParameterfNV(service_id, pname, value); | |
| 13974 return error::kNoError; | |
| 13975 } | |
| 13976 | |
| 13977 error::Error GLES2DecoderImpl::HandlePathParameteriCHROMIUM( | |
| 13978 uint32 immediate_data_size, | |
| 13979 const void* cmd_data) { | |
| 13980 static const char kFunctionName[] = "glPathParameteriCHROMIUM"; | |
| 13981 const gles2::cmds::PathParameteriCHROMIUM& c = | |
| 13982 *static_cast<const gles2::cmds::PathParameteriCHROMIUM*>(cmd_data); | |
| 13983 if (!features().chromium_path_rendering) { | |
| 13984 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13985 "function not available"); | |
| 13986 return error::kNoError; | |
| 13987 } | |
| 13988 GLuint service_id = 0; | |
| 13989 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { | |
| 13990 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 13991 "invalid path name"); | |
| 13992 return error::kNoError; | |
| 13993 } | |
| 13994 | |
| 13995 GLenum pname = static_cast<GLenum>(c.pname); | |
| 13996 GLint value = static_cast<GLint>(c.value); | |
| 13997 bool hasValueError = false; | |
| 13998 | |
| 13999 switch (pname) { | |
| 14000 case GL_PATH_STROKE_WIDTH_CHROMIUM: | |
| 14001 case GL_PATH_MITER_LIMIT_CHROMIUM: | |
| 14002 hasValueError = value < 0; | |
| 14003 break; | |
| 14004 case GL_PATH_STROKE_BOUND_CHROMIUM: | |
| 14005 value = std::max(std::min(1, value), 0); | |
| 14006 break; | |
| 14007 case GL_PATH_END_CAPS_CHROMIUM: | |
| 14008 hasValueError = !validators_->path_parameter_cap_values.IsValid(value); | |
| 14009 break; | |
| 14010 case GL_PATH_JOIN_STYLE_CHROMIUM: | |
| 14011 hasValueError = !validators_->path_parameter_join_values.IsValid(value); | |
| 14012 break; | |
| 14013 default: | |
| 14014 DCHECK(!validators_->path_parameter.IsValid(pname)); | |
| 14015 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, pname, "pname"); | |
| 14016 return error::kNoError; | |
| 14017 } | |
| 14018 DCHECK(validators_->path_parameter.IsValid(pname)); | |
| 14019 | |
| 14020 if (hasValueError) { | |
| 14021 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "value not correct"); | |
| 14022 return error::kNoError; | |
| 14023 } | |
| 14024 | |
| 14025 glPathParameteriNV(service_id, pname, value); | |
| 14026 return error::kNoError; | |
| 14027 } | |
| 14028 | |
| 14029 error::Error GLES2DecoderImpl::HandleStencilFillPathCHROMIUM( | |
| 14030 uint32 immediate_data_size, | |
| 14031 const void* cmd_data) { | |
| 14032 static const char kFunctionName[] = "glStencilFillPathCHROMIUM"; | |
| 14033 const gles2::cmds::StencilFillPathCHROMIUM& c = | |
| 14034 *static_cast<const gles2::cmds::StencilFillPathCHROMIUM*>(cmd_data); | |
| 14035 if (!features().chromium_path_rendering) { | |
| 14036 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 14037 "function not available"); | |
| 14038 return error::kNoError; | |
| 14039 } | |
| 14040 GLenum fill_mode = static_cast<GLenum>(c.fillMode); | |
| 14041 if (!validators_->path_fill_mode.IsValid(fill_mode)) { | |
| 14042 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); | |
| 14043 return error::kNoError; | |
| 14044 } | |
| 14045 GLuint mask = static_cast<GLuint>(c.mask); | |
| 14046 if ((fill_mode == GL_COUNT_UP_CHROMIUM || | |
| 14047 fill_mode == GL_COUNT_DOWN_CHROMIUM) && | |
| 14048 GLES2Util::IsNPOT(mask + 1)) { | |
|
piman
2015/06/24 03:27:44
Did you mean !GLES2Util::IsNPOT(mask + 1) ?
Kimmo Kinnunen
2015/06/24 12:49:02
IsNPOT means "Is Not Power of Two"
It is error if
piman
2015/06/24 22:50:18
Ah, yes, my bad, this is fine.
| |
| 14049 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | |
| 14050 "mask is not power of two"); | |
| 14051 return error::kNoError; | |
| 14052 } | |
| 14053 GLuint service_id = 0; | |
| 14054 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { | |
| 14055 // "If /path/ does not name an existing path object, the command does | |
| 14056 // nothing (and no error is generated)." | |
| 14057 // This holds for other rendering functions, too. | |
| 14058 return error::kNoError; | |
| 14059 } | |
| 14060 ApplyDirtyState(); | |
| 14061 glStencilFillPathNV(service_id, fill_mode, mask); | |
| 14062 return error::kNoError; | |
| 14063 } | |
| 14064 | |
| 14065 error::Error GLES2DecoderImpl::HandleStencilStrokePathCHROMIUM( | |
| 14066 uint32 immediate_data_size, | |
| 14067 const void* cmd_data) { | |
| 14068 static const char kFunctionName[] = "glStencilStrokePathCHROMIUM"; | |
| 14069 const gles2::cmds::StencilStrokePathCHROMIUM& c = | |
| 14070 *static_cast<const gles2::cmds::StencilStrokePathCHROMIUM*>(cmd_data); | |
| 14071 if (!features().chromium_path_rendering) { | |
| 14072 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 14073 "function not available"); | |
| 14074 return error::kNoError; | |
| 14075 } | |
| 14076 GLuint service_id = 0; | |
| 14077 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { | |
| 14078 return error::kNoError; | |
| 14079 } | |
| 14080 GLint reference = static_cast<GLint>(c.reference); | |
| 14081 GLuint mask = static_cast<GLuint>(c.mask); | |
| 14082 ApplyDirtyState(); | |
| 14083 glStencilStrokePathNV(service_id, reference, mask); | |
| 14084 return error::kNoError; | |
| 14085 } | |
| 14086 | |
| 14087 error::Error GLES2DecoderImpl::HandleCoverFillPathCHROMIUM( | |
| 14088 uint32 immediate_data_size, | |
| 14089 const void* cmd_data) { | |
| 14090 static const char kFunctionName[] = "glCoverFillPathCHROMIUM"; | |
| 14091 const gles2::cmds::CoverFillPathCHROMIUM& c = | |
| 14092 *static_cast<const gles2::cmds::CoverFillPathCHROMIUM*>(cmd_data); | |
| 14093 if (!features().chromium_path_rendering) { | |
| 14094 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 14095 "function not available"); | |
| 14096 return error::kNoError; | |
| 14097 } | |
| 14098 GLenum cover_mode = static_cast<GLenum>(c.coverMode); | |
| 14099 if (!validators_->path_cover_mode.IsValid(cover_mode)) { | |
| 14100 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); | |
| 14101 return error::kNoError; | |
| 14102 } | |
| 14103 GLuint service_id = 0; | |
| 14104 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) | |
| 14105 return error::kNoError; | |
| 14106 | |
| 14107 ApplyDirtyState(); | |
| 14108 glCoverFillPathNV(service_id, cover_mode); | |
| 14109 return error::kNoError; | |
| 14110 } | |
| 14111 | |
| 14112 error::Error GLES2DecoderImpl::HandleCoverStrokePathCHROMIUM( | |
| 14113 uint32 immediate_data_size, | |
| 14114 const void* cmd_data) { | |
| 14115 static const char kFunctionName[] = "glCoverStrokePathCHROMIUM"; | |
| 14116 const gles2::cmds::CoverStrokePathCHROMIUM& c = | |
| 14117 *static_cast<const gles2::cmds::CoverStrokePathCHROMIUM*>(cmd_data); | |
| 14118 if (!features().chromium_path_rendering) { | |
| 14119 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 14120 "function not available"); | |
| 14121 return error::kNoError; | |
| 14122 } | |
| 14123 GLenum cover_mode = static_cast<GLenum>(c.coverMode); | |
| 14124 if (!validators_->path_cover_mode.IsValid(cover_mode)) { | |
| 14125 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); | |
| 14126 return error::kNoError; | |
| 14127 } | |
| 14128 GLuint service_id = 0; | |
| 14129 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) | |
| 14130 return error::kNoError; | |
| 14131 | |
| 14132 ApplyDirtyState(); | |
| 14133 glCoverStrokePathNV(service_id, cover_mode); | |
| 14134 return error::kNoError; | |
| 14135 } | |
| 14136 | |
| 14137 error::Error GLES2DecoderImpl::HandleStencilThenCoverFillPathCHROMIUM( | |
| 14138 uint32 immediate_data_size, | |
| 14139 const void* cmd_data) { | |
| 14140 static const char kFunctionName[] = "glStencilThenCoverFillPathCHROMIUM"; | |
| 14141 const gles2::cmds::StencilThenCoverFillPathCHROMIUM& c = | |
| 14142 *static_cast<const gles2::cmds::StencilThenCoverFillPathCHROMIUM*>( | |
| 14143 cmd_data); | |
| 14144 if (!features().chromium_path_rendering) { | |
| 14145 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 14146 "function not available"); | |
| 14147 return error::kNoError; | |
| 14148 } | |
| 14149 GLenum fill_mode = static_cast<GLenum>(c.fillMode); | |
| 14150 if (!validators_->path_fill_mode.IsValid(fill_mode)) { | |
| 14151 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); | |
| 14152 return error::kNoError; | |
| 14153 } | |
| 14154 GLuint mask = static_cast<GLuint>(c.mask); | |
| 14155 if ((fill_mode == GL_COUNT_UP_CHROMIUM || | |
| 14156 fill_mode == GL_COUNT_DOWN_CHROMIUM) && | |
| 14157 GLES2Util::IsNPOT(mask + 1)) { | |
|
piman
2015/06/24 03:27:44
Same here, !GLES2Util::IsNPOT() ?
Kimmo Kinnunen
2015/06/24 12:49:02
IsNPOT is intended. Fixed the error message.
| |
| 14158 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | |
| 14159 "mask is not power of two"); | |
| 14160 return error::kNoError; | |
| 14161 } | |
| 14162 GLenum cover_mode = static_cast<GLenum>(c.coverMode); | |
| 14163 if (!validators_->path_cover_mode.IsValid(cover_mode)) { | |
| 14164 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); | |
| 14165 return error::kNoError; | |
| 14166 } | |
| 14167 GLuint service_id = 0; | |
| 14168 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) | |
| 14169 return error::kNoError; | |
| 14170 | |
| 14171 ApplyDirtyState(); | |
| 14172 glStencilThenCoverFillPathNV(service_id, fill_mode, mask, cover_mode); | |
| 14173 return error::kNoError; | |
| 14174 } | |
| 14175 | |
| 14176 error::Error GLES2DecoderImpl::HandleStencilThenCoverStrokePathCHROMIUM( | |
| 14177 uint32 immediate_data_size, | |
| 14178 const void* cmd_data) { | |
| 14179 static const char kFunctionName[] = "glStencilThenCoverStrokePathCHROMIUM"; | |
| 14180 const gles2::cmds::StencilThenCoverStrokePathCHROMIUM& c = | |
| 14181 *static_cast<const gles2::cmds::StencilThenCoverStrokePathCHROMIUM*>( | |
| 14182 cmd_data); | |
| 14183 if (!features().chromium_path_rendering) { | |
| 14184 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | |
| 14185 "function not available"); | |
| 14186 return error::kNoError; | |
| 14187 } | |
| 14188 GLenum cover_mode = static_cast<GLenum>(c.coverMode); | |
| 14189 if (!validators_->path_cover_mode.IsValid(cover_mode)) { | |
| 14190 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); | |
| 14191 return error::kNoError; | |
| 14192 } | |
| 14193 GLuint service_id = 0; | |
| 14194 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) | |
| 14195 return error::kNoError; | |
| 14196 | |
| 14197 GLint reference = static_cast<GLint>(c.reference); | |
| 14198 GLuint mask = static_cast<GLuint>(c.mask); | |
| 14199 ApplyDirtyState(); | |
| 14200 glStencilThenCoverStrokePathNV(service_id, reference, mask, cover_mode); | |
| 14201 return error::kNoError; | |
| 14202 } | |
| 14203 | |
| 13708 // Include the auto-generated part of this file. We split this because it means | 14204 // 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 | 14205 // 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. | 14206 // instead of having to edit some template or the code generator. |
| 13711 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 14207 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 13712 | 14208 |
| 13713 } // namespace gles2 | 14209 } // namespace gles2 |
| 13714 } // namespace gpu | 14210 } // namespace gpu |
| OLD | NEW |