Index: ui/native_theme/native_theme_base.cc |
diff --git a/ui/native_theme/native_theme_base.cc b/ui/native_theme/native_theme_base.cc |
index cc0bacbadf26c894938f01601b3bebd20e20eaa2..3b2bdd2471a31c63fd53b53dbf8c58f716f07269 100644 |
--- a/ui/native_theme/native_theme_base.cc |
+++ b/ui/native_theme/native_theme_base.cc |
@@ -247,20 +247,18 @@ |
NativeThemeBase::~NativeThemeBase() { |
} |
-// static |
-scoped_ptr<gfx::Canvas> NativeThemeBase::CreateCanvas(SkCanvas* sk_canvas) { |
- // TODO(pkotwicz): Do something better and don't infer device |
- // scale factor from canvas scale. |
- SkMatrix m = sk_canvas->getTotalMatrix(); |
- float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); |
- return scoped_ptr<gfx::Canvas>( |
- gfx::Canvas::CreateCanvasWithoutScaling(sk_canvas, device_scale)); |
-} |
- |
void NativeThemeBase::PaintArrowButton( |
SkCanvas* canvas, |
const gfx::Rect& rect, Part direction, State state) const { |
+ int widthMiddle, lengthMiddle; |
SkPaint paint; |
+ if (direction == kScrollbarUpArrow || direction == kScrollbarDownArrow) { |
+ widthMiddle = rect.width() / 2 + 1; |
+ lengthMiddle = rect.height() / 2 + 1; |
+ } else { |
+ lengthMiddle = rect.width() / 2 + 1; |
+ widthMiddle = rect.height() / 2 + 1; |
+ } |
// Calculate button color. |
SkScalar trackHSV[3]; |
@@ -335,24 +333,11 @@ |
paint.setColor(OutlineColor(trackHSV, thumbHSV)); |
canvas->drawPath(outline, paint); |
- PaintArrow(canvas, rect, direction, GetArrowColor(state)); |
-} |
- |
-void NativeThemeBase::PaintArrow(SkCanvas* gc, |
- const gfx::Rect& rect, |
- Part direction, |
- SkColor color) const { |
- int width_middle, length_middle; |
- if (direction == kScrollbarUpArrow || direction == kScrollbarDownArrow) { |
- width_middle = rect.width() / 2 + 1; |
- length_middle = rect.height() / 2 + 1; |
- } else { |
- length_middle = rect.width() / 2 + 1; |
- width_middle = rect.height() / 2 + 1; |
- } |
- |
- SkPaint paint; |
- paint.setColor(color); |
+ // If the button is disabled or read-only, the arrow is drawn with the |
+ // outline color. |
+ if (state != kDisabled) |
+ paint.setColor(SK_ColorBLACK); |
+ |
paint.setAntiAlias(false); |
paint.setStyle(SkPaint::kFill_Style); |
@@ -361,22 +346,22 @@ |
// looking arrows without anti-aliasing. |
switch (direction) { |
case kScrollbarUpArrow: |
- path.moveTo(rect.x() + width_middle - 4, rect.y() + length_middle + 2); |
+ path.moveTo(rect.x() + widthMiddle - 4, rect.y() + lengthMiddle + 2); |
path.rLineTo(7, 0); |
path.rLineTo(-4, -4); |
break; |
case kScrollbarDownArrow: |
- path.moveTo(rect.x() + width_middle - 4, rect.y() + length_middle - 3); |
+ path.moveTo(rect.x() + widthMiddle - 4, rect.y() + lengthMiddle - 3); |
path.rLineTo(7, 0); |
path.rLineTo(-4, 4); |
break; |
case kScrollbarRightArrow: |
- path.moveTo(rect.x() + length_middle - 3, rect.y() + width_middle - 4); |
+ path.moveTo(rect.x() + lengthMiddle - 3, rect.y() + widthMiddle - 4); |
path.rLineTo(0, 7); |
path.rLineTo(4, -4); |
break; |
case kScrollbarLeftArrow: |
- path.moveTo(rect.x() + length_middle + 1, rect.y() + width_middle - 5); |
+ path.moveTo(rect.x() + lengthMiddle + 1, rect.y() + widthMiddle - 5); |
path.rLineTo(0, 9); |
path.rLineTo(-4, -4); |
break; |
@@ -385,7 +370,7 @@ |
} |
path.close(); |
- gc->drawPath(path, paint); |
+ canvas->drawPath(path, paint); |
} |
void NativeThemeBase::PaintScrollbarTrack(SkCanvas* canvas, |
@@ -1014,7 +999,12 @@ |
SkCanvas* sk_canvas, const gfx::ImageSkia& image, |
int src_x, int src_y, int src_w, int src_h, |
int dest_x, int dest_y, int dest_w, int dest_h) const { |
- scoped_ptr<gfx::Canvas> canvas(CreateCanvas(sk_canvas)); |
+ // TODO(pkotwicz): Do something better and don't infer device |
+ // scale factor from canvas scale. |
+ SkMatrix m = sk_canvas->getTotalMatrix(); |
+ float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); |
+ scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( |
+ sk_canvas, device_scale)); |
canvas->DrawImageInt(image, src_x, src_y, src_w, src_h, |
dest_x, dest_y, dest_w, dest_h, true); |
} |
@@ -1023,7 +1013,12 @@ |
const gfx::ImageSkia& image, |
int src_x, int src_y, float tile_scale_x, float tile_scale_y, |
int dest_x, int dest_y, int w, int h) const { |
- scoped_ptr<gfx::Canvas> canvas(CreateCanvas(sk_canvas)); |
+ // TODO(pkotwicz): Do something better and don't infer device |
+ // scale factor from canvas scale. |
+ SkMatrix m = sk_canvas->getTotalMatrix(); |
+ float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); |
+ scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( |
+ sk_canvas, device_scale)); |
canvas->TileImageInt(image, src_x, src_y, tile_scale_x, |
tile_scale_y, dest_x, dest_y, w, h); |
} |
@@ -1036,17 +1031,6 @@ |
color[1] = Clamp(hsv[1] + saturate_amount, 0.0, 1.0); |
color[2] = Clamp(hsv[2] + brighten_amount, 0.0, 1.0); |
return SkHSVToColor(color); |
-} |
- |
-SkColor NativeThemeBase::GetArrowColor(State state) const { |
- if (state != kDisabled) |
- return SK_ColorBLACK; |
- |
- SkScalar track_hsv[3]; |
- SkColorToHSV(track_color_, track_hsv); |
- SkScalar thumb_hsv[3]; |
- SkColorToHSV(thumb_inactive_color_, thumb_hsv); |
- return OutlineColor(track_hsv, thumb_hsv); |
} |
void NativeThemeBase::DrawVertLine(SkCanvas* canvas, |