Changeset 65876 in webkit
- Timestamp:
- Aug 24, 2010 1:38:35 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r65874 r65876 1 2010-08-24 Ariya Hidayat <ariya@sencha.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Support text-shadow blur 6 https://bugs.webkit.org/show_bug.cgi?id=19728 7 8 Implement blur for text shadow using the shadow layer in r65782. 9 10 * platform/graphics/qt/ContextShadow.cpp: 11 (WebCore::ContextShadow::beginShadowLayer): 12 * platform/graphics/qt/FontQt.cpp: 13 (WebCore::drawTextCommon): 14 1 15 2010-08-23 Andreas Kling <andreas.kling@nokia.com> 2 16 -
trunk/WebCore/platform/graphics/qt/ContextShadow.cpp
r65795 r65876 315 315 m_layerPainter = new QPainter; 316 316 m_layerPainter->begin(&m_layerImage); 317 m_layerPainter->setFont(p->font()); 317 318 m_layerPainter->translate(offset); 318 319 -
trunk/WebCore/platform/graphics/qt/FontQt.cpp
r65801 r65876 24 24 25 25 #include "AffineTransform.h" 26 #include "ContextShadow.h" 26 27 #include "FontDescription.h" 27 28 #include "FontFallbackList.h" … … 109 110 QPointF pt(point.x(), point.y()); 110 111 111 // text shadow112 FloatSize shadowSize;113 float shadowBlur;114 Color shadowColor;115 bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor);116 117 112 if (from > 0 || to < run.length()) { 118 113 if (isComplexText) { … … 126 121 QFontMetrics fm(font); 127 122 int ascent = fm.ascent(); 128 QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height()); 129 130 if (hasShadow) { 131 // TODO: when blur support is added, the clip will need to account 132 // for the blur radius 123 QRectF boundingRect(point.x() + x1, point.y() - ascent, x2 - x1, fm.height()); 124 QRectF clip = boundingRect; 125 126 ContextShadow* ctxShadow = ctx->contextShadow(); 127 128 if (ctxShadow->type != ContextShadow::NoShadow) { 133 129 qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; 134 if ( shadowSize.width() > 0)135 dx2 = shadowSize.width();130 if (ctxShadow->offset.x() > 0) 131 dx2 = ctxShadow->offset.x(); 136 132 else 137 dx1 = - shadowSize.width();138 if ( shadowSize.height() > 0)139 dy2 = shadowSize.height();133 dx1 = -ctxShadow->offset.x(); 134 if (ctxShadow->offset.y() > 0) 135 dy2 = ctxShadow->offset.y(); 140 136 else 141 dy1 = - shadowSize.height();137 dy1 = -ctxShadow->offset.y(); 142 138 // expand the clip rect to include the text shadow as well 143 139 clip.adjust(dx1, dx2, dy1, dy2); 140 clip.adjust(-ctxShadow->blurRadius, -ctxShadow->blurRadius, ctxShadow->blurRadius, ctxShadow->blurRadius); 144 141 } 145 142 p->save(); 146 143 p->setClipRect(clip.toRect(), Qt::IntersectClip); 147 144 pt.setY(pt.y() - ascent); 148 if (hasShadow) { 149 p->save(); 150 p->setPen(QColor(shadowColor)); 151 p->translate(shadowSize.width(), shadowSize.height()); 152 line.draw(p, pt); 153 p->restore(); 145 146 if (ctxShadow->type != ContextShadow::NoShadow) { 147 ContextShadow* ctxShadow = ctx->contextShadow(); 148 if (ctxShadow->type != ContextShadow::BlurShadow) { 149 p->save(); 150 p->setPen(ctxShadow->color); 151 p->translate(ctxShadow->offset); 152 line.draw(p, pt); 153 p->restore(); 154 } else { 155 QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); 156 if (shadowPainter) { 157 // Since it will be blurred anyway, we don't care about render hints. 158 shadowPainter->setPen(ctxShadow->color); 159 line.draw(shadowPainter, pt); 160 ctxShadow->endShadowLayer(p); 161 } 162 } 154 163 } 155 164 p->setPen(textFillPen); … … 173 182 flags |= Qt::TextBypassShaping; 174 183 #endif 175 if (hasShadow) { 176 // TODO: text shadow blur support 177 p->save(); 178 p->setPen(QColor(shadowColor)); 179 p->translate(shadowSize.width(), shadowSize.height()); 180 p->drawText(pt, string, flags, run.padding()); 181 p->restore(); 184 if (ctx->contextShadow()->type != ContextShadow::NoShadow) { 185 ContextShadow* ctxShadow = ctx->contextShadow(); 186 if (ctxShadow->type != ContextShadow::BlurShadow) { 187 p->save(); 188 p->setPen(ctxShadow->color); 189 p->translate(ctxShadow->offset); 190 p->drawText(pt, string, flags, run.padding()); 191 p->restore(); 192 } else { 193 QFontMetrics fm(font); 194 QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); 195 QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); 196 if (shadowPainter) { 197 // Since it will be blurred anyway, we don't care about render hints. 198 shadowPainter->setFont(p->font()); 199 shadowPainter->setPen(ctxShadow->color); 200 shadowPainter->drawText(pt, string, flags, run.padding()); 201 ctxShadow->endShadowLayer(p); 202 } 203 } 182 204 } 183 205 if (ctx->textDrawingMode() & cTextStroke) {
Note: See TracChangeset
for help on using the changeset viewer.