--- /dev/null
+// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
+//
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SharedLibrary.hpp"
+
+#if defined(_WIN32)
+std::string getModuleDirectory()
+{
+ static int dummy_symbol = 0;
+
+ HMODULE module = NULL;
+ GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)&dummy_symbol, &module);
+
+ char filename[1024];
+ if(module && (GetModuleFileName(module, filename, sizeof(filename)) != 0))
+ {
+ std::string directory(filename);
+ return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
+ }
+ else
+ {
+ return "";
+ }
+}
+#else
+std::string getModuleDirectory()
+{
+ static int dummy_symbol = 0;
+
+ Dl_info dl_info;
+ if(dladdr(&dummy_symbol, &dl_info) != 0)
+ {
+ std::string directory(dl_info.dli_fname);
+ return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
+ }
+ else
+ {
+ return "";
+ }
+}
+#endif
void *loadLibrary(const char *path);
void freeLibrary(void *library);
void *getProcAddress(void *library, const char *name);
+std::string getModuleDirectory();
template<int n>
void *loadLibrary(const std::string &libraryDirectory, const char *(&names)[n], const char *mustContainSymbol = nullptr)
{
return (void*)GetProcAddress((HMODULE)library, name);
}
-
- inline std::string getModuleDirectory()
- {
- static int dummy_symbol = 0;
-
- HMODULE module = NULL;
- GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)&dummy_symbol, &module);
-
- char filename[1024];
- if(module && (GetModuleFileName(module, filename, sizeof(filename)) != 0))
- {
- std::string directory(filename);
- return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
- }
- else
- {
- return "";
- }
- }
#else
inline void *loadLibrary(const char *path)
{
return symbol;
}
-
- inline std::string getModuleDirectory()
- {
- static int dummy_symbol = 0;
-
- Dl_info dl_info;
- if(dladdr(&dummy_symbol, &dl_info) != 0)
- {
- std::string directory(dl_info.dli_fname);
- return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
- }
- else
- {
- return "";
- }
- }
#endif
#endif // SharedLibrary_hpp
Display.cpp \
Surface.cpp \
libEGL.cpp \
- main.cpp
+ main.cpp \
+ ../../Common/SharedLibrary.cpp
COMMON_C_INCLUDES := \
bionic \
}
sources = [
+ "../../Common/SharedLibrary.cpp",
"../common/debug.cpp",
"../common/Object.cpp",
"Config.cpp",
</ResourceCompile>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
+ <ClCompile Include="..\..\Common\SharedLibrary.cpp" />\r
<ClCompile Include="..\common\Object.cpp" />\r
<ClCompile Include="Config.cpp" />\r
<ClCompile Include="..\Common\debug.cpp" />\r
<ClCompile Include="Surface.cpp">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\Common\SharedLibrary.cpp">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="Config.h">\r
ResourceManager.cpp \
Texture.cpp \
utilities.cpp \
- VertexDataManager.cpp
+ VertexDataManager.cpp \
+ ../../Common/SharedLibrary.cpp
COMMON_C_INCLUDES := \
bionic \
</ResourceCompile>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
+ <ClCompile Include="..\..\Common\SharedLibrary.cpp" />\r
<ClCompile Include="..\common\Image.cpp" />\r
<ClCompile Include="..\common\MatrixStack.cpp" />\r
<ClCompile Include="..\common\Object.cpp" />\r
<ClCompile Include="..\common\Image.cpp">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\Common\SharedLibrary.cpp">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="Buffer.h">\r
utilities.cpp \
VertexArray.cpp \
VertexDataManager.cpp \
+ ../../Common/SharedLibrary.cpp
COMMON_C_INCLUDES := \
bionic \
]
sources = [
+ "../../Common/SharedLibrary.cpp",
"Buffer.cpp",
"Context.cpp",
"Device.cpp",
namespace es2
{
+egl::Image*& ImageLevels::getNullImage()
+{
+ static egl::Image* nullImage;
+ nullImage = nullptr;
+ return nullImage;
+}
+
Texture::Texture(GLuint name) : egl::Texture(name)
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
return image[index];
}
- static egl::Image* nullImage;
- nullImage = nullptr;
- return nullImage;
+ return getNullImage();
}
inline void release()
private:
egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS] = {};
+ static egl::Image*& getNullImage();
};
class Texture : public egl::Texture
</ResourceCompile>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
+ <ClCompile Include="..\..\Common\SharedLibrary.cpp" />\r
<ClCompile Include="..\common\Image.cpp" />\r
<ClCompile Include="..\common\Object.cpp" />\r
<ClCompile Include="Buffer.cpp" />\r
<ClCompile Include="entry_points.cpp">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\Common\SharedLibrary.cpp">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="Buffer.h">\r