summaryrefslogtreecommitdiffstats
path: root/Common/src
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2015-10-21 03:46:28 +0000
committerEgor Yusov <egor.yusov@gmail.com>2015-10-21 03:46:28 +0000
commit9ccee73baca0fd7ecb95c90cb983133b737c6c55 (patch)
tree66fea1e6521df31727431520fe3c1ead1896bc5d /Common/src
downloadDiligentCore-9ccee73baca0fd7ecb95c90cb983133b737c6c55.tar.gz
DiligentCore-9ccee73baca0fd7ecb95c90cb983133b737c6c55.zip
Release v1.0.0
Diffstat (limited to 'Common/src')
-rw-r--r--Common/src/BasicFileStream.cpp61
-rw-r--r--Common/src/DataBlobImpl.cpp52
-rw-r--r--Common/src/Timer.cpp58
-rw-r--r--Common/src/pch.cpp31
4 files changed, 202 insertions, 0 deletions
diff --git a/Common/src/BasicFileStream.cpp b/Common/src/BasicFileStream.cpp
new file mode 100644
index 00000000..09719821
--- /dev/null
+++ b/Common/src/BasicFileStream.cpp
@@ -0,0 +1,61 @@
+/* Copyright 2015 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+#include "BasicFileStream.h"
+
+namespace Diligent
+{
+ BasicFileStream::BasicFileStream(const Diligent::Char *Path,
+ EFileAccessMode Access/* = EFileAccessMode::Read*/) :
+ m_FileWrpr(Path, Access)
+ {
+ }
+
+ IMPLEMENT_QUERY_INTERFACE(BasicFileStream, IID_FileStream, TBase)
+
+ bool BasicFileStream::Read(void *Data, size_t BufferSize)
+ {
+ return m_FileWrpr->Read( Data, BufferSize );
+ }
+
+ void BasicFileStream::Read( Diligent::IDataBlob *pData )
+ {
+ return m_FileWrpr->Read( pData );
+ }
+
+ bool BasicFileStream::Write(const void *Data, size_t Size)
+ {
+ return m_FileWrpr->Write( Data, Size );
+ }
+
+ bool BasicFileStream::IsValid()
+ {
+ return !!m_FileWrpr;
+ }
+
+ size_t BasicFileStream::GetSize()
+ {
+ return m_FileWrpr->GetSize();
+ }
+}
diff --git a/Common/src/DataBlobImpl.cpp b/Common/src/DataBlobImpl.cpp
new file mode 100644
index 00000000..9255f2e3
--- /dev/null
+++ b/Common/src/DataBlobImpl.cpp
@@ -0,0 +1,52 @@
+/* Copyright 2015 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+
+
+#include "DataBlobImpl.h"
+
+namespace Diligent
+{
+
+/// Sets the size of the internal data buffer
+void DataBlobImpl::Resize( size_t NewSize )
+{
+ m_DataBuff.resize( NewSize );
+}
+
+/// Returns the size of the internal data buffer
+size_t DataBlobImpl::GetSize()
+{
+ return m_DataBuff.size();
+}
+
+ /// Returns the pointer to the internal data buffer
+void* DataBlobImpl::GetDataPtr()
+{
+ return m_DataBuff.data();
+}
+
+IMPLEMENT_QUERY_INTERFACE(DataBlobImpl, IID_DataBlob, TBase)
+
+}
diff --git a/Common/src/Timer.cpp b/Common/src/Timer.cpp
new file mode 100644
index 00000000..caf6ffdb
--- /dev/null
+++ b/Common/src/Timer.cpp
@@ -0,0 +1,58 @@
+/* Copyright 2015 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "pch.h"
+#include "Timer.h"
+
+using namespace std::chrono;
+namespace Diligent
+{
+ Timer::Timer()
+ {
+ Restart();
+ }
+
+ void Timer::Restart()
+ {
+ m_StartTime = high_resolution_clock().now();
+ }
+
+ template<typename T>
+ T GetElapsedTime( high_resolution_clock::time_point StartTime )
+ {
+ auto CurrTime = high_resolution_clock::now();
+ auto time_span = duration_cast<duration<T>>(CurrTime - StartTime);
+ return time_span.count();
+ }
+
+ double Timer::GetElapsedTime()const
+ {
+ return Diligent::GetElapsedTime<double>( m_StartTime );
+ }
+
+ float Timer::GetElapsedTimef()const
+ {
+
+ return Diligent::GetElapsedTime<float>( m_StartTime );
+ }
+}
diff --git a/Common/src/pch.cpp b/Common/src/pch.cpp
new file mode 100644
index 00000000..1a94193e
--- /dev/null
+++ b/Common/src/pch.cpp
@@ -0,0 +1,31 @@
+/* Copyright 2015 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+// stdafx.cpp : source file that includes just the standard includes
+// Common.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "pch.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file