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

Side by Side Diff: third_party/WebKit/Source/core/paint/ThemePainterMac.mm

Issue 2785203002: Split Gradient impl into separate classes (Closed)
Patch Set: review Created 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 FloatSize shadowOffset(isVerticalSlider ? 1 : 0, isVerticalSlider ? 0 : 1); 379 FloatSize shadowOffset(isVerticalSlider ? 1 : 0, isVerticalSlider ? 0 : 1);
380 float shadowBlur = 3; 380 float shadowBlur = 3;
381 float shadowSpread = 0; 381 float shadowSpread = 0;
382 paintInfo.context.save(); 382 paintInfo.context.save();
383 paintInfo.context.drawInnerShadow(fillRect, shadowColor, shadowOffset, 383 paintInfo.context.drawInnerShadow(fillRect, shadowColor, shadowOffset,
384 shadowBlur, shadowSpread); 384 shadowBlur, shadowSpread);
385 paintInfo.context.restore(); 385 paintInfo.context.restore();
386 386
387 RefPtr<Gradient> borderGradient = 387 RefPtr<Gradient> borderGradient =
388 Gradient::create(fillBounds.minXMinYCorner(), 388 Gradient::createLinear(fillBounds.minXMinYCorner(),
389 isVerticalSlider ? fillBounds.maxXMinYCorner() 389 isVerticalSlider ? fillBounds.maxXMinYCorner()
390 : fillBounds.minXMaxYCorner()); 390 : fillBounds.minXMaxYCorner());
391 borderGradient->addColorStop(0.0, borderGradientTopColor); 391 borderGradient->addColorStop(0.0, borderGradientTopColor);
392 borderGradient->addColorStop(1.0, borderGradientBottomColor); 392 borderGradient->addColorStop(1.0, borderGradientBottomColor);
393 393
394 FloatRect borderRect(unzoomedRect); 394 FloatRect borderRect(unzoomedRect);
395 borderRect.inflate(-LayoutThemeMac::sliderTrackBorderWidth / 2.0); 395 borderRect.inflate(-LayoutThemeMac::sliderTrackBorderWidth / 2.0);
396 float borderRadiusSize = 396 float borderRadiusSize =
397 (isVerticalSlider ? borderRect.width() : borderRect.height()) / 2; 397 (isVerticalSlider ? borderRect.width() : borderRect.height()) / 2;
398 FloatSize borderRadius(borderRadiusSize, borderRadiusSize); 398 FloatSize borderRadius(borderRadiusSize, borderRadiusSize);
399 FloatRoundedRect borderRRect(borderRect, borderRadius, borderRadius, 399 FloatRoundedRect borderRRect(borderRect, borderRadius, borderRadius,
400 borderRadius, borderRadius); 400 borderRadius, borderRadius);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 borderBounds.inflate(-LayoutThemeMac::sliderThumbBorderWidth); 458 borderBounds.inflate(-LayoutThemeMac::sliderThumbBorderWidth);
459 FloatSize shadowOffset(0, 1); 459 FloatSize shadowOffset(0, 1);
460 paintInfo.context.setShadow( 460 paintInfo.context.setShadow(
461 shadowOffset, LayoutThemeMac::sliderThumbShadowBlur, shadowColor); 461 shadowOffset, LayoutThemeMac::sliderThumbShadowBlur, shadowColor);
462 paintInfo.context.setFillColor(Color::black); 462 paintInfo.context.setFillColor(Color::black);
463 paintInfo.context.fillEllipse(borderBounds); 463 paintInfo.context.fillEllipse(borderBounds);
464 paintInfo.context.setDrawLooper(nullptr); 464 paintInfo.context.setDrawLooper(nullptr);
465 465
466 IntRect fillBounds = enclosedIntRect(unzoomedRect); 466 IntRect fillBounds = enclosedIntRect(unzoomedRect);
467 RefPtr<Gradient> fillGradient = Gradient::create(fillBounds.minXMinYCorner(), 467 RefPtr<Gradient> fillGradient = Gradient::createLinear(
468 fillBounds.minXMaxYCorner()); 468 fillBounds.minXMinYCorner(), fillBounds.minXMaxYCorner());
469 fillGradient->addColorStop(0.0, fillGradientTopColor); 469 fillGradient->addColorStop(0.0, fillGradientTopColor);
470 fillGradient->addColorStop(0.52, fillGradientUpperMiddleColor); 470 fillGradient->addColorStop(0.52, fillGradientUpperMiddleColor);
471 fillGradient->addColorStop(0.52, fillGradientLowerMiddleColor); 471 fillGradient->addColorStop(0.52, fillGradientLowerMiddleColor);
472 fillGradient->addColorStop(1.0, fillGradientBottomColor); 472 fillGradient->addColorStop(1.0, fillGradientBottomColor);
473 PaintFlags fillFlags(paintInfo.context.fillFlags()); 473 PaintFlags fillFlags(paintInfo.context.fillFlags());
474 fillGradient->applyToFlags(fillFlags, SkMatrix::I()); 474 fillGradient->applyToFlags(fillFlags, SkMatrix::I());
475 paintInfo.context.drawOval(borderBounds, fillFlags); 475 paintInfo.context.drawOval(borderBounds, fillFlags);
476 476
477 RefPtr<Gradient> borderGradient = Gradient::create( 477 RefPtr<Gradient> borderGradient = Gradient::createLinear(
478 fillBounds.minXMinYCorner(), fillBounds.minXMaxYCorner()); 478 fillBounds.minXMinYCorner(), fillBounds.minXMaxYCorner());
479 borderGradient->addColorStop(0.0, borderGradientTopColor); 479 borderGradient->addColorStop(0.0, borderGradientTopColor);
480 borderGradient->addColorStop(1.0, borderGradientBottomColor); 480 borderGradient->addColorStop(1.0, borderGradientBottomColor);
481 paintInfo.context.setStrokeThickness(LayoutThemeMac::sliderThumbBorderWidth); 481 paintInfo.context.setStrokeThickness(LayoutThemeMac::sliderThumbBorderWidth);
482 PaintFlags borderFlags(paintInfo.context.strokeFlags()); 482 PaintFlags borderFlags(paintInfo.context.strokeFlags());
483 borderGradient->applyToFlags(borderFlags, SkMatrix::I()); 483 borderGradient->applyToFlags(borderFlags, SkMatrix::I());
484 paintInfo.context.drawOval(borderBounds, borderFlags); 484 paintInfo.context.drawOval(borderBounds, borderFlags);
485 485
486 if (LayoutTheme::isFocused(o)) { 486 if (LayoutTheme::isFocused(o)) {
487 Path borderPath; 487 Path borderPath;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 backgroundBounds.origin.y = bounds.origin.y + (heightDiff / 2) + 1; 803 backgroundBounds.origin.y = bounds.origin.y + (heightDiff / 2) + 1;
804 } 804 }
805 805
806 LocalCurrentGraphicsContext localContext(paintInfo.context, rect); 806 LocalCurrentGraphicsContext localContext(paintInfo.context, rect);
807 HIThemeDrawButton(&backgroundBounds, &drawInfo, localContext.cgContext(), 807 HIThemeDrawButton(&backgroundBounds, &drawInfo, localContext.cgContext(),
808 kHIThemeOrientationNormal, 0); 808 kHIThemeOrientationNormal, 0);
809 return false; 809 return false;
810 } 810 }
811 811
812 } // namespace blink 812 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698