Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1721)

Unified Diff: Source/platform/scroll/ScrollbarThemeMacCommon.mm

Issue 1093383003: Remove mainthread overhang painting code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeMacCommon.h ('k') | Source/web/ChromeClientImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scroll/ScrollbarThemeMacCommon.mm
diff --git a/Source/platform/scroll/ScrollbarThemeMacCommon.mm b/Source/platform/scroll/ScrollbarThemeMacCommon.mm
index ca4a59859db8831d1ef3678ea735bcddff0a6e25..efca048f10662bc8a919c6da6e984e2210036814 100644
--- a/Source/platform/scroll/ScrollbarThemeMacCommon.mm
+++ b/Source/platform/scroll/ScrollbarThemeMacCommon.mm
@@ -130,140 +130,6 @@ void ScrollbarThemeMacCommon::paintGivenTickmarks(GraphicsContext* context, Scro
}
}
-void ScrollbarThemeMacCommon::paintOverhangBackground(GraphicsContext* context, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
-{
- const bool hasHorizontalOverhang = !horizontalOverhangRect.isEmpty();
- const bool hasVerticalOverhang = !verticalOverhangRect.isEmpty();
-
- GraphicsContextStateSaver stateSaver(*context);
-
- if (!m_overhangPattern) {
- // Lazily load the linen pattern image used for overhang drawing.
- RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern");
- m_overhangPattern = Pattern::createBitmapPattern(patternImage);
- }
- context->setFillPattern(m_overhangPattern);
- if (hasHorizontalOverhang)
- context->fillRect(intersection(horizontalOverhangRect, dirtyRect));
- if (hasVerticalOverhang)
- context->fillRect(intersection(verticalOverhangRect, dirtyRect));
-}
-
-void ScrollbarThemeMacCommon::paintOverhangShadows(GraphicsContext* context, const IntSize& scrollOffset, const IntRect& horizontalOverhangRect, const IntRect& verticalOverhangRect, const IntRect& dirtyRect)
-{
- // The extent of each shadow in pixels.
- const int kShadowSize = 4;
- // Offset of negative one pixel to make the gradient blend with the toolbar's bottom border.
- const int kToolbarShadowOffset = -1;
- const struct {
- float stop;
- Color color;
- } kShadowColors[] = {
- { 0.000, Color(0, 0, 0, 255) },
- { 0.125, Color(0, 0, 0, 57) },
- { 0.375, Color(0, 0, 0, 41) },
- { 0.625, Color(0, 0, 0, 18) },
- { 0.875, Color(0, 0, 0, 6) },
- { 1.000, Color(0, 0, 0, 0) }
- };
- const unsigned kNumShadowColors = sizeof(kShadowColors)/sizeof(kShadowColors[0]);
-
- const bool hasHorizontalOverhang = !horizontalOverhangRect.isEmpty();
- const bool hasVerticalOverhang = !verticalOverhangRect.isEmpty();
- // Prefer non-additive shadows, but degrade to additive shadows if there is vertical overhang.
- const bool useAdditiveShadows = hasVerticalOverhang;
-
- GraphicsContextStateSaver stateSaver(*context);
-
- FloatPoint shadowCornerOrigin;
- FloatPoint shadowCornerOffset;
-
- // Draw the shadow for the horizontal overhang.
- if (hasHorizontalOverhang) {
- int toolbarShadowHeight = kShadowSize;
- RefPtr<Gradient> gradient;
- IntRect shadowRect = horizontalOverhangRect;
- shadowRect.setHeight(kShadowSize);
- if (scrollOffset.height() < 0) {
- if (useAdditiveShadows) {
- toolbarShadowHeight = std::min(horizontalOverhangRect.height(), kShadowSize);
- } else if (horizontalOverhangRect.height() < 2 * kShadowSize + kToolbarShadowOffset) {
- // Split the overhang area between the web content shadow and toolbar shadow if it's too small.
- shadowRect.setHeight((horizontalOverhangRect.height() + 1) / 2);
- toolbarShadowHeight = horizontalOverhangRect.height() - shadowRect.height() - kToolbarShadowOffset;
- }
- shadowRect.setY(horizontalOverhangRect.maxY() - shadowRect.height());
- gradient = Gradient::create(FloatPoint(0, shadowRect.maxY()), FloatPoint(0, shadowRect.maxY() - kShadowSize));
- shadowCornerOrigin.setY(shadowRect.maxY());
- shadowCornerOffset.setY(-kShadowSize);
- } else {
- gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.maxY()));
- shadowCornerOrigin.setY(shadowRect.y());
- }
- if (hasVerticalOverhang) {
- shadowRect.setWidth(shadowRect.width() - verticalOverhangRect.width());
- if (scrollOffset.width() < 0) {
- shadowRect.setX(shadowRect.x() + verticalOverhangRect.width());
- shadowCornerOrigin.setX(shadowRect.x());
- shadowCornerOffset.setX(-kShadowSize);
- } else {
- shadowCornerOrigin.setX(shadowRect.maxX());
- }
- }
- for (unsigned i = 0; i < kNumShadowColors; i++)
- gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
- context->setFillGradient(gradient);
- context->fillRect(intersection(shadowRect, dirtyRect));
-
- // Draw a drop-shadow from the toolbar.
- if (scrollOffset.height() < 0) {
- shadowRect.setY(kToolbarShadowOffset);
- shadowRect.setHeight(toolbarShadowHeight);
- gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.y() + kShadowSize));
- for (unsigned i = 0; i < kNumShadowColors; i++)
- gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
- context->setFillGradient(gradient);
- context->fillRect(intersection(shadowRect, dirtyRect));
- }
- }
-
- // Draw the shadow for the vertical overhang.
- if (hasVerticalOverhang) {
- RefPtr<Gradient> gradient;
- IntRect shadowRect = verticalOverhangRect;
- shadowRect.setWidth(kShadowSize);
- if (scrollOffset.width() < 0) {
- shadowRect.setX(verticalOverhangRect.maxX() - shadowRect.width());
- gradient = Gradient::create(FloatPoint(shadowRect.maxX(), 0), FloatPoint(shadowRect.x(), 0));
- } else {
- gradient = Gradient::create(FloatPoint(shadowRect.x(), 0), FloatPoint(shadowRect.maxX(), 0));
- }
- for (unsigned i = 0; i < kNumShadowColors; i++)
- gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
- context->setFillGradient(gradient);
- context->fillRect(intersection(shadowRect, dirtyRect));
-
- // Draw a drop-shadow from the toolbar.
- shadowRect = verticalOverhangRect;
- shadowRect.setY(kToolbarShadowOffset);
- shadowRect.setHeight(kShadowSize);
- gradient = Gradient::create(FloatPoint(0, shadowRect.y()), FloatPoint(0, shadowRect.maxY()));
- for (unsigned i = 0; i < kNumShadowColors; i++)
- gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
- context->setFillGradient(gradient);
- context->fillRect(intersection(shadowRect, dirtyRect));
- }
-
- // If both rectangles present, draw a radial gradient for the corner.
- if (hasHorizontalOverhang && hasVerticalOverhang) {
- RefPtr<Gradient> gradient = Gradient::create(shadowCornerOrigin, 0, shadowCornerOrigin, kShadowSize);
- for (unsigned i = 0; i < kNumShadowColors; i++)
- gradient->addColorStop(kShadowColors[i].stop, kShadowColors[i].color);
- context->setFillGradient(gradient);
- context->fillRect(FloatRect(shadowCornerOrigin.x() + shadowCornerOffset.x(), shadowCornerOrigin.y() + shadowCornerOffset.y(), kShadowSize, kShadowSize));
- }
-}
-
void ScrollbarThemeMacCommon::paintTickmarks(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
{
// Note: This is only used for css-styled scrollbars on mac.
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeMacCommon.h ('k') | Source/web/ChromeClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698