├── .gitmodules ├── .travis.yml ├── ASTCEncoder ├── CMakeLists.txt ├── include │ └── FasTC │ │ └── ASTCCompressor.h ├── src │ ├── Decompressor.cpp │ ├── IntegerEncoding.cpp │ ├── IntegerEncoding.h │ └── Utils.h └── test │ ├── CMakeLists.txt │ ├── TestASTCDecompression.cpp │ ├── TestIntegerEncoding.cpp │ └── data │ ├── mandrill_10x8.astc │ ├── mandrill_12x12.astc │ ├── mandrill_4x4.astc │ ├── mandrill_6x5.astc │ ├── mandrill_8x8.astc │ ├── mandrill_decompressed_10x8.png │ ├── mandrill_decompressed_12x12.png │ ├── mandrill_decompressed_4x4.png │ ├── mandrill_decompressed_6x5.png │ └── mandrill_decompressed_8x8.png ├── BPTCEncoder ├── CMakeLists.txt ├── config │ └── BPTCConfig.h.in ├── include │ └── FasTC │ │ ├── BPTCCompressor.h │ │ └── Shapes.h └── src │ ├── AnchorTables.h │ ├── BCLookupTables.h │ ├── CompressNVTT.cpp │ ├── CompressionMode.h │ ├── CompressionModeSIMD.h │ ├── Compressor.cpp │ ├── CompressorSIMD.cpp │ ├── Decompressor.cpp │ ├── ParallelStage.cpp │ ├── ParallelStage.h │ ├── RGBAEndpoints.cpp │ ├── RGBAEndpoints.h │ ├── RGBAEndpointsSIMD.cpp │ └── RGBAEndpointsSIMD.h ├── Base ├── CMakeLists.txt ├── config │ └── BaseConfig.h.in ├── include │ └── FasTC │ │ ├── BitStream.h │ │ ├── Bits.h │ │ ├── Color.h │ │ ├── CompressionFormat.h │ │ ├── CompressionJob.h │ │ ├── IPixel.h │ │ ├── Image.h │ │ ├── ImageFwd.h │ │ ├── Matrix2x2.h │ │ ├── Matrix3x3.h │ │ ├── Matrix4x4.h │ │ ├── MatrixBase.h │ │ ├── MatrixSquare.h │ │ ├── Pixel.h │ │ ├── ScopedAllocator.h │ │ ├── TexCompTypes.h │ │ ├── Vector2.h │ │ ├── Vector3.h │ │ ├── Vector4.h │ │ └── VectorBase.h ├── src │ ├── Color.cpp │ ├── CompressionJob.cpp │ ├── IPixel.cpp │ ├── Image.cpp │ └── Pixel.cpp └── test │ ├── CMakeLists.txt │ ├── TestARGBPixel.cpp │ ├── TestBits.cpp │ ├── TestColor.cpp │ ├── TestImage.cpp │ ├── TestMatrix.cpp │ ├── TestPixel.cpp │ ├── TestVector.cpp │ └── Utils.h ├── CLTool ├── CMakeLists.txt └── src │ ├── compare.cpp │ ├── decomp.cpp │ └── tc.cpp ├── CMakeLists.txt ├── CMakeModules ├── FasTCConfig.cmake.in ├── FasTCVersion.cmake.in ├── FindBC7Export.cmake ├── FindPVRTexLib.cmake └── bc7_export │ └── CMakeLists.txt ├── Core ├── CMakeLists.txt ├── include │ └── FasTC │ │ ├── CompressedImage.h │ │ ├── ReferenceCounter.h │ │ ├── StopWatch.h │ │ ├── TexComp.h │ │ └── ThreadSafeStreambuf.h └── src │ ├── CompressedImage.cpp │ ├── CompressionFuncs.h │ ├── StopWatchOSX.cpp │ ├── StopWatchUnix.cpp │ ├── StopWatchWin32.cpp │ ├── TexComp.cpp │ ├── Thread.cpp │ ├── Thread.h │ ├── ThreadGroup.cpp │ ├── ThreadGroup.h │ ├── ThreadPThread.cpp │ ├── ThreadSafeStreambuf.cpp │ ├── ThreadWin32.cpp │ ├── WorkerQueue.cpp │ └── WorkerQueue.h ├── DXTEncoder ├── CMakeLists.txt ├── include │ └── FasTC │ │ └── DXTCompressor.h └── src │ ├── Compressor.cpp │ ├── Decompressor.cpp │ └── stb_dxt.h ├── ETCEncoder ├── CMakeLists.txt ├── include │ └── FasTC │ │ └── ETCCompressor.h └── src │ ├── Compressor.cpp │ ├── Decompressor.cpp │ ├── rg_etc1.cpp │ └── rg_etc1.h ├── GTest ├── CHANGES ├── CMakeLists.txt ├── CONTRIBUTORS ├── LICENSE ├── Makefile.am ├── README ├── build-aux │ └── .keep ├── cmake │ └── internal_utils.cmake ├── codegear │ ├── gtest.cbproj │ ├── gtest.groupproj │ ├── gtest_all.cc │ ├── gtest_link.cc │ ├── gtest_main.cbproj │ └── gtest_unittest.cbproj ├── configure.ac ├── include │ └── gtest │ │ ├── gtest-death-test.h │ │ ├── gtest-message.h │ │ ├── gtest-param-test.h │ │ ├── gtest-param-test.h.pump │ │ ├── gtest-printers.h │ │ ├── gtest-spi.h │ │ ├── gtest-test-part.h │ │ ├── gtest-typed-test.h │ │ ├── gtest.h │ │ ├── gtest_pred_impl.h │ │ ├── gtest_prod.h │ │ └── internal │ │ ├── gtest-death-test-internal.h │ │ ├── gtest-filepath.h │ │ ├── gtest-internal.h │ │ ├── gtest-linked_ptr.h │ │ ├── gtest-param-util-generated.h │ │ ├── gtest-param-util-generated.h.pump │ │ ├── gtest-param-util.h │ │ ├── gtest-port.h │ │ ├── gtest-string.h │ │ ├── gtest-tuple.h │ │ ├── gtest-tuple.h.pump │ │ ├── gtest-type-util.h │ │ └── gtest-type-util.h.pump ├── m4 │ ├── acx_pthread.m4 │ └── gtest.m4 ├── make │ └── Makefile ├── msvc │ ├── gtest-md.sln │ ├── gtest-md.vcproj │ ├── gtest.sln │ ├── gtest.vcproj │ ├── gtest_main-md.vcproj │ ├── gtest_main.vcproj │ ├── gtest_prod_test-md.vcproj │ ├── gtest_prod_test.vcproj │ ├── gtest_unittest-md.vcproj │ └── gtest_unittest.vcproj ├── samples │ ├── prime_tables.h │ ├── sample1.cc │ ├── sample1.h │ ├── sample10_unittest.cc │ ├── sample1_unittest.cc │ ├── sample2.cc │ ├── sample2.h │ ├── sample2_unittest.cc │ ├── sample3-inl.h │ ├── sample3_unittest.cc │ ├── sample4.cc │ ├── sample4.h │ ├── sample4_unittest.cc │ ├── sample5_unittest.cc │ ├── sample6_unittest.cc │ ├── sample7_unittest.cc │ ├── sample8_unittest.cc │ └── sample9_unittest.cc ├── scripts │ ├── fuse_gtest_files.py │ ├── gen_gtest_pred_impl.py │ ├── gtest-config.in │ ├── pump.py │ ├── test │ │ └── Makefile │ ├── upload.py │ └── upload_gtest.py ├── src │ ├── gtest-all.cc │ ├── gtest-death-test.cc │ ├── gtest-filepath.cc │ ├── gtest-internal-inl.h │ ├── gtest-port.cc │ ├── gtest-printers.cc │ ├── gtest-test-part.cc │ ├── gtest-typed-test.cc │ ├── gtest.cc │ └── gtest_main.cc ├── test │ ├── gtest-death-test_ex_test.cc │ ├── gtest-death-test_test.cc │ ├── gtest-filepath_test.cc │ ├── gtest-linked_ptr_test.cc │ ├── gtest-listener_test.cc │ ├── gtest-message_test.cc │ ├── gtest-options_test.cc │ ├── gtest-param-test2_test.cc │ ├── gtest-param-test_test.cc │ ├── gtest-param-test_test.h │ ├── gtest-port_test.cc │ ├── gtest-printers_test.cc │ ├── gtest-test-part_test.cc │ ├── gtest-tuple_test.cc │ ├── gtest-typed-test2_test.cc │ ├── gtest-typed-test_test.cc │ ├── gtest-typed-test_test.h │ ├── gtest-unittest-api_test.cc │ ├── gtest_all_test.cc │ ├── gtest_break_on_failure_unittest.py │ ├── gtest_break_on_failure_unittest_.cc │ ├── gtest_catch_exceptions_test.py │ ├── gtest_catch_exceptions_test_.cc │ ├── gtest_color_test.py │ ├── gtest_color_test_.cc │ ├── gtest_env_var_test.py │ ├── gtest_env_var_test_.cc │ ├── gtest_environment_test.cc │ ├── gtest_filter_unittest.py │ ├── gtest_filter_unittest_.cc │ ├── gtest_help_test.py │ ├── gtest_help_test_.cc │ ├── gtest_list_tests_unittest.py │ ├── gtest_list_tests_unittest_.cc │ ├── gtest_main_unittest.cc │ ├── gtest_no_test_unittest.cc │ ├── gtest_output_test.py │ ├── gtest_output_test_.cc │ ├── gtest_output_test_golden_lin.txt │ ├── gtest_pred_impl_unittest.cc │ ├── gtest_prod_test.cc │ ├── gtest_repeat_test.cc │ ├── gtest_shuffle_test.py │ ├── gtest_shuffle_test_.cc │ ├── gtest_sole_header_test.cc │ ├── gtest_stress_test.cc │ ├── gtest_test_utils.py │ ├── gtest_test_utils.pyc │ ├── gtest_throw_on_failure_ex_test.cc │ ├── gtest_throw_on_failure_test.py │ ├── gtest_throw_on_failure_test_.cc │ ├── gtest_uninitialized_test.py │ ├── gtest_uninitialized_test_.cc │ ├── gtest_unittest.cc │ ├── gtest_xml_outfile1_test_.cc │ ├── gtest_xml_outfile2_test_.cc │ ├── gtest_xml_outfiles_test.py │ ├── gtest_xml_output_unittest.py │ ├── gtest_xml_output_unittest_.cc │ ├── gtest_xml_test_utils.py │ ├── gtest_xml_test_utils.pyc │ ├── production.cc │ └── production.h └── xcode │ ├── Config │ ├── DebugProject.xcconfig │ ├── FrameworkTarget.xcconfig │ ├── General.xcconfig │ ├── ReleaseProject.xcconfig │ ├── StaticLibraryTarget.xcconfig │ └── TestTarget.xcconfig │ ├── Resources │ └── Info.plist │ ├── Samples │ └── FrameworkSample │ │ ├── Info.plist │ │ ├── WidgetFramework.xcodeproj │ │ └── project.pbxproj │ │ ├── runtests.sh │ │ ├── widget.cc │ │ ├── widget.h │ │ └── widget_test.cc │ ├── Scripts │ ├── runtests.sh │ └── versiongenerate.py │ └── gtest.xcodeproj │ └── project.pbxproj ├── IO ├── CMakeLists.txt ├── config │ ├── ImageLoader.h.in │ └── ImageWriter.h.in ├── include │ └── FasTC │ │ ├── FileStream.h │ │ ├── ImageFile.h │ │ └── ImageFileFormat.h ├── src │ ├── FileStreamUnix.cpp │ ├── FileStreamWin32.cpp │ ├── GLDefines.h │ ├── ImageFile.cpp │ ├── ImageLoader.cpp │ ├── ImageLoaderASTC.cpp │ ├── ImageLoaderASTC.h │ ├── ImageLoaderKTX.cpp │ ├── ImageLoaderKTX.h │ ├── ImageLoaderPNG.cpp │ ├── ImageLoaderPNG.h │ ├── ImageLoaderPVR.cpp │ ├── ImageLoaderPVR.h │ ├── ImageLoaderTGA.cpp │ ├── ImageLoaderTGA.h │ ├── ImageWriter.cpp │ ├── ImageWriterKTX.cpp │ ├── ImageWriterKTX.h │ ├── ImageWriterPNG.cpp │ └── ImageWriterPNG.h └── third_party │ └── tga │ ├── targa.c │ └── targa.h ├── LICENSE ├── PVRTCEncoder ├── CMakeLists.txt ├── config │ └── PVRTCDefines.h.in ├── include │ └── FasTC │ │ └── PVRTCCompressor.h ├── src │ ├── Block.cpp │ ├── Block.h │ ├── Compressor.cpp │ ├── CompressorPVRLib.cpp │ ├── Decompressor.cpp │ ├── Indexer.h │ ├── PVRTCImage.cpp │ └── PVRTCImage.h └── test │ ├── BlockTest.cpp │ ├── CMakeLists.txt │ ├── DecompTestPVR.cpp │ ├── DecompressorTest.cpp │ ├── ImageTest.cpp │ ├── TestUtils.h │ └── data │ ├── 2bpp-gradient.pvr │ ├── 2bpp-gray.pvr │ ├── 2bpp-trans-gradient.pvr │ ├── 2bpp-transparent.pvr │ ├── 2bpp-white.pvr │ ├── 4bpp-gradient.pvr │ ├── 4bpp-gray.pvr │ ├── 4bpp-trans-gradient.pvr │ ├── 4bpp-transparent.pvr │ └── 4bpp-white.pvr └── README.md /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Windows"] 2 | path = Windows 3 | url = https://github.com/Mokosha/FasTC-MSVCLibs.git 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | git: 3 | submodules: false 4 | 5 | compiler: 6 | - gcc 7 | - clang 8 | 9 | addons: 10 | apt: 11 | sources: 12 | - george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3 13 | packages: 14 | - cmake 15 | - cmake-data 16 | 17 | before_script: 18 | - mkdir build 19 | - cd build 20 | - cmake .. -DCMAKE_BUILD_TYPE=Release 21 | 22 | script: make && make test 23 | 24 | after_failure: if [ -d Testing ]; then cat Testing/Temporary/LastTest.log; fi -------------------------------------------------------------------------------- /ASTCEncoder/include/FasTC/ASTCCompressor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef ASTCENCODER_INCLUDE_ASTCCOMPRESSOR_H_ 19 | #define ASTCENCODER_INCLUDE_ASTCCOMPRESSOR_H_ 20 | 21 | #include "FasTC/CompressionJob.h" 22 | 23 | namespace ASTCC { 24 | 25 | // Takes a stream of compressed ASTC data and decompresses it into R8G8B8A8 26 | // format. The block size must be specified in order to properly 27 | // decompress the data, but it is included in the format descriptor passed 28 | // by FasTC::DecompressionJob 29 | void Decompress(const FasTC::DecompressionJob &); 30 | 31 | } // namespace ASTCC 32 | 33 | #endif // ASTCENCODER_INCLUDE_ASTCCOMPRESSOR_H_ 34 | -------------------------------------------------------------------------------- /ASTCEncoder/test/TestASTCDecompression.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "gtest/gtest.h" 19 | 20 | // This is our library header 21 | #include "FasTC/ASTCCompressor.h" 22 | 23 | #include "FasTC/ImageFile.h" 24 | #include "FasTC/Image.h" 25 | 26 | #include 27 | 28 | class ImageTester { 29 | private: 30 | static std::string GenerateTestFilename(const std::string &basename, 31 | const std::string &suffix, 32 | const std::string &ext) { 33 | return basename + suffix + std::string(".") + ext; 34 | } 35 | 36 | public: 37 | explicit ImageTester(const char *suffix) { 38 | std::string astcFilename = 39 | GenerateTestFilename("mandrill_", std::string(suffix), "astc"); 40 | std::string pngFilename = 41 | GenerateTestFilename("mandrill_decompressed_", std::string(suffix), "png"); 42 | 43 | ImageFile astc (astcFilename.c_str()); 44 | bool success = astc.Load(); 45 | EXPECT_TRUE(success); 46 | if (!success) { 47 | return; 48 | } 49 | 50 | ImageFile png (pngFilename.c_str()); 51 | success = png.Load(); 52 | EXPECT_TRUE(success); 53 | if (!success) { 54 | return; 55 | } 56 | 57 | double PSNR = astc.GetImage()->ComputePSNR(png.GetImage()); 58 | EXPECT_GT(PSNR, 60.0); 59 | } 60 | }; 61 | 62 | TEST(Decompressor, Decompress4x4) { 63 | ImageTester("4x4"); 64 | } 65 | 66 | TEST(Decompressor, Decompress12x12) { 67 | ImageTester("12x12"); 68 | } 69 | 70 | TEST(Decompressor, Decompress8x8) { 71 | ImageTester("8x8"); 72 | } 73 | 74 | TEST(Decompressor, Decompress6x5) { 75 | ImageTester("6x5"); 76 | } 77 | 78 | TEST(Decompressor, Decompress10x8) { 79 | ImageTester("10x8"); 80 | } 81 | -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_10x8.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_10x8.astc -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_12x12.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_12x12.astc -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_4x4.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_4x4.astc -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_6x5.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_6x5.astc -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_8x8.astc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_8x8.astc -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_decompressed_10x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_decompressed_10x8.png -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_decompressed_12x12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_decompressed_12x12.png -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_decompressed_4x4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_decompressed_4x4.png -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_decompressed_6x5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_decompressed_6x5.png -------------------------------------------------------------------------------- /ASTCEncoder/test/data/mandrill_decompressed_8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/ASTCEncoder/test/data/mandrill_decompressed_8x8.png -------------------------------------------------------------------------------- /BPTCEncoder/config/BPTCConfig.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | // BPTCConfig.h.in -- This file contains variables that are introduced 19 | // explicitly by the CMake build process. 20 | 21 | // Do we have the proper popcnt instruction defined? 22 | #cmakedefine NO_INLINE_ASSEMBLY 23 | #cmakedefine HAS_SSE_POPCNT 24 | #cmakedefine HAS_SSE_41 25 | 26 | #cmakedefine HAS_ATOMICS 27 | #cmakedefine HAS_GCC_ATOMICS 28 | #cmakedefine HAS_MSVC_ATOMICS 29 | 30 | #cmakedefine FOUND_NVTT_BPTC_EXPORT 31 | -------------------------------------------------------------------------------- /BPTCEncoder/src/AnchorTables.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/Shapes.h" 19 | 20 | #include 21 | 22 | static const int kAnchorIdx2[BPTCC::kNumShapes2] = { 23 | 15, 15, 15, 15, 15, 15, 15, 15, 24 | 15, 15, 15, 15, 15, 15, 15, 15, 25 | 15, 2, 8, 2, 2, 8, 8, 15, 26 | 2 , 8, 2, 2, 8, 8, 2, 2, 27 | 15, 15, 6, 8, 2, 8, 15, 15, 28 | 2 , 8, 2, 2, 2, 15, 15, 6, 29 | 6 , 2, 6, 8, 15, 15, 2, 2, 30 | 15, 15, 15, 15, 15, 2, 2, 15 31 | }; 32 | 33 | static const int kAnchorIdx3[2][BPTCC::kNumShapes3] = { 34 | {3, 3, 15, 15, 8, 3, 15, 15, 35 | 8 , 8, 6, 6, 6, 5, 3, 3, 36 | 3 , 3, 8, 15, 3, 3, 6, 10, 37 | 5 , 8, 8, 6, 8, 5, 15, 15, 38 | 8 , 15, 3, 5, 6, 10, 8, 15, 39 | 15, 3, 15, 5, 15, 15, 15, 15, 40 | 3 , 15, 5, 5, 5, 8, 5, 10, 41 | 5 , 10, 8, 13, 15, 12, 3, 3 }, 42 | 43 | {15, 8, 8, 3, 15, 15, 3, 8, 44 | 15 , 15, 15, 15, 15, 15, 15, 8, 45 | 15 , 8, 15, 3, 15, 8, 15, 8, 46 | 3 , 15, 6, 10, 15, 15, 10, 8, 47 | 15 , 3, 15, 10, 10, 8, 9, 10, 48 | 6 , 15, 8, 15, 3, 6, 6, 8, 49 | 15 , 3, 15, 15, 15, 15, 15, 15, 50 | 15 , 15, 15, 15, 3, 15, 15, 8 } 51 | }; 52 | 53 | namespace BPTCC { 54 | 55 | static uint32 GetAnchorIndexForSubset( 56 | int subset, const int shapeIdx, const int nSubsets 57 | ) { 58 | 59 | int anchorIdx = 0; 60 | switch(subset) { 61 | case 1: 62 | { 63 | if(nSubsets == 2) { 64 | anchorIdx = kAnchorIdx2[shapeIdx]; 65 | } else { 66 | anchorIdx = kAnchorIdx3[0][shapeIdx]; 67 | } 68 | } 69 | break; 70 | 71 | case 2: 72 | { 73 | assert(nSubsets == 3); 74 | anchorIdx = kAnchorIdx3[1][shapeIdx]; 75 | } 76 | break; 77 | 78 | default: 79 | break; 80 | } 81 | 82 | return anchorIdx; 83 | } 84 | 85 | } // namespace BPTCC 86 | -------------------------------------------------------------------------------- /BPTCEncoder/src/ParallelStage.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/TexCompTypes.h" 19 | 20 | enum BPTCParallelStage { 21 | eParallelStage_Uniform, 22 | eParallelStage_Partitioned, 23 | eParallelStage_Normal, 24 | 25 | kNumParallelStages 26 | }; 27 | 28 | class ParallelStage { 29 | public: 30 | ParallelStage( 31 | BPTCParallelStage stage, 32 | const unsigned char *inbuf, 33 | unsigned char *outbuf, 34 | uint32 numBlocks, 35 | uint32 outBlockSz = 16, 36 | uint32 inBlockSz = 64 37 | ); 38 | ParallelStage(const ParallelStage &); 39 | ParallelStage &operator=(const ParallelStage &); 40 | 41 | ~ParallelStage(); 42 | 43 | const BPTCParallelStage m_Stage; 44 | 45 | // Adds the block number to the list of blocks for this parallel stage 46 | void AddBlock(uint32 blockNum); 47 | 48 | // Loads the desired number of blocks into the destination buffer. Returns 49 | // the number of blocks loaded. 50 | uint32 LoadBlocks(uint32 blockOffset, uint32 numBlocks, unsigned char *dst); 51 | 52 | // Writes the block data from src into numBlocks blocks starting from 53 | // the block given by blockOffset. 54 | bool WriteBlocks(uint32 blockOffset, uint32 numBlocks, const unsigned char *src); 55 | 56 | private: 57 | 58 | // This is the stream of data that will be used to read the block data. 59 | const unsigned char *const m_InBuf; 60 | 61 | // This is the destination buffer to which the block data will be written to. 62 | unsigned char *const m_OutBuf; 63 | 64 | // This is the array of block offsets that belong to this stage. 65 | uint32 *m_Blocks; 66 | 67 | // This is the total number of blocks in the given image. 68 | const uint32 m_TotalNumBlocks; 69 | 70 | // This is the total number of blocks in this particular stage. 71 | uint32 m_NumBlocks; 72 | 73 | const uint32 m_OutBlockSz; 74 | const uint32 m_InBlockSz; 75 | }; 76 | -------------------------------------------------------------------------------- /Base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | INCLUDE(CheckCXXSourceCompiles) 19 | CHECK_CXX_SOURCE_COMPILES(" 20 | #include 21 | int main() { 22 | int8_t x8 = 0; 23 | int16_t x16 = 1; 24 | int32_t x32 = 2; 25 | int64_t x64 = 3; 26 | uint8_t ux8 = 0; 27 | uint16_t ux16 = 1; 28 | uint32_t ux32 = 2; 29 | uint64_t ux64 = 3; 30 | return (x8 | ux8 | x16 | ux16 | x32 | ux32 | x64 | ux64); 31 | }" 32 | FASTC_BASE_HAS_CPP11_TYPES 33 | ) 34 | 35 | CONFIGURE_FILE( 36 | "config/BaseConfig.h.in" 37 | "include/FasTC/BaseConfig.h" 38 | ) 39 | 40 | SET( SOURCES 41 | "src/Image.cpp" 42 | "src/CompressionJob.cpp" 43 | "src/Pixel.cpp" 44 | "src/IPixel.cpp" 45 | "src/Color.cpp" 46 | ) 47 | 48 | SET( LIBRARY_HEADERS 49 | "include/FasTC/Image.h" 50 | "include/FasTC/ImageFwd.h" 51 | "include/FasTC/Pixel.h" 52 | "include/FasTC/TexCompTypes.h" 53 | "include/FasTC/CompressionFormat.h" 54 | "include/FasTC/CompressionJob.h" 55 | "include/FasTC/IPixel.h" 56 | "include/FasTC/Color.h" 57 | "include/FasTC/Bits.h" 58 | "include/FasTC/BitStream.h" 59 | "include/FasTC/MatrixBase.h" 60 | "include/FasTC/MatrixSquare.h" 61 | "include/FasTC/Matrix3x3.h" 62 | "include/FasTC/Matrix4x4.h" 63 | "include/FasTC/ScopedAllocator.h" 64 | "include/FasTC/VectorBase.h" 65 | "include/FasTC/Vector2.h" 66 | "include/FasTC/Vector3.h" 67 | "include/FasTC/Vector4.h") 68 | 69 | SET( HEADERS 70 | ${LIBRARY_HEADERS} 71 | "${FasTC_BINARY_DIR}/Base/include/FasTC/BaseConfig.h" 72 | "config/BaseConfig.h.in" 73 | ) 74 | 75 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/Base/include) 76 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/Base/include) 77 | 78 | ADD_LIBRARY( FasTCBase 79 | ${HEADERS} 80 | ${SOURCES} 81 | ) 82 | 83 | INSTALL( 84 | TARGETS FasTCBase 85 | EXPORT FasTCTargets 86 | ARCHIVE DESTINATION lib COMPONENT lib) 87 | 88 | INSTALL( 89 | FILES ${LIBRARY_HEADERS} "${FasTC_BINARY_DIR}/Base/include/FasTC/BaseConfig.h" 90 | DESTINATION ${INCLUDE_INSTALL_DIR}/FasTC COMPONENT dev) 91 | 92 | IF( NOT WIN32 AND NOT APPLE ) 93 | TARGET_LINK_LIBRARIES( FasTCBase rt ) 94 | ENDIF() 95 | -------------------------------------------------------------------------------- /Base/config/BaseConfig.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | // Does our compiler support cpp11 types? 19 | #cmakedefine FASTC_BASE_HAS_CPP11_TYPES 20 | -------------------------------------------------------------------------------- /Base/include/FasTC/Bits.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef __BASE_INCLUDE_BITS_H__ 19 | #define __BASE_INCLUDE_BITS_H__ 20 | 21 | #include "TexCompTypes.h" 22 | 23 | namespace FasTC { 24 | 25 | template 26 | class Bits { 27 | private: 28 | const IntType &m_Bits; 29 | 30 | // Don't copy 31 | Bits() { } 32 | Bits(const Bits &) { } 33 | Bits &operator=(const Bits &) { } 34 | 35 | public: 36 | explicit Bits(IntType &v) : m_Bits(v) { } 37 | 38 | uint8 operator[](uint32 bitPos) { 39 | return static_cast((m_Bits >> bitPos) & 1); 40 | } 41 | 42 | IntType operator()(uint32 start, uint32 end) { 43 | if(start == end) { 44 | return (*this)[start]; 45 | } else if(start > end) { 46 | uint32 t = start; 47 | start = end; 48 | end = t; 49 | } 50 | 51 | uint64 mask = (1 << (end - start + 1)) - 1; 52 | return (m_Bits >> start) & mask; 53 | } 54 | }; 55 | 56 | // Replicates low numBits such that [(toBit - 1):(toBit - 1 - fromBit)] 57 | // is the same as [(numBits - 1):0] and repeats all the way down. 58 | template 59 | IntType Replicate(const IntType &val, uint32 numBits, uint32 toBit) { 60 | if(numBits == 0) return 0; 61 | if(toBit == 0) return 0; 62 | IntType v = val & ((1 << numBits) - 1); 63 | IntType res = v; 64 | uint32 reslen = numBits; 65 | while(reslen < toBit) { 66 | uint32 comp = 0; 67 | if(numBits > toBit - reslen) { 68 | uint32 newshift = toBit - reslen; 69 | comp = numBits - newshift; 70 | numBits = newshift; 71 | } 72 | res <<= numBits; 73 | res |= v >> comp; 74 | reslen += numBits; 75 | } 76 | return res; 77 | } 78 | 79 | } // namespace FasTC 80 | #endif // __BASE_INCLUDE_BITS_H__ 81 | -------------------------------------------------------------------------------- /Base/include/FasTC/Color.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_COLOR_H_ 19 | #define BASE_INCLUDE_COLOR_H_ 20 | 21 | #include "TexCompTypes.h" 22 | #include "Vector4.h" 23 | 24 | namespace FasTC { 25 | 26 | class Color : public Vec4f { 27 | public: 28 | Color(float r, float g, float b, float a) : Vec4f(a, r, g, b) { } 29 | Color() : Vec4f(0, 0, 0, 0) { } 30 | 31 | // Let's allow us to use the operators... 32 | template 33 | Color &operator=(const Vector4 &other) { 34 | Vec4f::operator=(other); 35 | return *this; 36 | } 37 | 38 | template 39 | Color(const Vector4 &other) : Vec4f(other) { } 40 | 41 | const float &A() const { return vec[0]; } 42 | float &A() { return vec[0]; } 43 | const float &R() const { return vec[1]; } 44 | float &R() { return vec[1]; } 45 | const float &G() const { return vec[2]; } 46 | float &G() { return vec[2]; } 47 | const float &B() const { return vec[3]; } 48 | float &B() { return vec[3]; } 49 | const float &Component(uint32 idx) const { return vec[idx]; } 50 | float &Component(uint32 idx) { return vec[idx]; } 51 | 52 | // Take all of the components, transform them to their 8-bit variants, 53 | // and then pack each channel into an R8G8B8A8 32-bit integer. We assume 54 | // that the architecture is little-endian, so the alpha channel will end 55 | // up in the most-significant byte. 56 | uint32 Pack() const; 57 | void Unpack(uint32 rgba); 58 | 59 | // Tests for equality by comparing the values and the bit depths. 60 | bool operator==(const Color &) const; 61 | 62 | void MakeOpaque() { A() = 1.f ; } 63 | }; 64 | REGISTER_VECTOR_TYPE(Color); 65 | 66 | } // namespace FasTC 67 | 68 | #endif // BASE_INCLUDE_COLOR_H_ 69 | -------------------------------------------------------------------------------- /Base/include/FasTC/IPixel.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_IPIXEL_H_ 19 | #define BASE_INCLUDE_IPIXEL_H_ 20 | 21 | #include "TexCompTypes.h" 22 | #include "VectorBase.h" 23 | 24 | namespace FasTC { 25 | 26 | class IPixel : public VectorBase { 27 | public: 28 | IPixel() : VectorBase() { vec[0] = 0.0f; } 29 | IPixel(float f) : VectorBase(&f) { } 30 | 31 | operator float() const { 32 | return vec[0]; 33 | } 34 | 35 | IPixel operator=(const float &f) { 36 | return vec[0] = f; 37 | } 38 | 39 | // Take all of the components, transform them to their 8-bit variants, 40 | // and then pack each channel into an R8G8B8A8 32-bit integer. We assume 41 | // that the architecture is little-endian, so the alpha channel will end 42 | // up in the most-significant byte. 43 | uint32 Pack() const; 44 | void Unpack(uint32 rgba); 45 | 46 | void MakeOpaque() { /* Do nothing.. */ } 47 | 48 | bool operator==(const IPixel &other) const { 49 | return static_cast(*this) == static_cast(other); 50 | } 51 | 52 | bool operator!=(const IPixel &other) const { 53 | return static_cast(*this) != static_cast(other); 54 | } 55 | }; 56 | REGISTER_VECTOR_TYPE(IPixel); 57 | 58 | } // namespace FasTC 59 | 60 | #endif // BASE_INCLUDE_PIXEL_H_ 61 | -------------------------------------------------------------------------------- /Base/include/FasTC/ImageFwd.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef FASTC_BASE_INCLUDE_IMAGEFWD_H_ 19 | #define FASTC_BASE_INCLUDE_IMAGEFWD_H_ 20 | 21 | #include "TexCompTypes.h" 22 | 23 | namespace FasTC { 24 | class Pixel; 25 | template class Image; 26 | } 27 | 28 | #endif // FASTC_BASE_INCLUDE_IMAGEFWD_H_ 29 | -------------------------------------------------------------------------------- /Base/include/FasTC/Matrix2x2.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_MATRIX2X2_H_ 19 | #define BASE_INCLUDE_MATRIX2X2_H_ 20 | 21 | #include "MatrixSquare.h" 22 | 23 | namespace FasTC { 24 | 25 | template 26 | class Matrix2x2 : public MatrixSquare { 27 | public: 28 | // Constructors 29 | Matrix2x2() { } 30 | Matrix2x2(const Matrix2x2 &other) 31 | : MatrixSquare(other) { } 32 | Matrix2x2(const MatrixSquare &other) 33 | : MatrixSquare(other) { } 34 | Matrix2x2(const MatrixBase &other) 35 | : MatrixSquare(other) { } 36 | }; 37 | REGISTER_ONE_TEMPLATE_MATRIX_TYPE(Matrix2x2); 38 | }; 39 | 40 | #endif // BASE_INCLUDE_MATRIX2X2_H_ 41 | -------------------------------------------------------------------------------- /Base/include/FasTC/Matrix3x3.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_MATRIX3X3_H_ 19 | #define BASE_INCLUDE_MATRIX3X3_H_ 20 | 21 | #include "MatrixSquare.h" 22 | 23 | namespace FasTC { 24 | 25 | template 26 | class Matrix3x3 : public MatrixSquare { 27 | public: 28 | // Constructors 29 | Matrix3x3() { } 30 | Matrix3x3(const Matrix3x3 &other) 31 | : MatrixSquare(other) { } 32 | Matrix3x3(const MatrixSquare &other) 33 | : MatrixSquare(other) { } 34 | Matrix3x3(const MatrixBase &other) 35 | : MatrixSquare(other) { } 36 | }; 37 | REGISTER_ONE_TEMPLATE_MATRIX_TYPE(Matrix3x3); 38 | }; 39 | 40 | #endif // BASE_INCLUDE_MATRIX3X3_H_ 41 | -------------------------------------------------------------------------------- /Base/include/FasTC/Matrix4x4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_MATRIX4X4_H_ 19 | #define BASE_INCLUDE_MATRIX4X4_H_ 20 | 21 | #include "MatrixSquare.h" 22 | 23 | namespace FasTC { 24 | 25 | template 26 | class Matrix4x4 : public MatrixSquare { 27 | public: 28 | // Constructors 29 | Matrix4x4() { } 30 | Matrix4x4(const Matrix4x4 &other) 31 | : MatrixSquare(other) { } 32 | Matrix4x4(const MatrixSquare &other) 33 | : MatrixSquare(other) { } 34 | Matrix4x4(const MatrixBase &other) 35 | : MatrixSquare(other) { } 36 | }; 37 | REGISTER_ONE_TEMPLATE_MATRIX_TYPE(Matrix4x4); 38 | }; 39 | 40 | #endif // BASE_INCLUDE_MATRIX3X3_H_ 41 | -------------------------------------------------------------------------------- /Base/include/FasTC/ScopedAllocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_SCOPEDALLOCATOR_H_ 19 | #define BASE_INCLUDE_SCOPEDALLOCATOR_H_ 20 | 21 | #include "TexCompTypes.h" 22 | 23 | namespace FasTC { 24 | 25 | template 26 | class ScopedAllocator { 27 | private: 28 | T *m_Ptr; 29 | ScopedAllocator() : m_Ptr(NULL) { } 30 | public: 31 | ScopedAllocator(uint32 nBytes) : m_Ptr(new T[nBytes]) { } 32 | ~ScopedAllocator() { 33 | if(m_Ptr) { 34 | delete [] m_Ptr; 35 | m_Ptr = NULL; 36 | } 37 | } 38 | 39 | T &operator[](uint32 idx) { 40 | return m_Ptr[idx]; 41 | } 42 | 43 | operator T *() { 44 | return m_Ptr; 45 | } 46 | 47 | operator bool() { 48 | return m_Ptr != NULL; 49 | } 50 | }; 51 | 52 | } // namespace FasTC 53 | 54 | #endif // BASE_INCLUDE_SCOPEDALLOCATOR_H_ 55 | -------------------------------------------------------------------------------- /Base/include/FasTC/TexCompTypes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | // This file contains all of the various platform definitions for fixed width integers 19 | // on various platforms. 20 | 21 | // !FIXME! Still needs to be tested on Windows platforms. 22 | #ifndef _TEX_COMP_TYPES_H_ 23 | #define _TEX_COMP_TYPES_H_ 24 | 25 | #include "FasTC/BaseConfig.h" 26 | 27 | // Do we support C++11? 28 | #ifdef FASTC_BASE_HAS_CPP11_TYPES 29 | #include 30 | 31 | typedef int8_t int8; 32 | typedef uint8_t uint8; 33 | 34 | typedef int16_t int16; 35 | typedef uint16_t uint16; 36 | 37 | typedef int32_t int32; 38 | typedef uint32_t uint32; 39 | 40 | typedef int64_t int64; 41 | typedef uint64_t uint64; 42 | 43 | typedef char CHAR; 44 | 45 | #else 46 | 47 | // Windows? 48 | #ifdef _MSC_VER 49 | 50 | typedef __int16 int16; 51 | typedef unsigned __int16 uint16; 52 | typedef __int32 int32; 53 | typedef unsigned __int32 uint32; 54 | typedef __int8 int8; 55 | typedef unsigned __int8 uint8; 56 | 57 | typedef unsigned __int64 uint64; 58 | typedef __int64 int64; 59 | 60 | #include 61 | typedef TCHAR CHAR; 62 | 63 | // If not, assume GCC, or at least standard defines... 64 | #else 65 | 66 | #include 67 | 68 | typedef int8_t int8; 69 | typedef int16_t int16; 70 | typedef int32_t int32; 71 | typedef int64_t int64; 72 | 73 | typedef uint8_t uint8; 74 | typedef uint16_t uint16; 75 | typedef uint32_t uint32; 76 | typedef uint64_t uint64; 77 | 78 | typedef char CHAR; 79 | 80 | #endif // _MSC_VER 81 | 82 | #endif // FASTC_BASE_HAS_CPP11_TYPES 83 | 84 | #endif // _TEX_COMP_TYPES_H_ 85 | -------------------------------------------------------------------------------- /Base/include/FasTC/Vector2.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef BASE_INCLUDE_VECTOR2_H_ 19 | #define BASE_INCLUDE_VECTOR2_H_ 20 | 21 | #include "VectorBase.h" 22 | 23 | # define _VEX_VEC2_SWIZZLE_DEF(X, Y) \ 24 | Vector2 X##Y() const { return Vector2( X(), Y() ); } 25 | 26 | namespace FasTC { 27 | 28 | template 29 | class Vector2 : public VectorBase { 30 | public: 31 | // Ideally, we would be able to do this with initialization 32 | // lists, but I'm not really sure how to do that without gross 33 | // code duplication. 34 | Vector2() { } 35 | Vector2(T x, T y) { 36 | X() = x; 37 | Y() = y; 38 | } 39 | 40 | explicit Vector2(const T *_vec) { 41 | for(int i = 0; i < 2; i++) 42 | this->vec[i] = _vec[i]; 43 | } 44 | 45 | // Overloaded functions 46 | template 47 | Vector2(const Vector2<_T> &v) : VectorBase(v) { } 48 | 49 | template 50 | Vector2 &operator=(const Vector2<_T> &v) { 51 | VectorBase::operator=(v); 52 | return *this; 53 | } 54 | 55 | Vector2 &operator=(const T *_vec) { 56 | VectorBase::operator=(_vec); 57 | return *this; 58 | } 59 | 60 | // Accessors 61 | T &X() { return (*this)[0]; } 62 | const T &X() const { return (*this)[0]; } 63 | 64 | T &Y() { return (*this)[1]; } 65 | const T &Y() const { return (*this)[1]; } 66 | 67 | // Swizzle 68 | _VEX_VEC2_SWIZZLE_DEF(X, X) 69 | _VEX_VEC2_SWIZZLE_DEF(X, Y) 70 | _VEX_VEC2_SWIZZLE_DEF(Y, X) 71 | _VEX_VEC2_SWIZZLE_DEF(Y, Y) 72 | }; 73 | REGISTER_ONE_TEMPLATE_VECTOR_TYPE(Vector2); 74 | 75 | typedef Vector2 Vec2f; 76 | typedef Vector2 Vec2d; 77 | typedef Vector2 Vec2i; 78 | }; 79 | 80 | #endif // BASE_INCLUDE_VECTOR2_H_ 81 | -------------------------------------------------------------------------------- /Base/src/Color.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/Color.h" 19 | 20 | namespace FasTC { 21 | 22 | uint32 Color::Pack() const { 23 | uint32 result = 0; 24 | result |= static_cast((A() * 255.0f) + 0.5f); 25 | result <<= 8; 26 | result |= static_cast((B() * 255.0f) + 0.5f); 27 | result <<= 8; 28 | result |= static_cast((G() * 255.0f) + 0.5f); 29 | result <<= 8; 30 | result |= static_cast((R() * 255.0f) + 0.5f); 31 | return result; 32 | } 33 | 34 | void Color::Unpack(uint32 rgba) { 35 | R() = static_cast(rgba & 0xFF) / 255.0f; 36 | G() = static_cast((rgba >> 8) & 0xFF) / 255.0f; 37 | B() = static_cast((rgba >> 16) & 0xFF) / 255.0f; 38 | A() = static_cast((rgba >> 24) & 0xFF) / 255.0f; 39 | } 40 | 41 | // Tests for equality by comparing the values and the bit depths. 42 | bool Color::operator==(const Color &other) const { 43 | static const float kEpsilon = 0.001f; 44 | for(uint32 c = 0; c < 4; c++) { 45 | if(fabs(Component(c) - other.Component(c)) > kEpsilon) { 46 | return false; 47 | } 48 | } 49 | 50 | return true; 51 | } 52 | } // namespace FasTC 53 | -------------------------------------------------------------------------------- /Base/src/IPixel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/Pixel.h" 19 | #include "FasTC/IPixel.h" 20 | 21 | namespace FasTC { 22 | 23 | // Take all of the components, transform them to their 8-bit variants, 24 | // and then pack each channel into an R8G8B8A8 32-bit integer. We assume 25 | // that the architecture is little-endian, so the alpha channel will end 26 | // up in the most-significant byte. 27 | uint32 IPixel::Pack() const { 28 | uint32 ret = 0xFF << 24; 29 | for(uint32 i = 0; i < 3; i++) { 30 | if(vec[0] > 1.0) { 31 | ret |= static_cast(vec[0]) << i*8; 32 | } else { 33 | ret |= static_cast((255.0 * vec[0]) + 0.5f) << i*8; 34 | } 35 | } 36 | return ret; 37 | } 38 | 39 | void IPixel::Unpack(uint32 rgba) { 40 | Pixel p(rgba); 41 | vec[0] = p.ToIntensity(); 42 | } 43 | 44 | } // namespace FasTC 45 | -------------------------------------------------------------------------------- /Base/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/Base/include ) 19 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/Base/include ) 20 | 21 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/GTest/include) 22 | 23 | SET(TESTS 24 | Vector Matrix Pixel Image Color Bits 25 | ) 26 | 27 | FOREACH(TEST ${TESTS}) 28 | SET(TEST_NAME Test_Base_${TEST}) 29 | SET(TEST_MODULE Test${TEST}.cpp) 30 | 31 | # HACK for MSVC 2012... 32 | IF(MSVC) 33 | ADD_DEFINITIONS(-D_VARIADIC_MAX=10) 34 | ENDIF() 35 | 36 | ADD_EXECUTABLE(${TEST_NAME} ${TEST_MODULE}) 37 | 38 | # Vector tests need to use uninitialized variables 39 | IF((${TEST_NAME} STREQUAL "Test_Base_Vector") 40 | OR 41 | (${TEST_NAME} STREQUAL "Test_Base_Matrix")) 42 | IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX) 43 | SET_TARGET_PROPERTIES( 44 | ${TEST_NAME} 45 | PROPERTIES 46 | COMPILE_FLAGS 47 | "-Wno-uninitialized") 48 | ENDIF() 49 | ENDIF() 50 | 51 | TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCBase) 52 | TARGET_LINK_LIBRARIES(${TEST_NAME} gtest_main) 53 | ADD_TEST(${TEST_NAME} ${TEST_NAME}) 54 | ENDFOREACH() 55 | -------------------------------------------------------------------------------- /Base/test/TestBits.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "gtest/gtest.h" 19 | #include "FasTC/Bits.h" 20 | 21 | TEST(Bits, Replicate) { 22 | uint32 xv = 3; 23 | EXPECT_EQ(FasTC::Replicate(xv, 2, 8), 0xFFU); 24 | EXPECT_EQ(FasTC::Replicate(xv, 0, 7), 0U); 25 | EXPECT_EQ(FasTC::Replicate(xv, 3, 4), 0x06U); 26 | 27 | xv = 0; 28 | EXPECT_EQ(FasTC::Replicate(xv, 1, 0), 0U); 29 | EXPECT_EQ(FasTC::Replicate(xv, 0, 7), 0U); 30 | 31 | xv = 5; 32 | EXPECT_EQ(FasTC::Replicate(xv, 2, 0), 0U); 33 | EXPECT_EQ(FasTC::Replicate(xv, 3, 6), 0x2DU); 34 | } 35 | -------------------------------------------------------------------------------- /Base/test/TestColor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "gtest/gtest.h" 19 | #include "FasTC/Color.h" 20 | 21 | static const float kEpsilon = 1e-6f; 22 | 23 | TEST(Color, DefaultConstructor) { 24 | FasTC::Color c; 25 | EXPECT_EQ(c.R(), 0.0f); 26 | EXPECT_EQ(c.G(), 0.0f); 27 | EXPECT_EQ(c.B(), 0.0f); 28 | EXPECT_EQ(c.A(), 0.0f); 29 | } 30 | 31 | TEST(Color, AssignmentConstructor) { 32 | FasTC::Color c(1.0f, 0.0f, 3.0f, -1.0f); 33 | EXPECT_EQ(c.R(), 1.0f); 34 | EXPECT_EQ(c.G(), 0.0f); 35 | EXPECT_EQ(c.B(), 3.0f); 36 | EXPECT_EQ(c.A(), -1.0f); 37 | } 38 | 39 | TEST(Color, VectorOperators) { 40 | FasTC::Color a(0.1f, 0.2f, 0.3f, 0.4f); 41 | FasTC::Color b(0.2f, 0.3f, 0.4f, 0.5f); 42 | FasTC::Color c = a + b; 43 | 44 | EXPECT_NEAR(c.R(), 0.3, kEpsilon); 45 | EXPECT_NEAR(c.G(), 0.5, kEpsilon); 46 | EXPECT_NEAR(c.B(), 0.7, kEpsilon); 47 | EXPECT_NEAR(c.A(), 0.9, kEpsilon); 48 | 49 | FasTC::Color d = a - b; 50 | 51 | EXPECT_NEAR(d.R(), -0.1, kEpsilon); 52 | EXPECT_NEAR(d.G(), -0.1, kEpsilon); 53 | EXPECT_NEAR(d.B(), -0.1, kEpsilon); 54 | EXPECT_NEAR(d.A(), -0.1, kEpsilon); 55 | } 56 | 57 | TEST(Color, EqualityComparison) { 58 | FasTC::Color a(0.1f, 0.2f, 0.3f, 0.4f); 59 | FasTC::Color b(0.2f, 0.3f, 0.4f, 0.5f); 60 | 61 | EXPECT_TRUE(a == a && b == b); 62 | EXPECT_FALSE(a == b && b == a); 63 | } 64 | -------------------------------------------------------------------------------- /Base/test/Utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef PVRTCENCODER_TEST_TESTUTILS_H_ 19 | #define PVRTCENCODER_TEST_TESTUTILS_H_ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | 23 | class PixelPrinter { 24 | private: 25 | uint32 m_PixelValue; 26 | public: 27 | explicit PixelPrinter(uint32 p) : m_PixelValue(p) { } 28 | bool operator==(const PixelPrinter &other) const { 29 | return other.m_PixelValue == this->m_PixelValue; 30 | } 31 | uint32 Value() const { return m_PixelValue; } 32 | }; 33 | 34 | inline ::std::ostream& operator<<(::std::ostream& os, const PixelPrinter& pp) { 35 | uint32 p = pp.Value(); 36 | uint32 r = p & 0xFF; 37 | uint32 g = (p >> 8) & 0xFF; 38 | uint32 b = (p >> 16) & 0xFF; 39 | uint32 a = (p >> 24) & 0xFF; 40 | return os << 41 | "R: 0x" << ::std::hex << r << " " << 42 | "G: 0x" << ::std::hex << g << " " << 43 | "B: 0x" << ::std::hex << b << " " << 44 | "A: 0x" << ::std::hex << a; 45 | } 46 | 47 | #endif // PVRTCENCODER_TEST_TESTUTILS_H_ 48 | -------------------------------------------------------------------------------- /CLTool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | INCLUDE_DIRECTORIES( ${FasTC_SOURCE_DIR}/Base/include ) 19 | INCLUDE_DIRECTORIES( ${FasTC_BINARY_DIR}/Base/include ) 20 | 21 | INCLUDE_DIRECTORIES( ${FasTC_SOURCE_DIR}/Core/include ) 22 | INCLUDE_DIRECTORIES( ${FasTC_SOURCE_DIR}/IO/include ) 23 | 24 | ADD_EXECUTABLE( 25 | tc 26 | "src/tc.cpp" 27 | ) 28 | 29 | ADD_EXECUTABLE( 30 | compare 31 | "src/compare.cpp" 32 | ) 33 | 34 | ADD_EXECUTABLE( 35 | decomp 36 | "src/decomp.cpp" 37 | ) 38 | 39 | # Add flag for link time code generation. This was used to build the libpng 40 | # libraries, so we should probably also include it for this project as well... 41 | IF( MSVC ) 42 | SET_TARGET_PROPERTIES(tc PROPERTIES LINK_FLAGS "/LTCG") 43 | SET_TARGET_PROPERTIES(compare PROPERTIES LINK_FLAGS "/LTCG") 44 | SET_TARGET_PROPERTIES(decomp PROPERTIES LINK_FLAGS "/LTCG") 45 | ENDIF() 46 | 47 | TARGET_LINK_LIBRARIES( tc FasTCBase ) 48 | TARGET_LINK_LIBRARIES( tc FasTCIO ) 49 | TARGET_LINK_LIBRARIES( tc FasTCCore ) 50 | 51 | TARGET_LINK_LIBRARIES( compare FasTCBase ) 52 | TARGET_LINK_LIBRARIES( compare FasTCIO ) 53 | 54 | TARGET_LINK_LIBRARIES( decomp FasTCBase ) 55 | TARGET_LINK_LIBRARIES( decomp FasTCIO ) 56 | 57 | INSTALL(TARGETS tc compare decomp EXPORT FasTCTargets 58 | RUNTIME DESTINATION bin COMPONENT bin) 59 | -------------------------------------------------------------------------------- /CLTool/src/decomp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #define _CRT_SECURE_NO_WARNINGS 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #ifdef _MSC_VER 27 | # include 28 | # include 29 | #endif 30 | 31 | #include "FasTC/Image.h" 32 | #include "FasTC/ImageFile.h" 33 | #include "FasTC/TexComp.h" 34 | #include "FasTC/ThreadSafeStreambuf.h" 35 | 36 | void PrintUsage() { 37 | fprintf(stderr, "Usage: decomp \n"); 38 | fprintf(stderr, "\tIf in_img is not a compressed image, then this tool simply copies the image.\n"); 39 | } 40 | 41 | int main(int argc, char **argv) { 42 | if(argc != 3) { 43 | return 1; 44 | } 45 | 46 | ImageFile imgf (argv[1]); 47 | if(!imgf.Load()) { 48 | return 1; 49 | } 50 | 51 | FasTC::Image<> *img = imgf.GetImage(); 52 | 53 | EImageFileFormat fmt = ImageFile::DetectFileFormat(argv[2]); 54 | ImageFile cImgFile (argv[2], fmt, *img); 55 | cImgFile.Write(); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /CMakeModules/FasTCConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | SET(FASTC_VERSION @FasTC_VERSION@) 19 | 20 | @PACKAGE_INIT@ 21 | 22 | SET(FasTC_LIBRARIES FasTCBase FasTCIO FasTCCore BPTCEncoder PVRTCEncoder DXTEncoder ETCEncoder ASTCEncoder) 23 | 24 | IF(NOT TARGET FasTCBase) 25 | # We're coming from a build tree -- include all of the targets 26 | # from the project and try to make sure that our includes are set properly 27 | INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FasTCTargets.cmake") 28 | 29 | FOREACH(LIB ${FasTC_LIBRARIES}) 30 | STRING(REPLACE "FasTC" "" DIR "${LIB}") 31 | 32 | SET(CURRENT_DIR "@FasTC_SOURCE_DIR@/${DIR}/include") 33 | IF( EXISTS "${CURRENT_DIR}/" ) 34 | SET(FasTC_INCLUDE_DIRS ${FasTC_INCLUDE_DIRS} ${CURRENT_DIR}) 35 | ENDIF() 36 | 37 | SET(CURRENT_DIR "@FasTC_BINARY_DIR@/${DIR}/include") 38 | IF( EXISTS "${CURRENT_DIR}/" ) 39 | SET(FasTC_INCLUDE_DIRS ${FasTC_INCLUDE_DIRS} ${CURRENT_DIR}) 40 | ENDIF() 41 | 42 | ENDFOREACH() 43 | 44 | SET(FasTC_EXECUTABLES tc compare decomp) 45 | 46 | ELSE() 47 | 48 | # This is an install tree -- everything should be a lot easier.... 49 | SET_AND_CHECK(FasTC_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@/FasTC") 50 | SET_AND_CHECK(FasTC_BIN_DIR "@PACKAGE_BIN_INSTALL_DIR@") 51 | SET_AND_CHECK(FasTC_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") 52 | 53 | ENDIF() 54 | -------------------------------------------------------------------------------- /CMakeModules/FasTCVersion.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | SET(PACKAGE_VERSION "@FasTC_VERSION@") 19 | 20 | # Check whether the requested PACKAGE_FIND_VERSION is compatible 21 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 22 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 23 | else() 24 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 25 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 26 | set(PACKAGE_VERSION_EXACT TRUE) 27 | endif() 28 | endif() -------------------------------------------------------------------------------- /CMakeModules/FindBC7Export.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | # - Try to find libPVRTexLib 19 | # Once done this will define 20 | # PVRTEXLIB_FOUND - System has PVRTexLib 21 | # PVRTEXLIB_INCLUDE_DIRS - The PVRTexLib include directories 22 | # PVRTEXLIB_LIBRARIES - The libraries needed to use PVRTexLib 23 | 24 | SET(AVPCLLIB_ROOT "" CACHE STRING "Location of the BC7 Export library from NVTT") 25 | 26 | IF(NOT AVPCLLIB_ROOT STREQUAL "") 27 | IF(NOT EXISTS "${AVPCLLIB_ROOT}/src/CMakeLists.txt") 28 | CONFIGURE_FILE( 29 | "${CMAKE_CURRENT_LIST_DIR}/bc7_export/CMakeLists.txt" 30 | "${AVPCLLIB_ROOT}/src" 31 | COPYONLY) 32 | ENDIF() 33 | ADD_SUBDIRECTORY(${AVPCLLIB_ROOT}/src ${CMAKE_CURRENT_BINARY_DIR}/bc7_export) 34 | set(AVPCLLIB_INCLUDE_DIR ${AVPCLLIB_ROOT}/src ) 35 | SET(FOUND_NVTT_BPTC_EXPORT TRUE) 36 | ENDIF() 37 | 38 | mark_as_advanced( FORCE AVPCLLIB_ROOT AVPCLLIB_INCLUDE_DIR ) 39 | -------------------------------------------------------------------------------- /CMakeModules/bc7_export/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}) 19 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/arvo) 20 | 21 | SET( HEADERS 22 | avpcl.h 23 | bits.h 24 | endpts.h 25 | ImfArray.h 26 | rgba.h 27 | shapes_three.h 28 | shapes_two.h 29 | targa.h 30 | tile.h 31 | utils.h 32 | arvo/ArvoMath.h 33 | arvo/Char.h 34 | arvo/Complex.h 35 | arvo/form.h 36 | arvo/Matrix.h 37 | arvo/Perm.h 38 | arvo/Rand.h 39 | arvo/SI_units.h 40 | arvo/SphTri.h 41 | arvo/SVD.h 42 | arvo/Token.h 43 | arvo/Vec2.h 44 | arvo/Vec3.h 45 | arvo/Vec4.h 46 | arvo/Vector.h 47 | ) 48 | 49 | SET( SOURCES 50 | avpcl.cpp 51 | avpcl_mode0.cpp 52 | avpcl_mode1.cpp 53 | avpcl_mode2.cpp 54 | avpcl_mode3.cpp 55 | avpcl_mode4.cpp 56 | avpcl_mode5.cpp 57 | avpcl_mode6.cpp 58 | avpcl_mode7.cpp 59 | targa.cpp 60 | utils.cpp 61 | arvo/ArvoMath.cpp 62 | arvo/Char.cpp 63 | arvo/Complex.cpp 64 | arvo/Matrix.cpp 65 | arvo/Perm.cpp 66 | arvo/Rand.cpp 67 | arvo/SphTri.cpp 68 | arvo/SVD.cpp 69 | arvo/Token.cpp 70 | arvo/Vec2.cpp 71 | arvo/Vec3.cpp 72 | arvo/Vec4.cpp 73 | arvo/Vector.cpp 74 | ) 75 | 76 | ADD_LIBRARY( avpcl 77 | ${HEADERS} 78 | ${SOURCES} 79 | ) 80 | -------------------------------------------------------------------------------- /Core/include/FasTC/CompressedImage.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _COMPRESSED_IMAGE_H_ 19 | #define _COMPRESSED_IMAGE_H_ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | #include "FasTC/CompressionFormat.h" 23 | #include "FasTC/Image.h" 24 | 25 | class CompressedImage : public FasTC::Image { 26 | private: 27 | FasTC::ECompressionFormat m_Format; 28 | uint8 *m_CompressedData; 29 | 30 | typedef FasTC::Image UncompressedImage; 31 | 32 | public: 33 | CompressedImage(const CompressedImage &); 34 | CompressedImage &operator=(const CompressedImage &); 35 | 36 | // Create a compressed image from the given data according to 37 | // the passed format. The size of the data is expected to conform 38 | // to the width, height, and format specified. 39 | CompressedImage( 40 | const uint32 width, 41 | const uint32 height, 42 | const FasTC::ECompressionFormat format, 43 | const uint8 *data 44 | ); 45 | 46 | virtual ~CompressedImage(); 47 | 48 | virtual FasTC::Image *Clone() const { 49 | return new CompressedImage(*this); 50 | } 51 | 52 | virtual void ComputePixels(); 53 | 54 | static uint32 GetCompressedSize(uint32 width, uint32 height, FasTC::ECompressionFormat format); 55 | 56 | uint32 GetCompressedSize() const { 57 | return GetCompressedSize(GetWidth(), GetHeight(), m_Format); 58 | } 59 | uint32 GetUncompressedSize() const { 60 | return GetWidth() * GetHeight() * sizeof(uint32); 61 | } 62 | 63 | // Decompress the compressed image data into outBuf. outBufSz is expected 64 | // to be the proper size determined by the width, height, and format. 65 | // !FIXME! We should have a function to explicitly return the in/out buf 66 | // size for a given compressed image. 67 | bool DecompressImage(uint8 *outBuf, uint32 outBufSz) const; 68 | 69 | const uint8 *GetCompressedData() const { return m_CompressedData; } 70 | 71 | FasTC::ECompressionFormat GetFormat() const { return m_Format; } 72 | }; 73 | 74 | #endif // _COMPRESSED_IMAGE_H_ 75 | -------------------------------------------------------------------------------- /Core/include/FasTC/ReferenceCounter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef __REFERENCE_COUNTER_H__ 19 | #define __REFERENCE_COUNTER_H__ 20 | 21 | #include "TexCompTypes.h" 22 | 23 | class ReferenceCounter { 24 | public: 25 | ReferenceCounter() : m_ReferenceCount( new uint32 ) { 26 | *m_ReferenceCount = 1; 27 | } 28 | ReferenceCounter(const ReferenceCounter &other) 29 | : m_ReferenceCount(other.m_ReferenceCount) { 30 | IncRefCount(); 31 | } 32 | 33 | ReferenceCounter &operator=(const ReferenceCounter &other) { 34 | DecRefCount(); 35 | m_ReferenceCount = other.m_ReferenceCount; 36 | IncRefCount(); 37 | return *this; 38 | } 39 | 40 | uint32 GetRefCount() const { 41 | if(m_ReferenceCount) 42 | return *m_ReferenceCount; 43 | else 44 | return 0; 45 | } 46 | 47 | void DecRefCount() { 48 | if(!m_ReferenceCount) return; 49 | 50 | (*m_ReferenceCount)--; 51 | 52 | if(*m_ReferenceCount == 0) { 53 | delete m_ReferenceCount; 54 | m_ReferenceCount = 0; 55 | } 56 | } 57 | 58 | void IncRefCount() { 59 | if(!m_ReferenceCount) return; 60 | (*m_ReferenceCount)++; 61 | } 62 | 63 | private: 64 | uint32 *m_ReferenceCount; 65 | }; 66 | 67 | #endif // __REFERENCE_COUNTER_H__ 68 | -------------------------------------------------------------------------------- /Core/include/FasTC/ThreadSafeStreambuf.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef CORE_INCLUDE_THREADSAFESTREAMBUF_H_ 19 | #define CORE_INCLUDE_THREADSAFESTREAMBUF_H_ 20 | 21 | // Forward Declarations 22 | class TCMutex; 23 | 24 | #include 25 | #include 26 | 27 | class ThreadSafeStreambuf : public ::std::streambuf { 28 | public: 29 | ThreadSafeStreambuf(std::ostream &sink); 30 | virtual ~ThreadSafeStreambuf(); 31 | 32 | protected: 33 | virtual std::streamsize xsputn(const char_type *s, std::streamsize count); 34 | private: 35 | // Not implemented -- not allowed... 36 | ThreadSafeStreambuf(const ThreadSafeStreambuf &); 37 | ThreadSafeStreambuf &operator=(const ThreadSafeStreambuf &); 38 | std::ostream &m_Sink; 39 | TCMutex *m_Mutex; 40 | }; 41 | 42 | #endif // CORE_INCLUDE_THREADSAFESTREAMBUF_H_ 43 | -------------------------------------------------------------------------------- /Core/src/CompressionFuncs.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef CORE_SRC_COMPRESSIONFUNCS_H_ 19 | #define CORE_SRC_COMPRESSIONFUNCS_H_ 20 | 21 | #include "FasTC/CompressionJob.h" 22 | #include 23 | 24 | // A compression function format. It takes the raw data and image dimensions and 25 | // returns the compressed image data into outData. It is assumed that there is 26 | // enough space allocated for outData to store the compressed data. Allocation 27 | // is dependent on the compression format. 28 | typedef void (* CompressionFunc)(const FasTC::CompressionJob &); 29 | 30 | // A compression function format. It takes the raw data and image dimensions and 31 | // returns the compressed image data into outData. It is assumed that there is 32 | // enough space allocated for outData to store the compressed data. Allocation 33 | // is dependent on the compression format. 34 | typedef void (* CompressionFuncWithStats)(const FasTC::CompressionJob &, std::ostream *logStream); 35 | 36 | #endif // CORE_SRC_COMPRESSIONFUNCS_H_ 37 | -------------------------------------------------------------------------------- /Core/src/StopWatchOSX.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/StopWatch.h" 19 | #include "FasTC/TexCompTypes.h" 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | class StopWatchImpl { 26 | public: 27 | uint64 start; 28 | uint64 duration; 29 | }; 30 | 31 | static uint64 Now() { 32 | timeval tv; 33 | gettimeofday(&tv, NULL); 34 | return tv.tv_usec + (1e6 * tv.tv_sec); 35 | } 36 | 37 | StopWatch::StopWatch(const StopWatch &other) { 38 | impl = new StopWatchImpl(); 39 | memcpy(impl, other.impl, sizeof(StopWatchImpl)); 40 | } 41 | 42 | StopWatch &StopWatch::operator=(const StopWatch &other) { 43 | if(impl) { 44 | delete impl; 45 | } 46 | impl = new StopWatchImpl(); 47 | memcpy(impl, other.impl, sizeof(StopWatchImpl)); 48 | return *this; 49 | } 50 | 51 | StopWatch::~StopWatch() { 52 | delete impl; 53 | } 54 | 55 | StopWatch::StopWatch() : impl(new StopWatchImpl) { 56 | Reset(); 57 | } 58 | 59 | void StopWatch::Start() { 60 | impl->start = Now(); 61 | } 62 | 63 | void StopWatch::Stop() { 64 | impl->duration = Now() - impl->start; 65 | } 66 | 67 | void StopWatch::Reset() { 68 | impl->start = impl->duration = 0.0; 69 | } 70 | 71 | double StopWatch::TimeInSeconds() const { 72 | return double(impl->duration) / 1e6; 73 | } 74 | 75 | double StopWatch::TimeInMilliseconds() const { 76 | return double(impl->duration) / 1e3; 77 | } 78 | 79 | double StopWatch::TimeInMicroseconds() const { 80 | return double(impl->duration); 81 | } 82 | -------------------------------------------------------------------------------- /Core/src/StopWatchUnix.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/StopWatch.h" 19 | #include "FasTC/TexCompTypes.h" 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | class StopWatchImpl { 26 | public: 27 | timespec ts; 28 | 29 | double timer; 30 | double duration; 31 | }; 32 | 33 | StopWatch::StopWatch(const StopWatch &other) { 34 | impl = new StopWatchImpl(); 35 | memcpy(impl, other.impl, sizeof(StopWatchImpl)); 36 | } 37 | 38 | StopWatch &StopWatch::operator=(const StopWatch &other) { 39 | if(impl) { 40 | delete impl; 41 | } 42 | impl = new StopWatchImpl(); 43 | memcpy(impl, other.impl, sizeof(StopWatchImpl)); 44 | return *this; 45 | } 46 | 47 | StopWatch::~StopWatch() { 48 | delete impl; 49 | } 50 | 51 | StopWatch::StopWatch() : impl(new StopWatchImpl) { 52 | Reset(); 53 | } 54 | 55 | void StopWatch::Start() { 56 | clock_gettime(CLOCK_REALTIME, &(impl->ts)); 57 | impl->timer = double(impl->ts.tv_sec) + 1e-9 * double(impl->ts.tv_nsec); 58 | } 59 | 60 | void StopWatch::Stop() { 61 | clock_gettime(CLOCK_REALTIME, &(impl->ts)); 62 | impl->duration = -(impl->timer) + (double(impl->ts.tv_sec) + 1e-9 * double(impl->ts.tv_nsec)); 63 | } 64 | 65 | void StopWatch::Reset() { 66 | impl->timer = impl->duration = 0.0; 67 | memset(&(impl->ts), 0, sizeof(timespec)); 68 | } 69 | 70 | double StopWatch::TimeInSeconds() const { 71 | return impl->duration; 72 | } 73 | 74 | double StopWatch::TimeInMilliseconds() const { 75 | return impl->duration * 1000; 76 | } 77 | 78 | double StopWatch::TimeInMicroseconds() const { 79 | return impl->duration * 1000000; 80 | } 81 | -------------------------------------------------------------------------------- /Core/src/ThreadSafeStreambuf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/ThreadSafeStreambuf.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "Thread.h" 28 | 29 | ThreadSafeStreambuf::ThreadSafeStreambuf(std::ostream &sink) 30 | : ::std::streambuf() 31 | , m_Sink(sink) 32 | , m_Mutex(new TCMutex) 33 | { } 34 | 35 | ThreadSafeStreambuf::~ThreadSafeStreambuf() { 36 | if(m_Mutex) { 37 | delete m_Mutex; 38 | } 39 | } 40 | 41 | ::std::streamsize ThreadSafeStreambuf::xsputn(const char_type *s, 42 | ::std::streamsize count) { 43 | // Lock it. 44 | TCLock lock(*m_Mutex); 45 | ::std::streambuf *sinkStream = m_Sink.rdbuf(); 46 | return sinkStream->sputn(s, count); 47 | } 48 | -------------------------------------------------------------------------------- /DXTEncoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | SET( LIBRARY_HEADERS 19 | "include/FasTC/DXTCompressor.h" 20 | ) 21 | 22 | SET( SOURCES 23 | "src/Compressor.cpp" 24 | "src/Decompressor.cpp" 25 | ) 26 | 27 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/Base/include) 28 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/Base/include) 29 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/DXTEncoder/include) 30 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/DXTEncoder/include) 31 | 32 | ADD_LIBRARY( DXTEncoder 33 | ${HEADERS} 34 | ${SOURCES} 35 | ) 36 | 37 | INSTALL(TARGETS DXTEncoder EXPORT FasTCTargets ARCHIVE DESTINATION lib COMPONENT lib) 38 | INSTALL( 39 | FILES ${LIBRARY_HEADERS} 40 | DESTINATION ${INCLUDE_INSTALL_DIR}/FasTC 41 | COMPONENT dev) 42 | 43 | TARGET_LINK_LIBRARIES( DXTEncoder FasTCBase ) 44 | -------------------------------------------------------------------------------- /DXTEncoder/include/FasTC/DXTCompressor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/TexCompTypes.h" 19 | #include "FasTC/CompressionJob.h" 20 | 21 | namespace DXTC 22 | { 23 | // DXT compressor 24 | void CompressImageDXT1(const FasTC::CompressionJob &); 25 | void CompressImageDXT5(const FasTC::CompressionJob &); 26 | 27 | void DecompressDXT1(const FasTC::DecompressionJob &); 28 | void DecompressDXT5(const FasTC::DecompressionJob &); 29 | } 30 | -------------------------------------------------------------------------------- /ETCEncoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | SET( LIBRARY_HEADERS 19 | "include/FasTC/ETCCompressor.h" 20 | ) 21 | 22 | SET( HEADERS 23 | ${LIBRARY_HEADERS} 24 | src/rg_etc1.h 25 | ) 26 | 27 | SET( SOURCES 28 | src/Compressor.cpp 29 | src/Decompressor.cpp 30 | src/rg_etc1.cpp 31 | ) 32 | 33 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/Base/include) 34 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/Base/include) 35 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/ETCEncoder/include) 36 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/ETCEncoder/include) 37 | 38 | ADD_LIBRARY( ETCEncoder 39 | ${HEADERS} 40 | ${SOURCES} 41 | ) 42 | 43 | INSTALL(TARGETS ETCEncoder EXPORT FasTCTargets ARCHIVE DESTINATION lib COMPONENT lib) 44 | INSTALL( 45 | FILES ${LIBRARY_HEADERS} 46 | DESTINATION ${INCLUDE_INSTALL_DIR}/FasTC 47 | COMPONENT dev) 48 | 49 | TARGET_LINK_LIBRARIES( ETCEncoder FasTCBase ) 50 | -------------------------------------------------------------------------------- /ETCEncoder/include/FasTC/ETCCompressor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef ETCENCODER_INCLUDE_ETCCOMPRESSOR_H_ 19 | #define ETCENCODER_INCLUDE_ETCCOMPRESSOR_H_ 20 | 21 | #include "FasTC/CompressionJob.h" 22 | #include "FasTC/TexCompTypes.h" 23 | 24 | namespace ETCC { 25 | 26 | // Takes a stream of compressed ETC1 data and decompresses it into R8G8B8A8 27 | // format. The width and height must be specified in order to properly 28 | // decompress the data. 29 | void Decompress(const FasTC::DecompressionJob &); 30 | 31 | // Takes a stream of uncompressed RGBA8 data and compresses it into ETC1 32 | // version one. The width and height must be specified in order to properly 33 | // decompress the data. This uses the library created by Rich Geldreich found here: 34 | // https://code.google.com/p/rg-etc1 35 | void Compress_RG(const FasTC::CompressionJob &); 36 | 37 | } // namespace PVRTCC 38 | 39 | #endif // ETCENCODER_INCLUDE_ETCCOMPRESSOR_H_ 40 | -------------------------------------------------------------------------------- /ETCEncoder/src/Compressor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/ETCCompressor.h" 19 | 20 | #include "rg_etc1.h" 21 | #include 22 | #include 23 | 24 | namespace ETCC { 25 | 26 | void Compress_RG(const FasTC::CompressionJob &cj) { 27 | 28 | rg_etc1::etc1_pack_params params; 29 | params.m_quality = rg_etc1::cLowQuality; 30 | rg_etc1::pack_etc1_block_init(); 31 | 32 | uint32 kBlockSz = GetBlockSize(FasTC::eCompressionFormat_ETC1); 33 | const uint32 startBlock = cj.CoordsToBlockIdx(cj.XStart(), cj.YStart()); 34 | uint8 *outBuf = cj.OutBuf() + startBlock * kBlockSz; 35 | 36 | const uint32 endY = std::min(cj.YEnd(), cj.Height() - 4); 37 | uint32 startX = cj.XStart(); 38 | for(uint32 j = cj.YStart(); j <= endY; j += 4) { 39 | const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width(); 40 | for(uint32 i = startX; i < endX; i += 4) { 41 | 42 | uint32 pixels[16]; 43 | const uint32 *inPixels = reinterpret_cast(cj.InBuf()); 44 | memcpy(pixels, inPixels + j*cj.Width() + i, 4 * sizeof(uint32)); 45 | memcpy(pixels + 4, inPixels + (j+1)*cj.Width() + i, 4 * sizeof(uint32)); 46 | memcpy(pixels + 8, inPixels + (j+2)*cj.Width() + i, 4 * sizeof(uint32)); 47 | memcpy(pixels + 12, inPixels + (j+3)*cj.Width() + i, 4 * sizeof(uint32)); 48 | 49 | pack_etc1_block(outBuf, pixels, params); 50 | outBuf += kBlockSz; 51 | } 52 | startX = 0; 53 | } 54 | } 55 | } // namespace PVRTCC 56 | -------------------------------------------------------------------------------- /ETCEncoder/src/Decompressor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/ETCCompressor.h" 19 | 20 | #include "rg_etc1.h" 21 | 22 | #include 23 | #include 24 | 25 | namespace ETCC { 26 | 27 | void Decompress(const FasTC::DecompressionJob &dcj) { 28 | uint32 blocksX = (dcj.Width() + 3) / 4; 29 | uint32 blocksY = (dcj.Height() + 3) / 4; 30 | 31 | for(uint32 j = 0; j < blocksY; j++) { 32 | for(uint32 i = 0; i < blocksX; i++) { 33 | uint32 pixels[16]; 34 | uint32 blockIdx = j*blocksX + i; 35 | rg_etc1::unpack_etc1_block(dcj.InBuf() + blockIdx * 8, pixels); 36 | 37 | uint32 decompWidth = std::min(4U, dcj.Width() - i * 4); 38 | uint32 decompHeight = std::min(4U, dcj.Height() - j * 4); 39 | 40 | for(uint32 y = 0; y < decompHeight; y++) 41 | for(uint32 x = 0; x < decompWidth; x++) { 42 | uint32 *out = reinterpret_cast(dcj.OutBuf()); 43 | out[(j*4 + y)*dcj.Width() + (i*4 + x)] = pixels[y*4 + x]; 44 | } 45 | } 46 | } 47 | } 48 | 49 | } // namespace PVRTCC 50 | -------------------------------------------------------------------------------- /GTest/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /GTest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /GTest/build-aux/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/GTest/build-aux/.keep -------------------------------------------------------------------------------- /GTest/codegear/gtest.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Default.Personality 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /GTest/codegear/gtest_all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // C++Builder's IDE cannot build a static library from files with hyphens 35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 . 36 | // This file serves as a workaround. 37 | 38 | #include "src/gtest-all.cc" 39 | -------------------------------------------------------------------------------- /GTest/codegear/gtest_link.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder. 35 | // This means that these libraries can't be renamed, but it's the only way to 36 | // ensure that Debug versus Release test builds are linked against the 37 | // appropriate Debug or Release build of the libraries. 38 | 39 | #pragma link "gtest.lib" 40 | #pragma link "gtest_main.lib" 41 | -------------------------------------------------------------------------------- /GTest/configure.ac: -------------------------------------------------------------------------------- 1 | m4_include(m4/acx_pthread.m4) 2 | 3 | # At this point, the Xcode project assumes the version string will be three 4 | # integers separated by periods and surrounded by square brackets (e.g. 5 | # "[1.0.1]"). It also asumes that there won't be any closing parenthesis 6 | # between "AC_INIT(" and the closing ")" including comments and strings. 7 | AC_INIT([Google C++ Testing Framework], 8 | [1.7.0], 9 | [googletestframework@googlegroups.com], 10 | [gtest]) 11 | 12 | # Provide various options to initialize the Autoconf and configure processes. 13 | AC_PREREQ([2.59]) 14 | AC_CONFIG_SRCDIR([./LICENSE]) 15 | AC_CONFIG_MACRO_DIR([m4]) 16 | AC_CONFIG_AUX_DIR([build-aux]) 17 | AC_CONFIG_HEADERS([build-aux/config.h]) 18 | AC_CONFIG_FILES([Makefile]) 19 | AC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config]) 20 | 21 | # Initialize Automake with various options. We require at least v1.9, prevent 22 | # pedantic complaints about package files, and enable various distribution 23 | # targets. 24 | AM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects]) 25 | 26 | # Check for programs used in building Google Test. 27 | AC_PROG_CC 28 | AC_PROG_CXX 29 | AC_LANG([C++]) 30 | AC_PROG_LIBTOOL 31 | 32 | # TODO(chandlerc@google.com): Currently we aren't running the Python tests 33 | # against the interpreter detected by AM_PATH_PYTHON, and so we condition 34 | # HAVE_PYTHON by requiring "python" to be in the PATH, and that interpreter's 35 | # version to be >= 2.3. This will allow the scripts to use a "/usr/bin/env" 36 | # hashbang. 37 | PYTHON= # We *do not* allow the user to specify a python interpreter 38 | AC_PATH_PROG([PYTHON],[python],[:]) 39 | AS_IF([test "$PYTHON" != ":"], 40 | [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])]) 41 | AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"]) 42 | 43 | # Configure pthreads. 44 | AC_ARG_WITH([pthreads], 45 | [AS_HELP_STRING([--with-pthreads], 46 | [use pthreads (default is yes)])], 47 | [with_pthreads=$withval], 48 | [with_pthreads=check]) 49 | 50 | have_pthreads=no 51 | AS_IF([test "x$with_pthreads" != "xno"], 52 | [ACX_PTHREAD( 53 | [], 54 | [AS_IF([test "x$with_pthreads" != "xcheck"], 55 | [AC_MSG_FAILURE( 56 | [--with-pthreads was specified, but unable to be used])])]) 57 | have_pthreads="$acx_pthread_ok"]) 58 | AM_CONDITIONAL([HAVE_PTHREADS],[test "x$have_pthreads" = "xyes"]) 59 | AC_SUBST(PTHREAD_CFLAGS) 60 | AC_SUBST(PTHREAD_LIBS) 61 | 62 | # TODO(chandlerc@google.com) Check for the necessary system headers. 63 | 64 | # TODO(chandlerc@google.com) Check the types, structures, and other compiler 65 | # and architecture characteristics. 66 | 67 | # Output the generated files. No further autoconf macros may be used. 68 | AC_OUTPUT 69 | -------------------------------------------------------------------------------- /GTest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /GTest/msvc/gtest-md.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-md", "gtest-md.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main-md", "gtest_main-md.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862033}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test-md", "gtest_prod_test-md.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest-md", "gtest_unittest-md.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32 32 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32 33 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32 34 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32 35 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32 36 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32 37 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32 38 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32 39 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /GTest/msvc/gtest.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32 32 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32 33 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32 34 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32 35 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32 36 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32 37 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32 38 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32 39 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /GTest/samples/sample1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample1.h" 35 | 36 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 37 | int Factorial(int n) { 38 | int result = 1; 39 | for (int i = 1; i <= n; i++) { 40 | result *= i; 41 | } 42 | 43 | return result; 44 | } 45 | 46 | // Returns true iff n is a prime number. 47 | bool IsPrime(int n) { 48 | // Trivial case 1: small numbers 49 | if (n <= 1) return false; 50 | 51 | // Trivial case 2: even numbers 52 | if (n % 2 == 0) return n == 2; 53 | 54 | // Now, we have that n is odd and n >= 3. 55 | 56 | // Try to divide n by every odd number i, starting from 3 57 | for (int i = 3; ; i += 2) { 58 | // We only have to try i up to the squre root of n 59 | if (i > n/i) break; 60 | 61 | // Now, we have i <= n/i < n. 62 | // If n is divisible by i, n is not prime. 63 | if (n % i == 0) return false; 64 | } 65 | 66 | // n has no integer factor in the range (1, n), and thus is prime. 67 | return true; 68 | } 69 | -------------------------------------------------------------------------------- /GTest/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 35 | #define GTEST_SAMPLES_SAMPLE1_H_ 36 | 37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 38 | int Factorial(int n); 39 | 40 | // Returns true iff n is a prime number. 41 | bool IsPrime(int n); 42 | 43 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 44 | -------------------------------------------------------------------------------- /GTest/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample2.h" 35 | 36 | #include 37 | 38 | // Clones a 0-terminated C string, allocating memory using new. 39 | const char* MyString::CloneCString(const char* a_c_string) { 40 | if (a_c_string == NULL) return NULL; 41 | 42 | const size_t len = strlen(a_c_string); 43 | char* const clone = new char[ len + 1 ]; 44 | memcpy(clone, a_c_string, len + 1); 45 | 46 | return clone; 47 | } 48 | 49 | // Sets the 0-terminated C string this MyString object 50 | // represents. 51 | void MyString::Set(const char* a_c_string) { 52 | // Makes sure this works when c_string == c_string_ 53 | const char* const temp = MyString::CloneCString(a_c_string); 54 | delete[] c_string_; 55 | c_string_ = temp; 56 | } 57 | -------------------------------------------------------------------------------- /GTest/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include 35 | 36 | #include "sample4.h" 37 | 38 | // Returns the current counter value, and increments it. 39 | int Counter::Increment() { 40 | return counter_++; 41 | } 42 | 43 | // Prints the current counter value to STDOUT. 44 | void Counter::Print() const { 45 | printf("%d", counter_); 46 | } 47 | -------------------------------------------------------------------------------- /GTest/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_ 35 | #define GTEST_SAMPLES_SAMPLE4_H_ 36 | 37 | // A simple monotonic counter. 38 | class Counter { 39 | private: 40 | int counter_; 41 | 42 | public: 43 | // Creates a counter that starts at 0. 44 | Counter() : counter_(0) {} 45 | 46 | // Returns the current counter value, and increments it. 47 | int Increment(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GTEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /GTest/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | #include "sample4.h" 34 | 35 | // Tests the Increment() method. 36 | TEST(Counter, Increment) { 37 | Counter c; 38 | 39 | // EXPECT_EQ() evaluates its arguments exactly once, so they 40 | // can have side effects. 41 | 42 | EXPECT_EQ(0, c.Increment()); 43 | EXPECT_EQ(1, c.Increment()); 44 | EXPECT_EQ(2, c.Increment()); 45 | } 46 | -------------------------------------------------------------------------------- /GTest/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /GTest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /GTest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /GTest/test/gtest-param-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Authors: vladl@google.com (Vlad Losev) 31 | // 32 | // The Google C++ Testing Framework (Google Test) 33 | // 34 | // This header file provides classes and functions used internally 35 | // for testing Google Test itself. 36 | 37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 39 | 40 | #include "gtest/gtest.h" 41 | 42 | #if GTEST_HAS_PARAM_TEST 43 | 44 | // Test fixture for testing definition and instantiation of a test 45 | // in separate translation units. 46 | class ExternalInstantiationTest : public ::testing::TestWithParam { 47 | }; 48 | 49 | // Test fixture for testing instantiation of a test in multiple 50 | // translation units. 51 | class InstantiationInMultipleTranslaionUnitsTest 52 | : public ::testing::TestWithParam { 53 | }; 54 | 55 | #endif // GTEST_HAS_PARAM_TEST 56 | 57 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 58 | -------------------------------------------------------------------------------- /GTest/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include 33 | 34 | #include "test/gtest-typed-test_test.h" 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | // Tests that the same type-parameterized test case can be 40 | // instantiated in different translation units linked together. 41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest, 43 | testing::Types >); 44 | 45 | #endif // GTEST_HAS_TYPED_TEST_P 46 | -------------------------------------------------------------------------------- /GTest/test/gtest-typed-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 33 | #define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 34 | 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | using testing::Test; 40 | 41 | // For testing that the same type-parameterized test case can be 42 | // instantiated in different translation units linked together. 43 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc 44 | // and gtest-typed-test2_test.cc. 45 | 46 | template 47 | class ContainerTest : public Test { 48 | }; 49 | 50 | TYPED_TEST_CASE_P(ContainerTest); 51 | 52 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { 53 | TypeParam container; 54 | } 55 | 56 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { 57 | TypeParam container; 58 | EXPECT_EQ(0U, container.size()); 59 | } 60 | 61 | REGISTER_TYPED_TEST_CASE_P(ContainerTest, 62 | CanBeDefaultConstructed, InitialSizeIsZero); 63 | 64 | #endif // GTEST_HAS_TYPED_TEST_P 65 | 66 | #endif // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ 67 | -------------------------------------------------------------------------------- /GTest/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build most of Google Test's own tests 35 | // by compiling a single file. This file serves this purpose. 36 | #include "test/gtest-filepath_test.cc" 37 | #include "test/gtest-linked_ptr_test.cc" 38 | #include "test/gtest-message_test.cc" 39 | #include "test/gtest-options_test.cc" 40 | #include "test/gtest-port_test.cc" 41 | #include "test/gtest_pred_impl_unittest.cc" 42 | #include "test/gtest_prod_test.cc" 43 | #include "test/gtest-test-part_test.cc" 44 | #include "test/gtest-typed-test_test.cc" 45 | #include "test/gtest-typed-test2_test.cc" 46 | #include "test/gtest_unittest.cc" 47 | #include "test/production.cc" 48 | -------------------------------------------------------------------------------- /GTest/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // This program is meant to be run by gtest_help_test.py. Do not run 33 | // it directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | // When a help flag is specified, this program should skip the tests 38 | // and exit with 0; otherwise the following test will be executed, 39 | // causing this program to exit with a non-zero code. 40 | TEST(HelpFlagTest, ShouldNotBeRun) { 41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 42 | } 43 | 44 | #if GTEST_HAS_DEATH_TEST 45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 46 | #endif 47 | -------------------------------------------------------------------------------- /GTest/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | // Tests that we don't have to define main() when we link to 35 | // gtest_main instead of gtest. 36 | 37 | namespace { 38 | 39 | TEST(GTestMainTest, ShouldSucceed) { 40 | } 41 | 42 | } // namespace 43 | 44 | // We are using the main() function defined in src/gtest_main.cc, so 45 | // we don't define it here. 46 | -------------------------------------------------------------------------------- /GTest/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | // 33 | // Author: wan@google.com (Zhanyong Wan) 34 | 35 | #include "gtest/gtest.h" 36 | 37 | int main(int argc, char **argv) { 38 | testing::InitGoogleTest(&argc, argv); 39 | 40 | // An ad-hoc assertion outside of all tests. 41 | // 42 | // This serves three purposes: 43 | // 44 | // 1. It verifies that an ad-hoc assertion can be executed even if 45 | // no test is defined. 46 | // 2. It verifies that a failed ad-hoc assertion causes the test 47 | // program to fail. 48 | // 3. We had a bug where the XML output won't be generated if an 49 | // assertion is executed before RUN_ALL_TESTS() is called, even 50 | // though --gtest_output=xml is specified. This makes sure the 51 | // bug is fixed and doesn't regress. 52 | EXPECT_EQ(1, 2); 53 | 54 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 55 | return RUN_ALL_TESTS() ? 0 : 1; 56 | } 57 | -------------------------------------------------------------------------------- /GTest/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "gtest/gtest.h" 35 | #include "test/production.h" 36 | 37 | // Tests that private members can be accessed from a TEST declared as 38 | // a friend of the class. 39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 40 | PrivateCode a; 41 | EXPECT_EQ(0, a.x_); 42 | 43 | a.set_x(1); 44 | EXPECT_EQ(1, a.x_); 45 | } 46 | 47 | typedef testing::Test PrivateCodeFixtureTest; 48 | 49 | // Tests that private members can be accessed from a TEST_F declared 50 | // as a friend of the class. 51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 52 | PrivateCode a; 53 | EXPECT_EQ(0, a.x_); 54 | 55 | a.set_x(2); 56 | EXPECT_EQ(2, a.x_); 57 | } 58 | -------------------------------------------------------------------------------- /GTest/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // This test verifies that it's possible to use Google Test by including 33 | // the gtest.h header file alone. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | void Subroutine() { 40 | EXPECT_EQ(42, 42); 41 | } 42 | 43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 44 | EXPECT_NO_FATAL_FAILURE(;); 45 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 46 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 48 | } 49 | 50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 51 | ASSERT_NO_FATAL_FAILURE(;); 52 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 53 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 55 | } 56 | 57 | } // namespace 58 | -------------------------------------------------------------------------------- /GTest/test/gtest_test_utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/GTest/test/gtest_test_utils.pyc -------------------------------------------------------------------------------- /GTest/test/gtest_uninitialized_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """Verifies that Google Test warns the user when not initialized properly.""" 33 | 34 | __author__ = 'wan@google.com (Zhanyong Wan)' 35 | 36 | import gtest_test_utils 37 | 38 | 39 | COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_') 40 | 41 | 42 | def Assert(condition): 43 | if not condition: 44 | raise AssertionError 45 | 46 | 47 | def AssertEq(expected, actual): 48 | if expected != actual: 49 | print 'Expected: %s' % (expected,) 50 | print ' Actual: %s' % (actual,) 51 | raise AssertionError 52 | 53 | 54 | def TestExitCodeAndOutput(command): 55 | """Runs the given command and verifies its exit code and output.""" 56 | 57 | # Verifies that 'command' exits with code 1. 58 | p = gtest_test_utils.Subprocess(command) 59 | Assert(p.exited) 60 | AssertEq(1, p.exit_code) 61 | Assert('InitGoogleTest' in p.output) 62 | 63 | 64 | class GTestUninitializedTest(gtest_test_utils.TestCase): 65 | def testExitCodeAndOutput(self): 66 | TestExitCodeAndOutput(COMMAND) 67 | 68 | 69 | if __name__ == '__main__': 70 | gtest_test_utils.Main() 71 | -------------------------------------------------------------------------------- /GTest/test/gtest_uninitialized_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | TEST(DummyTest, Dummy) { 35 | // This test doesn't verify anything. We just need it to create a 36 | // realistic stage for testing the behavior of Google Test when 37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being 38 | // called first. 39 | } 40 | 41 | int main() { 42 | return RUN_ALL_TESTS(); 43 | } 44 | -------------------------------------------------------------------------------- /GTest/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyOne : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 1); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 1); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyOne, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 1); 49 | } 50 | -------------------------------------------------------------------------------- /GTest/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyTwo : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 2); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 2); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyTwo, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 2); 49 | } 50 | -------------------------------------------------------------------------------- /GTest/test/gtest_xml_test_utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/GTest/test/gtest_xml_test_utils.pyc -------------------------------------------------------------------------------- /GTest/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "production.h" 35 | 36 | PrivateCode::PrivateCode() : x_(0) {} 37 | -------------------------------------------------------------------------------- /GTest/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #ifndef GTEST_TEST_PRODUCTION_H_ 35 | #define GTEST_TEST_PRODUCTION_H_ 36 | 37 | #include "gtest/gtest_prod.h" 38 | 39 | class PrivateCode { 40 | public: 41 | // Declares a friend test that does not use a fixture. 42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 43 | 44 | // Declares a friend test that uses a fixture. 45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 46 | 47 | PrivateCode(); 48 | 49 | int x() const { return x_; } 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GTEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /GTest/xcode/Config/DebugProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // DebugProject.xcconfig 3 | // 4 | // These are Debug Configuration project settings for the gtest framework and 5 | // examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // No optimization 14 | GCC_OPTIMIZATION_LEVEL = 0 15 | 16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off 17 | DEPLOYMENT_POSTPROCESSING = NO 18 | 19 | // Dead code stripping off 20 | DEAD_CODE_STRIPPING = NO 21 | 22 | // Debug symbols should be on obviously 23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 24 | 25 | // Define the DEBUG macro in all debug builds 26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1 27 | 28 | // These are turned off to avoid STL incompatibilities with client code 29 | // // Turns on special C++ STL checks to "encourage" good STL use 30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS 31 | -------------------------------------------------------------------------------- /GTest/xcode/Config/FrameworkTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // FrameworkTarget.xcconfig 3 | // 4 | // These are Framework target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Dynamic libs need to be position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Dynamic libs should not have their external symbols stripped. 14 | STRIP_STYLE = non-global 15 | 16 | // Let the user install by specifying the $DSTROOT with xcodebuild 17 | SKIP_INSTALL = NO 18 | -------------------------------------------------------------------------------- /GTest/xcode/Config/General.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // General.xcconfig 3 | // 4 | // These are General configuration settings for the gtest framework and 5 | // examples. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Build for PPC and Intel, 32- and 64-bit 11 | ARCHS = i386 x86_64 ppc ppc64 12 | 13 | // Zerolink prevents link warnings so turn it off 14 | ZERO_LINK = NO 15 | 16 | // Prebinding considered unhelpful in 10.3 and later 17 | PREBINDING = NO 18 | 19 | // Strictest warning policy 20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow 21 | 22 | // Work around Xcode bugs by using external strip. See: 23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html 24 | SEPARATE_STRIP = YES 25 | 26 | // Force C99 dialect 27 | GCC_C_LANGUAGE_STANDARD = c99 28 | 29 | // not sure why apple defaults this on, but it's pretty risky 30 | ALWAYS_SEARCH_USER_PATHS = NO 31 | 32 | // Turn on position dependent code for most cases (overridden where appropriate) 33 | GCC_DYNAMIC_NO_PIC = YES 34 | 35 | // Default SDK and minimum OS version is 10.4 36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk 37 | MACOSX_DEPLOYMENT_TARGET = 10.4 38 | GCC_VERSION = 4.0 39 | 40 | // VERSIONING BUILD SETTINGS (used in Info.plist) 41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc. 42 | -------------------------------------------------------------------------------- /GTest/xcode/Config/ReleaseProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // ReleaseProject.xcconfig 3 | // 4 | // These are Release Configuration project settings for the gtest framework 5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // subconfig/Release.xcconfig 14 | 15 | // Optimize for space and size (Apple recommendation) 16 | GCC_OPTIMIZATION_LEVEL = s 17 | 18 | // Deploment postprocessing is what triggers Xcode to strip 19 | DEPLOYMENT_POSTPROCESSING = YES 20 | 21 | // No symbols 22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO 23 | 24 | // Dead code strip does not affect ObjC code but can help for C 25 | DEAD_CODE_STRIPPING = YES 26 | 27 | // NDEBUG is used by things like assert.h, so define it for general compat. 28 | // ASSERT going away in release tends to create unused vars. 29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable 30 | 31 | // When we strip we want to strip all symbols in release, but save externals. 32 | STRIP_STYLE = all 33 | -------------------------------------------------------------------------------- /GTest/xcode/Config/StaticLibraryTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // StaticLibraryTarget.xcconfig 3 | // 4 | // These are static library target settings for libgtest.a. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Static libs can be included in bundles so make them position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Static libs should not have their internal globals or external symbols 14 | // stripped. 15 | STRIP_STYLE = debugging 16 | 17 | // Let the user install by specifying the $DSTROOT with xcodebuild 18 | SKIP_INSTALL = NO 19 | -------------------------------------------------------------------------------- /GTest/xcode/Config/TestTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // TestTarget.xcconfig 3 | // 4 | // These are Test target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | 7 | PRODUCT_NAME = $(TARGET_NAME) 8 | HEADER_SEARCH_PATHS = ../include 9 | -------------------------------------------------------------------------------- /GTest/xcode/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.${PRODUCT_NAME} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | GTEST_VERSIONINFO_LONG 21 | CFBundleShortVersionString 22 | GTEST_VERSIONINFO_SHORT 23 | CFBundleGetInfoString 24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT} 25 | NSHumanReadableCopyright 26 | ${GTEST_VERSIONINFO_ABOUT} 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /GTest/xcode/Samples/FrameworkSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.gtest.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /GTest/xcode/Samples/FrameworkSample/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=$@ 40 | 41 | # Now execute each one in turn keeping track of how many succeeded and failed. 42 | succeeded=0 43 | failed=0 44 | failed_list=() 45 | for test in ${test_executables[*]}; do 46 | "$test" 47 | result=$? 48 | if [ $result -eq 0 ]; then 49 | succeeded=$(( $succeeded + 1 )) 50 | else 51 | failed=$(( failed + 1 )) 52 | failed_list="$failed_list $test" 53 | fi 54 | done 55 | 56 | # Report the successes and failures to the console. 57 | echo "Tests complete with $succeeded successes and $failed failures." 58 | if [ $failed -ne 0 ]; then 59 | echo "The following tests failed:" 60 | echo $failed_list 61 | fi 62 | exit $failed 63 | -------------------------------------------------------------------------------- /GTest/xcode/Samples/FrameworkSample/widget.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.cc 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest 37 | 38 | #include "widget.h" 39 | 40 | Widget::Widget(int number, const std::string& name) 41 | : number_(number), 42 | name_(name) {} 43 | 44 | Widget::~Widget() {} 45 | 46 | float Widget::GetFloatValue() const { 47 | return number_; 48 | } 49 | 50 | int Widget::GetIntValue() const { 51 | return static_cast(number_); 52 | } 53 | 54 | std::string Widget::GetStringValue() const { 55 | return name_; 56 | } 57 | 58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const { 59 | // Copy the char* representation of name_ into buffer, up to max_size. 60 | strncpy(buffer, name_.c_str(), max_size-1); 61 | buffer[max_size-1] = '\0'; 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /GTest/xcode/Samples/FrameworkSample/widget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.h 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest. It 37 | // simply stores two values a string and an integer, which are returned via 38 | // public accessors in multiple forms. 39 | 40 | #import 41 | 42 | class Widget { 43 | public: 44 | Widget(int number, const std::string& name); 45 | ~Widget(); 46 | 47 | // Public accessors to number data 48 | float GetFloatValue() const; 49 | int GetIntValue() const; 50 | 51 | // Public accessors to the string data 52 | std::string GetStringValue() const; 53 | void GetCharPtrValue(char* buffer, size_t max_size) const; 54 | 55 | private: 56 | // Data members 57 | float number_; 58 | std::string name_; 59 | }; 60 | -------------------------------------------------------------------------------- /GTest/xcode/Scripts/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=("$BUILT_PRODUCTS_DIR/gtest_unittest-framework" 40 | "$BUILT_PRODUCTS_DIR/gtest_unittest" 41 | "$BUILT_PRODUCTS_DIR/sample1_unittest-framework" 42 | "$BUILT_PRODUCTS_DIR/sample1_unittest-static") 43 | 44 | # Now execute each one in turn keeping track of how many succeeded and failed. 45 | succeeded=0 46 | failed=0 47 | failed_list=() 48 | for test in ${test_executables[*]}; do 49 | "$test" 50 | result=$? 51 | if [ $result -eq 0 ]; then 52 | succeeded=$(( $succeeded + 1 )) 53 | else 54 | failed=$(( failed + 1 )) 55 | failed_list="$failed_list $test" 56 | fi 57 | done 58 | 59 | # Report the successes and failures to the console. 60 | echo "Tests complete with $succeeded successes and $failed failures." 61 | if [ $failed -ne 0 ]; then 62 | echo "The following tests failed:" 63 | echo $failed_list 64 | fi 65 | exit $failed 66 | -------------------------------------------------------------------------------- /IO/config/ImageWriter.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_WRITER_H_ 19 | #define _IMAGE_WRITER_H_ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | #include "FasTC/ImageFileFormat.h" 23 | 24 | namespace FasTC { 25 | class Pixel; 26 | } 27 | 28 | class ImageWriter { 29 | 30 | protected: 31 | 32 | const FasTC::Pixel *m_Pixels; 33 | uint32 m_RawFileDataSz; 34 | uint8 *m_RawFileData; 35 | 36 | uint32 m_Width; 37 | uint32 m_Height; 38 | 39 | ImageWriter(const int width, const int height, const FasTC::Pixel *rawData) 40 | : m_Pixels(rawData) 41 | , m_RawFileDataSz(256) 42 | , m_RawFileData(new uint8[m_RawFileDataSz]) 43 | , m_Width(width), m_Height(height) 44 | { } 45 | 46 | uint32 GetChannelForPixel(uint32 x, uint32 y, uint32 ch); 47 | 48 | public: 49 | virtual ~ImageWriter() { 50 | if(m_RawFileData) { 51 | delete [] m_RawFileData; 52 | m_RawFileData = 0; 53 | } 54 | } 55 | 56 | uint32 GetWidth() const { return m_Width; } 57 | uint32 GetHeight() const { return m_Height; } 58 | uint32 GetImageDataSz() const { return m_Width * m_Height * sizeof(uint32); } 59 | uint32 GetRawFileDataSz() const { return m_RawFileDataSz; } 60 | uint8 *GetRawFileData() const { return m_RawFileData; } 61 | virtual bool WriteImage() = 0; 62 | }; 63 | 64 | #ifndef PNG_FOUND 65 | #cmakedefine PNG_FOUND 66 | #endif // PNG_FOUND 67 | 68 | #ifndef PVRTEXLIB_FOUND 69 | #cmakedefine PVRTEXLIB_FOUND 70 | #endif // PVRTEXLIB_FOUND 71 | 72 | #ifndef OPENGL_FOUND 73 | #cmakedefine OPENGL_FOUND 74 | #endif // OPENGL_FOUND 75 | 76 | #endif // _IMAGE_LOADER_H_ 77 | -------------------------------------------------------------------------------- /IO/include/FasTC/FileStream.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef __FILE_STREAM_H__ 19 | #define __FILE_STREAM_H__ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | 23 | enum EFileMode { 24 | eFileMode_Read, 25 | eFileMode_ReadBinary, 26 | eFileMode_Write, 27 | eFileMode_WriteBinary, 28 | eFileMode_WriteAppend, 29 | eFileMode_WriteBinaryAppend, 30 | 31 | kNumFileModes 32 | }; 33 | 34 | class FileStreamImpl; 35 | class FileStream { 36 | 37 | public: 38 | FileStream(const CHAR *filename, EFileMode mode); 39 | FileStream(const FileStream &); 40 | FileStream &operator=(const FileStream &); 41 | ~FileStream(); 42 | 43 | // Read the contents of the file into the specified buffer. This 44 | // function returns the number of bytes read on success. It returns 45 | // -2 if the file was opened with an incompatible mode and -1 on 46 | // platform specific error. 47 | int32 Read(uint8 *buf, uint32 bufSz); 48 | 49 | // Write the contents of buf to the filestream. This function returns 50 | // the number of bytes written on success. It returns -2 if the file 51 | // was opened with an incompatible mode and -1 on platform specific 52 | // error. 53 | int32 Write(const uint8 *buf, uint32 bufSz); 54 | 55 | // Returns where in the filestream we are. Returns -1 on error. 56 | int32 Tell(); 57 | 58 | enum ESeekPosition { 59 | eSeekPosition_Beginning, 60 | eSeekPosition_Current, 61 | eSeekPosition_End 62 | }; 63 | 64 | // Repositions the stream to the specified offset away from the 65 | // position in the stream. This function will always fail if the 66 | // file mode is append. Otherwise, it returns true on success. 67 | bool Seek(uint32 offset, ESeekPosition pos); 68 | 69 | // Flush the data of the stream. This function is platform specific. 70 | void Flush(); 71 | 72 | const CHAR *GetFilename() const { return m_Filename; } 73 | 74 | private: 75 | 76 | // Platform specific implementation 77 | FileStreamImpl *m_Impl; 78 | 79 | EFileMode m_Mode; 80 | 81 | static const uint32 kMaxFilenameSz = 256; 82 | CHAR m_Filename[kMaxFilenameSz]; 83 | }; 84 | 85 | #endif // __FILE_STREAM_H__ 86 | -------------------------------------------------------------------------------- /IO/include/FasTC/ImageFile.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_FILE_H_ 19 | #define _IMAGE_FILE_H_ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | #include "FasTC/ImageFwd.h" 23 | 24 | #include "ImageFileFormat.h" 25 | 26 | // Forward declare 27 | class CompressedImage; 28 | struct SCompressionSettings; 29 | 30 | // Class definition 31 | class ImageFile { 32 | 33 | public: 34 | 35 | // Opens and loads an image file from the given path. The file format 36 | // is inferred from the filename. 37 | ImageFile(const char *filename); 38 | 39 | // Opens and loads a given image file with the passed format. 40 | ImageFile(const char *filename, EImageFileFormat format); 41 | 42 | // Creates an imagefile with the corresponding image data. This is ready 43 | // to be written to disk with the passed filename. 44 | ImageFile(const char *filename, EImageFileFormat format, const FasTC::Image<> &); 45 | 46 | ~ImageFile(); 47 | 48 | static EImageFileFormat DetectFileFormat(const CHAR *filename); 49 | unsigned int GetWidth() const { return m_Width; } 50 | unsigned int GetHeight() const { return m_Height; } 51 | FasTC::Image<> *GetImage() const { return m_Image; } 52 | 53 | // Loads the image into memory. If this function returns true, then a valid 54 | // m_Image will be created and available. 55 | bool Load(); 56 | 57 | // Writes the given image to disk. Returns true on success. 58 | bool Write(); 59 | 60 | private: 61 | 62 | static const unsigned int kMaxFilenameSz = 256; 63 | char m_Filename[kMaxFilenameSz]; 64 | unsigned int m_Width; 65 | unsigned int m_Height; 66 | 67 | const EImageFileFormat m_FileFormat; 68 | 69 | uint8 *m_FileData; 70 | int32 m_FileDataSz; 71 | 72 | FasTC::Image<> *m_Image; 73 | 74 | bool ReadFileData(const CHAR *filename); 75 | static bool WriteImageDataToFile(const uint8 *data, const uint32 dataSz, const CHAR *filename); 76 | 77 | FasTC::Image<> *LoadImage() const; 78 | }; 79 | #endif // _IMAGE_FILE_H_ 80 | -------------------------------------------------------------------------------- /IO/include/FasTC/ImageFileFormat.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_FILE_FORMAT_H_ 19 | #define _IMAGE_FILE_FORMAT_H_ 20 | 21 | enum EImageFileFormat { 22 | eFileFormat_PNG, 23 | eFileFormat_PVR, 24 | eFileFormat_TGA, 25 | eFileFormat_KTX, 26 | eFileFormat_ASTC, 27 | 28 | kNumImageFileFormats 29 | }; 30 | 31 | #endif // _IMAGE_FILE_FORMAT_H_ 32 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderASTC.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IO_SRC_IMAGE_LOADER_ASTC_H_ 19 | #define _IO_SRC_IMAGE_LOADER_ASTC_H_ 20 | 21 | #include "FasTC/ImageLoader.h" 22 | 23 | class ImageLoaderASTC : public ImageLoader { 24 | private: 25 | uint8 m_BlockSizeX; 26 | uint8 m_BlockSizeY; 27 | public: 28 | ImageLoaderASTC(const uint8 *rawData, const int32 rawDataSz); 29 | virtual ~ImageLoaderASTC(); 30 | 31 | virtual bool ReadData(); 32 | virtual FasTC::Image<> *LoadImage(); 33 | }; 34 | 35 | #endif // _IO_SRC_IMAGE_LOADER_ASTC_H_ 36 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderKTX.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IO_SRC_IMAGE_LOADER_KTX_H_ 19 | #define _IO_SRC_IMAGE_LOADER_KTX_H_ 20 | 21 | #include "FasTC/ImageLoader.h" 22 | #include "FasTC/CompressionFormat.h" 23 | 24 | class ImageLoaderKTX : public ImageLoader { 25 | public: 26 | typedef void (*KTXKeyValueProcessor)(const char *key, const char *value); 27 | 28 | ImageLoaderKTX(const uint8 *rawData, const int32 rawDataSz); 29 | virtual ~ImageLoaderKTX(); 30 | 31 | virtual bool ReadData(); 32 | 33 | void SetProcessor(KTXKeyValueProcessor proc) { 34 | m_Processor = proc; 35 | } 36 | 37 | virtual FasTC::Image<> *LoadImage(); 38 | private: 39 | KTXKeyValueProcessor m_Processor; 40 | 41 | bool m_bIsCompressed; 42 | FasTC::ECompressionFormat m_Format; 43 | }; 44 | 45 | #endif // _IO_SRC_IMAGE_LOADER_KTX_H_ 46 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderPNG.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_LOADER_PNG_H_ 19 | #define _IMAGE_LOADER_PNG_H_ 20 | 21 | #include "FasTC/ImageLoader.h" 22 | 23 | class ImageLoaderPNG : public ImageLoader { 24 | public: 25 | ImageLoaderPNG(const unsigned char *rawData); 26 | virtual ~ImageLoaderPNG() { } 27 | 28 | virtual bool ReadData(); 29 | 30 | private: 31 | uint64 m_StreamPosition; 32 | friend class PNGStreamReader; 33 | }; 34 | 35 | #endif // _IMAGE_LOADER_H_ 36 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderPVR.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "ImageLoaderPVR.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "FasTC/TexCompTypes.h" 26 | 27 | #include "PVRTextureUtilities.h" 28 | 29 | static void ReportError(const char *msg) { 30 | fprintf(stderr, "ERROR: ImageLoaderPVR -- %s\n", msg); 31 | } 32 | 33 | ImageLoaderPVR::ImageLoaderPVR(const unsigned char *rawData) 34 | : ImageLoader(rawData) 35 | { 36 | } 37 | 38 | ImageLoaderPVR::~ImageLoaderPVR() { 39 | } 40 | 41 | bool ImageLoaderPVR::ReadData() { 42 | pvrtexture::CPVRTexture pvrTex((const void *)m_RawData); 43 | if(!pvrtexture::Transcode(pvrTex, 44 | pvrtexture::PVRStandard8PixelType, 45 | ePVRTVarTypeUnsignedByte, 46 | ePVRTCSpacelRGB)) { 47 | ReportError("Unable to convert PVRTexture... possibly failed to load file"); 48 | return false; 49 | } 50 | 51 | const pvrtexture::CPVRTextureHeader &hdr = pvrTex.getHeader(); 52 | 53 | m_Width = hdr.getWidth(); 54 | m_Height = hdr.getHeight(); 55 | 56 | return LoadFromPixelBuffer(reinterpret_cast(pvrTex.getDataPtr())); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderPVR.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_LOADER_PVR_H_ 19 | #define _IMAGE_LOADER_PVR_H_ 20 | 21 | #include "FasTC/ImageLoader.h" 22 | 23 | class ImageLoaderPVR : public ImageLoader { 24 | public: 25 | ImageLoaderPVR(const unsigned char *rawData); 26 | virtual ~ImageLoaderPVR(); 27 | 28 | virtual bool ReadData(); 29 | }; 30 | 31 | #endif // _IMAGE_LOADER_PVR_H_ 32 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderTGA.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "ImageLoaderTGA.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "FasTC/TexCompTypes.h" 26 | 27 | #include "targa.h" 28 | 29 | ImageLoaderTGA::ImageLoaderTGA(const uint8 *rawData, const int32 rawDataSz) 30 | : ImageLoader(rawData, rawDataSz) 31 | { } 32 | 33 | ImageLoaderTGA::~ImageLoaderTGA() { } 34 | 35 | bool ImageLoaderTGA::ReadData() { 36 | Targa tga; 37 | if (targa_loadFromData(&tga, m_RawData, m_NumRawDataBytes) < 0) { 38 | return false; 39 | } 40 | 41 | m_Width = tga.width; 42 | m_Height = tga.height; 43 | 44 | assert(static_cast(tga.imageLength) == m_Width * m_Height * 4); 45 | 46 | return LoadFromPixelBuffer(reinterpret_cast(tga.image), true); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /IO/src/ImageLoaderTGA.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef IO_SRC_IMAGELOADERTGA_H_ 19 | #define IO_SRC_IMAGELOADERTGA_H_ 20 | 21 | #include "FasTC/ImageLoader.h" 22 | 23 | class ImageLoaderTGA : public ImageLoader { 24 | public: 25 | ImageLoaderTGA(const uint8 *rawData, const int32 rawDataSz); 26 | virtual ~ImageLoaderTGA(); 27 | 28 | virtual bool ReadData(); 29 | }; 30 | 31 | #endif // IO_SRC_IMAGELOADERTGA_H_ 32 | -------------------------------------------------------------------------------- /IO/src/ImageWriter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "FasTC/ImageWriter.h" 19 | #include "FasTC/Pixel.h" 20 | 21 | uint32 ImageWriter::GetChannelForPixel(uint32 x, uint32 y, uint32 ch) { 22 | return m_Pixels[y * GetWidth() + x].Component((ch+1) % 4); 23 | } 24 | -------------------------------------------------------------------------------- /IO/src/ImageWriterKTX.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_WRITER_KTX_H_ 19 | #define _IMAGE_WRITER_KTX_H_ 20 | 21 | #include "FasTC/ImageWriter.h" 22 | #include "FasTC/ImageFwd.h" 23 | 24 | // Forward Declare 25 | class ImageWriterKTX : public ImageWriter { 26 | public: 27 | ImageWriterKTX(FasTC::Image<> &); 28 | virtual ~ImageWriterKTX() { } 29 | 30 | virtual bool WriteImage(); 31 | 32 | private: 33 | FasTC::Image<> &m_Image; 34 | }; 35 | 36 | #endif // _IMAGE_LOADER_H_ 37 | -------------------------------------------------------------------------------- /IO/src/ImageWriterPNG.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef _IMAGE_WRITER_PNG_H_ 19 | #define _IMAGE_WRITER_PNG_H_ 20 | 21 | #include "FasTC/ImageWriter.h" 22 | #include "FasTC/ImageFwd.h" 23 | 24 | // Forward Declare 25 | class ImageWriterPNG : public ImageWriter { 26 | public: 27 | ImageWriterPNG(FasTC::Image<> &); 28 | virtual ~ImageWriterPNG() { } 29 | 30 | virtual bool WriteImage(); 31 | private: 32 | uint32 m_StreamPosition; 33 | friend class PNGStreamWriter; 34 | }; 35 | 36 | #endif // _IMAGE_LOADER_H_ 37 | -------------------------------------------------------------------------------- /PVRTCEncoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The University of North Carolina at Chapel Hill 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Please send all BUG REPORTS to . 16 | # 17 | 18 | SET( LIBRARY_HEADERS 19 | "include/FasTC/PVRTCCompressor.h" 20 | ) 21 | 22 | SET( HEADERS 23 | ${LIBRARY_HEADERS} 24 | src/Block.h 25 | src/PVRTCImage.h 26 | src/Indexer.h 27 | ) 28 | 29 | SET( SOURCES 30 | src/Compressor.cpp 31 | src/Decompressor.cpp 32 | src/Block.cpp 33 | src/PVRTCImage.cpp 34 | ) 35 | 36 | OPTION(DEBUG_PVRTC_DECODER "Output intermediate images during PVRTC decoding." OFF) 37 | 38 | CONFIGURE_FILE( 39 | "config/PVRTCDefines.h.in" 40 | "include/FasTC/PVRTCDefines.h" 41 | ) 42 | 43 | IF( PVRTEXLIB_FOUND ) 44 | INCLUDE_DIRECTORIES( ${PVRTEXLIB_INCLUDE_DIRS} ) 45 | SET( SOURCES 46 | ${SOURCES} 47 | src/CompressorPVRLib.cpp 48 | ) 49 | ENDIF() 50 | 51 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/PVRTCEncoder/include) 52 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/PVRTCEncoder/include) 53 | INCLUDE_DIRECTORIES(${FasTC_SOURCE_DIR}/Base/include) 54 | INCLUDE_DIRECTORIES(${FasTC_BINARY_DIR}/Base/include) 55 | 56 | ADD_LIBRARY( PVRTCEncoder 57 | ${HEADERS} 58 | ${SOURCES} 59 | ) 60 | 61 | INSTALL(TARGETS PVRTCEncoder EXPORT FasTCTargets ARCHIVE DESTINATION lib COMPONENT lib) 62 | INSTALL( 63 | FILES ${LIBRARY_HEADERS} "${FasTC_BINARY_DIR}/PVRTCEncoder/include/FasTC/PVRTCDefines.h" 64 | DESTINATION ${INCLUDE_INSTALL_DIR}/FasTC 65 | COMPONENT dev) 66 | 67 | TARGET_LINK_LIBRARIES( PVRTCEncoder FasTCBase ) 68 | IF( DEBUG_PVRTC_DECODER ) 69 | TARGET_LINK_LIBRARIES( PVRTCEncoder FasTCIO ) 70 | ENDIF( DEBUG_PVRTC_DECODER ) 71 | 72 | IF( PVRTEXLIB_FOUND ) 73 | TARGET_LINK_LIBRARIES( PVRTCEncoder ${PVRTEXLIB_LIBRARIES} ) 74 | ENDIF( PVRTEXLIB_FOUND ) 75 | -------------------------------------------------------------------------------- /PVRTCEncoder/config/PVRTCDefines.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #cmakedefine PVRTEXLIB_FOUND 19 | #cmakedefine DEBUG_PVRTC_DECODER 20 | -------------------------------------------------------------------------------- /PVRTCEncoder/include/FasTC/PVRTCCompressor.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef PVRTCENCODER_INCLUDE_PVRTCCOMPRESSOR_H_ 19 | #define PVRTCENCODER_INCLUDE_PVRTCCOMPRESSOR_H_ 20 | 21 | #include "FasTC/CompressionJob.h" 22 | #include "FasTC/PVRTCDefines.h" 23 | 24 | namespace PVRTCC { 25 | 26 | // PVRTC works by bilinearly interpolating between blocks in order to 27 | // compress and decompress data. As such, the wrap mode defines how the 28 | // texture behaves at the boundaries. 29 | enum EWrapMode { 30 | eWrapMode_Clamp, // Block endpoints are clamped at boundaries 31 | eWrapMode_Wrap, // Block endpoints wrap around at boundaries 32 | }; 33 | 34 | // Takes a stream of compressed PVRTC data and decompresses it into R8G8B8A8 35 | // format. The width and height must be specified in order to properly 36 | // decompress the data. 37 | void Decompress(const FasTC::DecompressionJob &, 38 | const EWrapMode wrapMode = eWrapMode_Wrap, 39 | bool bDebugImages = false); 40 | 41 | // Takes a stream of uncompressed RGBA8 data and compresses it into PVRTC 42 | // version one. The width and height must be specified in order to properly 43 | // decompress the data. 44 | void Compress(const FasTC::CompressionJob &, 45 | const EWrapMode wrapMode = eWrapMode_Wrap); 46 | 47 | #ifdef PVRTEXLIB_FOUND 48 | void CompressPVRLib(const FasTC::CompressionJob &, 49 | bool bTwoBitMode = false, 50 | const EWrapMode wrapMode = eWrapMode_Wrap); 51 | #endif 52 | 53 | static const uint32 kBlockSize = sizeof(uint64); 54 | 55 | } // namespace PVRTCC 56 | 57 | #endif // PVRTCENCODER_INCLUDE_PVRTCCOMPRESSOR_H_ 58 | -------------------------------------------------------------------------------- /PVRTCEncoder/src/CompressorPVRLib.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | // Our library include... 19 | #include "FasTC/PVRTCCompressor.h" 20 | 21 | // PVRLib library include... 22 | #include "PVRTextureUtilities.h" 23 | 24 | #include 25 | 26 | namespace PVRTCC { 27 | 28 | void CompressPVRLib(const FasTC::CompressionJob &cj, 29 | bool bTwoBitMode, 30 | const EWrapMode) { 31 | pvrtexture::CPVRTextureHeader pvrTexHdr; 32 | pvrTexHdr.setPixelFormat(pvrtexture::PVRStandard8PixelType); 33 | pvrTexHdr.setWidth(cj.Width()); 34 | pvrTexHdr.setHeight(cj.Height()); 35 | pvrTexHdr.setIsFileCompressed(false); 36 | pvrTexHdr.setIsPreMultiplied(false); 37 | 38 | pvrtexture::CPVRTexture pvrTex = pvrtexture::CPVRTexture(pvrTexHdr, cj.InBuf()); 39 | bool result = pvrtexture::Transcode(pvrTex, 40 | ePVRTPF_PVRTCI_4bpp_RGBA, 41 | ePVRTVarTypeUnsignedByte, 42 | ePVRTCSpacelRGB, 43 | pvrtexture::ePVRTCFast); 44 | assert(result); 45 | (void)result; 46 | 47 | memcpy(cj.OutBuf(), static_cast(pvrTex.getDataPtr()), cj.Width() * cj.Height() / 2); 48 | } 49 | 50 | } // namespace PVRTCC 51 | -------------------------------------------------------------------------------- /PVRTCEncoder/src/Indexer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef PVRTCENCODER_SRC_INDEXER_H_ 19 | #define PVRTCENCODER_SRC_INDEXER_H_ 20 | 21 | #include "FasTC/PVRTCCompressor.h" 22 | 23 | #include 24 | #include 25 | 26 | namespace PVRTCC { 27 | 28 | class Indexer { 29 | private: 30 | const EWrapMode m_WrapMode; 31 | const uint32 m_Width; 32 | const uint32 m_Height; 33 | 34 | uint32 Resolve(int32 i, uint32 limit) const { 35 | int32 l = static_cast(limit); 36 | 37 | // Assumptions 38 | assert(i > -l); 39 | assert(i < 2*l); 40 | 41 | int32 r = -1; 42 | switch(m_WrapMode) { 43 | case eWrapMode_Clamp: 44 | r = static_cast(std::max(0, std::min(i, l-1))); 45 | break; 46 | 47 | case eWrapMode_Wrap: 48 | { 49 | r = i; 50 | if ((l & (l-1)) == 0) { 51 | r = (r + l) & (l - 1); 52 | } else { 53 | if (r >= l) { r -= l; } 54 | if (r < 0) { r += l; } 55 | } 56 | } 57 | break; 58 | } 59 | 60 | assert (r >= 0); 61 | assert (r < static_cast(limit)); 62 | return r; 63 | } 64 | 65 | public: 66 | Indexer(uint32 width, uint32 height, EWrapMode wrapMode = eWrapMode_Wrap) 67 | : m_WrapMode(wrapMode) 68 | , m_Width(width) 69 | , m_Height(height) 70 | { } 71 | 72 | uint32 GetWidth() const { return this->m_Width; } 73 | uint32 GetHeight() const { return this->m_Height; } 74 | EWrapMode GetWrapMode() const { return this->m_WrapMode; } 75 | 76 | uint32 ResolveX(int32 i) const { return Resolve(i, this->m_Width); } 77 | uint32 ResolveY(int32 i) const { return Resolve(i, this->m_Height); } 78 | 79 | uint32 operator()(int32 i, int32 j) const { 80 | uint32 _i = this->ResolveX(i); 81 | uint32 _j = this->ResolveY(j); 82 | 83 | uint32 index = _j * this->m_Width + _i; 84 | assert (index < this->m_Width * this->m_Height); 85 | return index; 86 | } 87 | }; 88 | 89 | } // namespace PVRTCC 90 | 91 | #endif // PVRTCENCODER_SRC_INDEXER_H_ 92 | -------------------------------------------------------------------------------- /PVRTCEncoder/src/PVRTCImage.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef PVRTCENCODER_SRC_IMAGE_H_ 19 | #define PVRTCENCODER_SRC_IMAGE_H_ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | #include "FasTC/Image.h" 23 | 24 | #include "FasTC/PVRTCCompressor.h" 25 | 26 | #include 27 | 28 | // Forward include 29 | namespace FasTC { 30 | class Pixel; 31 | } 32 | 33 | namespace PVRTCC { 34 | 35 | class Image : public FasTC::Image { 36 | public: 37 | Image(uint32 width, uint32 height); 38 | Image(uint32 width, uint32 height, const FasTC::Pixel *pixels); 39 | Image(const Image &); 40 | Image &operator=(const Image &); 41 | virtual ~Image(); 42 | void BilinearUpscale(uint32 xtimes, uint32 ytimes, 43 | EWrapMode wrapMode = eWrapMode_Wrap); 44 | 45 | // Downscales the image by taking an anisotropic diffusion approach 46 | // with respect to the gradient of the intensity. In this way, we can 47 | // preserve the most important image structures by not blurring across 48 | // edge boundaries, which when upscaled will retain the structural 49 | // image quality... 50 | void ContentAwareDownscale(uint32 xtimes, uint32 ytimes, 51 | EWrapMode wrapMode = eWrapMode_Wrap, 52 | bool bOffsetNewPixels = false); 53 | 54 | // Downscales the image by using a simple averaging of the neighboring pixel values 55 | void AverageDownscale(uint32 xtimes, uint32 ytimes); 56 | 57 | void ComputeHessianEigenvalues(::std::vector &eigOne, 58 | ::std::vector &eigTwo, 59 | EWrapMode wrapMode = eWrapMode_Wrap); 60 | 61 | void ChangeBitDepth(const uint8 (&depths)[4]); 62 | 63 | void ExpandTo8888(); 64 | void DebugOutput(const char *filename) const; 65 | 66 | private: 67 | FasTC::Pixel *m_FractionalPixels; 68 | 69 | uint32 GetPixelIndex(int32 i, int32 j, EWrapMode wrapMode = eWrapMode_Clamp) const; 70 | const FasTC::Pixel &GetPixel(int32 i, int32 j, EWrapMode wrapMode = eWrapMode_Clamp) const; 71 | }; 72 | 73 | } // namespace PVRTCC 74 | 75 | #endif // PVRTCENCODER_SRC_IMAGE_H_ 76 | -------------------------------------------------------------------------------- /PVRTCEncoder/test/DecompressorTest.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #include "gtest/gtest.h" 19 | 20 | #include "TestUtils.h" 21 | 22 | #include "FasTC/PVRTCCompressor.h" 23 | 24 | static const FasTC::ECompressionFormat kFmt = FasTC::eCompressionFormat_PVRTC4; 25 | 26 | TEST(Decompressor, DecompressWhite) { 27 | const uint32 kWidth = 32; 28 | const uint32 kHeight = 32; 29 | 30 | uint8 pvrData[512]; 31 | 32 | for(int i = 0; i < 512; i += 8) { 33 | uint8 whiteBlock[8] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xFE, 0xFF, 0xFF, 0xFF }; 34 | memcpy(pvrData + i, whiteBlock, 8); 35 | } 36 | 37 | uint8 outData[4 * kWidth * kHeight]; 38 | 39 | FasTC::DecompressionJob dcj (kFmt, pvrData, outData, kWidth, kHeight); 40 | PVRTCC::Decompress(dcj); 41 | 42 | for(uint32 i = 0; i < kWidth; i++) { 43 | for(uint32 j = 0; j < kHeight; j++) { 44 | const uint32 *pixelData = reinterpret_cast(outData); 45 | const uint32 p = pixelData[j*kWidth + i]; 46 | EXPECT_EQ(PixelPrinter(p), PixelPrinter(0xFFFFFFFF)); 47 | } 48 | } 49 | } 50 | 51 | TEST(Decompressor, DecompressGray) { 52 | const uint32 kWidth = 32; 53 | const uint32 kHeight = 32; 54 | 55 | uint8 pvrData[512]; 56 | 57 | for(uint32 i = 0; i < 512; i += 8) { 58 | uint8 grayBlock[8] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xF0, 0xBD, 0x0F, 0xC2 }; 59 | memcpy(pvrData + i, grayBlock, 8); 60 | } 61 | 62 | uint8 outData[4 * kWidth * kHeight]; 63 | 64 | FasTC::DecompressionJob dcj (kFmt, pvrData, outData, kWidth, kHeight); 65 | PVRTCC::Decompress(dcj); 66 | 67 | for(uint32 i = 0; i < kWidth; i++) { 68 | for(uint32 j = 0; j < kHeight; j++) { 69 | const uint32 *pixelData = reinterpret_cast(outData); 70 | const uint32 p = pixelData[j*kWidth + i]; 71 | EXPECT_EQ(PixelPrinter(p), PixelPrinter(0xFF818080)); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /PVRTCEncoder/test/TestUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The University of North Carolina at Chapel Hill 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // Please send all BUG REPORTS to . 16 | // 17 | 18 | #ifndef PVRTCENCODER_TEST_TESTUTILS_H_ 19 | #define PVRTCENCODER_TEST_TESTUTILS_H_ 20 | 21 | #include "FasTC/TexCompTypes.h" 22 | 23 | class PixelPrinter { 24 | private: 25 | uint32 m_PixelValue; 26 | public: 27 | explicit PixelPrinter(uint32 p) : m_PixelValue(p) { } 28 | bool operator==(const PixelPrinter &other) const { 29 | return other.m_PixelValue == this->m_PixelValue; 30 | } 31 | uint32 Value() const { return m_PixelValue; } 32 | }; 33 | 34 | inline ::std::ostream& operator<<(::std::ostream& os, const PixelPrinter& pp) { 35 | uint32 p = pp.Value(); 36 | uint32 r = p & 0xFF; 37 | uint32 g = (p >> 8) & 0xFF; 38 | uint32 b = (p >> 16) & 0xFF; 39 | uint32 a = (p >> 24) & 0xFF; 40 | return os << 41 | "R: 0x" << ::std::hex << r << " " << 42 | "G: 0x" << ::std::hex << g << " " << 43 | "B: 0x" << ::std::hex << b << " " << 44 | "A: 0x" << ::std::hex << a; 45 | } 46 | 47 | #endif // PVRTCENCODER_TEST_TESTUTILS_H_ 48 | -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/2bpp-gradient.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/2bpp-gradient.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/2bpp-gray.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/2bpp-gray.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/2bpp-trans-gradient.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/2bpp-trans-gradient.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/2bpp-transparent.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/2bpp-transparent.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/2bpp-white.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/2bpp-white.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/4bpp-gradient.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/4bpp-gradient.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/4bpp-gray.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/4bpp-gray.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/4bpp-trans-gradient.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/4bpp-trans-gradient.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/4bpp-transparent.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/4bpp-transparent.pvr -------------------------------------------------------------------------------- /PVRTCEncoder/test/data/4bpp-white.pvr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GammaUNC/FasTC/0f8cef65cf8f0fc5c58a2d06af3e0c3ad2374678/PVRTCEncoder/test/data/4bpp-white.pvr --------------------------------------------------------------------------------