diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk index 803f28e68..88d8bdf1c 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk +++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/Android.mk @@ -19,8 +19,8 @@ LOCAL_SRC_FILES := \ TextureUtils.cpp \ PaletteTexture.cpp \ etc1.cpp \ - objectNameManager.cpp - + objectNameManager.cpp \ + FramebufferData.cpp ifeq ($(HOST_OS),linux) # $(call emugl-export,LDFLAGS,-Wl,--whole-archive) diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp new file mode 100644 index 000000000..1e38ba8d9 --- /dev/null +++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/FramebufferData.cpp @@ -0,0 +1,103 @@ +/* +* 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. +*/ +#include +#include +#include + +RenderbufferData::RenderbufferData() : sourceEGLImage(0), + eglImageDetach(NULL), + attachedFB(0), + attachedPoint(0), + eglImageGlobalTexName(0) { +} + +RenderbufferData::~RenderbufferData() { + if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage); +} + + +FramebufferData::FramebufferData(GLuint name) { + m_fbName = name; + for (int i=0; iattachedFB = m_fbName; + rbData->attachedPoint = attachment; + } + } +} + +GLuint FramebufferData::getAttachment(GLenum attachment, + GLenum *outTarget, + ObjectDataPtr *outObj) { + int idx = attachmentPointIndex(attachment); + if (outTarget) *outTarget = m_attachPoints[idx].target; + if (outObj) *outObj = m_attachPoints[idx].obj; + return m_attachPoints[idx].name; +} + +int FramebufferData::attachmentPointIndex(GLenum attachment) +{ + switch(attachment) { + case GL_COLOR_ATTACHMENT0_OES: + return 0; + case GL_DEPTH_ATTACHMENT_OES: + return 1; + case GL_STENCIL_ATTACHMENT_OES: + return 3; + default: + return MAX_ATTACH_POINTS; + } +} + +void FramebufferData::detachObject(int idx) { + if (m_attachPoints[idx].target == GL_RENDERBUFFER_OES && m_attachPoints[idx].obj.Ptr() != NULL) { + RenderbufferData *rbData = (RenderbufferData *)m_attachPoints[idx].obj.Ptr(); + rbData->attachedFB = 0; + rbData->attachedPoint = 0; + } + m_attachPoints[idx].target = 0; + m_attachPoints[idx].name = 0; + m_attachPoints[idx].obj = ObjectDataPtr(NULL); +} diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h index 60064a29a..c6ee3b496 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/FramebufferData.h @@ -23,16 +23,8 @@ class RenderbufferData : public ObjectData { public: - RenderbufferData() : sourceEGLImage(0), - eglImageDetach(NULL), - attachedFB(0), - attachedPoint(0), - eglImageGlobalTexName(0) - {} - - ~RenderbufferData() { - if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage); - } + RenderbufferData(); + ~RenderbufferData(); unsigned int sourceEGLImage; void (*eglImageDetach)(unsigned int imageId); @@ -47,81 +39,21 @@ const int MAX_ATTACH_POINTS = 3; class FramebufferData : public ObjectData { public: - explicit FramebufferData(GLuint name) { - m_fbName = name; - for (int i=0; iattachedFB = m_fbName; - rbData->attachedPoint = attachment; - } - } - } + ObjectDataPtr obj); GLuint getAttachment(GLenum attachment, GLenum *outTarget, - ObjectDataPtr *outObj) { - int idx = attachmentPointIndex(attachment); - if (outTarget) *outTarget = m_attachPoints[idx].target; - if (outObj) *outObj = m_attachPoints[idx].obj; - return m_attachPoints[idx].name; - } + ObjectDataPtr *outObj); private: - inline int attachmentPointIndex(GLenum attachment) - { - switch(attachment) { - case GL_COLOR_ATTACHMENT0_OES: - return 0; - case GL_DEPTH_ATTACHMENT_OES: - return 1; - case GL_STENCIL_ATTACHMENT_OES: - return 3; - default: - return MAX_ATTACH_POINTS; - } - } - - void detachObject(int idx) { - if (m_attachPoints[idx].target == GL_RENDERBUFFER_OES && - m_attachPoints[idx].obj.Ptr() != NULL) { - RenderbufferData *rbData = (RenderbufferData *)m_attachPoints[idx].obj.Ptr(); - rbData->attachedFB = 0; - rbData->attachedPoint = 0; - } - m_attachPoints[idx].target = 0; - m_attachPoints[idx].name = 0; - m_attachPoints[idx].obj = ObjectDataPtr(NULL); - } + inline int attachmentPointIndex(GLenum attachment); + void detachObject(int idx); private: GLuint m_fbName;