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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Return the union of |rect1| and |rect2| if they share an edge. | 210 // Return the union of |rect1| and |rect2| if they share an edge. |
211 if (rect1.SharesEdgeWith(rect2)) { | 211 if (rect1.SharesEdgeWith(rect2)) { |
212 *result = gfx::UnionRects(rect1, rect2); | 212 *result = gfx::UnionRects(rect1, rect2); |
213 return true; | 213 return true; |
214 } | 214 } |
215 | 215 |
216 // Return false if it's not possible to combine |rect1| and |rect2|. | 216 // Return false if it's not possible to combine |rect1| and |rect2|. |
217 return false; | 217 return false; |
218 } | 218 } |
219 | 219 |
| 220 bool IsValidPathCommandMask(GLenum fill_mode, GLuint mask) { |
| 221 /* The error INVALID_VALUE |
| 222 is generated if /fillMode/ is COUNT_UP_CHROMIUM or COUNT_DOWN_CHROMIUM and |
| 223 the effective /mask/+1 is not an integer power of two |
| 224 */ |
| 225 return (fill_mode != GL_COUNT_UP_CHROMIUM && |
| 226 fill_mode != GL_COUNT_DOWN_CHROMIUM) || |
| 227 !GLES2Util::IsNPOT(mask + 1); |
| 228 } |
| 229 |
220 } // namespace | 230 } // namespace |
221 | 231 |
222 class GLES2DecoderImpl; | 232 class GLES2DecoderImpl; |
223 | 233 |
224 // Local versions of the SET_GL_ERROR macros | 234 // Local versions of the SET_GL_ERROR macros |
225 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ | 235 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ |
226 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) | 236 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg) |
227 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \ | 237 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \ |
228 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \ | 238 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \ |
229 function_name, value, label) | 239 function_name, value, label) |
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 back_buffer_color_format_ == GL_RGBA8); | 1880 back_buffer_color_format_ == GL_RGBA8); |
1871 } | 1881 } |
1872 | 1882 |
1873 // Set remaining commands to process to 0 to force DoCommands to return | 1883 // Set remaining commands to process to 0 to force DoCommands to return |
1874 // and allow context preemption and GPU watchdog checks in GpuScheduler(). | 1884 // and allow context preemption and GPU watchdog checks in GpuScheduler(). |
1875 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } | 1885 void ExitCommandProcessingEarly() { commands_to_process_ = 0; } |
1876 | 1886 |
1877 void ProcessPendingReadPixels(bool did_finish); | 1887 void ProcessPendingReadPixels(bool did_finish); |
1878 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); | 1888 void FinishReadPixels(const cmds::ReadPixels& c, GLuint buffer); |
1879 | 1889 |
| 1890 bool PrepareInstancedPathCommand(GLsizei num_paths, |
| 1891 GLenum path_name_type, |
| 1892 uint32 paths_shm_id, |
| 1893 uint32 paths_shm_offset, |
| 1894 GLuint path_base, |
| 1895 GLenum transform_type, |
| 1896 uint32 transforms_shm_id, |
| 1897 uint32 transforms_shm_offset, |
| 1898 error::Error* out_error, |
| 1899 GLuint** out_paths, |
| 1900 const GLfloat** out_transforms, |
| 1901 scoped_ptr<GLuint[]>* out_temp_path_buffer); |
| 1902 template <typename T> |
| 1903 bool PrepareInstancedPathCommand(GLsizei num_paths, |
| 1904 uint32 paths_shm_id, |
| 1905 uint32 paths_shm_offset, |
| 1906 GLuint path_base, |
| 1907 GLenum transform_type, |
| 1908 uint32 transforms_shm_id, |
| 1909 uint32 transforms_shm_offset, |
| 1910 error::Error* out_error, |
| 1911 GLuint** out_paths, |
| 1912 const GLfloat** out_transforms, |
| 1913 scoped_ptr<GLuint[]>* out_temp_path_buffer); |
| 1914 |
1880 // Generate a member function prototype for each command in an automated and | 1915 // Generate a member function prototype for each command in an automated and |
1881 // typesafe way. | 1916 // typesafe way. |
1882 #define GLES2_CMD_OP(name) \ | 1917 #define GLES2_CMD_OP(name) \ |
1883 Error Handle##name(uint32 immediate_data_size, const void* data); | 1918 Error Handle##name(uint32 immediate_data_size, const void* data); |
1884 | 1919 |
1885 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1920 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1886 | 1921 |
1887 #undef GLES2_CMD_OP | 1922 #undef GLES2_CMD_OP |
1888 | 1923 |
1889 // The GL context this decoder renders to on behalf of the client. | 1924 // The GL context this decoder renders to on behalf of the client. |
(...skipping 12612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14502 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | 14537 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
14503 "function not available"); | 14538 "function not available"); |
14504 return error::kNoError; | 14539 return error::kNoError; |
14505 } | 14540 } |
14506 GLenum fill_mode = static_cast<GLenum>(c.fillMode); | 14541 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
14507 if (!validators_->path_fill_mode.IsValid(fill_mode)) { | 14542 if (!validators_->path_fill_mode.IsValid(fill_mode)) { |
14508 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); | 14543 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); |
14509 return error::kNoError; | 14544 return error::kNoError; |
14510 } | 14545 } |
14511 GLuint mask = static_cast<GLuint>(c.mask); | 14546 GLuint mask = static_cast<GLuint>(c.mask); |
14512 if ((fill_mode == GL_COUNT_UP_CHROMIUM || | 14547 if (!IsValidPathCommandMask(fill_mode, mask)) { |
14513 fill_mode == GL_COUNT_DOWN_CHROMIUM) && | |
14514 GLES2Util::IsNPOT(mask + 1)) { | |
14515 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 14548 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
14516 "mask + 1 is not power of two"); | 14549 "mask + 1 is not power of two"); |
14517 return error::kNoError; | 14550 return error::kNoError; |
14518 } | 14551 } |
14519 GLuint service_id = 0; | 14552 GLuint service_id = 0; |
14520 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { | 14553 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) { |
14521 // "If /path/ does not name an existing path object, the command does | 14554 // "If /path/ does not name an existing path object, the command does |
14522 // nothing (and no error is generated)." | 14555 // nothing (and no error is generated)." |
14523 // This holds for other rendering functions, too. | 14556 // This holds for other rendering functions, too. |
14524 return error::kNoError; | 14557 return error::kNoError; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14611 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | 14644 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
14612 "function not available"); | 14645 "function not available"); |
14613 return error::kNoError; | 14646 return error::kNoError; |
14614 } | 14647 } |
14615 GLenum fill_mode = static_cast<GLenum>(c.fillMode); | 14648 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
14616 if (!validators_->path_fill_mode.IsValid(fill_mode)) { | 14649 if (!validators_->path_fill_mode.IsValid(fill_mode)) { |
14617 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); | 14650 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); |
14618 return error::kNoError; | 14651 return error::kNoError; |
14619 } | 14652 } |
14620 GLuint mask = static_cast<GLuint>(c.mask); | 14653 GLuint mask = static_cast<GLuint>(c.mask); |
14621 if ((fill_mode == GL_COUNT_UP_CHROMIUM || | 14654 if (!IsValidPathCommandMask(fill_mode, mask)) { |
14622 fill_mode == GL_COUNT_DOWN_CHROMIUM) && | |
14623 GLES2Util::IsNPOT(mask + 1)) { | |
14624 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 14655 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
14625 "mask + 1 is not power of two"); | 14656 "mask + 1 is not power of two"); |
14626 return error::kNoError; | 14657 return error::kNoError; |
14627 } | 14658 } |
14628 GLenum cover_mode = static_cast<GLenum>(c.coverMode); | 14659 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
14629 if (!validators_->path_cover_mode.IsValid(cover_mode)) { | 14660 if (!validators_->path_cover_mode.IsValid(cover_mode)) { |
14630 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); | 14661 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
14631 return error::kNoError; | 14662 return error::kNoError; |
14632 } | 14663 } |
14633 GLuint service_id = 0; | 14664 GLuint service_id = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
14660 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) | 14691 if (!path_manager()->GetPath(static_cast<GLuint>(c.path), &service_id)) |
14661 return error::kNoError; | 14692 return error::kNoError; |
14662 | 14693 |
14663 GLint reference = static_cast<GLint>(c.reference); | 14694 GLint reference = static_cast<GLint>(c.reference); |
14664 GLuint mask = static_cast<GLuint>(c.mask); | 14695 GLuint mask = static_cast<GLuint>(c.mask); |
14665 ApplyDirtyState(); | 14696 ApplyDirtyState(); |
14666 glStencilThenCoverStrokePathNV(service_id, reference, mask, cover_mode); | 14697 glStencilThenCoverStrokePathNV(service_id, reference, mask, cover_mode); |
14667 return error::kNoError; | 14698 return error::kNoError; |
14668 } | 14699 } |
14669 | 14700 |
| 14701 bool GLES2DecoderImpl::PrepareInstancedPathCommand( |
| 14702 GLsizei num_paths, |
| 14703 GLenum path_name_type, |
| 14704 uint32 paths_shm_id, |
| 14705 uint32 paths_shm_offset, |
| 14706 GLuint path_base, |
| 14707 GLenum transform_type, |
| 14708 uint32 transforms_shm_id, |
| 14709 uint32 transforms_shm_offset, |
| 14710 error::Error* out_error, |
| 14711 GLuint** out_paths, |
| 14712 const GLfloat** out_transforms, |
| 14713 scoped_ptr<GLuint[]>* out_temp_path_buffer) { |
| 14714 if (path_name_type == GL_BYTE) { |
| 14715 DCHECK(validators_->path_name_type.IsValid(path_name_type)); |
| 14716 return PrepareInstancedPathCommand<GLbyte>( |
| 14717 num_paths, paths_shm_id, paths_shm_offset, path_base, transform_type, |
| 14718 transforms_shm_id, transforms_shm_offset, out_error, out_paths, |
| 14719 out_transforms, out_temp_path_buffer); |
| 14720 } else if (path_name_type == GL_UNSIGNED_BYTE) { |
| 14721 DCHECK(validators_->path_name_type.IsValid(path_name_type)); |
| 14722 return PrepareInstancedPathCommand<GLubyte>( |
| 14723 num_paths, paths_shm_id, paths_shm_offset, path_base, transform_type, |
| 14724 transforms_shm_id, transforms_shm_offset, out_error, out_paths, |
| 14725 out_transforms, out_temp_path_buffer); |
| 14726 } else if (path_name_type == GL_SHORT) { |
| 14727 DCHECK(validators_->path_name_type.IsValid(path_name_type)); |
| 14728 return PrepareInstancedPathCommand<GLshort>( |
| 14729 num_paths, paths_shm_id, paths_shm_offset, path_base, transform_type, |
| 14730 transforms_shm_id, transforms_shm_offset, out_error, out_paths, |
| 14731 out_transforms, out_temp_path_buffer); |
| 14732 } else if (path_name_type == GL_UNSIGNED_SHORT) { |
| 14733 DCHECK(validators_->path_name_type.IsValid(path_name_type)); |
| 14734 return PrepareInstancedPathCommand<GLushort>( |
| 14735 num_paths, paths_shm_id, paths_shm_offset, path_base, transform_type, |
| 14736 transforms_shm_id, transforms_shm_offset, out_error, out_paths, |
| 14737 out_transforms, out_temp_path_buffer); |
| 14738 } else if (path_name_type == GL_INT) { |
| 14739 DCHECK(validators_->path_name_type.IsValid(path_name_type)); |
| 14740 return PrepareInstancedPathCommand<GLint>( |
| 14741 num_paths, paths_shm_id, paths_shm_offset, path_base, transform_type, |
| 14742 transforms_shm_id, transforms_shm_offset, out_error, out_paths, |
| 14743 out_transforms, out_temp_path_buffer); |
| 14744 } else if (path_name_type == GL_UNSIGNED_INT) { |
| 14745 DCHECK(validators_->path_name_type.IsValid(path_name_type)); |
| 14746 return PrepareInstancedPathCommand<GLuint>( |
| 14747 num_paths, paths_shm_id, paths_shm_offset, path_base, transform_type, |
| 14748 transforms_shm_id, transforms_shm_offset, out_error, out_paths, |
| 14749 out_transforms, out_temp_path_buffer); |
| 14750 } |
| 14751 |
| 14752 DCHECK(!validators_->path_name_type.IsValid(path_name_type)); |
| 14753 NOTREACHED(); |
| 14754 |
| 14755 *out_error = error::kOutOfBounds; |
| 14756 return false; |
| 14757 } |
| 14758 |
| 14759 template <typename T> |
| 14760 bool GLES2DecoderImpl::PrepareInstancedPathCommand( |
| 14761 GLsizei num_paths, |
| 14762 uint32 paths_shm_id, |
| 14763 uint32 paths_shm_offset, |
| 14764 GLuint path_base, |
| 14765 GLenum transform_type, |
| 14766 uint32 transforms_shm_id, |
| 14767 uint32 transforms_shm_offset, |
| 14768 error::Error* out_error, |
| 14769 GLuint** out_paths, |
| 14770 const GLfloat** out_transforms, |
| 14771 scoped_ptr<GLuint[]>* out_temp_path_buffer) { |
| 14772 if (num_paths == 0) { |
| 14773 // No GL error, just nothing to do. |
| 14774 *out_error = error::kNoError; |
| 14775 return false; |
| 14776 } |
| 14777 uint32 paths_size = 0; |
| 14778 if (!SafeMultiplyUint32(num_paths, sizeof(T), &paths_size)) { |
| 14779 *out_error = error::kOutOfBounds; |
| 14780 return false; |
| 14781 } |
| 14782 |
| 14783 T* paths = NULL; |
| 14784 if (paths_shm_id != 0 || paths_shm_offset != 0) |
| 14785 paths = GetSharedMemoryAs<T*>(paths_shm_id, paths_shm_offset, paths_size); |
| 14786 |
| 14787 if (!paths) { |
| 14788 *out_error = error::kOutOfBounds; |
| 14789 return false; |
| 14790 } |
| 14791 |
| 14792 const GLfloat* transforms = NULL; |
| 14793 |
| 14794 if (transform_type != GL_NONE) { |
| 14795 uint32 transforms_component_count = |
| 14796 GLES2Util::GetComponentCountForGLTransformType(transform_type); |
| 14797 // Below multiplication will not overflow. |
| 14798 DCHECK(transforms_component_count <= 12); |
| 14799 uint32 one_transform_size = sizeof(GLfloat) * transforms_component_count; |
| 14800 |
| 14801 uint32 transforms_size = 0; |
| 14802 if (!SafeMultiplyUint32(one_transform_size, num_paths, &transforms_size)) { |
| 14803 *out_error = error::kOutOfBounds; |
| 14804 return false; |
| 14805 } |
| 14806 if (transforms_shm_id != 0 || transforms_shm_offset != 0) |
| 14807 transforms = GetSharedMemoryAs<const GLfloat*>( |
| 14808 transforms_shm_id, transforms_shm_offset, transforms_size); |
| 14809 |
| 14810 if (!transforms) { |
| 14811 *out_error = error::kOutOfBounds; |
| 14812 return false; |
| 14813 } |
| 14814 } |
| 14815 |
| 14816 scoped_ptr<GLuint[]> temp_path_buffer; |
| 14817 GLuint* result_paths; |
| 14818 if (sizeof(T) == sizeof(GLuint)) { |
| 14819 result_paths = reinterpret_cast<GLuint*>(paths); |
| 14820 } else { |
| 14821 result_paths = new GLuint[num_paths]; |
| 14822 temp_path_buffer.reset(result_paths); |
| 14823 } |
| 14824 bool has_paths = false; |
| 14825 for (GLsizei i = 0; i < num_paths; ++i) { |
| 14826 GLuint service_id = 0; |
| 14827 uint32 client_id = 0; |
| 14828 if (!SafeAddUint32(paths[i], path_base, &client_id)) { |
| 14829 *out_error = error::kOutOfBounds; |
| 14830 return false; |
| 14831 } |
| 14832 |
| 14833 if (path_manager()->GetPath(client_id, &service_id)) |
| 14834 has_paths = true; |
| 14835 |
| 14836 // Will use path 0 if the path is not found. This is in line |
| 14837 // of the spec: missing paths will produce nothing, let |
| 14838 // the instanced draw continue. |
| 14839 result_paths[i] = service_id; |
| 14840 } |
| 14841 |
| 14842 if (!has_paths) { |
| 14843 *out_error = error::kNoError; |
| 14844 return false; |
| 14845 } |
| 14846 *out_error = error::kNoError; |
| 14847 *out_paths = result_paths; |
| 14848 *out_transforms = transforms; |
| 14849 out_temp_path_buffer->swap(temp_path_buffer); |
| 14850 return true; |
| 14851 } |
| 14852 |
| 14853 error::Error GLES2DecoderImpl::HandleStencilFillPathInstancedCHROMIUM( |
| 14854 uint32 immediate_data_size, |
| 14855 const void* cmd_data) { |
| 14856 static const char kFunctionName[] = "glStencilFillPathInstancedCHROMIUM"; |
| 14857 const gles2::cmds::StencilFillPathInstancedCHROMIUM& c = |
| 14858 *static_cast<const gles2::cmds::StencilFillPathInstancedCHROMIUM*>( |
| 14859 cmd_data); |
| 14860 if (!features().chromium_path_rendering) { |
| 14861 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14862 "function not available"); |
| 14863 return error::kNoError; |
| 14864 } |
| 14865 |
| 14866 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 14867 if (num_paths < 0) { |
| 14868 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numPaths < 0"); |
| 14869 return error::kNoError; |
| 14870 } |
| 14871 |
| 14872 GLenum path_name_type = static_cast<GLsizei>(c.pathNameType); |
| 14873 if (!validators_->path_name_type.IsValid(path_name_type)) { |
| 14874 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, path_name_type, |
| 14875 "pathNameType"); |
| 14876 return error::kNoError; |
| 14877 } |
| 14878 |
| 14879 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 14880 if (!validators_->path_fill_mode.IsValid(fill_mode)) { |
| 14881 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); |
| 14882 return error::kNoError; |
| 14883 } |
| 14884 |
| 14885 GLuint mask = static_cast<GLuint>(c.mask); |
| 14886 if (!IsValidPathCommandMask(fill_mode, mask)) { |
| 14887 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
| 14888 "mask is not power of two"); |
| 14889 return error::kNoError; |
| 14890 } |
| 14891 |
| 14892 GLenum transform_type = static_cast<GLenum>(c.transformType); |
| 14893 if (!validators_->path_transform_type.IsValid(transform_type)) { |
| 14894 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, transform_type, |
| 14895 "transformType"); |
| 14896 return error::kNoError; |
| 14897 } |
| 14898 |
| 14899 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 14900 |
| 14901 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 14902 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 14903 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 14904 uint32 transforms_shm_offset = |
| 14905 static_cast<uint32>(c.transformValues_shm_offset); |
| 14906 |
| 14907 GLuint* paths = NULL; |
| 14908 const GLfloat* transforms = NULL; |
| 14909 error::Error prepare_error = error::kNoError; |
| 14910 scoped_ptr<GLuint[]> temp_path_buffer; |
| 14911 if (!PrepareInstancedPathCommand( |
| 14912 num_paths, path_name_type, paths_shm_id, paths_shm_offset, path_base, |
| 14913 transform_type, transforms_shm_id, transforms_shm_offset, |
| 14914 &prepare_error, &paths, &transforms, &temp_path_buffer)) { |
| 14915 return prepare_error; |
| 14916 } |
| 14917 |
| 14918 ApplyDirtyState(); |
| 14919 glStencilFillPathInstancedNV(num_paths, path_name_type, paths, 0, fill_mode, |
| 14920 mask, transform_type, transforms); |
| 14921 |
| 14922 return error::kNoError; |
| 14923 } |
| 14924 |
| 14925 error::Error GLES2DecoderImpl::HandleStencilStrokePathInstancedCHROMIUM( |
| 14926 uint32 immediate_data_size, |
| 14927 const void* cmd_data) { |
| 14928 static const char kFunctionName[] = "glStencilStrokePathInstancedCHROMIUM"; |
| 14929 const gles2::cmds::StencilStrokePathInstancedCHROMIUM& c = |
| 14930 *static_cast<const gles2::cmds::StencilStrokePathInstancedCHROMIUM*>( |
| 14931 cmd_data); |
| 14932 if (!features().chromium_path_rendering) { |
| 14933 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14934 "function not available"); |
| 14935 return error::kNoError; |
| 14936 } |
| 14937 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 14938 if (num_paths < 0) { |
| 14939 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numPaths < 0"); |
| 14940 return error::kNoError; |
| 14941 } |
| 14942 |
| 14943 GLenum path_name_type = static_cast<GLsizei>(c.pathNameType); |
| 14944 if (!validators_->path_name_type.IsValid(path_name_type)) { |
| 14945 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, path_name_type, |
| 14946 "pathNameType"); |
| 14947 return error::kNoError; |
| 14948 } |
| 14949 |
| 14950 GLenum transform_type = static_cast<GLenum>(c.transformType); |
| 14951 if (!validators_->path_transform_type.IsValid(transform_type)) { |
| 14952 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, transform_type, |
| 14953 "transformType"); |
| 14954 return error::kNoError; |
| 14955 } |
| 14956 |
| 14957 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 14958 GLuint ref = static_cast<GLuint>(c.reference); |
| 14959 GLuint mask = static_cast<GLuint>(c.mask); |
| 14960 |
| 14961 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 14962 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 14963 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 14964 uint32 transforms_shm_offset = |
| 14965 static_cast<uint32>(c.transformValues_shm_offset); |
| 14966 |
| 14967 GLuint* paths = NULL; |
| 14968 const GLfloat* transforms = NULL; |
| 14969 error::Error prepare_error = error::kNoError; |
| 14970 scoped_ptr<GLuint[]> temp_path_buffer; |
| 14971 if (!PrepareInstancedPathCommand( |
| 14972 num_paths, path_name_type, paths_shm_id, paths_shm_offset, path_base, |
| 14973 transform_type, transforms_shm_id, transforms_shm_offset, |
| 14974 &prepare_error, &paths, &transforms, &temp_path_buffer)) { |
| 14975 return prepare_error; |
| 14976 } |
| 14977 |
| 14978 ApplyDirtyState(); |
| 14979 glStencilStrokePathInstancedNV(num_paths, path_name_type, paths, 0, ref, mask, |
| 14980 transform_type, transforms); |
| 14981 |
| 14982 return error::kNoError; |
| 14983 } |
| 14984 |
| 14985 error::Error GLES2DecoderImpl::HandleCoverFillPathInstancedCHROMIUM( |
| 14986 uint32 immediate_data_size, |
| 14987 const void* cmd_data) { |
| 14988 static const char kFunctionName[] = "glCoverFillPathInstancedCHROMIUM"; |
| 14989 const gles2::cmds::CoverFillPathInstancedCHROMIUM& c = |
| 14990 *static_cast<const gles2::cmds::CoverFillPathInstancedCHROMIUM*>( |
| 14991 cmd_data); |
| 14992 if (!features().chromium_path_rendering) { |
| 14993 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 14994 "function not available"); |
| 14995 return error::kNoError; |
| 14996 } |
| 14997 |
| 14998 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 14999 if (num_paths < 0) { |
| 15000 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numPaths < 0"); |
| 15001 return error::kNoError; |
| 15002 } |
| 15003 |
| 15004 GLenum path_name_type = static_cast<GLsizei>(c.pathNameType); |
| 15005 if (!validators_->path_name_type.IsValid(path_name_type)) { |
| 15006 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, path_name_type, |
| 15007 "pathNameType"); |
| 15008 return error::kNoError; |
| 15009 } |
| 15010 |
| 15011 GLenum cover_mode = static_cast<GLuint>(c.coverMode); |
| 15012 if (!validators_->path_instanced_cover_mode.IsValid(cover_mode)) { |
| 15013 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 15014 return error::kNoError; |
| 15015 } |
| 15016 |
| 15017 GLenum transform_type = static_cast<GLenum>(c.transformType); |
| 15018 if (!validators_->path_transform_type.IsValid(transform_type)) { |
| 15019 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, transform_type, |
| 15020 "transformType"); |
| 15021 return error::kNoError; |
| 15022 } |
| 15023 |
| 15024 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 15025 |
| 15026 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 15027 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 15028 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 15029 uint32 transforms_shm_offset = |
| 15030 static_cast<uint32>(c.transformValues_shm_offset); |
| 15031 |
| 15032 GLuint* paths = NULL; |
| 15033 const GLfloat* transforms = NULL; |
| 15034 error::Error prepare_error = error::kNoError; |
| 15035 scoped_ptr<GLuint[]> temp_path_buffer; |
| 15036 if (!PrepareInstancedPathCommand( |
| 15037 num_paths, path_name_type, paths_shm_id, paths_shm_offset, path_base, |
| 15038 transform_type, transforms_shm_id, transforms_shm_offset, |
| 15039 &prepare_error, &paths, &transforms, &temp_path_buffer)) { |
| 15040 return prepare_error; |
| 15041 } |
| 15042 |
| 15043 ApplyDirtyState(); |
| 15044 glCoverFillPathInstancedNV(num_paths, path_name_type, paths, 0, cover_mode, |
| 15045 transform_type, transforms); |
| 15046 |
| 15047 return error::kNoError; |
| 15048 } |
| 15049 |
| 15050 error::Error GLES2DecoderImpl::HandleCoverStrokePathInstancedCHROMIUM( |
| 15051 uint32 immediate_data_size, |
| 15052 const void* cmd_data) { |
| 15053 static const char kFunctionName[] = "glCoverStrokePathInstancedCHROMIUM"; |
| 15054 const gles2::cmds::CoverStrokePathInstancedCHROMIUM& c = |
| 15055 *static_cast<const gles2::cmds::CoverStrokePathInstancedCHROMIUM*>( |
| 15056 cmd_data); |
| 15057 if (!features().chromium_path_rendering) { |
| 15058 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 15059 "function not available"); |
| 15060 return error::kNoError; |
| 15061 } |
| 15062 |
| 15063 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 15064 if (num_paths < 0) { |
| 15065 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numPaths < 0"); |
| 15066 return error::kNoError; |
| 15067 } |
| 15068 |
| 15069 GLenum path_name_type = static_cast<GLsizei>(c.pathNameType); |
| 15070 if (!validators_->path_name_type.IsValid(path_name_type)) { |
| 15071 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, path_name_type, |
| 15072 "pathNameType"); |
| 15073 return error::kNoError; |
| 15074 } |
| 15075 |
| 15076 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 15077 if (!validators_->path_instanced_cover_mode.IsValid(cover_mode)) { |
| 15078 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 15079 return error::kNoError; |
| 15080 } |
| 15081 |
| 15082 GLenum transform_type = static_cast<GLenum>(c.transformType); |
| 15083 if (!validators_->path_transform_type.IsValid(transform_type)) { |
| 15084 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, transform_type, |
| 15085 "transformType"); |
| 15086 return error::kNoError; |
| 15087 } |
| 15088 |
| 15089 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 15090 |
| 15091 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 15092 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 15093 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 15094 uint32 transforms_shm_offset = |
| 15095 static_cast<uint32>(c.transformValues_shm_offset); |
| 15096 |
| 15097 GLuint* paths = NULL; |
| 15098 const GLfloat* transforms = NULL; |
| 15099 error::Error prepare_error = error::kNoError; |
| 15100 scoped_ptr<GLuint[]> temp_path_buffer; |
| 15101 if (!PrepareInstancedPathCommand( |
| 15102 num_paths, path_name_type, paths_shm_id, paths_shm_offset, path_base, |
| 15103 transform_type, transforms_shm_id, transforms_shm_offset, |
| 15104 &prepare_error, &paths, &transforms, &temp_path_buffer)) { |
| 15105 return prepare_error; |
| 15106 } |
| 15107 |
| 15108 ApplyDirtyState(); |
| 15109 glCoverStrokePathInstancedNV(num_paths, path_name_type, paths, 0, cover_mode, |
| 15110 transform_type, transforms); |
| 15111 |
| 15112 return error::kNoError; |
| 15113 } |
| 15114 |
| 15115 error::Error GLES2DecoderImpl::HandleStencilThenCoverFillPathInstancedCHROMIUM( |
| 15116 uint32 immediate_data_size, |
| 15117 const void* cmd_data) { |
| 15118 static const char kFunctionName[] = |
| 15119 "glStencilThenCoverFillPathInstancedCHROMIUM"; |
| 15120 const gles2::cmds::StencilThenCoverFillPathInstancedCHROMIUM& c = |
| 15121 *static_cast< |
| 15122 const gles2::cmds::StencilThenCoverFillPathInstancedCHROMIUM*>( |
| 15123 cmd_data); |
| 15124 if (!features().chromium_path_rendering) { |
| 15125 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 15126 "function not available"); |
| 15127 return error::kNoError; |
| 15128 } |
| 15129 |
| 15130 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 15131 if (num_paths < 0) { |
| 15132 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numPaths < 0"); |
| 15133 return error::kNoError; |
| 15134 } |
| 15135 |
| 15136 GLenum path_name_type = static_cast<GLsizei>(c.pathNameType); |
| 15137 if (!validators_->path_name_type.IsValid(path_name_type)) { |
| 15138 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, path_name_type, |
| 15139 "pathNameType"); |
| 15140 return error::kNoError; |
| 15141 } |
| 15142 |
| 15143 GLenum fill_mode = static_cast<GLenum>(c.fillMode); |
| 15144 if (!validators_->path_fill_mode.IsValid(fill_mode)) { |
| 15145 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, fill_mode, "fillMode"); |
| 15146 return error::kNoError; |
| 15147 } |
| 15148 |
| 15149 GLuint mask = static_cast<GLuint>(c.mask); |
| 15150 if (!IsValidPathCommandMask(fill_mode, mask)) { |
| 15151 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
| 15152 "mask is not power of two"); |
| 15153 return error::kNoError; |
| 15154 } |
| 15155 |
| 15156 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 15157 if (!validators_->path_instanced_cover_mode.IsValid(cover_mode)) { |
| 15158 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 15159 return error::kNoError; |
| 15160 } |
| 15161 |
| 15162 GLenum transform_type = static_cast<GLenum>(c.transformType); |
| 15163 if (!validators_->path_transform_type.IsValid(transform_type)) { |
| 15164 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, transform_type, |
| 15165 "transformType"); |
| 15166 return error::kNoError; |
| 15167 } |
| 15168 |
| 15169 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 15170 |
| 15171 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 15172 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 15173 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 15174 uint32 transforms_shm_offset = |
| 15175 static_cast<uint32>(c.transformValues_shm_offset); |
| 15176 |
| 15177 GLuint* paths = NULL; |
| 15178 const GLfloat* transforms = NULL; |
| 15179 error::Error prepare_error = error::kNoError; |
| 15180 scoped_ptr<GLuint[]> temp_path_buffer; |
| 15181 if (!PrepareInstancedPathCommand( |
| 15182 num_paths, path_name_type, paths_shm_id, paths_shm_offset, path_base, |
| 15183 transform_type, transforms_shm_id, transforms_shm_offset, |
| 15184 &prepare_error, &paths, &transforms, &temp_path_buffer)) { |
| 15185 return prepare_error; |
| 15186 } |
| 15187 |
| 15188 ApplyDirtyState(); |
| 15189 glStencilThenCoverFillPathInstancedNV(num_paths, path_name_type, paths, 0, |
| 15190 fill_mode, mask, cover_mode, |
| 15191 transform_type, transforms); |
| 15192 |
| 15193 return error::kNoError; |
| 15194 } |
| 15195 |
| 15196 error::Error |
| 15197 GLES2DecoderImpl::HandleStencilThenCoverStrokePathInstancedCHROMIUM( |
| 15198 uint32 immediate_data_size, |
| 15199 const void* cmd_data) { |
| 15200 static const char kFunctionName[] = |
| 15201 "glStencilThenCoverStrokeInstancedCHROMIUM"; |
| 15202 const gles2::cmds::StencilThenCoverStrokePathInstancedCHROMIUM& c = |
| 15203 *static_cast< |
| 15204 const gles2::cmds::StencilThenCoverStrokePathInstancedCHROMIUM*>( |
| 15205 cmd_data); |
| 15206 if (!features().chromium_path_rendering) { |
| 15207 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
| 15208 "function not available"); |
| 15209 return error::kNoError; |
| 15210 } |
| 15211 |
| 15212 GLsizei num_paths = static_cast<GLsizei>(c.numPaths); |
| 15213 if (num_paths < 0) { |
| 15214 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "numPaths < 0"); |
| 15215 return error::kNoError; |
| 15216 } |
| 15217 |
| 15218 GLenum path_name_type = static_cast<GLsizei>(c.pathNameType); |
| 15219 if (!validators_->path_name_type.IsValid(path_name_type)) { |
| 15220 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, path_name_type, |
| 15221 "pathNameType"); |
| 15222 return error::kNoError; |
| 15223 } |
| 15224 |
| 15225 GLenum cover_mode = static_cast<GLenum>(c.coverMode); |
| 15226 if (!validators_->path_instanced_cover_mode.IsValid(cover_mode)) { |
| 15227 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, cover_mode, "coverMode"); |
| 15228 return error::kNoError; |
| 15229 } |
| 15230 |
| 15231 GLenum transform_type = static_cast<GLenum>(c.transformType); |
| 15232 if (!validators_->path_transform_type.IsValid(transform_type)) { |
| 15233 LOCAL_SET_GL_ERROR_INVALID_ENUM(kFunctionName, transform_type, |
| 15234 "transformType"); |
| 15235 return error::kNoError; |
| 15236 } |
| 15237 |
| 15238 GLuint path_base = static_cast<GLuint>(c.pathBase); |
| 15239 GLuint reference = static_cast<GLuint>(c.reference); |
| 15240 GLuint mask = static_cast<GLuint>(c.mask); |
| 15241 |
| 15242 uint32 paths_shm_id = static_cast<uint32>(c.paths_shm_id); |
| 15243 uint32 paths_shm_offset = static_cast<uint32>(c.paths_shm_offset); |
| 15244 uint32 transforms_shm_id = static_cast<uint32>(c.transformValues_shm_id); |
| 15245 uint32 transforms_shm_offset = |
| 15246 static_cast<uint32>(c.transformValues_shm_offset); |
| 15247 |
| 15248 GLuint* paths = NULL; |
| 15249 const GLfloat* transforms = NULL; |
| 15250 error::Error prepare_error = error::kNoError; |
| 15251 scoped_ptr<GLuint[]> temp_path_buffer; |
| 15252 if (!PrepareInstancedPathCommand( |
| 15253 num_paths, path_name_type, paths_shm_id, paths_shm_offset, path_base, |
| 15254 transform_type, transforms_shm_id, transforms_shm_offset, |
| 15255 &prepare_error, &paths, &transforms, &temp_path_buffer)) { |
| 15256 return prepare_error; |
| 15257 } |
| 15258 |
| 15259 ApplyDirtyState(); |
| 15260 glStencilThenCoverStrokePathInstancedNV(num_paths, path_name_type, paths, 0, |
| 15261 reference, mask, cover_mode, |
| 15262 transform_type, transforms); |
| 15263 |
| 15264 return error::kNoError; |
| 15265 } |
| 15266 |
14670 // Include the auto-generated part of this file. We split this because it means | 15267 // Include the auto-generated part of this file. We split this because it means |
14671 // we can easily edit the non-auto generated parts right here in this file | 15268 // we can easily edit the non-auto generated parts right here in this file |
14672 // instead of having to edit some template or the code generator. | 15269 // instead of having to edit some template or the code generator. |
14673 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15270 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
14674 | 15271 |
14675 } // namespace gles2 | 15272 } // namespace gles2 |
14676 } // namespace gpu | 15273 } // namespace gpu |
OLD | NEW |