本文整理汇总了C++中HTMLMediaElement::percentLoaded方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLMediaElement::percentLoaded方法的具体用法?C++ HTMLMediaElement::percentLoaded怎么用?C++ HTMLMediaElement::percentLoaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLMediaElement
的用法示例。
在下文中一共展示了HTMLMediaElement::percentLoaded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintMediaSlider
static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
HTMLMediaElement* mediaElement = toParentMediaElement(object);
if (!mediaElement)
return false;
RenderStyle* style = object->style();
GraphicsContext* context = paintInfo.context;
// Draw the border of the time bar.
// FIXME: this should be a rounded rect but need to fix GraphicsContextSkia first.
// https://bugs.webkit.org/show_bug.cgi?id=30143
context->save();
context->setShouldAntialias(true);
context->setStrokeStyle(SolidStroke);
context->setStrokeColor(style->visitedDependentColor(CSSPropertyBorderLeftColor), ColorSpaceDeviceRGB);
context->setStrokeThickness(style->borderLeftWidth());
context->setFillColor(style->visitedDependentColor(CSSPropertyBackgroundColor), ColorSpaceDeviceRGB);
context->drawRect(rect);
context->restore();
// Draw the buffered ranges.
// FIXME: Draw multiple ranges if there are multiple buffered ranges.
IntRect bufferedRect = rect;
bufferedRect.inflate(-style->borderLeftWidth());
double bufferedWidth = 0.0;
if (mediaElement->percentLoaded() > 0.0) {
// Account for the width of the slider thumb.
Image* mediaSliderThumb = getMediaSliderThumb();
double thumbWidth = mediaSliderThumb->width() / 2.0 + 1.0;
double rectWidth = bufferedRect.width() - thumbWidth;
if (rectWidth < 0.0)
rectWidth = 0.0;
bufferedWidth = rectWidth * mediaElement->percentLoaded() + thumbWidth;
}
bufferedRect.setWidth(bufferedWidth);
// Don't bother drawing an empty area.
if (!bufferedRect.isEmpty()) {
IntPoint sliderTopLeft = bufferedRect.location();
IntPoint sliderTopRight = sliderTopLeft;
sliderTopRight.move(0, bufferedRect.height());
RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight);
Color startColor = object->style()->visitedDependentColor(CSSPropertyColor);
gradient->addColorStop(0.0, startColor);
gradient->addColorStop(1.0, Color(startColor.red() / 2, startColor.green() / 2, startColor.blue() / 2, startColor.alpha()));
context->save();
context->setStrokeStyle(NoStroke);
context->setFillGradient(gradient);
context->fillRect(bufferedRect);
context->restore();
}
return true;
}
示例2: paintMediaSliderTrack
bool RenderThemeGtk::paintMediaSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
{
GraphicsContext* context = paintInfo.context;
context->fillRect(FloatRect(r), m_panelColor, DeviceColorSpace);
context->fillRect(FloatRect(IntRect(r.x(), r.y() + (r.height() - m_mediaSliderHeight) / 2,
r.width(), m_mediaSliderHeight)), m_sliderColor, DeviceColorSpace);
RenderStyle* style = o->style();
HTMLMediaElement* mediaElement = toParentMediaElement(o);
if (!mediaElement)
return false;
// Draw the buffered ranges. This code is highly inspired from
// Chrome.
// FIXME: Draw multiple ranges if there are multiple buffered
// ranges. The current implementation of the player is always
// buffering a single range anyway.
IntRect bufferedRect = r;
bufferedRect.inflate(-style->borderLeftWidth());
bufferedRect.setWidth((bufferedRect.width() * mediaElement->percentLoaded()));
// Don't bother drawing an empty area.
if (bufferedRect.isEmpty())
return false;
IntPoint sliderTopLeft = bufferedRect.location();
IntPoint sliderTopRight = sliderTopLeft;
sliderTopRight.move(0, bufferedRect.height());
RefPtr<Gradient> gradient = Gradient::create(sliderTopLeft, sliderTopRight);
Color startColor = m_panelColor;
gradient->addColorStop(0.0, startColor);
gradient->addColorStop(1.0, Color(startColor.red() / 2, startColor.green() / 2, startColor.blue() / 2, startColor.alpha()));
context->save();
context->setStrokeStyle(NoStroke);
context->setFillGradient(gradient);
context->fillRect(bufferedRect);
context->restore();
return false;
}
示例3: paintSliderTrack
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;
}
示例4: paintMediaSliderTrack
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
}