2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
24
#include "NuxGraphics/GraphicsEngine.h"
25
#include "NuxGraphics/RenderingPipe.h"
27
#include "PaintLayer.h"
32
ColorLayer::ColorLayer (const Color &color, bool write_alpha, const ROPConfig &ROP)
35
m_write_alpha = write_alpha;
39
void ColorLayer::Renderlayer (GraphicsEngine &GfxContext)
41
GfxContext.GetRenderStates().SetBlend (m_rop.Blend, m_rop.SrcBlend, m_rop.DstBlend);
42
GfxContext.QRP_GLSL_Color (m_geometry.x, m_geometry.y, m_geometry.GetWidth(), m_geometry.GetHeight(), m_color);
45
GfxContext.GetRenderStates().SetBlend (false);
48
AbstractPaintLayer *ColorLayer::Clone() const
50
return new ColorLayer (*this);
53
/////////////////////////////////////////////////////
54
ShapeLayer::ShapeLayer (UXStyleImageRef image_style, const Color &color, unsigned long corners, bool write_alpha, const ROPConfig &ROP)
56
m_image_style = image_style;
58
m_write_alpha = write_alpha;
64
void ShapeLayer::Renderlayer (GraphicsEngine &GfxContext)
66
GetPainter().PaintShapeCornerROP (GfxContext, m_geometry, m_color, m_image_style, m_corners, m_write_alpha, m_rop);
69
GfxContext.GetRenderStates().SetBlend (false);
72
AbstractPaintLayer *ShapeLayer::Clone() const
74
return new ShapeLayer (*this);
77
/////////////////////////////////////////////////////
78
SliceScaledTextureLayer::SliceScaledTextureLayer (UXStyleImageRef image_style, const Color &color, unsigned long corners, bool write_alpha, const ROPConfig &ROP)
80
m_image_style = image_style;
82
m_write_alpha = write_alpha;
87
void SliceScaledTextureLayer::Renderlayer (GraphicsEngine &GfxContext)
89
GetPainter().PaintTextureShape (GfxContext, m_geometry, m_image_style);
92
AbstractPaintLayer *SliceScaledTextureLayer::Clone() const
94
return new SliceScaledTextureLayer (*this);
97
/////////////////////////////////////////////////////
98
TextureLayer::TextureLayer (IntrusiveSP<IOpenGLBaseTexture> device_texture, TexCoordXForm texxform, const Color &color, bool write_alpha, const ROPConfig &ROP)
100
m_device_texture = device_texture;
102
m_write_alpha = write_alpha;
104
m_texxform = texxform;
107
void TextureLayer::Renderlayer (GraphicsEngine &GfxContext)
109
t_u32 current_alpha_blend;
110
t_u32 current_src_blend_factor;
111
t_u32 current_dest_blend_factor;
112
t_u32 current_red_mask;
113
t_u32 current_green_mask;
114
t_u32 current_blue_mask;
115
t_u32 current_alpha_mask;
117
// Get the current color mask and blend states. They will be restored later.
118
GfxContext.GetRenderStates ().GetColorMask (current_red_mask, current_green_mask, current_blue_mask, current_alpha_mask);
119
GfxContext.GetRenderStates ().GetBlend (current_alpha_blend, current_src_blend_factor, current_dest_blend_factor);
122
GfxContext.GetRenderStates ().SetColorMask (GL_TRUE, GL_TRUE, GL_TRUE, m_write_alpha ? GL_TRUE : GL_FALSE);
123
GfxContext.GetRenderStates ().SetBlend (m_rop.Blend, m_rop.SrcBlend, m_rop.DstBlend);
125
GfxContext.QRP_GLSL_1Tex (m_geometry.x, m_geometry.y, m_geometry.GetWidth(), m_geometry.GetHeight(), m_device_texture,
126
m_texxform, m_color);
128
// Restore Color mask and blend states.
129
GfxContext.GetRenderStates ().SetColorMask (current_red_mask, current_green_mask, current_blue_mask, current_alpha_mask);
130
GfxContext.GetRenderStates ().SetBlend (current_alpha_blend, current_src_blend_factor, current_dest_blend_factor);
134
AbstractPaintLayer *TextureLayer::Clone() const
136
return new TextureLayer (*this);