OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 return BufferSyncInterface::PARSE_NO_ERROR; | 465 return BufferSyncInterface::PARSE_NO_ERROR; |
466 } else { | 466 } else { |
467 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 467 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
468 } | 468 } |
469 case SET_POINT_LINE_RASTER: | 469 case SET_POINT_LINE_RASTER: |
470 if (arg_count == 2) { | 470 if (arg_count == 2) { |
471 namespace cmd = set_point_line_raster; | 471 namespace cmd = set_point_line_raster; |
472 Uint32 enables = args[0].value_uint32; | 472 Uint32 enables = args[0].value_uint32; |
473 if (cmd::Unused::Get(enables) != 0) | 473 if (cmd::Unused::Get(enables) != 0) |
474 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 474 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
475 bool line_smooth = cmd::LineSmoothEnable::Get(enables); | 475 bool line_smooth = !!cmd::LineSmoothEnable::Get(enables); |
476 bool point_sprite = cmd::PointSpriteEnable::Get(enables); | 476 bool point_sprite = !!cmd::PointSpriteEnable::Get(enables); |
477 float point_size = args[1].value_float; | 477 float point_size = args[1].value_float; |
478 gapi_->SetPointLineRaster(line_smooth, point_sprite, point_size); | 478 gapi_->SetPointLineRaster(line_smooth, point_sprite, point_size); |
479 return BufferSyncInterface::PARSE_NO_ERROR; | 479 return BufferSyncInterface::PARSE_NO_ERROR; |
480 } else { | 480 } else { |
481 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 481 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
482 } | 482 } |
483 case SET_POLYGON_RASTER: | 483 case SET_POLYGON_RASTER: |
484 if (arg_count == 1) { | 484 if (arg_count == 1) { |
485 namespace cmd = set_polygon_raster; | 485 namespace cmd = set_polygon_raster; |
486 Uint32 fill_cull = args[0].value_uint32; | 486 Uint32 fill_cull = args[0].value_uint32; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 unsigned int levels = cmd::Levels::Get(levels_format_flags); | 666 unsigned int levels = cmd::Levels::Get(levels_format_flags); |
667 unsigned int unused = cmd::Unused::Get(levels_format_flags); | 667 unsigned int unused = cmd::Unused::Get(levels_format_flags); |
668 unsigned int format = cmd::Format::Get(levels_format_flags); | 668 unsigned int format = cmd::Format::Get(levels_format_flags); |
669 unsigned int flags = cmd::Flags::Get(levels_format_flags); | 669 unsigned int flags = cmd::Flags::Get(levels_format_flags); |
670 unsigned int max_levels = | 670 unsigned int max_levels = |
671 1 + base::bits::Log2Ceiling(std::max(width, height)); | 671 1 + base::bits::Log2Ceiling(std::max(width, height)); |
672 if ((width == 0) || (height == 0) || (levels > max_levels) || | 672 if ((width == 0) || (height == 0) || (levels > max_levels) || |
673 (unused != 0) || (format >= texture::NUM_FORMATS)) | 673 (unused != 0) || (format >= texture::NUM_FORMATS)) |
674 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 674 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
675 if (levels == 0) levels = max_levels; | 675 if (levels == 0) levels = max_levels; |
676 bool enable_render_surfaces = flags; | 676 bool enable_render_surfaces = !!flags; |
677 return gapi_->CreateTexture2D(id, width, height, levels, | 677 return gapi_->CreateTexture2D(id, width, height, levels, |
678 static_cast<texture::Format>(format), flags, | 678 static_cast<texture::Format>(format), flags, |
679 enable_render_surfaces); | 679 enable_render_surfaces); |
680 } else { | 680 } else { |
681 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 681 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
682 } | 682 } |
683 } | 683 } |
684 | 684 |
685 // Decodes the CREATE_TEXTURE_3D command. | 685 // Decodes the CREATE_TEXTURE_3D command. |
686 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture3D( | 686 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTexture3D( |
(...skipping 13 matching lines...) Expand all Loading... |
700 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); | 700 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); |
701 unsigned int format = cmd::Format::Get(levels_format_flags); | 701 unsigned int format = cmd::Format::Get(levels_format_flags); |
702 unsigned int flags = cmd::Flags::Get(levels_format_flags); | 702 unsigned int flags = cmd::Flags::Get(levels_format_flags); |
703 unsigned int max_levels = | 703 unsigned int max_levels = |
704 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); | 704 1 + base::bits::Log2Ceiling(std::max(depth, std::max(width, height))); |
705 if ((width == 0) || (height == 0) || (depth == 0) || | 705 if ((width == 0) || (height == 0) || (depth == 0) || |
706 (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || | 706 (levels > max_levels) || (unused1 != 0) || (unused2 != 0) || |
707 (format >= texture::NUM_FORMATS)) | 707 (format >= texture::NUM_FORMATS)) |
708 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 708 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
709 if (levels == 0) levels = max_levels; | 709 if (levels == 0) levels = max_levels; |
710 bool enable_render_surfaces = flags; | 710 bool enable_render_surfaces = !!flags; |
711 return gapi_->CreateTexture3D(id, width, height, depth, levels, | 711 return gapi_->CreateTexture3D(id, width, height, depth, levels, |
712 static_cast<texture::Format>(format), flags, | 712 static_cast<texture::Format>(format), flags, |
713 enable_render_surfaces); | 713 enable_render_surfaces); |
714 } else { | 714 } else { |
715 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 715 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 // Decodes the CREATE_TEXTURE_CUBE command. | 719 // Decodes the CREATE_TEXTURE_CUBE command. |
720 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTextureCube( | 720 BufferSyncInterface::ParseError GAPIDecoder::DecodeCreateTextureCube( |
721 unsigned int arg_count, | 721 unsigned int arg_count, |
722 CommandBufferEntry *args) { | 722 CommandBufferEntry *args) { |
723 if (arg_count == 3) { | 723 if (arg_count == 3) { |
724 namespace cmd = create_texture_cube_cmd; | 724 namespace cmd = create_texture_cube_cmd; |
725 unsigned int id = args[0].value_uint32; | 725 unsigned int id = args[0].value_uint32; |
726 unsigned int side_unused = args[1].value_uint32; | 726 unsigned int side_unused = args[1].value_uint32; |
727 unsigned int levels_format_flags = args[2].value_uint32; | 727 unsigned int levels_format_flags = args[2].value_uint32; |
728 unsigned int side = cmd::Side::Get(side_unused); | 728 unsigned int side = cmd::Side::Get(side_unused); |
729 unsigned int unused1 = cmd::Unused1::Get(side_unused); | 729 unsigned int unused1 = cmd::Unused1::Get(side_unused); |
730 unsigned int levels = cmd::Levels::Get(levels_format_flags); | 730 unsigned int levels = cmd::Levels::Get(levels_format_flags); |
731 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); | 731 unsigned int unused2 = cmd::Unused2::Get(levels_format_flags); |
732 unsigned int format = cmd::Format::Get(levels_format_flags); | 732 unsigned int format = cmd::Format::Get(levels_format_flags); |
733 unsigned int flags = cmd::Flags::Get(levels_format_flags); | 733 unsigned int flags = cmd::Flags::Get(levels_format_flags); |
734 unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); | 734 unsigned int max_levels = 1 + base::bits::Log2Ceiling(side); |
735 if ((side == 0) || (levels > max_levels) || (unused1 != 0) || | 735 if ((side == 0) || (levels > max_levels) || (unused1 != 0) || |
736 (unused2 != 0) || (format >= texture::NUM_FORMATS)) | 736 (unused2 != 0) || (format >= texture::NUM_FORMATS)) |
737 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 737 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
738 if (levels == 0) levels = max_levels; | 738 if (levels == 0) levels = max_levels; |
739 bool enable_render_surfaces = flags; | 739 bool enable_render_surfaces = !!flags; |
740 return gapi_->CreateTextureCube(id, side, levels, | 740 return gapi_->CreateTextureCube(id, side, levels, |
741 static_cast<texture::Format>(format), | 741 static_cast<texture::Format>(format), |
742 flags, enable_render_surfaces); | 742 flags, enable_render_surfaces); |
743 } else { | 743 } else { |
744 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; | 744 return BufferSyncInterface::PARSE_INVALID_ARGUMENTS; |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 // Decodes the SET_TEXTURE_DATA command. | 748 // Decodes the SET_TEXTURE_DATA command. |
749 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetTextureData( | 749 BufferSyncInterface::ParseError GAPIDecoder::DecodeSetTextureData( |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 unsigned int size) { | 958 unsigned int size) { |
959 void * shm_addr = engine_->GetSharedMemoryAddress(shm_id); | 959 void * shm_addr = engine_->GetSharedMemoryAddress(shm_id); |
960 if (!shm_addr) return NULL; | 960 if (!shm_addr) return NULL; |
961 size_t shm_size = engine_->GetSharedMemorySize(shm_id); | 961 size_t shm_size = engine_->GetSharedMemorySize(shm_id); |
962 if (offset + size > shm_size) return NULL; | 962 if (offset + size > shm_size) return NULL; |
963 return static_cast<char *>(shm_addr) + offset; | 963 return static_cast<char *>(shm_addr) + offset; |
964 } | 964 } |
965 | 965 |
966 } // namespace command_buffer | 966 } // namespace command_buffer |
967 } // namespace o3d | 967 } // namespace o3d |
OLD | NEW |