diff options
-rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/RenderSkinMediaButton.cpp | 35 | ||||
-rw-r--r-- | WebKit/android/RenderSkinMediaButton.h | 5 |
3 files changed, 39 insertions, 4 deletions
diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp index 5a0bfb8..944504e 100644 --- a/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/WebCore/platform/android/RenderThemeAndroid.cpp @@ -327,7 +327,8 @@ bool RenderThemeAndroid::paintMediaSliderTrack(RenderObject* o, const PaintInfo& bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::SLIDER_TRACK, translucent); + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, + RenderSkinMediaButton::SLIDER_TRACK, translucent, o); return false; } diff --git a/WebKit/android/RenderSkinMediaButton.cpp b/WebKit/android/RenderSkinMediaButton.cpp index c3ab80f..6a11eda 100644 --- a/WebKit/android/RenderSkinMediaButton.cpp +++ b/WebKit/android/RenderSkinMediaButton.cpp @@ -30,7 +30,9 @@ #include "Document.h" #include "IntRect.h" #include "Node.h" +#include "RenderObject.h" #include "RenderSkinMediaButton.h" +#include "RenderSlider.h" #include "SkCanvas.h" #include "SkNinePatch.h" #include "SkRect.h" @@ -45,7 +47,7 @@ struct PatchData { static const PatchData gFiles[] = { - { "btn_media_player.9.png", 0, 0 }, // DEFAULT BGD BUTTON + { "scrubber_primary_holo.9.png", 0, 0 }, // SLIDER_TRACK, left of the SLIDER_THUMB { "ic_media_pause.png", 0, 0}, // PAUSE { "ic_media_play.png", 0, 0 }, // PLAY { "ic_media_pause.png", 0, 0 }, // MUTE @@ -82,7 +84,8 @@ void RenderSkinMediaButton::Init(android::AssetManager* am, String drawableDirec } } -void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType, bool translucent) +void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType, + bool translucent, RenderObject* o) { // If we failed to decode, do nothing. This way the browser still works, // and webkit will still draw the label and layout space for us. @@ -107,6 +110,7 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT SkColor backgroundColor = SkColorSetARGB(alpha, 34, 34, 34); paint.setColor(backgroundColor); + paint.setFlags(SkPaint::kFilterBitmap_Flag); switch (buttonType) { case PAUSE: @@ -154,6 +158,33 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT SkIRect margin; margin.set(marginValue, marginValue, marginValue, marginValue); + if (buttonType == SLIDER_TRACK) { + // Cut the height in half (with some extra slop determined by trial + // and error to get the placement just right. + SkScalar quarterHeight = SkScalarHalf(SkScalarHalf(bounds.height())); + bounds.fTop += quarterHeight + SkScalarHalf(3); + bounds.fBottom += -quarterHeight + SK_ScalarHalf; + if (o && o->isSlider()) { + RenderSlider* slider = toRenderSlider(o); + IntRect thumb = slider->thumbRect(); + // Inset the track by half the width of the thumb, so the track + // does not appear to go beyond the space where the thumb can + // be. + SkScalar thumbHalfWidth = SkIntToScalar(thumb.width()/2); + bounds.fLeft += thumbHalfWidth; + bounds.fRight -= thumbHalfWidth; + if (thumb.x() > 0) { + // The video is past the starting point. Show the area to + // left of the thumb as having been played. + SkScalar alreadyPlayed = SkIntToScalar(thumb.center().x() + r.x()); + SkRect playedRect(bounds); + playedRect.fRight = alreadyPlayed; + SkNinePatch::DrawNine(canvas, playedRect, gButton[0], margin); + bounds.fLeft = alreadyPlayed; + } + + } + } SkNinePatch::DrawNine(canvas, bounds, gButton[ninePatchIndex], margin); } diff --git a/WebKit/android/RenderSkinMediaButton.h b/WebKit/android/RenderSkinMediaButton.h index bde31eb..026f538 100644 --- a/WebKit/android/RenderSkinMediaButton.h +++ b/WebKit/android/RenderSkinMediaButton.h @@ -32,6 +32,8 @@ class SkCanvas; namespace WebCore { class IntRect; +class RenderObject; + class RenderSkinMediaButton { public: @@ -44,7 +46,8 @@ public: * Draw the skin to the canvas, using the rectangle for its bounds and the * State to determine which skin to use, i.e. focused or not focused. */ - static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false); + static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false, + RenderObject* o = 0); /** * Button types */ |