bool RenderThemeChromiumSkia::paintMediaControlsBackground(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) HTMLMediaElement* mediaElement = mediaElementParent(object->node()); if (!mediaElement) return false; if (!rect.isEmpty()) { SkCanvas* canvas = paintInfo.context->platformContext()->canvas(); SkPaint paint; // Draws the left border, it is always 1px wide. paint.setColor(object->style()->borderLeftColor().rgb()); canvas->drawLine(rect.x() + 1, rect.y(), rect.x() + 1, rect.y() + rect.height(), paint); // Draws the right border, it is always 1px wide. paint.setColor(object->style()->borderRightColor().rgb()); canvas->drawLine(rect.x() + rect.width() - 1, rect.y(), rect.x() + rect.width() - 1, rect.y() + rect.height(), paint); } return true; #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); UNUSED_PARAM(rect); return false; #endif }
bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) HTMLMediaElement* mediaElement = mediaElementParent(object->node()); if (!mediaElement) return false; static Image* soundFull = Image::loadPlatformResource("mediaSoundFull").releaseRef(); static Image* soundNone = Image::loadPlatformResource("mediaSoundNone").releaseRef(); return paintMediaButtonInternal(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); UNUSED_PARAM(rect); return false; #endif }
bool RenderThemeWinCE::paintSliderThumb(RenderObject* o, const PaintInfo& i, const IntRect& r) { bool rc = RenderTheme::paintSliderThumb(o, i, r); i.context->save(); i.context->setStrokeColor(Color::black, ColorSpaceDeviceRGB); i.context->setFillColor(Color::black, ColorSpaceDeviceRGB); #if ENABLE(VIDEO) HTMLMediaElement* mediaElement = mediaElementParent(o->node()); if (mediaElement) { float pt = (mediaElement->currentTime() - mediaElement->startTime()) / mediaElement->duration(); FloatRect intRect = r; intRect.setX(intRect.x() + intRect.width() * pt - 2); intRect.setWidth(5); i.context->fillRect(intRect); } #endif i.context->restore(); return rc; }
bool RenderThemeWinCE::paintSliderTrack(RenderObject* o, const PaintInfo& i, const IntRect& r) { bool rc = RenderTheme::paintSliderTrack(o, i, r); IntPoint left = IntPoint(r.x() + 2, (r.y() + r.maxY()) / 2); i.context->save(); i.context->setStrokeColor(Color::gray, ColorSpaceDeviceRGB); i.context->setFillColor(Color::gray, ColorSpaceDeviceRGB); i.context->fillRect(r); #if ENABLE(VIDEO) HTMLMediaElement* mediaElement = mediaElementParent(o->node()); if (mediaElement) { i.context->setStrokeColor(Color(0, 0xff, 0)); IntPoint right = IntPoint(left.x() + mediaElement->percentLoaded() * (r.maxX() - r.x() - 4), (r.y() + r.maxY()) / 2); i.context->drawLine(left, right); left = right; } #endif i.context->setStrokeColor(Color::black, ColorSpaceDeviceRGB); i.context->drawLine(left, IntPoint(r.maxX() - 2, left.y())); i.context->restore(); return rc; }
bool RenderThemeWinCE::paintMediaPlayButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { bool rc = paintButton(o, paintInfo, r); FloatRect imRect = r; imRect.inflate(-3); paintInfo.context->save(); paintInfo.context->setStrokeColor(Color::black); paintInfo.context->setFillColor(Color::black); HTMLMediaElement* mediaElement = mediaElementParent(o->node()); bool paused = !mediaElement || mediaElement->paused(); if (paused) { float width = imRect.width(); imRect.setWidth(width / 3.0); paintInfo.context->fillRect(imRect); imRect.move(2.0 * width / 3.0, 0); paintInfo.context->fillRect(imRect); } else { FloatPoint pts[3] = { FloatPoint(imRect.x(), imRect.y()), FloatPoint(imRect.maxX(), (imRect.y() + imRect.maxY()) / 2.0), FloatPoint(imRect.x(), imRect.maxY()) }; paintInfo.context->drawConvexPolygon(3, pts); } paintInfo.context->restore(); return rc; }
bool RenderThemeWinCE::paintMediaMuteButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { bool rc = paintButton(o, paintInfo, r); HTMLMediaElement* mediaElement = mediaElementParent(o->node()); bool muted = !mediaElement || mediaElement->muted(); FloatRect imRect = r; imRect.inflate(-2); paintInfo.context->save(); paintInfo.context->setStrokeColor(Color::black); paintInfo.context->setFillColor(Color::black); FloatPoint pts[6] = { FloatPoint(imRect.x() + 1, imRect.y() + imRect.height() / 3.0), FloatPoint(imRect.x() + 1 + imRect.width() / 2.0, imRect.y() + imRect.height() / 3.0), FloatPoint(imRect.maxX() - 1, imRect.y()), FloatPoint(imRect.maxX() - 1, imRect.maxY()), FloatPoint(imRect.x() + 1 + imRect.width() / 2.0, imRect.y() + 2.0 * imRect.height() / 3.0), FloatPoint(imRect.x() + 1, imRect.y() + 2.0 * imRect.height() / 3.0) }; paintInfo.context->drawConvexPolygon(6, pts); if (muted) paintInfo.context->drawLine(IntPoint(imRect.maxX(), imRect.y()), IntPoint(imRect.x(), imRect.maxY())); paintInfo.context->restore(); return rc; }
bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { #if ENABLE(VIDEO) HTMLMediaElement* mediaElement = mediaElementParent(object->node()); if (!mediaElement) return false; SkCanvas* canvas = paintInfo.context->platformContext()->canvas(); SkRect backgroundRect; backgroundRect.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height()); SkPaint paint; paint.setAntiAlias(true); // Draw the border of the time bar. The border only has one single color, // width and radius. So use the property of the left border. SkColor borderColor = object->style()->borderLeftColor().rgb(); int borderWidth = object->style()->borderLeftWidth(); IntSize borderRadius = object->style()->borderTopLeftRadius(); paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(borderWidth); paint.setColor(borderColor); canvas->drawRoundRect(backgroundRect, borderRadius.width(), borderRadius.height(), paint); // Draw the background of the time bar. SkColor backgroundColor = object->style()->backgroundColor().rgb(); paint.setStyle(SkPaint::kFill_Style); paint.setColor(backgroundColor); canvas->drawRoundRect(backgroundRect, borderRadius.width(), borderRadius.height(), paint); if (backgroundRect.width() >= 3 && backgroundRect.height() >= 3) { // Draw the buffered ranges. // FIXME: Draw multiple ranges if there are multiple buffered ranges. SkRect bufferedRect; bufferedRect.set(backgroundRect.fLeft + 2, backgroundRect.fTop + 2, backgroundRect.fRight - 1, backgroundRect.fBottom - 1); int width = static_cast<int>(bufferedRect.width() * mediaElement->percentLoaded()); bufferedRect.fRight = bufferedRect.fLeft + width; SkPoint points[2] = { { 0, bufferedRect.fTop }, { 0, bufferedRect.fBottom } }; SkColor startColor = object->style()->color().rgb(); SkColor endColor = SkColorSetRGB(SkColorGetR(startColor) / 2, SkColorGetG(startColor) / 2, SkColorGetB(startColor) / 2); SkColor colors[2] = { startColor, endColor }; SkShader* gradient = SkGradientShader::CreateLinear(points, colors, 0, sizeof(points) / sizeof(points[0]), SkShader::kMirror_TileMode, 0); paint.reset(); paint.setShader(gradient); paint.setAntiAlias(true); // Check for round rect with zero width or height, otherwise Skia will assert if (bufferedRect.width() > 0 && bufferedRect.height() > 0) canvas->drawRoundRect(bufferedRect, borderRadius.width(), borderRadius.height(), paint); gradient->unref(); } return true; #else UNUSED_PARAM(object); UNUSED_PARAM(paintInfo); UNUSED_PARAM(rect); return false; #endif }