diff options
-rw-r--r-- | WebCore/platform/graphics/android/FontAndroid.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsContextAndroid.cpp | 52 | ||||
-rw-r--r-- | WebKit/android/RenderSkinMediaButton.cpp | 27 | ||||
-rw-r--r-- | WebKit/android/RenderSkinMediaButton.h | 4 |
4 files changed, 60 insertions, 28 deletions
diff --git a/WebCore/platform/graphics/android/FontAndroid.cpp b/WebCore/platform/graphics/android/FontAndroid.cpp index ffaeded..e896a46 100644 --- a/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/WebCore/platform/graphics/android/FontAndroid.cpp @@ -83,8 +83,9 @@ static bool setupForText(SkPaint* paint, GraphicsContext* gc, float shadowBlur; Color shadowColor; bool hasShadow = gc->getShadow(shadowOffset, shadowBlur, shadowColor); - - if (hasShadow || (mode == (cTextStroke & cTextFill))) { + bool hasBothStrokeAndFill = + (mode & (cTextStroke | cTextFill)) == (cTextStroke | cTextFill); + if (hasShadow || hasBothStrokeAndFill) { SkLayerDrawLooper* looper = new SkLayerDrawLooper; paint->setLooper(looper)->unref(); diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp index ef0cc25..64b6ad3 100644 --- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp @@ -62,6 +62,37 @@ template <typename T> T* deepCopyPtr(const T* src) return src ? new T(*src) : 0; } +// Set a bitmap shader that mimics dashing by width-on, width-off. +// Returns false if it could not succeed (e.g. there was an existing shader) +static bool setBitmapDash(SkPaint* paint, int width) { + if (width <= 0 || paint->getShader()) + return false; + + SkColor c = paint->getColor(); + + SkBitmap bm; + bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 1); + bm.allocPixels(); + bm.lockPixels(); + + // set the ON pixel + *bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c), + SkColorGetG(c), SkColorGetB(c)); + // set the OFF pixel + *bm.getAddr32(1, 0) = 0; + bm.unlockPixels(); + + SkMatrix matrix; + matrix.setScale(SkIntToScalar(width), SK_Scalar1); + + SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, + SkShader::kClamp_TileMode); + s->setLocalMatrix(matrix); + + paint->setShader(s)->unref(); + return true; +} + // TODO / questions // alpha: how does this interact with the alpha in Color? multiply them together? @@ -282,7 +313,7 @@ public: // Sets up the paint for stroking. Returns true if the style is really // just a dash of squares (the size of the paint's stroke-width. - bool setupPaintStroke(SkPaint* paint, SkRect* rect) + bool setupPaintStroke(SkPaint* paint, SkRect* rect, bool isHLine = false) { this->setupPaintCommon(paint); paint->setColor(m_state->applyAlpha(m_state->strokeColor)); @@ -322,12 +353,19 @@ public: } if (width > 0) { - // TODO: Add this back when SkDashPathEffect's performance has been improved - //SkScalar intervals[] = { width, width }; - //pe = new SkDashPathEffect(intervals, 2, 0); - //paint->setPathEffect(pe)->unref(); // Return true if we're basically a dotted dash of squares - return RoundToInt(width) == RoundToInt(paint->getStrokeWidth()); + bool justSqrs = RoundToInt(width) == RoundToInt(paint->getStrokeWidth()); + + if (justSqrs || !isHLine || !setBitmapDash(paint, width)) { +#if 0 + // this is slow enough that we just skip it for now + // see http://b/issue?id=4163023 + SkScalar intervals[] = { width, width }; + pe = new SkDashPathEffect(intervals, 2, 0); + paint->setPathEffect(pe)->unref(); +#endif + } + return justSqrs; } return false; } @@ -525,7 +563,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) const int idy = SkAbs32(point2.y() - point1.y()); // Special-case horizontal and vertical lines that are really just dots - if (m_data->setupPaintStroke(&paint, 0) && (!idx || !idy)) { + if (m_data->setupPaintStroke(&paint, 0, !idy) && (!idx || !idy)) { const SkScalar diameter = paint.getStrokeWidth(); const SkScalar radius = SkScalarHalf(diameter); SkScalar x = SkIntToScalar(SkMin32(point1.x(), point2.x())); diff --git a/WebKit/android/RenderSkinMediaButton.cpp b/WebKit/android/RenderSkinMediaButton.cpp index 240bbd6..090d55e 100644 --- a/WebKit/android/RenderSkinMediaButton.cpp +++ b/WebKit/android/RenderSkinMediaButton.cpp @@ -58,8 +58,8 @@ static const PatchData gFiles[] = { "spinner_76_inner_holo.png", 0, 0 }, // SPINNER_INNER { "ic_media_video_poster.png", 0, 0 }, // VIDEO { "btn_media_player_disabled.9.png", 0, 0 }, // BACKGROUND_SLIDER - { "btn_media_player_pressed.9.png", 0, 0 }, // SLIDER_TRACK - { "btn_media_player.9.png", 0, 0 } // SLIDER_THUMB + { "scrubber_track_holo_dark.9.png", 0, 0 }, // SLIDER_TRACK + { "scrubber_control_holo.png", 0, 0 } // SLIDER_THUMB }; static SkBitmap gButton[sizeof(gFiles)/sizeof(gFiles[0])]; @@ -96,9 +96,9 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT return; } - bool drawsNinePatch = true; + bool drawsNinePatch = false; bool drawsImage = true; - bool drawsBackgroundColor = false; + bool drawsBackgroundColor = true; int ninePatchIndex = 0; int imageIndex = 0; @@ -125,7 +125,6 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT case FULLSCREEN: { imageIndex = buttonType + 1; - drawsBackgroundColor = true; paint.setColor(backgroundColor); break; } @@ -141,30 +140,24 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT { drawsBackgroundColor = false; drawsImage = false; - drawsNinePatch = false; - drawsBackgroundColor = true; - paint.setColor(backgroundColor); break; } case SLIDER_TRACK: { + drawsNinePatch = true; drawsImage = false; - drawsNinePatch = false; - drawsBackgroundColor = true; - paint.setColor(trackBackgroundColor); - bounds.fTop += 8; - bounds.fBottom -= 8; + ninePatchIndex = buttonType + 1; break; } case SLIDER_THUMB: { - drawsImage = false; - ninePatchIndex = buttonType + 1; + drawsBackgroundColor = false; + imageMargin = 0; + imageIndex = buttonType + 1; break; } default: - drawsImage = false; - drawsNinePatch = false; + return; } if (drawsBackgroundColor) { diff --git a/WebKit/android/RenderSkinMediaButton.h b/WebKit/android/RenderSkinMediaButton.h index c429ce4..6aa9c4e 100644 --- a/WebKit/android/RenderSkinMediaButton.h +++ b/WebKit/android/RenderSkinMediaButton.h @@ -54,8 +54,8 @@ public: /** * Slider dimensions */ - static int sliderThumbWidth() { return 10; } - static int sliderThumbHeight() { return 30; } + static int sliderThumbWidth() { return 32; } + static int sliderThumbHeight() { return 32; } }; |