summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorManuel de la Pena <manuel@canonical.com>2012-10-15 10:55:28 +0200
committerManuel de la Pena <manuel@canonical.com>2012-10-15 10:55:28 +0200
commit34114c823e78a7ca5f26d2412b76166fe238aa15 (patch)
tree79aca3c7f7e9768c8558a9b9a5f12a65c9947429 /unity-shared
parent0538f5c41013cdc3bfdf020b60bb8a6ba2b5743e (diff)
parent45d88218e1cb132bc68796cb107d7e22f380ed36 (diff)
Remerged with turnk.
(bzr r2791.8.9)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/BackgroundEffectHelper.cpp16
-rw-r--r--unity-shared/BackgroundEffectHelper.h6
-rw-r--r--unity-shared/IconRenderer.cpp56
-rw-r--r--unity-shared/IconRenderer.h14
-rw-r--r--unity-shared/OverlayRenderer.cpp26
-rw-r--r--unity-shared/PreviewStyle.cpp2
6 files changed, 61 insertions, 59 deletions
diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp
index f9078b801..33b1ee03a 100644
--- a/unity-shared/BackgroundEffectHelper.cpp
+++ b/unity-shared/BackgroundEffectHelper.cpp
@@ -129,7 +129,7 @@ void BackgroundEffectHelper::DirtyCache ()
owner()->QueueDraw();
}
-nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetBlurRegion(nux::Geometry geo, bool force_update)
+nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetBlurRegion(nux::Geometry const& geo, bool force_update)
{
bool should_update = force_update || cache_dirty;
@@ -187,7 +187,7 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetBlurRegion(nu
graphics_engine->SetViewport(0, 0, larger_blur_geometry.width, larger_blur_geometry.height);
graphics_engine->SetScissor(0, 0, larger_blur_geometry.width, larger_blur_geometry.height);
// Disable nux scissoring
- graphics_engine->GetRenderStates ().EnableScissor (false);
+ graphics_engine->GetRenderStates().EnableScissor(false);
// The background texture is the same size as the monitor where we are rendering.
nux::TexCoordXForm texxform__bg;
@@ -327,7 +327,7 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetBlurRegion(nu
return blur_texture_;
}
-nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetRegion(nux::Geometry geo, bool force_update)
+nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetRegion(nux::Geometry const& geo, bool force_update)
{
bool should_update = force_update || cache_dirty;
@@ -346,9 +346,11 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetRegion(nux::G
nux::Geometry temp = geo;
temp.OffsetPosition(-monitor_rect_.x, -monitor_rect_.y);
+
blur_geometry_ = nux::Geometry(0, 0, monitor_width, monitor_height).Intersect(temp);
nux::GpuDevice* gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice();
+
if (blur_geometry_.IsNull() || !gpu_device->backup_texture0_.IsValid())
{
return nux::ObjectPtr<nux::IOpenGLBaseTexture>();
@@ -365,18 +367,16 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetRegion(nux::G
graphics_engine->SetViewport(0, 0, blur_geometry_.width, blur_geometry_.height);
graphics_engine->SetScissor(0, 0, blur_geometry_.width, blur_geometry_.height);
// Disable nux scissoring
- graphics_engine->GetRenderStates ().EnableScissor (false);
+ graphics_engine->GetRenderStates().EnableScissor(false);
// The background texture is the same size as the monitor where we are rendering.
nux::TexCoordXForm texxform__bg;
- texxform__bg.flip_v_coord = false;
texxform__bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
texxform__bg.uoffset = ((float) blur_geometry_.x) / monitor_width;
- texxform__bg.voffset = ((float) monitor_height - blur_geometry_.y - blur_geometry_.height) / monitor_height;
+ texxform__bg.voffset = ((float) blur_geometry_.y) / monitor_height;
{
nux::ObjectPtr<nux::IOpenGLBaseTexture> device_texture = gpu_device->backup_texture0_;
- nux::ObjectPtr<nux::CachedBaseTexture> noise_device_texture = graphics_engine->CacheResource(noise_texture_);
unsigned int offset = 0;
int quad_width = blur_geometry_.width;
@@ -398,7 +398,7 @@ nux::ObjectPtr<nux::IOpenGLBaseTexture> BackgroundEffectHelper::GetRegion(nux::G
{
current_fbo->Activate(true);
graphics_engine->Push2DWindow(current_fbo->GetWidth(), current_fbo->GetHeight());
- graphics_engine->GetRenderStates ().EnableScissor (true);
+ graphics_engine->GetRenderStates().EnableScissor(true);
}
else
{
diff --git a/unity-shared/BackgroundEffectHelper.h b/unity-shared/BackgroundEffectHelper.h
index e6fa18030..996928f26 100644
--- a/unity-shared/BackgroundEffectHelper.h
+++ b/unity-shared/BackgroundEffectHelper.h
@@ -46,11 +46,11 @@ public:
nux::Property<nux::View*> owner;
nux::Property<bool> enabled;
- nux::ObjectPtr<nux::IOpenGLBaseTexture> GetBlurRegion(nux::Geometry geo, bool force_update = false);
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> GetBlurRegion(nux::Geometry const& geo, bool force_update = false);
// We could add more functions here to get different types of effects based on the background texture
- nux::ObjectPtr<nux::IOpenGLBaseTexture> GetPixelatedRegion(nux::Rect rect, int pixel_size, bool update);
+ // nux::ObjectPtr<nux::IOpenGLBaseTexture> GetPixelatedRegion(nux::Rect rect, int pixel_size, bool update);
- nux::ObjectPtr<nux::IOpenGLBaseTexture> GetRegion(nux::Geometry geo, bool force_update = false);
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> GetRegion(nux::Geometry const& geometry, bool force_update = false);
void DirtyCache();
diff --git a/unity-shared/IconRenderer.cpp b/unity-shared/IconRenderer.cpp
index cd90186de..c2ffb91f0 100644
--- a/unity-shared/IconRenderer.cpp
+++ b/unity-shared/IconRenderer.cpp
@@ -67,7 +67,7 @@ namespace ui
#define LUMIN_GREEN "0.59"
#define LUMIN_BLUE "0.11"
-nux::NString gPerspectiveCorrectShader = TEXT(
+std::string gPerspectiveCorrectShader = TEXT(
"[Vertex Shader] \n"
VertexShaderHeader
"uniform mat4 ViewProjectionMatrix; \n\
@@ -112,7 +112,7 @@ void main() \n\
} \n\
");
-nux::NString PerspectiveCorrectVtx = TEXT(
+std::string PerspectiveCorrectVtx = TEXT(
"!!ARBvp1.0 \n\
ATTRIB iPos = vertex.position; \n\
ATTRIB iColor = vertex.attrib[3]; \n\
@@ -129,7 +129,7 @@ MOV oColor, iColor; \n\
MOV oTexCoord0, vertex.attrib[8]; \n\
END");
-nux::NString PerspectiveCorrectTexFrg = TEXT(
+std::string PerspectiveCorrectTexFrg = TEXT(
"!!ARBfp1.0 \n\
PARAM color0 = program.local[0]; \n\
PARAM factor = program.local[1]; \n\
@@ -151,7 +151,7 @@ MUL result.color.rgb, temp, colorify_color; \n\
MOV result.color.a, color; \n\
END");
-nux::NString PerspectiveCorrectTexRectFrg = TEXT(
+std::string PerspectiveCorrectTexRectFrg = TEXT(
"!!ARBfp1.0 \n\
PARAM color0 = program.local[0]; \n\
PARAM factor = program.local[1]; \n\
@@ -246,11 +246,11 @@ void IconRenderer::PreprocessIcons(std::list<RenderArg>& args, nux::Geometry con
GetInverseScreenPerspectiveMatrix(ViewMatrix, ProjectionMatrix, geo.width, geo.height, 0.1f, 1000.0f, DEGTORAD(90));
- nux::Matrix4 PremultMatrix = ProjectionMatrix * ViewMatrix;
+ nux::Matrix4 const& PremultMatrix = ProjectionMatrix * ViewMatrix;
std::list<RenderArg>::iterator it;
int i;
- for (it = args.begin(), i = 0; it != args.end(); ++it, i++)
+ for (it = args.begin(), i = 0; it != args.end(); ++it, ++i)
{
IconTextureSource* launcher_icon = it->icon;
@@ -343,19 +343,19 @@ void IconRenderer::PreprocessIcons(std::list<RenderArg>& args, nux::Geometry con
}
}
-void IconRenderer::UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
+void IconRenderer::UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 const& ViewProjectionMatrix, nux::Geometry const& geo,
float x, float y, float w, float h, float z, ui::IconTextureSource::TransformIndex index)
{
- UpdateIconSectionTransform (icon, ViewProjectionMatrix, geo, x, y, w, h, z, x, y, w, h, index);
+ UpdateIconSectionTransform(icon, ViewProjectionMatrix, geo, x, y, w, h, z, x, y, w, h, index);
}
-void IconRenderer::UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
+void IconRenderer::UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 const& ViewProjectionMatrix, nux::Geometry const& geo,
float x, float y, float w, float h, float z, float xx, float yy, float ww, float hh, ui::IconTextureSource::TransformIndex index)
{
- nux::Vector4 v0 = nux::Vector4(x, y, z, 1.0f);
- nux::Vector4 v1 = nux::Vector4(x, y + h, z, 1.0f);
- nux::Vector4 v2 = nux::Vector4(x + w, y + h, z, 1.0f);
- nux::Vector4 v3 = nux::Vector4(x + w, y, z, 1.0f);
+ nux::Vector4 v0(x, y, z, 1.0f);
+ nux::Vector4 v1(x, y + h, z, 1.0f);
+ nux::Vector4 v2(x + w, y + h, z, 1.0f);
+ nux::Vector4 v3(x + w, y, z, 1.0f);
v0 = ViewProjectionMatrix * v0;
v1 = ViewProjectionMatrix * v1;
@@ -377,9 +377,7 @@ void IconRenderer::UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::
v3.x = geo.width * (v3.x + 1.0f) / 2.0f - geo.width / 2.0f + xx + ww / 2.0f;
v3.y = -geo.height * (v3.y - 1.0f) / 2.0f - geo.height / 2.0f + yy + hh / 2.0f;
-
std::vector<nux::Vector4>& vectors = icon->GetTransform(index, monitor);
-
vectors[0] = v0;
vectors[1] = v1;
vectors[2] = v2;
@@ -705,23 +703,27 @@ nux::BaseTexture* IconRenderer::RenderCharToTexture(const char label, int width,
void IconRenderer::RenderElement(nux::GraphicsEngine& GfxContext,
RenderArg const& arg,
- nux::ObjectPtr<nux::IOpenGLBaseTexture> icon,
- nux::Color bkg_color,
- nux::Color colorify,
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> const& icon,
+ nux::Color const& bkg_color,
+ nux::Color const& colorify,
float alpha,
bool force_filter,
- std::vector<nux::Vector4>& xform_coords)
+ std::vector<nux::Vector4> const& xform_coords)
{
if (icon.IsNull())
return;
- if (nux::Abs(arg.x_rotation) < 0.01f &&
- nux::Abs(arg.y_rotation) < 0.01f &&
- nux::Abs(arg.z_rotation) < 0.01f &&
+ if (std::abs(arg.x_rotation) < 0.01f &&
+ std::abs(arg.y_rotation) < 0.01f &&
+ std::abs(arg.z_rotation) < 0.01f &&
!force_filter)
+ {
icon->SetFiltering(GL_NEAREST, GL_NEAREST);
+ }
else
+ {
icon->SetFiltering(GL_LINEAR, GL_LINEAR);
+ }
nux::Vector4 const& v0 = xform_coords[0];
nux::Vector4 const& v1 = xform_coords[1];
@@ -969,7 +971,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext,
}
void IconRenderer::RenderProgressToTexture(nux::GraphicsEngine& GfxContext,
- nux::ObjectPtr<nux::IOpenGLBaseTexture> texture,
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> const& texture,
float progress_fill,
float bias)
{
@@ -1161,24 +1163,24 @@ void setup_shaders()
if (nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath())
{
shader_program_uv_persp_correction = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram();
- shader_program_uv_persp_correction->LoadIShader(gPerspectiveCorrectShader.GetTCharPtr());
+ shader_program_uv_persp_correction->LoadIShader(gPerspectiveCorrectShader.c_str());
shader_program_uv_persp_correction->Link();
}
else
{
asm_shader = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateAsmShaderProgram();
- asm_shader->LoadVertexShader(TCHAR_TO_ANSI(*PerspectiveCorrectVtx));
+ asm_shader->LoadVertexShader(TCHAR_TO_ANSI(PerspectiveCorrectVtx.c_str()));
if ((nux::GetGraphicsDisplay()->GetGpuDevice()->SUPPORT_GL_ARB_TEXTURE_NON_POWER_OF_TWO() == false) &&
(nux::GetGraphicsDisplay()->GetGpuDevice()->SUPPORT_GL_EXT_TEXTURE_RECTANGLE() ||
nux::GetGraphicsDisplay()->GetGpuDevice()->SUPPORT_GL_ARB_TEXTURE_RECTANGLE()))
{
// No support for non power of two textures but support for rectangle textures
- asm_shader->LoadPixelShader(TCHAR_TO_ANSI(*PerspectiveCorrectTexRectFrg));
+ asm_shader->LoadPixelShader(TCHAR_TO_ANSI(PerspectiveCorrectTexRectFrg.c_str()));
}
else
{
- asm_shader->LoadPixelShader(TCHAR_TO_ANSI(*PerspectiveCorrectTexFrg));
+ asm_shader->LoadPixelShader(TCHAR_TO_ANSI(PerspectiveCorrectTexFrg.c_str()));
}
asm_shader->Link();
diff --git a/unity-shared/IconRenderer.h b/unity-shared/IconRenderer.h
index 4ee5013f1..d45fcd715 100644
--- a/unity-shared/IconRenderer.h
+++ b/unity-shared/IconRenderer.h
@@ -52,12 +52,12 @@ protected:
void RenderElement(nux::GraphicsEngine& GfxContext,
RenderArg const& arg,
- nux::ObjectPtr<nux::IOpenGLBaseTexture> icon,
- nux::Color bkg_color,
- nux::Color colorify,
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> const& icon,
+ nux::Color const& bkg_color,
+ nux::Color const& colorify,
float alpha,
bool force_filter,
- std::vector<nux::Vector4>& xform_coords);
+ std::vector<nux::Vector4> const& xform_coords);
void RenderIndicators(nux::GraphicsEngine& GfxContext,
RenderArg const& arg,
@@ -67,14 +67,14 @@ protected:
nux::Geometry const& geo);
void RenderProgressToTexture(nux::GraphicsEngine& GfxContext,
- nux::ObjectPtr<nux::IOpenGLBaseTexture> texture,
+ nux::ObjectPtr<nux::IOpenGLBaseTexture> const& texture,
float progress_fill,
float bias);
- void UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
+ void UpdateIconTransform(ui::IconTextureSource* icon, nux::Matrix4 const& ViewProjectionMatrix, nux::Geometry const& geo,
float x, float y, float w, float h, float z, ui::IconTextureSource::TransformIndex index);
- void UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 ViewProjectionMatrix, nux::Geometry const& geo,
+ void UpdateIconSectionTransform(ui::IconTextureSource* icon, nux::Matrix4 const& ViewProjectionMatrix, nux::Geometry const& geo,
float x, float y, float w, float h, float z, float xx, float yy, float ww, float hh, ui::IconTextureSource::TransformIndex index);
void GetInverseScreenPerspectiveMatrix(nux::Matrix4& ViewMatrix, nux::Matrix4& PerspectiveMatrix,
diff --git a/unity-shared/OverlayRenderer.cpp b/unity-shared/OverlayRenderer.cpp
index ac9b97f67..6575172a5 100644
--- a/unity-shared/OverlayRenderer.cpp
+++ b/unity-shared/OverlayRenderer.cpp
@@ -204,7 +204,7 @@ void OverlayRendererImpl::OnBackgroundColorChanged(GVariant* args)
void OverlayRendererImpl::InitASMInverseTextureMaskShader()
{
- nux::NString AsmVtx =
+ std::string AsmVtx =
"!!ARBvp1.0 \n\
ATTRIB iPos = vertex.position; \n\
ATTRIB iColor = vertex.attrib[3]; \n\
@@ -221,7 +221,7 @@ void OverlayRendererImpl::InitASMInverseTextureMaskShader()
MOV oTexCoord0, vertex.attrib[8]; \n\
END";
- nux::NString AsmFrg =
+ std::string AsmFrg =
"!!ARBfp1.0 \n\
TEMP tex0; \n\
TEMP temp0; \n\
@@ -230,7 +230,7 @@ void OverlayRendererImpl::InitASMInverseTextureMaskShader()
SUB result.color, {1.0, 1.0, 1.0, 1.0}, temp0.aaaa;\n\
END";
- nux::NString AsmFrgRect =
+ std::string AsmFrgRect =
"!!ARBfp1.0 \n\
TEMP tex0; \n\
TEMP temp0; \n\
@@ -240,13 +240,13 @@ void OverlayRendererImpl::InitASMInverseTextureMaskShader()
END";
inverse_texture_mask_asm_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateAsmShaderProgram();
- inverse_texture_mask_asm_prog_->LoadVertexShader(AsmVtx.GetTCharPtr());
- inverse_texture_mask_asm_prog_->LoadPixelShader(AsmFrg.GetTCharPtr());
+ inverse_texture_mask_asm_prog_->LoadVertexShader(AsmVtx.c_str());
+ inverse_texture_mask_asm_prog_->LoadPixelShader(AsmFrg.c_str());
inverse_texture_mask_asm_prog_->Link();
inverse_texture_rect_mask_asm_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateAsmShaderProgram();
- inverse_texture_rect_mask_asm_prog_->LoadVertexShader(AsmVtx.GetTCharPtr());
- inverse_texture_rect_mask_asm_prog_->LoadPixelShader(AsmFrgRect.GetTCharPtr());
+ inverse_texture_rect_mask_asm_prog_->LoadVertexShader(AsmVtx.c_str());
+ inverse_texture_rect_mask_asm_prog_->LoadPixelShader(AsmFrgRect.c_str());
inverse_texture_rect_mask_asm_prog_->Link();
}
@@ -325,8 +325,8 @@ void OverlayRendererImpl::InitSlInverseTextureMaskShader()
{
nux::ObjectPtr<nux::IOpenGLVertexShader> VS = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader();
nux::ObjectPtr<nux::IOpenGLPixelShader> PS = nux::GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader();
- nux::NString VSString;
- nux::NString PSString;
+ std::string VSString;
+ std::string PSString;
VSString =
NUX_VERTEX_SHADER_HEADER
@@ -356,8 +356,8 @@ void OverlayRendererImpl::InitSlInverseTextureMaskShader()
// Textured 2D Primitive Shader
inverse_texture_mask_prog_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram();
- VS->SetShaderCode(TCHAR_TO_ANSI(*VSString));
- PS->SetShaderCode(TCHAR_TO_ANSI(*PSString), "#define SAMPLERTEX2D");
+ VS->SetShaderCode(TCHAR_TO_ANSI(VSString.c_str()));
+ PS->SetShaderCode(TCHAR_TO_ANSI(PSString.c_str()), "#define SAMPLERTEX2D");
inverse_texture_mask_prog_->ClearShaderObjects();
inverse_texture_mask_prog_->AddShaderObject(VS);
@@ -484,7 +484,7 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
gfx_context.GetRenderStates().SetBlend(false);
#ifndef NUX_OPENGLES_20
if (gfx_context.UsingGLSLCodePath())
- gfx_context.QRP_GLSL_ColorBlendOverTex (larger_content_geo.x, larger_content_geo.y,
+ gfx_context.QRP_GLSL_ColorLayerOverTexture(larger_content_geo.x, larger_content_geo.y,
larger_content_geo.width, larger_content_geo.height,
bg_blur_texture_, texxform_absolute_bg, nux::color::White,
bg_color_, nux::LAYER_BLEND_MODE_OVERLAY);
@@ -494,7 +494,7 @@ void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry c
larger_content_geo.width, larger_content_geo.height,
bg_blur_texture_, texxform_absolute_bg, nux::color::White);
#else
- gfx_context.QRP_GLSL_ColorBlendOverTex (larger_content_geo.x, larger_content_geo.y,
+ gfx_context.QRP_GLSL_ColorLayerOverTexture(larger_content_geo.x, larger_content_geo.y,
larger_content_geo.width, larger_content_geo.height,
bg_blur_texture_, texxform_absolute_bg, nux::color::White,
bg_color_, nux::LAYER_BLEND_MODE_OVERLAY);
diff --git a/unity-shared/PreviewStyle.cpp b/unity-shared/PreviewStyle.cpp
index bcfa52df7..689d80000 100644
--- a/unity-shared/PreviewStyle.cpp
+++ b/unity-shared/PreviewStyle.cpp
@@ -229,7 +229,7 @@ int Style::GetActionButtonHeight() const
int Style::GetActionButtonMaximumWidth() const
{
- return 190;
+ return 175;
}
int Style::GetSpaceBetweenActions() const