Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

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

Powered by Google App Engine
This is Rietveld 408576698