bool RenderThemeChromiumSkia::paintProgressBar(RenderObject* renderObject, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { static Image* barImage = Image::loadPlatformResource("linuxProgressBar").releaseRef(); static Image* valueImage = Image::loadPlatformResource("linuxProgressValue").releaseRef(); static Image* leftBorderImage = Image::loadPlatformResource("linuxProgressBorderLeft").releaseRef(); static Image* rightBorderImage = Image::loadPlatformResource("linuxProgressBorderRight").releaseRef(); ASSERT(barImage->height() == valueImage->height()); if (!renderObject->isProgress()) return true; paintInfo.context->platformContext()->setImageResamplingHint(barImage->size(), rect.size()); RenderProgress* renderProgress = toRenderProgress(renderObject); double tileScale = static_cast<double>(rect.height()) / barImage->height(); IntSize barTileSize(static_cast<int>(barImage->width() * tileScale), rect.height()); ColorSpace colorSpace = renderObject->style()->colorSpace(); paintInfo.context->drawTiledImage(barImage, colorSpace, rect, IntPoint(0, 0), barTileSize); IntRect valueRect = progressValueRectFor(renderProgress, rect); if (valueRect.width()) { IntSize valueTileSize(static_cast<int>(valueImage->width() * tileScale), valueRect.height()); int leftOffset = valueRect.x() - rect.x(); int roundedLeftOffset= (leftOffset / valueTileSize.width()) * valueTileSize.width(); int dstLeftValueWidth = roundedLeftOffset - leftOffset + (leftOffset % valueImage->width()) ? valueTileSize.width() : 0; IntRect dstLeftValueRect(valueRect.x(), valueRect.y(), dstLeftValueWidth, valueRect.height()); int srcLeftValueWidth = dstLeftValueWidth / tileScale; IntRect srcLeftValueRect(valueImage->width() - srcLeftValueWidth, 0, srcLeftValueWidth, valueImage->height()); paintInfo.context->drawImage(valueImage, colorSpace, dstLeftValueRect, srcLeftValueRect); int rightOffset = valueRect.right() - rect.x(); int roundedRightOffset = (rightOffset / valueTileSize.width()) * valueTileSize.width(); int dstRightValueWidth = rightOffset - roundedRightOffset; IntRect dstRightValueRect(rect.x() + roundedRightOffset, valueRect.y(), dstRightValueWidth, valueTileSize.height()); int srcRightValueWidth = dstRightValueWidth / tileScale; IntRect srcRightValueRect(0, 0, srcRightValueWidth, valueImage->height()); paintInfo.context->drawImage(valueImage, colorSpace, dstRightValueRect, srcRightValueRect); IntRect alignedValueRect(dstLeftValueRect.right(), dstLeftValueRect.y(), dstRightValueRect.x() - dstLeftValueRect.right(), dstLeftValueRect.height()); paintInfo.context->drawTiledImage(valueImage, colorSpace, alignedValueRect, IntPoint(0, 0), valueTileSize); } int dstLeftBorderWidth = leftBorderImage->width() * tileScale; IntRect dstLeftBorderRect(rect.x(), rect.y(), dstLeftBorderWidth, rect.height()); paintInfo.context->drawImage(leftBorderImage, colorSpace, dstLeftBorderRect, leftBorderImage->rect()); int dstRightBorderWidth = rightBorderImage->width() * tileScale; IntRect dstRightBorderRect(rect.right() - dstRightBorderWidth, rect.y(), dstRightBorderWidth, rect.height()); paintInfo.context->drawImage(rightBorderImage, colorSpace, dstRightBorderRect, rightBorderImage->rect()); paintInfo.context->platformContext()->clearImageResamplingHint(); return false; }
bool RenderThemeAndroid::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); IntRect valueRect = progressValueRectFor(renderProgress, rect);//progressRect; SkPaint paint; SkRect dstRect; SkShader* m_shader = NULL; SkPoint pts[2]; SkColor colors[3]; SkScalar pos[] = { 0.0f, 0.5f, 1.0f}; SkCanvas* const canvas = i.context->platformContext()->getCanvas(); pts[0].fX = valueRect.x(); pts[0].fY = valueRect.y(); pts[1].fX = valueRect.x(); pts[1].fY = valueRect.y() + valueRect.height(); colors[0] = 0xFFC4EEA4; colors[1] = 0xFF3DC032; colors[2] = 0xFFC4EEA4; m_shader = SkGradientShader::CreateLinear(pts, colors, pos, 3, SkShader::kClamp_TileMode); // Paint the bar, the bar is valueRect dstRect.set(valueRect.x(), valueRect.y(), (valueRect.x() + valueRect.width()), (valueRect.y() + valueRect.height())); paint.setAntiAlias(true); paint.setFilterBitmap(true); paint.setShader(m_shader); canvas->drawRect(dstRect, paint); // Paint the border for progress bar, set the rect to complete progress bar rect dstRect.set(rect.x(), rect.y(), (rect.x() + rect.width()), (rect.y() + rect.height())); paint.setShader(NULL); paint.setColor(0x80000000); paint.setStyle(SkPaint::kStroke_Style); canvas->drawRect(dstRect, paint); if (m_shader) { m_shader->unref(); } return false; }
bool RenderThemeChromiumLinux::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); IntRect valueRect = progressValueRectFor(renderProgress, rect); PlatformSupport::ThemePaintExtraParams extraParams; extraParams.progressBar.determinate = renderProgress->isDeterminate(); extraParams.progressBar.valueRectX = valueRect.x(); extraParams.progressBar.valueRectY = valueRect.y(); extraParams.progressBar.valueRectWidth = valueRect.width(); extraParams.progressBar.valueRectHeight = valueRect.height(); PlatformSupport::paintThemePart(i.context, PlatformSupport::PartProgressBar, getWebThemeState(this, o), rect, &extraParams); return false; }
bool RenderThemeChromiumDefault::paintProgressBar(RenderObject* o, const PaintInfo& i, const IntRect& rect) { if (!o->isProgress()) return true; RenderProgress* renderProgress = toRenderProgress(o); IntRect valueRect = progressValueRectFor(renderProgress, rect); WebKit::WebThemeEngine::ExtraParams extraParams; extraParams.progressBar.determinate = renderProgress->isDeterminate(); extraParams.progressBar.valueRectX = valueRect.x(); extraParams.progressBar.valueRectY = valueRect.y(); extraParams.progressBar.valueRectWidth = valueRect.width(); extraParams.progressBar.valueRectHeight = valueRect.height(); DirectionFlippingScope scope(o, i, rect); WebKit::WebCanvas* canvas = i.context->canvas(); WebKit::Platform::current()->themeEngine()->paint(canvas, WebKit::WebThemeEngine::PartProgressBar, getWebThemeState(this, o), WebKit::WebRect(rect), &extraParams); return false; }
bool ThemePainterDefault::paintProgressBar(const LayoutObject& o, const PaintInfo& i, const IntRect& rect) { if (!o.isProgress()) return true; const LayoutProgress& layoutProgress = toLayoutProgress(o); IntRect valueRect = progressValueRectFor(layoutProgress, rect); WebThemeEngine::ExtraParams extraParams; extraParams.progressBar.determinate = layoutProgress.isDeterminate(); extraParams.progressBar.valueRectX = valueRect.x(); extraParams.progressBar.valueRectY = valueRect.y(); extraParams.progressBar.valueRectWidth = valueRect.width(); extraParams.progressBar.valueRectHeight = valueRect.height(); DirectionFlippingScope scope(o, i, rect); WebCanvas* canvas = i.context.canvas(); Platform::current()->themeEngine()->paint( canvas, WebThemeEngine::PartProgressBar, getWebThemeState(o), WebRect(rect), &extraParams); return false; }