61 } |
61 } |
62 |
62 |
63 void HbVgOutlineEffect::setOutline(const QPointF &outline) |
63 void HbVgOutlineEffect::setOutline(const QPointF &outline) |
64 { |
64 { |
65 Q_D(HbVgOutlineEffect); |
65 Q_D(HbVgOutlineEffect); |
66 if (d->outline == outline) |
66 if (d->outline == outline) { |
67 return; |
67 return; |
|
68 } |
68 d->outline = outline; |
69 d->outline = outline; |
69 updateEffectBoundingRect(); |
70 updateEffectBoundingRect(); |
70 emit outlineChanged(outline); |
71 emit outlineChanged(outline); |
71 } |
72 } |
72 |
73 |
93 } |
95 } |
94 |
96 |
95 void HbVgOutlineEffect::setSteepness(qreal steepness) |
97 void HbVgOutlineEffect::setSteepness(qreal steepness) |
96 { |
98 { |
97 Q_D(HbVgOutlineEffect); |
99 Q_D(HbVgOutlineEffect); |
98 if (d->steepness == steepness) |
100 if (d->steepness == steepness) { |
99 return; |
101 return; |
|
102 } |
100 d->steepness = steepness; |
103 d->steepness = steepness; |
101 updateEffect(); |
104 updateEffect(); |
102 emit steepnessChanged(steepness); |
105 emit steepnessChanged(steepness); |
103 } |
106 } |
104 |
107 |
139 |
143 |
140 QPixmap HbVgOutlineEffect::makeOutline(const QVariant &vgImage, const QSize &vgImageSize) |
144 QPixmap HbVgOutlineEffect::makeOutline(const QVariant &vgImage, const QSize &vgImageSize) |
141 { |
145 { |
142 #ifdef HB_EFFECTS_OPENVG |
146 #ifdef HB_EFFECTS_OPENVG |
143 QPixmap cachedPm = cached(vgImageSize); |
147 QPixmap cachedPm = cached(vgImageSize); |
144 if (!cachedPm.isNull()) |
148 if (!cachedPm.isNull()) { |
145 return cachedPm; |
149 return cachedPm; |
|
150 } |
146 |
151 |
147 Q_D(HbVgOutlineEffect); |
152 Q_D(HbVgOutlineEffect); |
148 VGImage srcImage = vgImage.value<VGImage>(); |
153 VGImage srcImage = vgImage.value<VGImage>(); |
149 VGImage dstImage = d->ensurePixmap(&d->dstPixmap, vgImageSize); |
154 VGImage dstImage = d->ensurePixmap(&d->dstPixmap, vgImageSize); |
150 |
155 |
151 if (d->paramsChanged) { |
156 if (d->paramsChanged) { |
152 VGubyte stpc = (VGubyte) clamp(d->steepness, 0.0f, 32.0f); |
157 VGubyte stpc = (VGubyte) clamp(d->steepness, 0.0f, 32.0f); |
153 VGubyte unnormalisedOpacity = (VGubyte) (clamp(d->opacity, 0.0f, 1.0f) * 255.0f); |
158 VGubyte unnormalisedOpacity = (VGubyte)(clamp(d->opacity, 0.0f, 1.0f) * 255.0f); |
154 for (int i = 0; i < 256; ++i) { |
159 for (int i = 0; i < 256; ++i) { |
155 VGubyte alpha = (i*stpc > unnormalisedOpacity) ? unnormalisedOpacity : i*stpc; |
160 VGubyte alpha = (i * stpc > unnormalisedOpacity) ? unnormalisedOpacity : i * stpc; |
156 d->lut[i] = 0x00000000 |
161 d->lut[i] = 0x00000000 |
157 | (d->color.red() << 24) |
162 | (d->color.red() << 24) |
158 | (d->color.green() << 16) |
163 | (d->color.green() << 16) |
159 | (d->color.blue() << 8) |
164 | (d->color.blue() << 8) |
160 | alpha; |
165 | alpha; |
161 } |
166 } |
162 } |
167 } |
163 |
168 |
164 QSizeF mappedOutline = d->mapSize(QSizeF(d->outline.x(), d->outline.y())); |
169 QSizeF mappedOutline = d->mapSize(QSizeF(d->outline.x(), d->outline.y())); |
165 VGfloat outline_x = (VGfloat) clamp(mappedOutline.width(), HBVG_EPSILON, 16.0f); |
170 VGfloat outline_x = (VGfloat) clamp(mappedOutline.width(), HBVG_EPSILON, 16.0f); |