author | Jose Thachil<jose.thachil@cell-telecom.com> |
Wed, 12 May 2010 13:05:33 +0100 | |
branch | EGL_MERGE |
changeset 59 | 0fb7b31791c3 |
parent 57 | 2bf8a359aa2f |
permissions | -rw-r--r-- |
57
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
1 |
/*------------------------------------------------------------------------ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
2 |
* |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
3 |
* OpenVG 1.1 Reference Implementation |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
4 |
* ----------------------------------- |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
5 |
* |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
6 |
* Copyright (c) 2007 The Khronos Group Inc. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
7 |
* |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
8 |
* Permission is hereby granted, free of charge, to any person obtaining a |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
9 |
* copy of this software and /or associated documentation files |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
10 |
* (the "Materials "), to deal in the Materials without restriction, |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
11 |
* including without limitation the rights to use, copy, modify, merge, |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
12 |
* publish, distribute, sublicense, and/or sell copies of the Materials, |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
13 |
* and to permit persons to whom the Materials are furnished to do so, |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
14 |
* subject to the following conditions: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
15 |
* |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
16 |
* The above copyright notice and this permission notice shall be included |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
17 |
* in all copies or substantial portions of the Materials. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
18 |
* |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
19 |
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
20 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
21 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
22 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
23 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
24 |
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
25 |
* THE USE OR OTHER DEALINGS IN THE MATERIALS. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
26 |
* |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
27 |
*//** |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
28 |
* \file |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
29 |
* \brief Implementation of Paint and pixel pipe functionality. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
30 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
31 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
32 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
33 |
#include "riPixelPipe.h" |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
34 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
35 |
//============================================================================================== |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
36 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
37 |
namespace OpenVGRI |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
38 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
39 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
40 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
41 |
* \brief Paint constructor. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
42 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
43 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
44 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
45 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
46 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
47 |
Paint::Paint() : |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
48 |
m_paintType(VG_PAINT_TYPE_COLOR), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
49 |
m_paintColor(0,0,0,1,Color::sRGBA_PRE), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
50 |
m_inputPaintColor(0,0,0,1,Color::sRGBA), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
51 |
m_colorRampSpreadMode(VG_COLOR_RAMP_SPREAD_PAD), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
52 |
m_colorRampStops(), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
53 |
m_inputColorRampStops(), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
54 |
m_colorRampPremultiplied(VG_TRUE), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
55 |
m_inputLinearGradientPoint0(0,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
56 |
m_inputLinearGradientPoint1(1,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
57 |
m_inputRadialGradientCenter(0,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
58 |
m_inputRadialGradientFocalPoint(0,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
59 |
m_inputRadialGradientRadius(1.0f), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
60 |
m_linearGradientPoint0(0,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
61 |
m_linearGradientPoint1(1,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
62 |
m_radialGradientCenter(0,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
63 |
m_radialGradientFocalPoint(0,0), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
64 |
m_radialGradientRadius(1.0f), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
65 |
m_patternTilingMode(VG_TILE_FILL), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
66 |
m_pattern(NULL), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
67 |
m_referenceCount(0) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
68 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
69 |
Paint::GradientStop gs; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
70 |
gs.offset = 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
71 |
gs.color.set(0,0,0,1,Color::sRGBA); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
72 |
m_colorRampStops.push_back(gs); //throws bad_alloc |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
73 |
gs.offset = 1.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
74 |
gs.color.set(1,1,1,1,Color::sRGBA); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
75 |
m_colorRampStops.push_back(gs); //throws bad_alloc |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
76 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
77 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
78 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
79 |
* \brief Paint destructor. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
80 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
81 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
82 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
83 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
84 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
85 |
Paint::~Paint() |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
86 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
87 |
RI_ASSERT(m_referenceCount == 0); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
88 |
if(m_pattern) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
89 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
90 |
m_pattern->removeInUse(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
91 |
if(!m_pattern->removeReference()) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
92 |
RI_DELETE(m_pattern); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
93 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
94 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
95 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
96 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
97 |
* \brief PixelPipe constructor. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
98 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
99 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
100 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
101 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
102 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
103 |
PixelPipe::PixelPipe() : |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
104 |
m_drawable(NULL), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
105 |
m_image(NULL), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
106 |
m_paint(NULL), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
107 |
m_defaultPaint(), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
108 |
m_blendMode(VG_BLEND_SRC_OVER), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
109 |
m_imageMode(VG_DRAW_IMAGE_NORMAL), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
110 |
m_imageQuality(VG_IMAGE_QUALITY_FASTER), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
111 |
m_tileFillColor(0,0,0,0,Color::sRGBA), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
112 |
m_colorTransform(false), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
113 |
m_colorTransformValues(), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
114 |
m_surfaceToPaintMatrix(), |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
115 |
m_surfaceToImageMatrix() |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
116 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
117 |
for(int i=0;i<8;i++) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
118 |
m_colorTransformValues[i] = (i < 4) ? 1.0f : 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
119 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
120 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
121 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
122 |
* \brief PixelPipe destructor. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
123 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
124 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
125 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
126 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
127 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
128 |
PixelPipe::~PixelPipe() |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
129 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
130 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
131 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
132 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
133 |
* \brief Sets the rendering surface. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
134 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
135 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
136 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
137 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
138 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
139 |
void PixelPipe::setDrawable(Drawable* drawable) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
140 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
141 |
RI_ASSERT(drawable); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
142 |
m_drawable = drawable; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
143 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
144 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
145 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
146 |
* \brief Sets the blend mode. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
147 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
148 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
149 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
150 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
151 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
152 |
void PixelPipe::setBlendMode(VGBlendMode blendMode) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
153 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
154 |
RI_ASSERT(blendMode >= VG_BLEND_SRC && blendMode <= VG_BLEND_ADDITIVE); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
155 |
m_blendMode = blendMode; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
156 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
157 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
158 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
159 |
* \brief Sets the mask image. NULL disables masking. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
160 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
161 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
162 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
163 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
164 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
165 |
void PixelPipe::setMask(bool masking) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
166 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
167 |
m_masking = masking; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
168 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
169 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
170 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
171 |
* \brief Sets the image to be drawn. NULL disables image drawing. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
172 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
173 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
174 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
175 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
176 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
177 |
void PixelPipe::setImage(Image* image, VGImageMode imageMode) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
178 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
179 |
RI_ASSERT(imageMode == VG_DRAW_IMAGE_NORMAL || imageMode == VG_DRAW_IMAGE_MULTIPLY || imageMode == VG_DRAW_IMAGE_STENCIL); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
180 |
m_image = image; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
181 |
m_imageMode = imageMode; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
182 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
183 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
184 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
185 |
* \brief Sets the surface-to-paint matrix. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
186 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
187 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
188 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
189 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
190 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
191 |
void PixelPipe::setSurfaceToPaintMatrix(const Matrix3x3& surfaceToPaintMatrix) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
192 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
193 |
m_surfaceToPaintMatrix = surfaceToPaintMatrix; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
194 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
195 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
196 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
197 |
* \brief Sets the surface-to-image matrix. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
198 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
199 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
200 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
201 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
202 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
203 |
void PixelPipe::setSurfaceToImageMatrix(const Matrix3x3& surfaceToImageMatrix) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
204 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
205 |
m_surfaceToImageMatrix = surfaceToImageMatrix; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
206 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
207 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
208 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
209 |
* \brief Sets image quality. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
210 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
211 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
212 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
213 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
214 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
215 |
void PixelPipe::setImageQuality(VGImageQuality imageQuality) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
216 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
217 |
RI_ASSERT(imageQuality == VG_IMAGE_QUALITY_NONANTIALIASED || imageQuality == VG_IMAGE_QUALITY_FASTER || imageQuality == VG_IMAGE_QUALITY_BETTER); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
218 |
m_imageQuality = imageQuality; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
219 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
220 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
221 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
222 |
* \brief Sets fill color for VG_TILE_FILL tiling mode (pattern only). |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
223 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
224 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
225 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
226 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
227 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
228 |
void PixelPipe::setTileFillColor(const Color& c) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
229 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
230 |
m_tileFillColor = c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
231 |
m_tileFillColor.clamp(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
232 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
233 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
234 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
235 |
* \brief Sets paint. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
236 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
237 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
238 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
239 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
240 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
241 |
void PixelPipe::setPaint(const Paint* paint) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
242 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
243 |
m_paint = paint; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
244 |
if(!m_paint) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
245 |
m_paint = &m_defaultPaint; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
246 |
if(m_paint->m_pattern) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
247 |
m_tileFillColor.convert(m_paint->m_pattern->getDescriptor().internalFormat); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
248 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
249 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
250 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
251 |
* \brief Color transform. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
252 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
253 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
254 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
255 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
256 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
257 |
void PixelPipe::setColorTransform(bool enable, RIfloat values[8]) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
258 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
259 |
m_colorTransform = enable; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
260 |
for(int i=0;i<4;i++) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
261 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
262 |
m_colorTransformValues[i] = RI_CLAMP(values[i], -127.0f, 127.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
263 |
m_colorTransformValues[i+4] = RI_CLAMP(values[i+4], -1.0f, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
264 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
265 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
266 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
267 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
268 |
* \brief Computes the linear gradient function at (x,y). |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
269 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
270 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
271 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
272 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
273 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
274 |
void PixelPipe::linearGradient(RIfloat& g, RIfloat& rho, RIfloat x, RIfloat y) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
275 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
276 |
RI_ASSERT(m_paint); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
277 |
Vector2 u = m_paint->m_linearGradientPoint1 - m_paint->m_linearGradientPoint0; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
278 |
RIfloat usq = dot(u,u); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
279 |
if( usq <= 0.0f ) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
280 |
{ //points are equal, gradient is always 1.0f |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
281 |
g = 1.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
282 |
rho = 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
283 |
return; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
284 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
285 |
RIfloat oou = 1.0f / usq; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
286 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
287 |
Vector2 p(x, y); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
288 |
p = affineTransform(m_surfaceToPaintMatrix, p); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
289 |
p -= m_paint->m_linearGradientPoint0; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
290 |
RI_ASSERT(usq >= 0.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
291 |
g = dot(p, u) * oou; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
292 |
RIfloat dgdx = oou * u.x * m_surfaceToPaintMatrix[0][0] + oou * u.y * m_surfaceToPaintMatrix[1][0]; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
293 |
RIfloat dgdy = oou * u.x * m_surfaceToPaintMatrix[0][1] + oou * u.y * m_surfaceToPaintMatrix[1][1]; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
294 |
rho = (RIfloat)sqrt(dgdx*dgdx + dgdy*dgdy); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
295 |
RI_ASSERT(rho >= 0.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
296 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
297 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
298 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
299 |
* \brief Computes the radial gradient function at (x,y). |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
300 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
301 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
302 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
303 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
304 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
305 |
void PixelPipe::radialGradient(RIfloat &g, RIfloat &rho, RIfloat x, RIfloat y) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
306 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
307 |
RI_ASSERT(m_paint); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
308 |
if( m_paint->m_radialGradientRadius <= 0.0f ) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
309 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
310 |
g = 1.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
311 |
rho = 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
312 |
return; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
313 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
314 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
315 |
RIfloat r = m_paint->m_radialGradientRadius; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
316 |
Vector2 c = m_paint->m_radialGradientCenter; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
317 |
Vector2 f = m_paint->m_radialGradientFocalPoint; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
318 |
Vector2 gx(m_surfaceToPaintMatrix[0][0], m_surfaceToPaintMatrix[1][0]); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
319 |
Vector2 gy(m_surfaceToPaintMatrix[0][1], m_surfaceToPaintMatrix[1][1]); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
320 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
321 |
Vector2 fp = f - c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
322 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
323 |
//clamp the focal point inside the gradient circle |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
324 |
RIfloat fpLen = fp.length(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
325 |
if( fpLen > 0.999f * r ) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
326 |
fp *= 0.999f * r / fpLen; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
327 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
328 |
RIfloat D = -1.0f / (dot(fp,fp) - r*r); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
329 |
Vector2 p(x, y); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
330 |
p = affineTransform(m_surfaceToPaintMatrix, p) - c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
331 |
Vector2 d = p - fp; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
332 |
RIfloat s = (RIfloat)sqrt(r*r*dot(d,d) - RI_SQR(p.x*fp.y - p.y*fp.x)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
333 |
g = (dot(fp,d) + s) * D; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
334 |
if(RI_ISNAN(g)) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
335 |
g = 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
336 |
RIfloat dgdx = D*dot(fp,gx) + (r*r*dot(d,gx) - (gx.x*fp.y - gx.y*fp.x)*(p.x*fp.y - p.y*fp.x)) * (D / s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
337 |
RIfloat dgdy = D*dot(fp,gy) + (r*r*dot(d,gy) - (gy.x*fp.y - gy.y*fp.x)*(p.x*fp.y - p.y*fp.x)) * (D / s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
338 |
rho = (RIfloat)sqrt(dgdx*dgdx + dgdy*dgdy); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
339 |
if(RI_ISNAN(rho)) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
340 |
rho = 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
341 |
RI_ASSERT(rho >= 0.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
342 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
343 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
344 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
345 |
* \brief Returns the average color within an offset range in the color ramp. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
346 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
347 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
348 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
349 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
350 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
351 |
static Color readStopColor(const Array<Paint::GradientStop>& colorRampStops, int i, VGboolean colorRampPremultiplied) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
352 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
353 |
RI_ASSERT(i >= 0 && i < colorRampStops.size()); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
354 |
Color c = colorRampStops[i].color; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
355 |
RI_ASSERT(c.getInternalFormat() == Color::sRGBA); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
356 |
if(colorRampPremultiplied) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
357 |
c.premultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
358 |
return c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
359 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
360 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
361 |
Color PixelPipe::integrateColorRamp(RIfloat gmin, RIfloat gmax) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
362 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
363 |
RI_ASSERT(gmin <= gmax); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
364 |
RI_ASSERT(gmin >= 0.0f && gmin <= 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
365 |
RI_ASSERT(gmax >= 0.0f && gmax <= 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
366 |
RI_ASSERT(m_paint->m_colorRampStops.size() >= 2); //there are at least two stops |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
367 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
368 |
Color c(0,0,0,0,m_paint->m_colorRampPremultiplied ? Color::sRGBA_PRE : Color::sRGBA); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
369 |
if(gmin == 1.0f || gmax == 0.0f) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
370 |
return c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
371 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
372 |
int i=0; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
373 |
for(;i<m_paint->m_colorRampStops.size()-1;i++) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
374 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
375 |
if(gmin >= m_paint->m_colorRampStops[i].offset && gmin < m_paint->m_colorRampStops[i+1].offset) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
376 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
377 |
RIfloat s = m_paint->m_colorRampStops[i].offset; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
378 |
RIfloat e = m_paint->m_colorRampStops[i+1].offset; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
379 |
RI_ASSERT(s < e); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
380 |
RIfloat g = (gmin - s) / (e - s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
381 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
382 |
Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
383 |
Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
384 |
Color rc = (1.0f-g) * sc + g * ec; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
385 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
386 |
//subtract the average color from the start of the stop to gmin |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
387 |
c -= 0.5f*(gmin - s)*(sc + rc); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
388 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
389 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
390 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
391 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
392 |
for(;i<m_paint->m_colorRampStops.size()-1;i++) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
393 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
394 |
RIfloat s = m_paint->m_colorRampStops[i].offset; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
395 |
RIfloat e = m_paint->m_colorRampStops[i+1].offset; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
396 |
RI_ASSERT(s <= e); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
397 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
398 |
Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
399 |
Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
400 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
401 |
//average of the stop |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
402 |
c += 0.5f*(e-s)*(sc + ec); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
403 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
404 |
if(gmax >= m_paint->m_colorRampStops[i].offset && gmax < m_paint->m_colorRampStops[i+1].offset) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
405 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
406 |
RIfloat g = (gmax - s) / (e - s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
407 |
Color rc = (1.0f-g) * sc + g * ec; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
408 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
409 |
//subtract the average color from gmax to the end of the stop |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
410 |
c -= 0.5f*(e - gmax)*(rc + ec); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
411 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
412 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
413 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
414 |
return c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
415 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
416 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
417 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
418 |
* \brief Maps a gradient function value to a color. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
419 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
420 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
421 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
422 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
423 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
424 |
Color PixelPipe::colorRamp(RIfloat gradient, RIfloat rho) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
425 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
426 |
RI_ASSERT(m_paint); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
427 |
RI_ASSERT(rho >= 0.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
428 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
429 |
Color c(0,0,0,0,m_paint->m_colorRampPremultiplied ? Color::sRGBA_PRE : Color::sRGBA); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
430 |
Color avg; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
431 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
432 |
if(rho == 0.0f) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
433 |
{ //filter size is zero or gradient is degenerate |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
434 |
switch(m_paint->m_colorRampSpreadMode) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
435 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
436 |
case VG_COLOR_RAMP_SPREAD_PAD: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
437 |
gradient = RI_CLAMP(gradient, 0.0f, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
438 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
439 |
case VG_COLOR_RAMP_SPREAD_REFLECT: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
440 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
441 |
RIfloat g = RI_MOD(gradient, 2.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
442 |
gradient = (g < 1.0f) ? g : 2.0f - g; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
443 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
444 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
445 |
default: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
446 |
RI_ASSERT(m_paint->m_colorRampSpreadMode == VG_COLOR_RAMP_SPREAD_REPEAT); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
447 |
gradient = gradient - (RIfloat)floor(gradient); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
448 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
449 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
450 |
RI_ASSERT(gradient >= 0.0f && gradient <= 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
451 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
452 |
for(int i=0;i<m_paint->m_colorRampStops.size()-1;i++) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
453 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
454 |
if(gradient >= m_paint->m_colorRampStops[i].offset && gradient < m_paint->m_colorRampStops[i+1].offset) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
455 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
456 |
RIfloat s = m_paint->m_colorRampStops[i].offset; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
457 |
RIfloat e = m_paint->m_colorRampStops[i+1].offset; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
458 |
RI_ASSERT(s < e); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
459 |
RIfloat g = RI_CLAMP((gradient - s) / (e - s), 0.0f, 1.0f); //clamp needed due to numerical inaccuracies |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
460 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
461 |
Color sc = readStopColor(m_paint->m_colorRampStops, i, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
462 |
Color ec = readStopColor(m_paint->m_colorRampStops, i+1, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
463 |
return (1.0f-g) * sc + g * ec; //return interpolated value |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
464 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
465 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
466 |
return readStopColor(m_paint->m_colorRampStops, m_paint->m_colorRampStops.size()-1, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
467 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
468 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
469 |
RIfloat gmin = gradient - rho*0.5f; //filter starting from the gradient point (if starts earlier, radial gradient center will be an average of the first and the last stop, which doesn't look good) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
470 |
RIfloat gmax = gradient + rho*0.5f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
471 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
472 |
switch(m_paint->m_colorRampSpreadMode) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
473 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
474 |
case VG_COLOR_RAMP_SPREAD_PAD: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
475 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
476 |
if(gmin < 0.0f) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
477 |
c += (RI_MIN(gmax, 0.0f) - gmin) * readStopColor(m_paint->m_colorRampStops, 0, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
478 |
if(gmax > 1.0f) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
479 |
c += (gmax - RI_MAX(gmin, 1.0f)) * readStopColor(m_paint->m_colorRampStops, m_paint->m_colorRampStops.size()-1, m_paint->m_colorRampPremultiplied); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
480 |
gmin = RI_CLAMP(gmin, 0.0f, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
481 |
gmax = RI_CLAMP(gmax, 0.0f, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
482 |
c += integrateColorRamp(gmin, gmax); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
483 |
c *= 1.0f/rho; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
484 |
c.clamp(); //clamp needed due to numerical inaccuracies |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
485 |
return c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
486 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
487 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
488 |
case VG_COLOR_RAMP_SPREAD_REFLECT: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
489 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
490 |
avg = integrateColorRamp(0.0f, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
491 |
RIfloat gmini = (RIfloat)floor(gmin); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
492 |
RIfloat gmaxi = (RIfloat)floor(gmax); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
493 |
c = (gmaxi + 1.0f - gmini) * avg; //full ramps |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
494 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
495 |
//subtract beginning |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
496 |
if(((int)gmini) & 1) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
497 |
c -= integrateColorRamp(RI_CLAMP(1.0f - (gmin - gmini), 0.0f, 1.0f), 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
498 |
else |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
499 |
c -= integrateColorRamp(0.0f, RI_CLAMP(gmin - gmini, 0.0f, 1.0f)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
500 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
501 |
//subtract end |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
502 |
if(((int)gmaxi) & 1) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
503 |
c -= integrateColorRamp(0.0f, RI_CLAMP(1.0f - (gmax - gmaxi), 0.0f, 1.0f)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
504 |
else |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
505 |
c -= integrateColorRamp(RI_CLAMP(gmax - gmaxi, 0.0f, 1.0f), 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
506 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
507 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
508 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
509 |
default: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
510 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
511 |
RI_ASSERT(m_paint->m_colorRampSpreadMode == VG_COLOR_RAMP_SPREAD_REPEAT); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
512 |
avg = integrateColorRamp(0.0f, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
513 |
RIfloat gmini = (RIfloat)floor(gmin); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
514 |
RIfloat gmaxi = (RIfloat)floor(gmax); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
515 |
c = (gmaxi + 1.0f - gmini) * avg; //full ramps |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
516 |
c -= integrateColorRamp(0.0f, RI_CLAMP(gmin - gmini, 0.0f, 1.0f)); //subtract beginning |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
517 |
c -= integrateColorRamp(RI_CLAMP(gmax - gmaxi, 0.0f, 1.0f), 1.0f); //subtract end |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
518 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
519 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
520 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
521 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
522 |
//divide color by the length of the range |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
523 |
c *= 1.0f / rho; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
524 |
c.clamp(); //clamp needed due to numerical inaccuracies |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
525 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
526 |
//hide aliasing by fading to the average color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
527 |
const RIfloat fadeStart = 0.5f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
528 |
const RIfloat fadeMultiplier = 2.0f; //the larger, the earlier fade to average is done |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
529 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
530 |
if(rho < fadeStart) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
531 |
return c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
532 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
533 |
RIfloat ratio = RI_MIN((rho - fadeStart) * fadeMultiplier, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
534 |
return ratio * avg + (1.0f - ratio) * c; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
535 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
536 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
537 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
538 |
* \brief Computes blend. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
539 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
540 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
541 |
* \note premultiplied blending formulas |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
542 |
//src |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
543 |
a = asrc |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
544 |
r = rsrc |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
545 |
//src over |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
546 |
a = asrc + adst * (1-asrc) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
547 |
r = rsrc + rdst * (1-asrc) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
548 |
//dst over |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
549 |
a = asrc * (1-adst) + adst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
550 |
r = rsrc * (1-adst) + adst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
551 |
//src in |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
552 |
a = asrc * adst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
553 |
r = rsrc * adst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
554 |
//dst in |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
555 |
a = adst * asrc |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
556 |
r = rdst * asrc |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
557 |
//multiply |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
558 |
a = asrc + adst * (1-asrc) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
559 |
r = rsrc * (1-adst) + rdst * (1-asrc) + rsrc * rdst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
560 |
//screen |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
561 |
a = asrc + adst * (1-asrc) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
562 |
r = rsrc + rdst - rsrc * rdst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
563 |
//darken |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
564 |
a = asrc + adst * (1-asrc) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
565 |
r = MIN(rsrc + rdst * (1-asrc), rdst + rsrc * (1-adst)) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
566 |
//lighten |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
567 |
a = asrc + adst * (1-asrc) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
568 |
r = MAX(rsrc + rdst * (1-asrc), rdst + rsrc * (1-adst)) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
569 |
//additive |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
570 |
a = MIN(asrc+adst,1) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
571 |
r = rsrc + rdst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
572 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
573 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
574 |
Color PixelPipe::blend(const Color& s, RIfloat ar, RIfloat ag, RIfloat ab, const Color& d, VGBlendMode blendMode) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
575 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
576 |
//apply blending in the premultiplied format |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
577 |
Color r(0,0,0,0,d.getInternalFormat()); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
578 |
RI_ASSERT(s.a >= 0.0f && s.a <= 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
579 |
RI_ASSERT(s.r >= 0.0f && s.r <= s.a && s.r <= ar); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
580 |
RI_ASSERT(s.g >= 0.0f && s.g <= s.a && s.g <= ag); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
581 |
RI_ASSERT(s.b >= 0.0f && s.b <= s.a && s.b <= ab); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
582 |
RI_ASSERT(d.a >= 0.0f && d.a <= 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
583 |
RI_ASSERT(d.r >= 0.0f && d.r <= d.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
584 |
RI_ASSERT(d.g >= 0.0f && d.g <= d.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
585 |
RI_ASSERT(d.b >= 0.0f && d.b <= d.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
586 |
switch(blendMode) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
587 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
588 |
case VG_BLEND_SRC: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
589 |
r = s; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
590 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
591 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
592 |
case VG_BLEND_SRC_OVER: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
593 |
r.r = s.r + d.r * (1.0f - ar); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
594 |
r.g = s.g + d.g * (1.0f - ag); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
595 |
r.b = s.b + d.b * (1.0f - ab); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
596 |
r.a = s.a + d.a * (1.0f - s.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
597 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
598 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
599 |
case VG_BLEND_DST_OVER: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
600 |
r.r = s.r * (1.0f - d.a) + d.r; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
601 |
r.g = s.g * (1.0f - d.a) + d.g; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
602 |
r.b = s.b * (1.0f - d.a) + d.b; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
603 |
r.a = s.a * (1.0f - d.a) + d.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
604 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
605 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
606 |
case VG_BLEND_SRC_IN: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
607 |
r.r = s.r * d.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
608 |
r.g = s.g * d.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
609 |
r.b = s.b * d.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
610 |
r.a = s.a * d.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
611 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
612 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
613 |
case VG_BLEND_DST_IN: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
614 |
r.r = d.r * ar; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
615 |
r.g = d.g * ag; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
616 |
r.b = d.b * ab; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
617 |
r.a = d.a * s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
618 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
619 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
620 |
case VG_BLEND_MULTIPLY: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
621 |
r.r = s.r * (1.0f - d.a + d.r) + d.r * (1.0f - ar); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
622 |
r.g = s.g * (1.0f - d.a + d.g) + d.g * (1.0f - ag); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
623 |
r.b = s.b * (1.0f - d.a + d.b) + d.b * (1.0f - ab); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
624 |
r.a = s.a + d.a * (1.0f - s.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
625 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
626 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
627 |
case VG_BLEND_SCREEN: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
628 |
r.r = s.r + d.r * (1.0f - s.r); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
629 |
r.g = s.g + d.g * (1.0f - s.g); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
630 |
r.b = s.b + d.b * (1.0f - s.b); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
631 |
r.a = s.a + d.a * (1.0f - s.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
632 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
633 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
634 |
case VG_BLEND_DARKEN: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
635 |
r.r = RI_MIN(s.r + d.r * (1.0f - ar), d.r + s.r * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
636 |
r.g = RI_MIN(s.g + d.g * (1.0f - ag), d.g + s.g * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
637 |
r.b = RI_MIN(s.b + d.b * (1.0f - ab), d.b + s.b * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
638 |
r.a = s.a + d.a * (1.0f - s.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
639 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
640 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
641 |
case VG_BLEND_LIGHTEN: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
642 |
r.r = RI_MAX(s.r + d.r * (1.0f - ar), d.r + s.r * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
643 |
r.g = RI_MAX(s.g + d.g * (1.0f - ag), d.g + s.g * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
644 |
r.b = RI_MAX(s.b + d.b * (1.0f - ab), d.b + s.b * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
645 |
//although the statement below is equivalent to r.a = s.a + d.a * (1.0f - s.a) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
646 |
//in practice there can be a very slight difference because |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
647 |
//of the max operation in the blending formula that may cause color to exceed alpha. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
648 |
//Because of this, we compute the result both ways and return the maximum. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
649 |
r.a = RI_MAX(s.a + d.a * (1.0f - s.a), d.a + s.a * (1.0f - d.a)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
650 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
651 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
652 |
default: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
653 |
RI_ASSERT(blendMode == VG_BLEND_ADDITIVE); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
654 |
r.r = RI_MIN(s.r + d.r, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
655 |
r.g = RI_MIN(s.g + d.g, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
656 |
r.b = RI_MIN(s.b + d.b, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
657 |
r.a = RI_MIN(s.a + d.a, 1.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
658 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
659 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
660 |
return r; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
661 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
662 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
663 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
664 |
* \brief Applies color transform. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
665 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
666 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
667 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
668 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
669 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
670 |
void PixelPipe::colorTransform(Color& c) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
671 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
672 |
if(m_colorTransform) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
673 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
674 |
c.unpremultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
675 |
c.luminanceToRGB(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
676 |
c.r = c.r * m_colorTransformValues[0] + m_colorTransformValues[4]; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
677 |
c.g = c.g * m_colorTransformValues[1] + m_colorTransformValues[5]; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
678 |
c.b = c.b * m_colorTransformValues[2] + m_colorTransformValues[6]; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
679 |
c.a = c.a * m_colorTransformValues[3] + m_colorTransformValues[7]; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
680 |
c.clamp(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
681 |
c.premultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
682 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
683 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
684 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
685 |
/*-------------------------------------------------------------------*//*! |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
686 |
* \brief Applies paint, image drawing, masking and blending at pixel (x,y). |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
687 |
* \param |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
688 |
* \return |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
689 |
* \note |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
690 |
*//*-------------------------------------------------------------------*/ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
691 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
692 |
void PixelPipe::pixelPipe(int x, int y, RIfloat coverage, unsigned int sampleMask) const |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
693 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
694 |
RI_ASSERT(m_drawable); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
695 |
RI_ASSERT(sampleMask); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
696 |
RI_ASSERT(coverage > 0.0f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
697 |
Color::InternalFormat dstFormat = (Color::InternalFormat)(m_drawable->getDescriptor().internalFormat | Color::PREMULTIPLIED); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
698 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
699 |
//evaluate paint |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
700 |
RI_ASSERT(m_paint); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
701 |
Color s; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
702 |
switch(m_paint->m_paintType) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
703 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
704 |
case VG_PAINT_TYPE_COLOR: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
705 |
s = m_paint->m_paintColor; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
706 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
707 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
708 |
case VG_PAINT_TYPE_LINEAR_GRADIENT: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
709 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
710 |
RIfloat g, rho; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
711 |
linearGradient(g, rho, x+0.5f, y+0.5f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
712 |
s = colorRamp(g, rho); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
713 |
RI_ASSERT((s.getInternalFormat() == Color::sRGBA && !m_paint->m_colorRampPremultiplied) || (s.getInternalFormat() == Color::sRGBA_PRE && m_paint->m_colorRampPremultiplied)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
714 |
s.premultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
715 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
716 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
717 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
718 |
case VG_PAINT_TYPE_RADIAL_GRADIENT: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
719 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
720 |
RIfloat g, rho; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
721 |
radialGradient(g, rho, x+0.5f, y+0.5f); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
722 |
s = colorRamp(g, rho); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
723 |
RI_ASSERT((s.getInternalFormat() == Color::sRGBA && !m_paint->m_colorRampPremultiplied) || (s.getInternalFormat() == Color::sRGBA_PRE && m_paint->m_colorRampPremultiplied)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
724 |
s.premultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
725 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
726 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
727 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
728 |
default: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
729 |
RI_ASSERT(m_paint->m_paintType == VG_PAINT_TYPE_PATTERN); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
730 |
if(m_paint->m_pattern) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
731 |
s = m_paint->m_pattern->resample(x+0.5f, y+0.5f, m_surfaceToPaintMatrix, m_imageQuality, m_paint->m_patternTilingMode, m_tileFillColor); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
732 |
else |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
733 |
s = m_paint->m_paintColor; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
734 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
735 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
736 |
s.assertConsistency(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
737 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
738 |
//apply image (vgDrawImage only) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
739 |
//1. paint: convert paint to dst space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
740 |
//2. image: convert image to dst space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
741 |
//3. paint MULTIPLY image: convert paint to image number of channels, multiply with image, and convert to dst |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
742 |
//4. paint STENCIL image: convert paint to dst, convert image to dst number of channels, multiply |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
743 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
744 |
//color transform: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
745 |
//paint => transform paint color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
746 |
//image normal => transform image color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
747 |
//image multiply => transform paint*image color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
748 |
//image stencil => transform paint color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
749 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
750 |
RIfloat ar = 0.0f, ag = 0.0f, ab = 0.0f; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
751 |
if(m_image) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
752 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
753 |
Color im = m_image->resample(x+0.5f, y+0.5f, m_surfaceToImageMatrix, m_imageQuality, VG_TILE_PAD, Color(0,0,0,0,m_image->getDescriptor().internalFormat)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
754 |
im.assertConsistency(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
755 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
756 |
switch(m_imageMode) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
757 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
758 |
case VG_DRAW_IMAGE_NORMAL: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
759 |
s = im; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
760 |
colorTransform(s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
761 |
ar = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
762 |
ag = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
763 |
ab = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
764 |
s.convert(dstFormat); //convert image color to destination color space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
765 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
766 |
case VG_DRAW_IMAGE_MULTIPLY: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
767 |
//the result will be in image color space, except when paint is RGB and image is L the result will be RGB. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
768 |
//paint == RGB && image == RGB: RGB*RGB |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
769 |
//paint == RGB && image == L : RGB*LLL |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
770 |
//paint == L && image == RGB: LLL*RGB |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
771 |
//paint == L && image == L : L*L |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
772 |
RI_ASSERT(m_surfaceToPaintMatrix.isAffine()); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
773 |
if(!s.isLuminance() && im.isLuminance()) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
774 |
im.convert((Color::InternalFormat)(im.getInternalFormat() & ~Color::LUMINANCE)); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
775 |
im.r *= s.r; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
776 |
im.g *= s.g; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
777 |
im.b *= s.b; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
778 |
im.a *= s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
779 |
s = im; //use image color space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
780 |
colorTransform(s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
781 |
ar = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
782 |
ag = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
783 |
ab = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
784 |
s.convert(dstFormat); //convert resulting color to destination color space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
785 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
786 |
default: |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
787 |
//the result will be in paint color space. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
788 |
//dst == RGB && image == RGB: RGB*RGB |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
789 |
//dst == RGB && image == L : RGB*LLL |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
790 |
//dst == L && image == RGB: L*(0.2126 R + 0.7152 G + 0.0722 B) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
791 |
//dst == L && image == L : L*L |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
792 |
RI_ASSERT(m_imageMode == VG_DRAW_IMAGE_STENCIL); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
793 |
if(dstFormat & Color::LUMINANCE && !im.isLuminance()) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
794 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
795 |
im.r = im.g = im.b = RI_MIN(0.2126f*im.r + 0.7152f*im.g + 0.0722f*im.b, im.a); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
796 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
797 |
RI_ASSERT(m_surfaceToPaintMatrix.isAffine()); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
798 |
//s and im are both in premultiplied format. Each image channel acts as an alpha channel. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
799 |
colorTransform(s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
800 |
s.convert(dstFormat); //convert paint color to destination space already here, since convert cannot deal with per channel alphas used in this mode. |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
801 |
//compute per channel alphas |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
802 |
ar = s.a * im.r; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
803 |
ag = s.a * im.g; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
804 |
ab = s.a * im.b; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
805 |
//premultiply each channel by per channel alphas from the image |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
806 |
s.r *= im.r; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
807 |
s.g *= im.g; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
808 |
s.b *= im.b; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
809 |
s.a *= im.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
810 |
//in nonpremultiplied form the result is |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
811 |
// s.rgb = paint.a * paint.rgb * image.a * image.rgb |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
812 |
// s.a = paint.a * image.a |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
813 |
// argb = paint.a * image.a * image.rgb |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
814 |
break; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
815 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
816 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
817 |
else |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
818 |
{ //paint only |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
819 |
colorTransform(s); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
820 |
ar = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
821 |
ag = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
822 |
ab = s.a; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
823 |
s.convert(dstFormat); //convert paint color to destination color space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
824 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
825 |
RI_ASSERT(s.getInternalFormat() == Color::lRGBA_PRE || s.getInternalFormat() == Color::sRGBA_PRE || s.getInternalFormat() == Color::lLA_PRE || s.getInternalFormat() == Color::sLA_PRE); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
826 |
s.assertConsistency(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
827 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
828 |
Surface* colorBuffer = m_drawable->getColorBuffer(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
829 |
Surface* maskBuffer = m_drawable->getMaskBuffer(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
830 |
RI_ASSERT(colorBuffer); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
831 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
832 |
if(m_drawable->getNumSamples() == 1) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
833 |
{ //coverage-based antialiasing |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
834 |
RIfloat cov = coverage; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
835 |
if(m_masking && maskBuffer) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
836 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
837 |
cov *= maskBuffer->readMaskCoverage(x, y); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
838 |
if(cov == 0.0f) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
839 |
return; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
840 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
841 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
842 |
//read destination color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
843 |
Color d = colorBuffer->readSample(x, y, 0); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
844 |
d.premultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
845 |
RI_ASSERT(dstFormat == Color::lRGBA_PRE || dstFormat == Color::sRGBA_PRE || dstFormat == Color::lLA_PRE || dstFormat == Color::sLA_PRE); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
846 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
847 |
//blend |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
848 |
Color r = blend(s, ar, ag, ab, d, m_blendMode); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
849 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
850 |
//apply antialiasing in linear color space |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
851 |
Color::InternalFormat aaFormat = (dstFormat & Color::LUMINANCE) ? Color::lLA_PRE : Color::lRGBA_PRE; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
852 |
r.convert(aaFormat); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
853 |
d.convert(aaFormat); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
854 |
r = r * cov + d * (1.0f - cov); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
855 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
856 |
//write result to the destination surface |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
857 |
r.convert(colorBuffer->getDescriptor().internalFormat); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
858 |
colorBuffer->writeSample(x, y, 0, r); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
859 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
860 |
else |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
861 |
{ //multisampling FSAA |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
862 |
if(m_masking && maskBuffer) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
863 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
864 |
sampleMask &= maskBuffer->readMaskMSAA(x, y); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
865 |
if(!sampleMask) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
866 |
return; |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
867 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
868 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
869 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
870 |
for(int i=0;i<m_drawable->getNumSamples();i++) |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
871 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
872 |
if(sampleMask & (1<<i)) //1-bit coverage |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
873 |
{ |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
874 |
//read destination color |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
875 |
Color d = colorBuffer->readSample(x, y, i); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
876 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
877 |
d.premultiply(); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
878 |
RI_ASSERT(dstFormat == Color::lRGBA_PRE || dstFormat == Color::sRGBA_PRE || dstFormat == Color::lLA_PRE || dstFormat == Color::sLA_PRE); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
879 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
880 |
//blend |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
881 |
Color r = blend(s, ar, ag, ab, d, m_blendMode); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
882 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
883 |
//write result to the destination surface |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
884 |
r.convert(colorBuffer->getDescriptor().internalFormat); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
885 |
colorBuffer->writeSample(x, y, i, r); |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
886 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
887 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
888 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
889 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
890 |
} |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
891 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
892 |
//======================================================================= |
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
893 |
|
2bf8a359aa2f
Create EGL 1.4 implementation by merging eglrefimpl and EGL from sfopenvg
Jose Thachil<jose.thachil@cell-telecom.com>
parents:
diff
changeset
|
894 |
} //namespace OpenVGRI |