diff options
Diffstat (limited to 'emulator/opengl/host/libs')
12 files changed, 25 insertions, 186 deletions
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/emulator/opengl/host/libs/Translator/EGL/EglContext.h index e4917c6..d8eb05e 100644 --- a/emulator/opengl/host/libs/Translator/EGL/EglContext.h +++ b/emulator/opengl/host/libs/Translator/EGL/EglContext.h @@ -19,10 +19,10 @@ #include <map> #include <EGL/egl.h> #include <GLcommon/GLutils.h> -#include <GLcommon/SmartPtr.h> #include <GLcommon/TranslatorIfaces.h> #include <GLcommon/objectNameManager.h> +#include "emugl/common/smart_ptr.h" #include "EglConfig.h" #include "EglSurface.h" @@ -30,7 +30,7 @@ class EglContext; -typedef SmartPtr<EglContext> ContextPtr; +typedef emugl::SmartPtr<EglContext> ContextPtr; class EglDisplay; diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h index 587e92a..889a84f 100644 --- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h +++ b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h @@ -21,7 +21,7 @@ #include <EGL/egl.h> #include <EGL/eglext.h> #include <utils/threads.h> -#include <GLcommon/SmartPtr.h> +#include "emugl/common/smart_ptr.h" #include "EglConfig.h" #include "EglContext.h" @@ -30,6 +30,7 @@ + typedef std::list<EglConfig*> ConfigsList; typedef std::map< unsigned int, ContextPtr> ContextsHndlMap; typedef std::map< unsigned int, SurfacePtr> SurfacesHndlMap; diff --git a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h index d65f480..ba28ae8 100644 --- a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h +++ b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h @@ -16,14 +16,15 @@ #ifndef EGL_SURFACE_H #define EGL_SURFACE_H +#include <map> + #include <EGL/egl.h> #include <EGL/eglinternalplatform.h> -#include <map> -#include <GLcommon/SmartPtr.h> +#include "emugl/common/smart_ptr.h" #include "EglConfig.h" class EglSurface; -typedef SmartPtr<EglSurface> SurfacePtr; +typedef emugl::SmartPtr<EglSurface> SurfacePtr; class EglDisplay; diff --git a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk index 1236566..2c16878 100644 --- a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk +++ b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk @@ -41,7 +41,7 @@ LOCAL_SRC_FILES := $(host_common_SRC_FILES) $(call emugl-export,LDLIBS,$(host_common_LDLIBS)) $(call emugl-export,LDFLAGS,$(host_common_LDFLAGS)) $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared) -$(call emugl-export,STATIC_LIBRARIES, libcutils libutils liblog) +$(call emugl-export,STATIC_LIBRARIES, libemugl_common libutils libcutils liblog) $(call emugl-end-module) @@ -56,6 +56,6 @@ LOCAL_SRC_FILES := $(host_common_SRC_FILES) $(call emugl-export,LDLIBS,$(host_common_LDLIBS)) $(call emugl-export,LDFLAGS,$(host_common_LDFLAGS)) $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared) -$(call emugl-export,STATIC_LIBRARIES, lib64cutils lib64utils lib64log) +$(call emugl-export,STATIC_LIBRARIES, lib64emugl_common lib64utils lib64cutils lib64log) $(call emugl-end-module) diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h index 3353ec1..38429d1 100644 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h +++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h @@ -43,5 +43,5 @@ private: bool m_wasBound; }; -typedef SmartPtr<GLESbuffer> GLESbufferPtr; +typedef emugl::SmartPtr<GLESbuffer> GLESbufferPtr; #endif diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h b/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h deleted file mode 100644 index 8ac93fb..0000000 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -* Copyright (C) 2011 The Android Open Source Project -* -* 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. -*/ -#ifndef __SMART_PTR_H -#define __SMART_PTR_H - -#include <cutils/threads.h> -#include <cutils/atomic.h> - -template <class T, bool threadSafe = false> -class SmartPtr -{ -public: - explicit SmartPtr(T* ptr = (T*)NULL) { - if (threadSafe) { - m_lock = new mutex_t; - mutex_init(m_lock); - } - else m_lock = NULL; - - m_ptr = ptr; - if (ptr) - m_pRefCount = new int32_t(1); - else - m_pRefCount = NULL; - } - - SmartPtr<T,threadSafe>(const SmartPtr<T,false>& rhs) { - if (threadSafe) { - m_lock = new mutex_t; - mutex_init(m_lock); - } - else m_lock = NULL; - - m_pRefCount = rhs.m_pRefCount; - m_ptr = rhs.m_ptr; - use(); - } - - SmartPtr<T,threadSafe>(SmartPtr<T,true>& rhs) { - if (threadSafe) { - m_lock = new mutex_t; - mutex_init(m_lock); - } - else m_lock = NULL; - - if (rhs.m_lock) mutex_lock(rhs.m_lock); - m_pRefCount = rhs.m_pRefCount; - m_ptr = rhs.m_ptr; - use(); - if (rhs.m_lock) mutex_unlock(rhs.m_lock); - } - - ~SmartPtr() { - if (m_lock) mutex_lock(m_lock); - release(); - if (m_lock) - { - mutex_unlock(m_lock); - mutex_destroy(m_lock); - delete m_lock; - } - } - - T* Ptr() const { - return m_ptr; - } - - const T* constPtr() const - { - return m_ptr; - } - - T* operator->() const { - return m_ptr; - } - - T& operator*() const { - return *m_ptr; - } - - // This gives STL lists something to compare. - bool operator <(const SmartPtr<T>& t1) const { - return m_ptr < t1.m_ptr; - } - - SmartPtr<T,threadSafe>& operator=(const SmartPtr<T,false>& rhs) - { - if (m_ptr == rhs.m_ptr) - return *this; - - if (m_lock) mutex_lock(m_lock); - release(); - m_pRefCount = rhs.m_pRefCount; - m_ptr = rhs.m_ptr; - use(); - if (m_lock) mutex_unlock(m_lock); - - return *this; - } - - SmartPtr<T,threadSafe>& operator=(SmartPtr<T,true>& rhs) - { - if (m_ptr == rhs.m_ptr) - return *this; - - if (m_lock) mutex_lock(m_lock); - release(); - if (rhs.m_lock) mutex_lock(rhs.m_lock); - m_pRefCount = rhs.m_pRefCount; - m_ptr = rhs.m_ptr; - use(); - if (rhs.m_lock) mutex_unlock(rhs.m_lock); - if (m_lock) mutex_unlock(m_lock); - - return *this; - } - -private: - int32_t *m_pRefCount; - mutex_t *m_lock; - T* m_ptr; - - // Increment the reference count on this pointer by 1. - int use() { - if (!m_pRefCount) return 0; - return android_atomic_inc(m_pRefCount) + 1; - } - - // Decrement the reference count on the pointer by 1. - // If the reference count goes to (or below) 0, the pointer is deleted. - int release() { - if (!m_pRefCount) return 0; - - int iVal = android_atomic_dec(m_pRefCount); - if (iVal > 1) - return iVal - 1; - - delete m_pRefCount; - m_pRefCount = NULL; - - if (m_ptr) { - delete m_ptr; - m_ptr = NULL; - } - return 0; - } - -}; - -#endif // of __SMART_PTR_H diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h index 3c5e15a..e0d1bfb 100644 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h +++ b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h @@ -74,8 +74,8 @@ struct EglImage unsigned int border; }; -typedef SmartPtr<EglImage> ImagePtr; -typedef std::map< unsigned int, ImagePtr> ImagesHndlMap; +typedef emugl::SmartPtr<EglImage> ImagePtr; +typedef std::map< unsigned int, ImagePtr> ImagesHndlMap; class GLEScontext; diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h index 605fd29..0a00644 100644 --- a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h +++ b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h @@ -18,7 +18,7 @@ #include <cutils/threads.h> #include <map> -#include "SmartPtr.h" +#include "emugl/common/smart_ptr.h" enum NamedObjectType { VERTEXBUFFER = 0, @@ -47,7 +47,7 @@ public: private: ObjectDataType m_dataType; }; -typedef SmartPtr<ObjectData> ObjectDataPtr; +typedef emugl::SmartPtr<ObjectData> ObjectDataPtr; typedef unsigned long long ObjectLocalName; typedef std::map<ObjectLocalName, unsigned int> NamesMap; @@ -143,7 +143,7 @@ private: class ShareGroup { friend class ObjectNameManager; - friend class SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero + friend class emugl::SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero public: @@ -209,7 +209,7 @@ private: void *m_objectsData; }; -typedef SmartPtr<ShareGroup> ShareGroupPtr; +typedef emugl::SmartPtr<ShareGroup> ShareGroupPtr; typedef std::multimap<void *, ShareGroupPtr> ShareGroupsMap; // diff --git a/emulator/opengl/host/libs/libOpenglRender/Android.mk b/emulator/opengl/host/libs/libOpenglRender/Android.mk index 1d923b4..8b8ba79 100644 --- a/emulator/opengl/host/libs/libOpenglRender/Android.mk +++ b/emulator/opengl/host/libs/libOpenglRender/Android.mk @@ -54,7 +54,7 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) # use Translator's egl/gles headers LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include -LOCAL_STATIC_LIBRARIES += libutils liblog +LOCAL_STATIC_LIBRARIES += libemugl_common libutils libcutils liblog $(call emugl-export,CFLAGS,$(host_common_CFLAGS)) @@ -76,7 +76,7 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) # use Translator's egl/gles headers LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include -LOCAL_STATIC_LIBRARIES += lib64utils lib64log +LOCAL_STATIC_LIBRARIES += lib64emugl_common lib64utils lib64cutils lib64log $(call emugl-export,CFLAGS,$(host_common_CFLAGS) -m64) diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h index 883162b..9a919c3 100644 --- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h +++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h @@ -19,7 +19,7 @@ #include <EGL/egl.h> #include <EGL/eglext.h> #include <GLES/gl.h> -#include <SmartPtr.h> +#include "emugl/common/smart_ptr.h" class ColorBuffer { @@ -55,6 +55,6 @@ private: GLenum m_internalFormat; }; -typedef SmartPtr<ColorBuffer> ColorBufferPtr; +typedef emugl::SmartPtr<ColorBuffer> ColorBufferPtr; #endif diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h index 9cbb5fc..80ac43f 100644 --- a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h +++ b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h @@ -16,12 +16,12 @@ #ifndef _LIBRENDER_RENDERCONTEXT_H #define _LIBRENDER_RENDERCONTEXT_H -#include "SmartPtr.h" +#include "emugl/common/smart_ptr.h" #include <EGL/egl.h> #include "GLDecoderContextData.h" class RenderContext; -typedef SmartPtr<RenderContext> RenderContextPtr; +typedef emugl::SmartPtr<RenderContext> RenderContextPtr; class RenderContext { diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h index e9f1f7d..fe35a94 100644 --- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h +++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h @@ -19,7 +19,7 @@ #include "ColorBuffer.h" #include "RenderContext.h" #include "FBConfig.h" -#include "SmartPtr.h" +#include "emugl/common/smart_ptr.h" #include "FixedBuffer.h" #include <EGL/egl.h> #include <GLES/gl.h> @@ -66,6 +66,6 @@ private: const FBConfig *m_fbconf; }; -typedef SmartPtr<WindowSurface> WindowSurfacePtr; +typedef emugl::SmartPtr<WindowSurface> WindowSurfacePtr; #endif |
