diff options
author | Russell Brenner <russellbrenner@google.com> | 2011-03-17 12:06:52 -0700 |
---|---|---|
committer | Russell Brenner <russellbrenner@google.com> | 2011-03-17 14:20:18 -0700 |
commit | 72b824a5bbed3afbd719564c8d603c8055ad3dfd (patch) | |
tree | 9221632ba4d5ed75fc629cc67cbcacca6cd262db /WebCore | |
parent | 49fff159362adc0289fe593ac113a8d0a0671edf (diff) | |
download | external_webkit-72b824a5bbed3afbd719564c8d603c8055ad3dfd.zip external_webkit-72b824a5bbed3afbd719564c8d603c8055ad3dfd.tar.gz external_webkit-72b824a5bbed3afbd719564c8d603c8055ad3dfd.tar.bz2 |
Enabled shadow drawing
Reworked the logic of setupForText() and setupShadowPaint() to render
correctly, as exhibited by http://acid3.acidtests.org.
Bug: 4075135
Change-Id: I595456b658d0872183dedcbc726be44783440f89
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/graphics/android/FontAndroid.cpp | 45 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsContextAndroid.cpp | 13 |
2 files changed, 33 insertions, 25 deletions
diff --git a/WebCore/platform/graphics/android/FontAndroid.cpp b/WebCore/platform/graphics/android/FontAndroid.cpp index b2abfcf..ffaeded 100644 --- a/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/WebCore/platform/graphics/android/FontAndroid.cpp @@ -75,36 +75,45 @@ static SkPaint* setupStroke(SkPaint* paint, GraphicsContext* gc, static bool setupForText(SkPaint* paint, GraphicsContext* gc, const SimpleFontData* font) { - int mode = gc->textDrawingMode(); + int mode = gc->textDrawingMode() & (cTextFill | cTextStroke); + if (!mode) + return false; + + FloatSize shadowOffset; + float shadowBlur; + Color shadowColor; + bool hasShadow = gc->getShadow(shadowOffset, shadowBlur, shadowColor); - if ((mode & (cTextFill | cTextStroke)) == (cTextFill | cTextStroke)) { + if (hasShadow || (mode == (cTextStroke & cTextFill))) { SkLayerDrawLooper* looper = new SkLayerDrawLooper; paint->setLooper(looper)->unref(); // we clear the looper, in case we have a shadow - SkPaint* fillP = NULL; - SkPaint* strokeP = NULL; - if (gc->willStroke()) { + SkPaint* fillP = 0; + SkPaint* strokeP = 0; + if ((mode & cTextStroke) && gc->willStroke()) { strokeP = setupStroke(looper->addLayer(), gc, font); - strokeP->setLooper(NULL); + strokeP->setLooper(0); } - if (gc->willFill()) { + if ((mode & cTextFill) && gc->willFill()) { fillP = setupFill(looper->addLayer(), gc, font); - fillP->setLooper(NULL); + fillP->setLooper(0); } - SkPaint shadowPaint; - SkPoint offset; - if (gc->setupShadowPaint(&shadowPaint, &offset)) { - SkPaint* p = looper->addLayer(offset.fX, offset.fY); - *p = shadowPaint; - if (strokeP && !fillP) { - // stroke the shadow if we have stroke but no fill - p->setStyle(SkPaint::kStroke_Style); - p->setStrokeWidth(strokeP->getStrokeWidth()); + if (hasShadow) { + SkPaint shadowPaint; + SkPoint offset; + if (gc->setupShadowPaint(&shadowPaint, &offset)) { + SkPaint* p = looper->addLayer(offset.fX, offset.fY); + *p = shadowPaint; + if (strokeP && !fillP) { + // stroke the shadow if we have stroke but no fill + p->setStyle(SkPaint::kStroke_Style); + p->setStrokeWidth(strokeP->getStrokeWidth()); + } + updateForFont(p, font); } - updateForFont(p, font); } } else if (mode & cTextFill) { (void)setupFill(paint, gc, font); diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index dce7b27..2f5a4b9 100644 --- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -149,17 +149,16 @@ public: bool setupShadowPaint(SkPaint* paint, SkPoint* offset) { + paint->setAntiAlias(true); + paint->setDither(true); + paint->setXfermodeMode(mode); + paint->setColor(shadow.color); + offset->set(shadow.dx, shadow.dy); if (shadow.blur > 0) { - paint->setAntiAlias(true); - paint->setDither(true); - paint->setXfermodeMode(mode); - paint->setColor(shadow.color); paint->setMaskFilter(SkBlurMaskFilter::Create(shadow.blur, SkBlurMaskFilter::kNormal_BlurStyle))->unref(); - offset->set(shadow.dx, shadow.dy); - return true; } - return false; + return SkColorGetA(shadow.color) && (shadow.blur || shadow.dx || shadow.dy); } SkColor applyAlpha(SkColor c) const |