Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
c7a5ce27
Kaydet (Commit)
c7a5ce27
authored
Kas 11, 2014
tarafından
Louis-Francis Ratté-Boulianne
Kaydeden (comit)
Markus Mohrhard
Kas 12, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
vcl: Add initial support for linear gradient with OpenGL
Change-Id: Iccc12c94bfd68387dfc0161a5fde4f595edda0e1
üst
b021b598
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
2 deletions
+142
-2
Package_opengl.mk
vcl/Package_opengl.mk
+1
-0
openglgdiimpl.hxx
vcl/inc/openglgdiimpl.hxx
+9
-0
gdiimpl.cxx
vcl/opengl/gdiimpl.cxx
+109
-2
linearGradientFragmentShader.glsl
vcl/opengl/linearGradientFragmentShader.glsl
+23
-0
No files found.
vcl/Package_opengl.mk
Dosyayı görüntüle @
c7a5ce27
...
@@ -11,6 +11,7 @@ $(eval $(call gb_Package_Package,vcl_opengl_shader,$(SRCDIR)/vcl/opengl))
...
@@ -11,6 +11,7 @@ $(eval $(call gb_Package_Package,vcl_opengl_shader,$(SRCDIR)/vcl/opengl))
$(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\
$(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\
convolutionFragmentShader.glsl \
convolutionFragmentShader.glsl \
linearGradientFragmentShader.glsl \
maskFragmentShader.glsl \
maskFragmentShader.glsl \
maskVertexShader.glsl \
maskVertexShader.glsl \
maskedTextureFragmentShader.glsl \
maskedTextureFragmentShader.glsl \
...
...
vcl/inc/openglgdiimpl.hxx
Dosyayı görüntüle @
c7a5ce27
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "opengl/texture.hxx"
#include "opengl/texture.hxx"
#include <tools/poly.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
class
SalFrame
;
class
SalFrame
;
...
@@ -59,10 +60,16 @@ protected:
...
@@ -59,10 +60,16 @@ protected:
GLuint
mnMaskUniform
;
GLuint
mnMaskUniform
;
GLuint
mnMaskColorUniform
;
GLuint
mnMaskColorUniform
;
GLuint
mnLinearGradientProgram
;
GLuint
mnLinearGradientStartColorUniform
;
GLuint
mnLinearGradientEndColorUniform
;
GLuint
mnLinearGradientTransformUniform
;
bool
CreateSolidProgram
(
void
);
bool
CreateSolidProgram
(
void
);
bool
CreateTextureProgram
(
void
);
bool
CreateTextureProgram
(
void
);
bool
CreateMaskedTextureProgram
(
void
);
bool
CreateMaskedTextureProgram
(
void
);
bool
CreateMaskProgram
(
void
);
bool
CreateMaskProgram
(
void
);
bool
CreateLinearGradientProgram
(
void
);
void
BeginSolid
(
SalColor
nColor
,
sal_uInt8
nTransparency
);
void
BeginSolid
(
SalColor
nColor
,
sal_uInt8
nTransparency
);
void
BeginSolid
(
SalColor
nColor
,
double
fTransparency
);
void
BeginSolid
(
SalColor
nColor
,
double
fTransparency
);
...
@@ -75,6 +82,7 @@ protected:
...
@@ -75,6 +82,7 @@ protected:
void
DrawLine
(
long
nX1
,
long
nY1
,
long
nX2
,
long
nY2
);
void
DrawLine
(
long
nX1
,
long
nY1
,
long
nX2
,
long
nY2
);
void
DrawLines
(
sal_uInt32
nPoints
,
const
SalPoint
*
pPtAry
,
bool
bClose
);
void
DrawLines
(
sal_uInt32
nPoints
,
const
SalPoint
*
pPtAry
,
bool
bClose
);
void
DrawConvexPolygon
(
sal_uInt32
nPoints
,
const
SalPoint
*
pPtAry
);
void
DrawConvexPolygon
(
sal_uInt32
nPoints
,
const
SalPoint
*
pPtAry
);
void
DrawConvexPolygon
(
const
Polygon
&
rPolygon
);
void
DrawRect
(
long
nX
,
long
nY
,
long
nWidth
,
long
nHeight
);
void
DrawRect
(
long
nX
,
long
nY
,
long
nWidth
,
long
nHeight
);
void
DrawPolygon
(
sal_uInt32
nPoints
,
const
SalPoint
*
pPtAry
);
void
DrawPolygon
(
sal_uInt32
nPoints
,
const
SalPoint
*
pPtAry
);
void
DrawPolyPolygon
(
const
basegfx
::
B2DPolyPolygon
&
rPolyPolygon
);
void
DrawPolyPolygon
(
const
basegfx
::
B2DPolyPolygon
&
rPolyPolygon
);
...
@@ -82,6 +90,7 @@ protected:
...
@@ -82,6 +90,7 @@ protected:
void
DrawTexture
(
GLuint
nTexture
,
const
Size
&
rSize
,
const
SalTwoRect
&
rPosAry
);
void
DrawTexture
(
GLuint
nTexture
,
const
Size
&
rSize
,
const
SalTwoRect
&
rPosAry
);
void
DrawTextureWithMask
(
GLuint
nTexture
,
GLuint
nMask
,
const
Size
&
rSize
,
const
SalTwoRect
&
rPosAry
);
void
DrawTextureWithMask
(
GLuint
nTexture
,
GLuint
nMask
,
const
Size
&
rSize
,
const
SalTwoRect
&
rPosAry
);
void
DrawMask
(
GLuint
nMask
,
SalColor
nMaskColor
,
const
SalTwoRect
&
rPosAry
);
void
DrawMask
(
GLuint
nMask
,
SalColor
nMaskColor
,
const
SalTwoRect
&
rPosAry
);
void
DrawLinearGradient
(
const
Gradient
&
rGradient
,
const
Rectangle
&
rRect
);
protected
:
protected
:
// get the width of the device
// get the width of the device
...
...
vcl/opengl/gdiimpl.cxx
Dosyayı görüntüle @
c7a5ce27
...
@@ -51,6 +51,13 @@
...
@@ -51,6 +51,13 @@
((float) SALCOLOR_BLUE( nColor )) / 255, \
((float) SALCOLOR_BLUE( nColor )) / 255, \
(1.0f - fTransparency) )
(1.0f - fTransparency) )
#define glUniformColorIntensity(nUniform, aColor, nFactor) \
glUniform4f( nUniform, \
((float) aColor.GetRed()) * nFactor / 25500.0, \
((float) aColor.GetGreen()) * nFactor / 25500.0, \
((float) aColor.GetBlue()) * nFactor / 25500.0, \
1.0f )
OpenGLSalGraphicsImpl
::
OpenGLSalGraphicsImpl
()
OpenGLSalGraphicsImpl
::
OpenGLSalGraphicsImpl
()
:
mpFrame
(
NULL
)
:
mpFrame
(
NULL
)
,
mbOffscreen
(
false
)
,
mbOffscreen
(
false
)
...
@@ -278,6 +285,20 @@ bool OpenGLSalGraphicsImpl::CreateMaskProgram( void )
...
@@ -278,6 +285,20 @@ bool OpenGLSalGraphicsImpl::CreateMaskProgram( void )
return
true
;
return
true
;
}
}
bool
OpenGLSalGraphicsImpl
::
CreateLinearGradientProgram
(
void
)
{
mnLinearGradientProgram
=
OpenGLHelper
::
LoadShaders
(
"textureVertexShader"
,
"linearGradientFragmentShader"
);
if
(
mnLinearGradientProgram
==
0
)
return
false
;
glBindAttribLocation
(
mnTextureProgram
,
GL_ATTRIB_POS
,
"position"
);
glBindAttribLocation
(
mnTextureProgram
,
GL_ATTRIB_TEX
,
"tex_coord_in"
);
mnLinearGradientStartColorUniform
=
glGetUniformLocation
(
mnLinearGradientProgram
,
"start_color"
);
mnLinearGradientEndColorUniform
=
glGetUniformLocation
(
mnLinearGradientProgram
,
"end_color"
);
mnLinearGradientTransformUniform
=
glGetUniformLocation
(
mnLinearGradientProgram
,
"transform"
);
return
true
;
}
void
OpenGLSalGraphicsImpl
::
BeginSolid
(
SalColor
nColor
,
sal_uInt8
nTransparency
)
void
OpenGLSalGraphicsImpl
::
BeginSolid
(
SalColor
nColor
,
sal_uInt8
nTransparency
)
{
{
if
(
mnSolidProgram
==
0
)
if
(
mnSolidProgram
==
0
)
...
@@ -403,6 +424,25 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
...
@@ -403,6 +424,25 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
glDisableVertexAttribArray
(
GL_ATTRIB_POS
);
glDisableVertexAttribArray
(
GL_ATTRIB_POS
);
}
}
void
OpenGLSalGraphicsImpl
::
DrawConvexPolygon
(
const
Polygon
&
rPolygon
)
{
sal_uInt16
nPoints
=
rPolygon
.
GetSize
()
-
1
;
std
::
vector
<
GLfloat
>
aVertices
(
nPoints
*
2
);
sal_uInt32
i
,
j
;
for
(
i
=
0
,
j
=
0
;
i
<
nPoints
;
i
++
,
j
+=
2
)
{
const
Point
&
rPt
=
rPolygon
.
GetPoint
(
i
);
aVertices
[
j
]
=
(
2
*
rPt
.
X
())
/
GetWidth
()
-
1.0
;
aVertices
[
j
+
1
]
=
(
2
*
(
GetHeight
()
-
rPt
.
Y
()))
/
GetHeight
()
-
1.0
;
}
glEnableVertexAttribArray
(
GL_ATTRIB_POS
);
glVertexAttribPointer
(
GL_ATTRIB_POS
,
2
,
GL_FLOAT
,
GL_FALSE
,
0
,
&
aVertices
[
0
]
);
glDrawArrays
(
GL_TRIANGLE_FAN
,
0
,
nPoints
);
glDisableVertexAttribArray
(
GL_ATTRIB_POS
);
}
void
OpenGLSalGraphicsImpl
::
DrawRect
(
long
nX
,
long
nY
,
long
nWidth
,
long
nHeight
)
void
OpenGLSalGraphicsImpl
::
DrawRect
(
long
nX
,
long
nY
,
long
nWidth
,
long
nHeight
)
{
{
long
nX1
(
nX
);
long
nX1
(
nX
);
...
@@ -550,6 +590,60 @@ void OpenGLSalGraphicsImpl::DrawMask( GLuint nMask, SalColor nMaskColor, const S
...
@@ -550,6 +590,60 @@ void OpenGLSalGraphicsImpl::DrawMask( GLuint nMask, SalColor nMaskColor, const S
glUseProgram
(
0
);
glUseProgram
(
0
);
}
}
void
OpenGLSalGraphicsImpl
::
DrawLinearGradient
(
const
Gradient
&
rGradient
,
const
Rectangle
&
rRect
)
{
if
(
rGradient
.
GetBorder
()
>=
100.0
)
{
// border >= 100%, draw solid rectangle
Color
aCol
=
rGradient
.
GetStartColor
();
long
nF
=
rGradient
.
GetStartIntensity
();
BeginSolid
(
MAKE_SALCOLOR
(
aCol
.
GetRed
()
*
nF
/
100
,
aCol
.
GetGreen
()
*
nF
/
100
,
aCol
.
GetBlue
()
*
nF
/
100
)
);
DrawRect
(
rRect
.
Left
(),
rRect
.
Top
(),
rRect
.
GetWidth
(),
rRect
.
GetHeight
()
);
EndSolid
();
return
;
}
if
(
mnLinearGradientProgram
==
0
)
{
if
(
!
CreateLinearGradientProgram
()
)
return
;
}
glUseProgram
(
mnLinearGradientProgram
);
Color
aStartCol
=
rGradient
.
GetStartColor
();
Color
aEndCol
=
rGradient
.
GetEndColor
();
long
nFactor
=
rGradient
.
GetStartIntensity
();
glUniformColorIntensity
(
mnLinearGradientStartColorUniform
,
aStartCol
,
nFactor
);
nFactor
=
rGradient
.
GetEndIntensity
();
glUniformColorIntensity
(
mnLinearGradientEndColorUniform
,
aEndCol
,
nFactor
);
Rectangle
aBoundRect
;
Point
aCenter
;
rGradient
.
GetBoundRect
(
rRect
,
aBoundRect
,
aCenter
);
aBoundRect
.
Left
()
--
;
aBoundRect
.
Top
()
--
;
aBoundRect
.
Right
()
++
;
aBoundRect
.
Bottom
()
++
;
Polygon
aPoly
(
aBoundRect
);
aPoly
.
Rotate
(
aCenter
,
rGradient
.
GetAngle
()
%
3600
);
GLfloat
aTexCoord
[
8
]
=
{
0
,
1
,
1
,
1
,
1
,
0
,
0
,
0
};
GLfloat
fMin
=
1.0
-
100.0
/
(
100.0
-
rGradient
.
GetBorder
());
aTexCoord
[
5
]
=
aTexCoord
[
7
]
=
fMin
;
glEnableVertexAttribArray
(
GL_ATTRIB_TEX
);
glVertexAttribPointer
(
GL_ATTRIB_TEX
,
2
,
GL_FLOAT
,
GL_FALSE
,
0
,
aTexCoord
);
DrawConvexPolygon
(
aPoly
);
glDisableVertexAttribArray
(
GL_ATTRIB_TEX
);
CHECK_GL_ERROR
();
glUseProgram
(
0
);
}
// draw --> LineColor and FillColor and RasterOp and ClipRegion
// draw --> LineColor and FillColor and RasterOp and ClipRegion
void
OpenGLSalGraphicsImpl
::
drawPixel
(
long
nX
,
long
nY
)
void
OpenGLSalGraphicsImpl
::
drawPixel
(
long
nX
,
long
nY
)
...
@@ -1083,9 +1177,22 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect(
...
@@ -1083,9 +1177,22 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect(
return
true
;
return
true
;
}
}
bool
OpenGLSalGraphicsImpl
::
drawGradient
(
const
tools
::
PolyPolygon
&
/*rPolygon*/
,
bool
OpenGLSalGraphicsImpl
::
drawGradient
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
const
Gradient
&
/*rGradient*/
)
const
Gradient
&
rGradient
)
{
{
const
Rectangle
aBoundRect
(
rPolyPoly
.
GetBoundRect
()
);
if
(
aBoundRect
.
IsEmpty
()
)
return
true
;
//TODO: lfrb: some missing transformation with the polygon in outdev
if
(
rGradient
.
GetStyle
()
==
GradientStyle_LINEAR
)
{
PreDraw
();
DrawLinearGradient
(
rGradient
,
aBoundRect
);
PostDraw
();
return
true
;
}
return
false
;
return
false
;
}
}
...
...
vcl/opengl/linearGradientFragmentShader.glsl
0 → 100644
Dosyayı görüntüle @
c7a5ce27
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#version 120
uniform
vec4
start_color
;
uniform
vec4
end_color
;
uniform
mat3x3
transform
;
varying
vec2
tex_coord
;
void
main
(
void
)
{
gl_FragColor
=
mix
(
start_color
,
end_color
,
clamp
(
tex_coord
.
t
,
0
.
0
,
1
.
0
));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment