diff options
author | Russell Brenner <russellbrenner@google.com> | 2011-03-17 14:49:30 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-03-17 14:49:30 -0700 |
commit | 8b6274a6a38fef781bd356dd9631472dae24582e (patch) | |
tree | 3dd6e4f75dd78ec1ceb372f3ff9c78dd6fb73cef /WebCore | |
parent | 2fa324b20baa34192231eab625ba0bf559dbf9e0 (diff) | |
parent | 9b533bf8fcfe66f4adbf692c1a4e1534983c4651 (diff) | |
download | external_webkit-8b6274a6a38fef781bd356dd9631472dae24582e.zip external_webkit-8b6274a6a38fef781bd356dd9631472dae24582e.tar.gz external_webkit-8b6274a6a38fef781bd356dd9631472dae24582e.tar.bz2 |
am 9b533bf8: am 1ae2d07b: Merge "Enabled shadow drawing" into honeycomb-mr1
* commit '9b533bf8fcfe66f4adbf692c1a4e1534983c4651':
Enabled shadow drawing
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 |