Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow color diffuse in any texture definition #268

Closed
wants to merge 3 commits into from

2 participants

@lemonboy999

This allows any texture defined within a skin to use colordiffuse such as:

texture.png

If a border is used it also allows a separate diffuse colour for the border ie:

texture.png

So if texture.png were a white square, it would be shown as a red square with a blue border 5 pixels wide.

@jmarshallnz
Owner

Thanks. I'll put some notes inline, but the larger thing is whether or not we actually need a separate borderdiffuse. I don't see many use cases for that that can't already be done other ways.

@jmarshallnz

Perhaps it would be better to make colorDiffuse a CGUIInfoColor directly?

Also, use .IsEmpty() for comparing empty strings, and no need to initialize strings in the constructor.

@jmarshallnz
Owner

Oh, and 'cause you're new to git, all you need do is add some commits to your local branch there and then push them up to your repo - they'll automatically get included in this pull req :)

@jmarshallnz
Owner

Apologies, I missed your latest commits. Note that there's no need to merge from upstream/master into your feature branch, unless you need something from upstream/master - it just makes things unnecessarily messy.

Two things need doing:

  1. Get rid of borderDiffuse. There is no case for it being required that I can see (i.e. it's achievable directly by using a bordered texture to begin with).
  2. Sort out the difference between m_diffuseColor and m_info.diffuseColor. If a control sets a diffuse color what should take priority? Currently you overwrite with the texture's color. I wonder whether a colour multiply might be more appropriate? Note that this has implications for dirty region rendering - by overwriting m_diffuseColor, the next time the color gets set the control will be marked dirty even though it's not.

Comment in the thread once you've made the changes - for some reason I didn't get email notification about it before.

@lemonboy999

OK understand the merge thing - just inexperienced, will try but can't guarantee to never do this again.

Finally understand the dirty region issue. Can keep this seperate by not changing the colordiffuse variable.

The priority I was going for was that if you set the colordiffuse attribute, it overrides the colordiffuse member, this seems appropriate for a new feature, a color multiply seems far too complicated. So if you dont use a colordiffuse attribute, the colordiffuse for the control is used - if you do then the colordiffuse for the texture is used - seems straightforward.

The borderdiffuse is key for me - bordered texture cannot be applied to all textures which is partly the point of this change in the first place

@lemonboy999 lemonboy999 reopened this
@jmarshallnz
Owner

borderdiffuse will not be accepted, so closing. The other change will be acceptable should someone wish to take it on.

@jmarshallnz jmarshallnz closed this
@tru tru referenced this pull request from a commit in plexinc/plex-home-theater-public
@tru tru Install our Credits page.
Fixes #268
c2ef3d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 10, 2011
  1. allows color diffuse in any texture definition

    lemonboy999 authored
Commits on Jul 11, 2011
  1. updated to use CGUIInfoColor directly

    lemonboy999 authored
This page is out of date. Refresh to see the latest.
View
2  xbmc/guilib/GUIControlFactory.cpp
@@ -291,6 +291,8 @@ bool CGUIControlFactory::GetTexture(const TiXmlNode* pRootNode, const char* strT
const char *flipY = pNode->Attribute("flipy");
if (flipY && strcmpi(flipY, "true") == 0) image.orientation = 3 - image.orientation; // either 3 or 2
image.diffuse = pNode->Attribute("diffuse");
+ image.colorDiffuse.Parse(pNode->Attribute("colordiffuse"));
+ image.borderDiffuse.Parse(pNode->Attribute("borderdiffuse"));
const char *background = pNode->Attribute("background");
if (background && strnicmp(background, "true", 4) == 0)
image.useLarge = true;
View
25 xbmc/guilib/GUITexture.cpp
@@ -24,6 +24,7 @@
#include "TextureManager.h"
#include "GUILargeTextureManager.h"
#include "utils/MathUtils.h"
+#include "GUIInfoTypes.h"
using namespace std;
@@ -47,6 +48,8 @@ CTextureInfo& CTextureInfo::operator=(const CTextureInfo &right)
diffuse = right.diffuse;
filename = right.filename;
useLarge = right.useLarge;
+ colorDiffuse = right.colorDiffuse;
+ borderDiffuse = right.borderDiffuse;
return *this;
}
@@ -175,12 +178,24 @@ void CGUITextureBase::Render()
// set our draw color
#define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
+ if (m_info.colorDiffuse)
+ {
+ m_diffuseColor = m_info.colorDiffuse;
+ }
color_t color = m_diffuseColor;
+ color_t bordercolor;
+ if (m_info.borderDiffuse)
+ {
+ bordercolor = m_info.borderDiffuse;
+ }
+ else
+ {
+ bordercolor = color;
+ }
if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
color = g_graphicsContext.MergeAlpha(color);
-
- // setup our renderer
- Begin(color);
+ if (m_alpha != 0xFF) bordercolor = MIX_ALPHA(m_alpha, bordercolor);
+ bordercolor = g_graphicsContext.MergeAlpha(bordercolor);
// compute the texture coordinates
float u1, u2, u3, v1, v2, v3;
@@ -206,6 +221,7 @@ void CGUITextureBase::Render()
// for flipping
// left segment (0,0,u1,v3)
+ Begin(bordercolor);
if (m_info.border.x1)
{
if (m_info.border.y1)
@@ -217,7 +233,6 @@ void CGUITextureBase::Render()
// middle segment (u1,0,u2,v3)
if (m_info.border.y1)
Render(m_vertex.x1 + m_info.border.x1, m_vertex.y1, m_vertex.x2 - m_info.border.x2, m_vertex.y1 + m_info.border.y1, u1, 0, u2, v1, u3, v3);
- Render(m_vertex.x1 + m_info.border.x1, m_vertex.y1 + m_info.border.y1, m_vertex.x2 - m_info.border.x2, m_vertex.y2 - m_info.border.y2, u1, v1, u2, v2, u3, v3);
if (m_info.border.y2)
Render(m_vertex.x1 + m_info.border.x1, m_vertex.y2 - m_info.border.y2, m_vertex.x2 - m_info.border.x2, m_vertex.y2, u1, v2, u2, v3, u3, v3);
// right segment
@@ -229,6 +244,8 @@ void CGUITextureBase::Render()
if (m_info.border.y2)
Render(m_vertex.x2 - m_info.border.x2, m_vertex.y2 - m_info.border.y2, m_vertex.x2, m_vertex.y2, u2, v2, u3, v3, u3, v3);
}
+ Begin(color);
+ Render(m_vertex.x1 + m_info.border.x1, m_vertex.y1 + m_info.border.y1, m_vertex.x2 - m_info.border.x2, m_vertex.y2 - m_info.border.y2, u1, v1, u2, v2, u3, v3);
// close off our renderer
End();
View
4 xbmc/guilib/GUITexture.h
@@ -32,6 +32,8 @@
#include "TextureManager.h"
#include "Geometry.h"
#include "system.h" // HAS_GL, HAS_DX, etc
+#include "GUIInfoTypes.h"
+
typedef uint32_t color_t;
@@ -79,6 +81,8 @@ class CTextureInfo
int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
CStdString diffuse; // diffuse overlay texture
CStdString filename; // main texture file
+ CGUIInfoColor colorDiffuse; //main diffuse color
+ CGUIInfoColor borderDiffuse; //diffuse color for border
};
class CGUITextureBase
Something went wrong with that request. Please try again.