Skip to content
This repository
Browse code

Merge pull request #2259 from elupus/studio

Limited color range for usage over HDMI
  • Loading branch information...
commit f65e61c8e8b075fec71ed28841b374299d1cbe4f 2 parents 79d9923 + 51ac78a
Joakim Plate authored March 01, 2013
5  language/English/strings.po
@@ -12008,3 +12008,8 @@ msgstr ""
12008 12008
 msgctxt "#36041"
12009 12009
 msgid "* Item folder"
12010 12010
 msgstr ""
  12011
+
  12012
+#: xbmc/settings/GUISettings.cpp
  12013
+msgctxt "#36042"
  12014
+msgid "Use limited color range (16-235)"
  12015
+msgstr ""
4  xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
@@ -3187,7 +3187,7 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature)
3187 3187
 {
3188 3188
   if(feature == RENDERFEATURE_BRIGHTNESS)
3189 3189
   {
3190  
-    if ((m_renderMethod & RENDER_VDPAU) && !g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
  3190
+    if ((m_renderMethod & RENDER_VDPAU) && !g_guiSettings.GetBool("videoscreen.limitedrange"))
3191 3191
       return true;
3192 3192
 
3193 3193
     if (m_renderMethod & RENDER_VAAPI)
@@ -3200,7 +3200,7 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature)
3200 3200
   
3201 3201
   if(feature == RENDERFEATURE_CONTRAST)
3202 3202
   {
3203  
-    if ((m_renderMethod & RENDER_VDPAU) && !g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
  3203
+    if ((m_renderMethod & RENDER_VDPAU) && !g_guiSettings.GetBool("videoscreen.limitedrange"))
3204 3204
       return true;
3205 3205
 
3206 3206
     if (m_renderMethod & RENDER_VAAPI)
13  xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
@@ -24,6 +24,7 @@
24 24
 #include "YUV2RGBShader.h"
25 25
 #include "settings/AdvancedSettings.h"
26 26
 #include "guilib/TransformMatrix.h"
  27
+#include "windowing/WindowingFactory.h"
27 28
 #include "utils/log.h"
28 29
 #if defined(HAS_GL) || defined(HAS_GLES)
29 30
 #include "utils/GLUtils.h"
@@ -106,8 +107,20 @@ void CalculateYUVMatrix(TransformMatrix &matrix
106 107
       coef.m[row][col] = conv[col][row];
107 108
   coef.identity = false;
108 109
 
  110
+
  111
+  if(g_Windowing.UseLimitedColor())
  112
+  {
  113
+    matrix *= TransformMatrix::CreateTranslation(+ 16.0f / 255
  114
+                                               , + 16.0f / 255
  115
+                                               , + 16.0f / 255);
  116
+    matrix *= TransformMatrix::CreateScaler((235 - 16) / 255.0f
  117
+                                          , (235 - 16) / 255.0f
  118
+                                          , (235 - 16) / 255.0f);
  119
+  }
  120
+
109 121
   matrix *= coef;
110 122
   matrix *= TransformMatrix::CreateTranslation(0.0, -0.5, -0.5);
  123
+
111 124
   if (!(flags & CONF_FLAGS_YUV_FULLRANGE))
112 125
   {
113 126
     matrix *= TransformMatrix::CreateScaler(255.0f / (235 - 16)
5  xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp
@@ -1571,7 +1571,10 @@ bool CProcessor::Render(CRect src, CRect dst, IDirect3DSurface9* target, REFEREN
1571 1571
 
1572 1572
   blt.DestFormat.VideoTransferFunction = DXVA2_VideoTransFunc_sRGB;
1573 1573
   blt.DestFormat.SampleFormat          = DXVA2_SampleProgressiveFrame;
1574  
-  blt.DestFormat.NominalRange          = DXVA2_NominalRange_0_255;
  1574
+  if(g_Windowing.UseLimitedColor())
  1575
+    blt.DestFormat.NominalRange          = DXVA2_NominalRange_16_235;
  1576
+  else
  1577
+    blt.DestFormat.NominalRange          = DXVA2_NominalRange_0_255;
1575 1578
   blt.Alpha = DXVA2_Fixed32OpaqueAlpha();
1576 1579
 
1577 1580
   blt.ProcAmpValues.Brightness = ConvertRange( m_brightness, g_settings.m_currentVideoSettings.m_Brightness
2  xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
@@ -591,7 +591,7 @@ void CVDPAU::SetColor()
591 591
     vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix);
592 592
 
593 593
   VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
594  
-  if (g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
  594
+  if (g_guiSettings.GetBool("videoscreen.limitedrange"))
595 595
   {
596 596
     void const * pm_CSCMatix[] = { &studioCSC };
597 597
     vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
21  xbmc/guilib/GUIFontTTF.cpp
@@ -27,6 +27,7 @@
27 27
 #include "utils/MathUtils.h"
28 28
 #include "utils/log.h"
29 29
 #include "windowing/WindowingFactory.h"
  30
+#include "settings/GUISettings.h"
30 31
 
31 32
 #include <math.h>
32 33
 
@@ -735,12 +736,24 @@ void CGUIFontTTFBase::RenderCharacter(float posX, float posY, const Character *c
735 736
   m_color = color;
736 737
   SVertex* v = m_vertex + m_vertex_count;
737 738
 
  739
+  unsigned char r = GET_R(color)
  740
+              , g = GET_G(color)
  741
+              , b = GET_B(color)
  742
+              , a = GET_A(color);
  743
+
  744
+  if(g_Windowing.UseLimitedColor())
  745
+  {
  746
+    r = (235 - 16) * r / 255;
  747
+    g = (235 - 16) * g / 255;
  748
+    b = (235 - 16) * b / 255;
  749
+  }
  750
+
738 751
   for(int i = 0; i < 4; i++)
739 752
   {
740  
-    v[i].r = GET_R(color);
741  
-    v[i].g = GET_G(color);
742  
-    v[i].b = GET_B(color);
743  
-    v[i].a = GET_A(color);
  753
+    v[i].r = r;
  754
+    v[i].g = g;
  755
+    v[i].b = b;
  756
+    v[i].a = a;
744 757
   }
745 758
 
746 759
 #if defined(HAS_GL) || defined(HAS_DX)
32  xbmc/guilib/GUIFontTTFDX.cpp
@@ -57,17 +57,33 @@ void CGUIFontTTFDX::Begin()
57 57
 
58 58
   if (m_nestedBeginCount == 0)
59 59
   {
  60
+    int unit = 0;
60 61
     // just have to blit from our texture.
61  
-    m_texture->BindToUnit(0);
62  
-    pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); // only use diffuse
63  
-    pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
64  
-    pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
65  
-    pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
66  
-    pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
  62
+    m_texture->BindToUnit(unit);
  63
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); // only use diffuse
  64
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
  65
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
  66
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
  67
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
  68
+    unit++;
  69
+
  70
+    if(g_Windowing.UseLimitedColor())
  71
+    {
  72
+      pD3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP  , D3DTOP_ADD );
  73
+      pD3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_CURRENT) ;
  74
+#if(1)
  75
+      pD3DDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(16,16,16,0) );
  76
+      pD3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_TFACTOR );
  77
+#else
  78
+      pD3DDevice->SetTextureStageState( unit, D3DTSS_CONSTANT , D3DCOLOR_RGBA(16,16,16,0) );
  79
+      pD3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_CONSTANT );
  80
+#endif
  81
+      unit++;
  82
+    }
67 83
 
68 84
     // no other texture stages needed
69  
-    pD3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
70  
-    pD3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
  85
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP, D3DTOP_DISABLE);
  86
+    pD3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
71 87
 
72 88
     pD3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
73 89
     pD3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
25  xbmc/guilib/GUIFontTTFGL.cpp
@@ -28,9 +28,7 @@
28 28
 #include "gui3d.h"
29 29
 #include "utils/log.h"
30 30
 #include "utils/GLUtils.h"
31  
-#if HAS_GLES == 2
32 31
 #include "windowing/WindowingFactory.h"
33  
-#endif
34 32
 
35 33
 // stuff for freetype
36 34
 #include <ft2build.h>
@@ -98,6 +96,26 @@ void CGUIFontTTFGL::Begin()
98 96
     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
99 97
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
100 98
     VerifyGLState();
  99
+
  100
+    if(g_Windowing.UseLimitedColor())
  101
+    {
  102
+      glActiveTexture(GL_TEXTURE1);
  103
+      glBindTexture(GL_TEXTURE_2D, m_nTexture); // dummy bind
  104
+      glEnable(GL_TEXTURE_2D);
  105
+
  106
+      const GLfloat rgba[4] = {16.0f / 255.0f, 16.0f / 255.0f, 16.0f / 255.0f, 0.0f};
  107
+      glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_COMBINE);
  108
+      glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, rgba);
  109
+      glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB      , GL_ADD);
  110
+      glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB      , GL_PREVIOUS);
  111
+      glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB      , GL_CONSTANT);
  112
+      glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB     , GL_SRC_COLOR);
  113
+      glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB     , GL_SRC_COLOR);
  114
+      glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA    , GL_REPLACE);
  115
+      glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA    , GL_PREVIOUS);
  116
+      VerifyGLState();
  117
+    }
  118
+
101 119
 #else
102 120
     g_Windowing.EnableGUIShader(SM_FONTS);
103 121
 #endif
@@ -127,6 +145,9 @@ void CGUIFontTTFGL::End()
127 145
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
128 146
   glDrawArrays(GL_QUADS, 0, m_vertex_count);
129 147
   glPopClientAttrib();
  148
+
  149
+  glBindTexture(GL_TEXTURE_2D, 0);
  150
+  glActiveTexture(GL_TEXTURE0);
130 151
 #else
131 152
   // GLES 2.0 version. Cannot draw quads. Convert to triangles.
132 153
   GLint posLoc  = g_Windowing.GUIShaderGetPos();
58  xbmc/guilib/GUITextureD3D.cpp
@@ -31,6 +31,7 @@ CGUITextureD3D::CGUITextureD3D(float posX, float posY, float width, float height
31 31
 
32 32
 void CGUITextureD3D::Begin(color_t color)
33 33
 {
  34
+  int unit = 0;
34 35
   CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
35 36
   LPDIRECT3DDEVICE9 p3DDevice = g_Windowing.Get3DDevice();
36 37
 
@@ -38,30 +39,50 @@ void CGUITextureD3D::Begin(color_t color)
38 39
   if (m_diffuse.size())
39 40
     m_diffuse.m_textures[0]->LoadToGPU();
40 41
   // Set state to render the image
41  
-  texture->BindToUnit(0);
42  
-  p3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
43  
-  p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
44  
-  p3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
45  
-  p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
46  
-  p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
47  
-  p3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
  42
+  texture->BindToUnit(unit);
  43
+  p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP  , D3DTOP_MODULATE );
  44
+  p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_TEXTURE   );
  45
+  p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_DIFFUSE   );
  46
+  p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP  , D3DTOP_MODULATE );
  47
+  p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE   );
  48
+  p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE   );
  49
+  unit++;
  50
+
48 51
   if (m_diffuse.size())
49 52
   {
50 53
     m_diffuse.m_textures[0]->BindToUnit(1);
51  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
52  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
53  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
54  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
55  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
56  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
57  
-    p3DDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE);
58  
-    p3DDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
  54
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_TEXTURE   );
  55
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_CURRENT   );
  56
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP  , D3DTOP_MODULATE );
  57
+    p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE   );
  58
+    p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_CURRENT   );
  59
+    p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP  , D3DTOP_MODULATE );
  60
+    unit++;
59 61
   }
60  
-  else
  62
+
  63
+  if(g_Windowing.UseLimitedColor())
61 64
   {
62  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
63  
-    p3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
  65
+    m_col = D3DCOLOR_RGBA(GET_R(color) * (235 - 16) / 255
  66
+                        , GET_G(color) * (235 - 16) / 255
  67
+                        , GET_B(color) * (235 - 16) / 255
  68
+                        , GET_A(color));
  69
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP  , D3DTOP_ADD );
  70
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_CURRENT) ;
  71
+#if(1)
  72
+    p3DDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(16,16,16, 0) );
  73
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_TFACTOR );
  74
+#else
  75
+    p3DDevice->SetTextureStageState( unit, D3DTSS_CONSTANT , D3DCOLOR_RGBA(16,16,16, 0) );
  76
+    p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_CONSTANT );
  77
+#endif
  78
+    unit++;
64 79
   }
  80
+  else
  81
+    m_col = color;
  82
+
  83
+  p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP, D3DTOP_DISABLE);
  84
+  p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
  85
+
65 86
   p3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
66 87
   p3DDevice->SetRenderState( D3DRS_ALPHAREF, 0 );
67 88
   p3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
@@ -76,7 +97,6 @@ void CGUITextureD3D::Begin(color_t color)
76 97
   p3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
77 98
 
78 99
   p3DDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 );
79  
-  m_col = color;
80 100
 }
81 101
 
82 102
 void CGUITextureD3D::End()
57  xbmc/guilib/GUITextureGL.cpp
@@ -26,6 +26,7 @@
26 26
 #include "utils/log.h"
27 27
 #include "utils/GLUtils.h"
28 28
 #include "guilib/Geometry.h"
  29
+#include "windowing/WindowingFactory.h"
29 30
 
30 31
 #if defined(HAS_GL)
31 32
 
@@ -37,17 +38,23 @@ CGUITextureGL::CGUITextureGL(float posX, float posY, float width, float height,
37 38
 
38 39
 void CGUITextureGL::Begin(color_t color)
39 40
 {
40  
-  m_col[0] = (GLubyte)GET_R(color);
41  
-  m_col[1] = (GLubyte)GET_G(color);
42  
-  m_col[2] = (GLubyte)GET_B(color);
43  
-  m_col[3] = (GLubyte)GET_A(color);
  41
+  int range, unit = 0;
  42
+  if(g_Windowing.UseLimitedColor())
  43
+    range = 235 - 16;
  44
+  else
  45
+    range = 255 -  0;
  46
+
  47
+  m_col[0] = GET_R(color) * range / 255;
  48
+  m_col[1] = GET_G(color) * range / 255;
  49
+  m_col[2] = GET_B(color) * range / 255;
  50
+  m_col[3] = GET_A(color);
44 51
 
45 52
   CBaseTexture* texture = m_texture.m_textures[m_currentFrame];
46 53
   texture->LoadToGPU();
47 54
   if (m_diffuse.size())
48 55
     m_diffuse.m_textures[0]->LoadToGPU();
49 56
 
50  
-  texture->BindToUnit(0);
  57
+  texture->BindToUnit(unit++);
51 58
 
52 59
   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
53 60
   glEnable(GL_BLEND);          // Turn Blending On
@@ -56,23 +63,53 @@ void CGUITextureGL::Begin(color_t color)
56 63
   // diffuse coloring
57 64
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
58 65
   glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
59  
-  glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
  66
+  glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
60 67
   glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
61 68
   glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
62 69
   glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
  70
+
  71
+  glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
  72
+  glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
  73
+  glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PRIMARY_COLOR);
  74
+  glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
  75
+  glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
63 76
   VerifyGLState();
64 77
 
65 78
   if (m_diffuse.size())
66 79
   {
67  
-    m_diffuse.m_textures[0]->BindToUnit(1);
  80
+    m_diffuse.m_textures[0]->BindToUnit(unit++);
68 81
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
69 82
     glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
70  
-    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
  83
+    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
71 84
     glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
72 85
     glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
73 86
     glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
  87
+
  88
+    glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
  89
+    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
  90
+    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS);
  91
+    glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
  92
+    glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
74 93
     VerifyGLState();
75 94
   }
  95
+
  96
+  if(g_Windowing.UseLimitedColor())
  97
+  {
  98
+    texture->BindToUnit(unit++); // dummy bind
  99
+    const GLfloat rgba[4] = {16.0f / 255.0f, 16.0f / 255.0f, 16.0f / 255.0f, 0.0f};
  100
+    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_COMBINE);
  101
+    glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, rgba);
  102
+    glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB      , GL_ADD);
  103
+    glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB      , GL_PREVIOUS);
  104
+    glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB      , GL_CONSTANT);
  105
+    glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB     , GL_SRC_COLOR);
  106
+    glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB     , GL_SRC_COLOR);
  107
+
  108
+    glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA    , GL_REPLACE);
  109
+    glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA    , GL_PREVIOUS);
  110
+    VerifyGLState();
  111
+  }
  112
+
76 113
   //glDisable(GL_TEXTURE_2D); // uncomment these 2 lines to switch to wireframe rendering
77 114
   //glBegin(GL_LINE_LOOP);
78 115
   glBegin(GL_QUADS);
@@ -82,10 +119,8 @@ void CGUITextureGL::End()
82 119
 {
83 120
   glEnd();
84 121
   if (m_diffuse.size())
85  
-  {
86 122
     glDisable(GL_TEXTURE_2D);
87  
-    glActiveTextureARB(GL_TEXTURE0_ARB);
88  
-  }
  123
+  glActiveTexture(GL_TEXTURE0_ARB);
89 124
   glDisable(GL_TEXTURE_2D);
90 125
 }
91 126
 
8  xbmc/guilib/TextureGL.cpp
@@ -185,14 +185,10 @@ void CGLTexture::LoadToGPU()
185 185
 
186 186
 void CGLTexture::BindToUnit(unsigned int unit)
187 187
 {
188  
-  // we support only 2 texture units at present
189  
-#ifndef HAS_GLES
190  
-  glActiveTexture((unit == 1) ? GL_TEXTURE1_ARB : GL_TEXTURE0_ARB);
  188
+  glActiveTexture(GL_TEXTURE0 + unit);
191 189
   glBindTexture(GL_TEXTURE_2D, m_texture);
  190
+#ifndef HAS_GLES
192 191
   glEnable(GL_TEXTURE_2D);
193  
-#else // GLES
194  
-  glActiveTexture((unit == 1) ? GL_TEXTURE1 : GL_TEXTURE0);
195  
-  glBindTexture(GL_TEXTURE_2D, m_texture);
196 192
 #endif
197 193
 }
198 194
 
16  xbmc/settings/GUISettings.cpp
@@ -433,6 +433,7 @@ void CGUISettings::Initialize()
433 433
 #else
434 434
   AddBool(vs, "videoscreen.blankdisplays", 13130, false);
435 435
 #endif
  436
+
436 437
   AddSeparator(vs, "videoscreen.sep1");
437 438
 #endif
438 439
 
@@ -451,6 +452,12 @@ void CGUISettings::Initialize()
451 452
   AddString(vs, "videoscreen.testpattern",226,"", BUTTON_CONTROL_STANDARD);
452 453
 #endif
453 454
 
  455
+#if defined(HAS_GL) || defined(HAS_DX)
  456
+  AddBool(vs  , "videoscreen.limitedrange", 36042, false);
  457
+#else
  458
+  AddBool(NULL, "videoscreen.limitedrange", 36042, false);
  459
+#endif
  460
+
454 461
   CSettingsCategory* ao = AddCategory(SETTINGS_SYSTEM, "audiooutput", 772);
455 462
 
456 463
   map<int,int> audiomode;
@@ -768,7 +775,7 @@ void CGUISettings::Initialize()
768 775
   AddSeparator(vp, "videoplayer.sep1.5");
769 776
 #ifdef HAVE_LIBVDPAU
770 777
   AddBool(NULL, "videoplayer.vdpauUpscalingLevel", 13121, false);
771  
-  AddBool(vp, "videoplayer.vdpaustudiolevel", 13122, false);
  778
+  AddBool(NULL, "videoplayer.vdpaustudiolevel", 0, false); //depreciated
772 779
 #endif
773 780
 #endif
774 781
   AddSeparator(vp, "videoplayer.sep5");
@@ -1411,6 +1418,13 @@ void CGUISettings::LoadXML(TiXmlElement *pRootElement, bool hideSettings /* = fa
1411 1418
     SetInt("videoscreen.vsync", VSYNC_ALWAYS);
1412 1419
   }
1413 1420
 #endif
  1421
+
  1422
+  // map old vpdau color range, to now global setting
  1423
+  if (GetBool("videoplayer.vdpaustudiolevel"))
  1424
+  {
  1425
+    SetBool("videoscreen.limitedrange", true);
  1426
+    SetBool("videoplayer.vdpaustudiolevel", false);
  1427
+  }
1414 1428
  // DXMERGE: This might have been useful?
1415 1429
  // g_videoConfig.SetVSyncMode((VSYNC)GetInt("videoscreen.vsync"));
1416 1430
 
11  xbmc/windowing/WinSystem.cpp
@@ -20,6 +20,7 @@
20 20
 
21 21
 #include "WinSystem.h"
22 22
 #include "settings/Settings.h"
  23
+#include "settings/GUISettings.h"
23 24
 
24 25
 using namespace std;
25 26
 
@@ -200,3 +201,13 @@ REFRESHRATE CWinSystemBase::DefaultRefreshRate(int screen, vector<REFRESHRATE> r
200 201
   }
201 202
   return bestmatch;
202 203
 }
  204
+
  205
+bool CWinSystemBase::UseLimitedColor()
  206
+{
  207
+#if defined(HAS_GL) || defined(HAS_DX)
  208
+  static CSettingBool* setting = (CSettingBool*)g_guiSettings.GetSetting("videoscreen.limitedrange");
  209
+  return setting->GetData();
  210
+#else
  211
+  return false;
  212
+#endif
  213
+}
3  xbmc/windowing/WinSystem.h
@@ -74,6 +74,9 @@ class CWinSystemBase
74 74
   //some plattforms have api for gesture inertial scrolling - default to false and use the InertialScrollingHandler
75 75
   virtual bool HasInertialGestures(){ return false; }
76 76
 
  77
+  //does the output expect limited color range (ie 16-235)
  78
+  virtual bool UseLimitedColor();
  79
+
77 80
   virtual bool Minimize() { return false; }
78 81
   virtual bool Restore() { return false; }
79 82
   virtual bool Hide() { return false; }

0 notes on commit f65e61c

Please sign in to comment.
Something went wrong with that request. Please try again.