summaryrefslogtreecommitdiff
path: root/indra/llappearance
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2012-09-04 15:18:15 +0000
committerDon Kjer <don@lindenlab.com>2012-09-04 15:18:15 +0000
commit204be2ba5261d794f8264e004b65725450bf1be9 (patch)
treedf69bb3250ed8b6a39aad8361d1560d392bfdcb9 /indra/llappearance
parent7b4385420edf3f431ddc4a7042bbc9623ffedd34 (diff)
Split LLTexLayerSetBuffer into llappearance portion, and viewer-specific LLViewerTexLayerSetBuffer
Diffstat (limited to 'indra/llappearance')
-rw-r--r--indra/llappearance/lltexlayer.cpp109
-rw-r--r--indra/llappearance/lltexlayer.h37
2 files changed, 146 insertions, 0 deletions
diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp
index bf2fd1e30d..0d3219c4e0 100644
--- a/indra/llappearance/lltexlayer.cpp
+++ b/indra/llappearance/lltexlayer.cpp
@@ -40,6 +40,7 @@
#include "lltexturemanagerbridge.h"
#include "llui.h"
#include "llwearable.h"
+#include "llvertexbuffer.h"
#include "llviewervisualparam.h"
//#include "../tools/imdebug/imdebug.h"
@@ -89,6 +90,92 @@ private:
param_alpha_info_list_t mParamAlphaInfoList;
};
+//-----------------------------------------------------------------------------
+// LLTexLayerSetBuffer
+// The composite image that a LLViewerTexLayerSet writes to. Each LLViewerTexLayerSet has one.
+//-----------------------------------------------------------------------------
+
+LLTexLayerSetBuffer::LLTexLayerSetBuffer(LLTexLayerSet* const owner) :
+ mTexLayerSet(owner)
+{
+}
+
+LLTexLayerSetBuffer::~LLTexLayerSetBuffer()
+{
+}
+
+void LLTexLayerSetBuffer::pushProjection() const
+{
+ gGL.matrixMode(LLRender::MM_PROJECTION);
+ gGL.pushMatrix();
+ gGL.loadIdentity();
+ gGL.ortho(0.0f, getCompositeWidth(), 0.0f, getCompositeHeight(), -1.0f, 1.0f);
+
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ gGL.pushMatrix();
+ gGL.loadIdentity();
+}
+
+void LLTexLayerSetBuffer::popProjection() const
+{
+ gGL.matrixMode(LLRender::MM_PROJECTION);
+ gGL.popMatrix();
+
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
+ gGL.popMatrix();
+}
+
+// virtual
+void LLTexLayerSetBuffer::preRenderTexLayerSet()
+{
+ // Set up an ortho projection
+ pushProjection();
+}
+
+// virtual
+void LLTexLayerSetBuffer::postRenderTexLayerSet(BOOL success)
+{
+ popProjection();
+}
+
+BOOL LLTexLayerSetBuffer::renderTexLayerSet()
+{
+ // Default color mask for tex layer render
+ gGL.setColorMask(true, true);
+
+ BOOL success = TRUE;
+
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.bind();
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
+
+ LLVertexBuffer::unbind();
+
+ // Composite the color data
+ LLGLSUIDefault gls_ui;
+ success &= mTexLayerSet->render( getCompositeOriginX(), getCompositeOriginY(),
+ getCompositeWidth(), getCompositeHeight() );
+ gGL.flush();
+
+ midRenderTexLayerSet(success);
+
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.unbind();
+ }
+
+ LLVertexBuffer::unbind();
+
+ // reset GL state
+ gGL.setColorMask(true, true);
+ gGL.setSceneBlendType(LLRender::BT_ALPHA);
+
+ return success;
+}
//-----------------------------------------------------------------------------
// LLTexLayerSetInfo
@@ -381,6 +468,28 @@ const std::string LLTexLayerSet::getBodyRegionName() const
}
+void LLTexLayerSet::destroyComposite()
+{
+ if( mComposite )
+ {
+ mComposite = NULL;
+ }
+}
+
+LLTexLayerSetBuffer* LLTexLayerSet::getComposite()
+{
+ if (!mComposite)
+ {
+ createComposite();
+ }
+ return mComposite;
+}
+
+const LLTexLayerSetBuffer* LLTexLayerSet::getComposite() const
+{
+ return mComposite;
+}
+
void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, bool forceClear)
{
const LLTexLayerSetInfo *info = getInfo();
diff --git a/indra/llappearance/lltexlayer.h b/indra/llappearance/lltexlayer.h
index 5a413e929f..4f2ee5b045 100644
--- a/indra/llappearance/lltexlayer.h
+++ b/indra/llappearance/lltexlayer.h
@@ -40,6 +40,7 @@ class LLXmlTreeNode;
class LLTexLayerSet;
class LLTexLayerSetInfo;
class LLTexLayerInfo;
+class LLTexLayerSetBuffer;
class LLWearable;
class LLViewerVisualParam;
@@ -178,10 +179,16 @@ private:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLTexLayerSet
{
+ friend class LLTexLayerSetBuffer;
public:
LLTexLayerSet(LLAvatarAppearance* const appearance);
virtual ~LLTexLayerSet();
+ LLTexLayerSetBuffer* getComposite();
+ const LLTexLayerSetBuffer* getComposite() const; // Do not create one if it doesn't exist.
+ virtual void createComposite() = 0;
+ void destroyComposite();
+
const LLTexLayerSetInfo* getInfo() const { return mInfo; }
BOOL setInfo(const LLTexLayerSetInfo *info); // This sets mInfo and calls initialization functions
@@ -199,6 +206,7 @@ public:
LLAvatarAppearance* getAvatarAppearance() const { return mAvatarAppearance; }
const std::string getBodyRegionName() const;
+ BOOL hasComposite() const { return (mComposite.notNull()); }
LLAvatarAppearanceDefines::EBakedTextureIndex getBakedTexIndex() { return mBakedTexIndex; }
void setBakedTexIndex(LLAvatarAppearanceDefines::EBakedTextureIndex index) { mBakedTexIndex = index; }
BOOL isVisible() const { return mIsVisible; }
@@ -209,6 +217,7 @@ protected:
typedef std::vector<LLTexLayerInterface *> layer_list_t;
layer_list_t mLayerList;
layer_list_t mMaskLayerList;
+ LLPointer<LLTexLayerSetBuffer> mComposite;
LLAvatarAppearance* const mAvatarAppearance; // note: backlink only; don't make this an LLPointer.
BOOL mIsVisible;
@@ -242,6 +251,34 @@ protected:
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// LLTexLayerSetBuffer
+//
+// The composite image that a LLTexLayerSet writes to. Each LLTexLayerSet has one.
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+class LLTexLayerSetBuffer : public virtual LLRefCount
+{
+ LOG_CLASS(LLTexLayerSetBuffer);
+
+public:
+ LLTexLayerSetBuffer(LLTexLayerSet* const owner);
+ virtual ~LLTexLayerSetBuffer();
+
+protected:
+ void pushProjection() const;
+ void popProjection() const;
+ virtual void preRenderTexLayerSet();
+ virtual void midRenderTexLayerSet(BOOL success) {}
+ virtual void postRenderTexLayerSet(BOOL success);
+ virtual S32 getCompositeOriginX() const = 0;
+ virtual S32 getCompositeOriginY() const = 0;
+ virtual S32 getCompositeWidth() const = 0;
+ virtual S32 getCompositeHeight() const = 0;
+ BOOL renderTexLayerSet();
+
+ LLTexLayerSet* const mTexLayerSet;
+};
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// LLTexLayerStaticImageList
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~