| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/detachable_toolbar_view.h" | 5 #include "chrome/browser/ui/views/detachable_toolbar_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/themes/theme_service.h" | 7 #include "chrome/browser/themes/theme_service.h" |
| 8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "third_party/skia/include/core/SkShader.h" | 10 #include "third_party/skia/include/core/SkShader.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 void DetachableToolbarView::PaintContentAreaBackground( | 65 void DetachableToolbarView::PaintContentAreaBackground( |
| 66 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, | 66 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, |
| 67 const SkRect& rect, double roundness) { | 67 const SkRect& rect, double roundness) { |
| 68 SkPaint paint; | 68 SkPaint paint; |
| 69 paint.setAntiAlias(true); | 69 paint.setAntiAlias(true); |
| 70 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); | 70 paint.setColor(theme_provider->GetColor(ThemeService::COLOR_TOOLBAR)); |
| 71 | 71 |
| 72 canvas->AsCanvasSkia()->drawRoundRect( | 72 canvas->AsCanvasSkia()->skia_canvas()->drawRoundRect( |
| 73 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint); | 73 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), paint); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 void DetachableToolbarView::PaintContentAreaBorder( | 77 void DetachableToolbarView::PaintContentAreaBorder( |
| 78 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, | 78 gfx::Canvas* canvas, ui::ThemeProvider* theme_provider, |
| 79 const SkRect& rect, double roundness) { | 79 const SkRect& rect, double roundness) { |
| 80 SkPaint border_paint; | 80 SkPaint border_paint; |
| 81 border_paint.setColor( | 81 border_paint.setColor( |
| 82 theme_provider->GetColor(ThemeService::COLOR_NTP_HEADER)); | 82 theme_provider->GetColor(ThemeService::COLOR_NTP_HEADER)); |
| 83 border_paint.setStyle(SkPaint::kStroke_Style); | 83 border_paint.setStyle(SkPaint::kStroke_Style); |
| 84 border_paint.setAlpha(96); | 84 border_paint.setAlpha(96); |
| 85 border_paint.setAntiAlias(true); | 85 border_paint.setAntiAlias(true); |
| 86 | 86 |
| 87 canvas->AsCanvasSkia()->drawRoundRect( | 87 canvas->AsCanvasSkia()->skia_canvas()->drawRoundRect( |
| 88 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), | 88 rect, SkDoubleToScalar(roundness), SkDoubleToScalar(roundness), |
| 89 border_paint); | 89 border_paint); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // static | 92 // static |
| 93 void DetachableToolbarView::PaintVerticalDivider( | 93 void DetachableToolbarView::PaintVerticalDivider( |
| 94 gfx::Canvas* canvas, int x, int height, int vertical_padding, | 94 gfx::Canvas* canvas, int x, int height, int vertical_padding, |
| 95 const SkColor& top_color, | 95 const SkColor& top_color, |
| 96 const SkColor& middle_color, | 96 const SkColor& middle_color, |
| 97 const SkColor& bottom_color) { | 97 const SkColor& bottom_color) { |
| 98 // Draw the upper half of the divider. | 98 // Draw the upper half of the divider. |
| 99 SkPaint paint; | 99 SkPaint paint; |
| 100 SkSafeUnref(paint.setShader(gfx::CreateGradientShader(vertical_padding + 1, | 100 SkSafeUnref(paint.setShader(gfx::CreateGradientShader(vertical_padding + 1, |
| 101 height / 2, | 101 height / 2, |
| 102 top_color, | 102 top_color, |
| 103 middle_color))); | 103 middle_color))); |
| 104 SkRect rc = { SkIntToScalar(x), | 104 SkRect rc = { SkIntToScalar(x), |
| 105 SkIntToScalar(vertical_padding + 1), | 105 SkIntToScalar(vertical_padding + 1), |
| 106 SkIntToScalar(x + 1), | 106 SkIntToScalar(x + 1), |
| 107 SkIntToScalar(height / 2) }; | 107 SkIntToScalar(height / 2) }; |
| 108 canvas->AsCanvasSkia()->drawRect(rc, paint); | 108 canvas->AsCanvasSkia()->skia_canvas()->drawRect(rc, paint); |
| 109 | 109 |
| 110 // Draw the lower half of the divider. | 110 // Draw the lower half of the divider. |
| 111 SkPaint paint_down; | 111 SkPaint paint_down; |
| 112 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader( | 112 SkSafeUnref(paint_down.setShader(gfx::CreateGradientShader( |
| 113 height / 2, height - vertical_padding, middle_color, bottom_color))); | 113 height / 2, height - vertical_padding, middle_color, bottom_color))); |
| 114 SkRect rc_down = { SkIntToScalar(x), | 114 SkRect rc_down = { SkIntToScalar(x), |
| 115 SkIntToScalar(height / 2), | 115 SkIntToScalar(height / 2), |
| 116 SkIntToScalar(x + 1), | 116 SkIntToScalar(x + 1), |
| 117 SkIntToScalar(height - vertical_padding) }; | 117 SkIntToScalar(height - vertical_padding) }; |
| 118 canvas->AsCanvasSkia()->drawRect(rc_down, paint_down); | 118 canvas->AsCanvasSkia()->skia_canvas()->drawRect(rc_down, paint_down); |
| 119 } | 119 } |
| OLD | NEW |