| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 29 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
| 30 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" | 30 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" |
| 31 #include "chrome/browser/ui/views/tabs/tab_strip_layout.h" | 31 #include "chrome/browser/ui/views/tabs/tab_strip_layout.h" |
| 32 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" | 32 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" |
| 33 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 33 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
| 34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 36 #include "chrome/grit/theme_resources.h" | 36 #include "chrome/grit/theme_resources.h" |
| 37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
| 38 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
| 39 #include "skia/ext/cdl_paint.h" |
| 39 #include "third_party/skia/include/core/SkColorFilter.h" | 40 #include "third_party/skia/include/core/SkColorFilter.h" |
| 40 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 41 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
| 41 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" | 42 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" |
| 42 #include "third_party/skia/include/pathops/SkPathOps.h" | 43 #include "third_party/skia/include/pathops/SkPathOps.h" |
| 43 #include "ui/accessibility/ax_node_data.h" | 44 #include "ui/accessibility/ax_node_data.h" |
| 44 #include "ui/base/default_theme_provider.h" | 45 #include "ui/base/default_theme_provider.h" |
| 45 #include "ui/base/dragdrop/drag_drop_types.h" | 46 #include "ui/base/dragdrop/drag_drop_types.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/models/list_selection_model.h" | 48 #include "ui/base/models/list_selection_model.h" |
| 48 #include "ui/base/resource/resource_bundle.h" | 49 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // We want to draw a drop shadow either inside or outside the stroke, | 395 // We want to draw a drop shadow either inside or outside the stroke, |
| 395 // depending on whether we're pressed; so, either clip out what's outside | 396 // depending on whether we're pressed; so, either clip out what's outside |
| 396 // the stroke, or clip out the fill inside it. | 397 // the stroke, or clip out the fill inside it. |
| 397 if (pressed) | 398 if (pressed) |
| 398 canvas->ClipPath(stroke, true); | 399 canvas->ClipPath(stroke, true); |
| 399 Op(stroke, fill, kDifference_SkPathOp, &stroke); | 400 Op(stroke, fill, kDifference_SkPathOp, &stroke); |
| 400 if (!pressed) | 401 if (!pressed) |
| 401 canvas->sk_canvas()->clipPath(fill, SkRegion::kDifference_Op, true); | 402 canvas->sk_canvas()->clipPath(fill, SkRegion::kDifference_Op, true); |
| 402 // Now draw the stroke and shadow; the stroke will always be visible, while | 403 // Now draw the stroke and shadow; the stroke will always be visible, while |
| 403 // the shadow will be affected by the clip we set above. | 404 // the shadow will be affected by the clip we set above. |
| 404 SkPaint paint; | 405 CdlPaint paint; |
| 405 paint.setAntiAlias(true); | 406 paint.setAntiAlias(true); |
| 406 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor(); | 407 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor(); |
| 407 const float alpha = SkColorGetA(stroke_color); | 408 const float alpha = SkColorGetA(stroke_color); |
| 408 const SkAlpha shadow_alpha = | 409 const SkAlpha shadow_alpha = |
| 409 base::saturated_cast<SkAlpha>(std::round(2.1875f * alpha)); | 410 base::saturated_cast<SkAlpha>(std::round(2.1875f * alpha)); |
| 410 paint.setLooper( | 411 paint.setLooper( |
| 411 CreateShadowDrawLooper(SkColorSetA(stroke_color, shadow_alpha))); | 412 CreateShadowDrawLooper(SkColorSetA(stroke_color, shadow_alpha))); |
| 412 const SkAlpha path_alpha = static_cast<SkAlpha>( | 413 const SkAlpha path_alpha = static_cast<SkAlpha>( |
| 413 std::round((pressed ? 0.875f : 0.609375f) * alpha)); | 414 std::round((pressed ? 0.875f : 0.609375f) * alpha)); |
| 414 paint.setColor(SkColorSetA(stroke_color, path_alpha)); | 415 paint.setColor(SkColorSetA(stroke_color, path_alpha)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 465 } |
| 465 path->close(); | 466 path->close(); |
| 466 } | 467 } |
| 467 | 468 |
| 468 void NewTabButton::PaintFill(bool pressed, | 469 void NewTabButton::PaintFill(bool pressed, |
| 469 float scale, | 470 float scale, |
| 470 const SkPath& fill, | 471 const SkPath& fill, |
| 471 gfx::Canvas* canvas) const { | 472 gfx::Canvas* canvas) const { |
| 472 gfx::ScopedCanvas scoped_canvas(canvas); | 473 gfx::ScopedCanvas scoped_canvas(canvas); |
| 473 canvas->UndoDeviceScaleFactor(); | 474 canvas->UndoDeviceScaleFactor(); |
| 474 SkPaint paint; | 475 CdlPaint paint; |
| 475 paint.setAntiAlias(true); | 476 paint.setAntiAlias(true); |
| 476 | 477 |
| 477 // For unpressed buttons, draw the fill and its shadow. | 478 // For unpressed buttons, draw the fill and its shadow. |
| 478 if (!pressed) { | 479 if (!pressed) { |
| 479 // First we compute the background image coordinates and scale, in case we | 480 // First we compute the background image coordinates and scale, in case we |
| 480 // need to draw a custom background image. | 481 // need to draw a custom background image. |
| 481 const ui::ThemeProvider* tp = GetThemeProvider(); | 482 const ui::ThemeProvider* tp = GetThemeProvider(); |
| 482 bool custom_image; | 483 bool custom_image; |
| 483 const int bg_id = tab_strip_->GetBackgroundResourceId(&custom_image); | 484 const int bg_id = tab_strip_->GetBackgroundResourceId(&custom_image); |
| 484 if (custom_image) { | 485 if (custom_image) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 502 canvas->InitSkPaintForTiling(*tp->GetImageSkiaNamed(bg_id), x, | 503 canvas->InitSkPaintForTiling(*tp->GetImageSkiaNamed(bg_id), x, |
| 503 GetNewTabButtonTopOffset() + offset_y, | 504 GetNewTabButtonTopOffset() + offset_y, |
| 504 x_scale * scale, scale, 0, 0, &paint); | 505 x_scale * scale, scale, 0, 0, &paint); |
| 505 DCHECK(succeeded); | 506 DCHECK(succeeded); |
| 506 } else { | 507 } else { |
| 507 paint.setColor(tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB)); | 508 paint.setColor(tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB)); |
| 508 } | 509 } |
| 509 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor(); | 510 const SkColor stroke_color = tab_strip_->GetToolbarTopSeparatorColor(); |
| 510 const SkAlpha alpha = static_cast<SkAlpha>( | 511 const SkAlpha alpha = static_cast<SkAlpha>( |
| 511 std::round(SkColorGetA(stroke_color) * 0.59375f)); | 512 std::round(SkColorGetA(stroke_color) * 0.59375f)); |
| 512 SkPaint shadow_paint = paint; | 513 CdlPaint shadow_paint = paint; |
| 513 shadow_paint.setLooper( | 514 shadow_paint.setLooper( |
| 514 CreateShadowDrawLooper(SkColorSetA(stroke_color, alpha))); | 515 CreateShadowDrawLooper(SkColorSetA(stroke_color, alpha))); |
| 515 canvas->DrawPath(fill, shadow_paint); | 516 canvas->DrawPath(fill, shadow_paint); |
| 516 } | 517 } |
| 517 | 518 |
| 518 // Draw a white highlight on hover. | 519 // Draw a white highlight on hover. |
| 519 const SkAlpha hover_alpha = static_cast<SkAlpha>( | 520 const SkAlpha hover_alpha = static_cast<SkAlpha>( |
| 520 hover_animation().CurrentValueBetween(0x00, 0x4D)); | 521 hover_animation().CurrentValueBetween(0x00, 0x4D)); |
| 521 if (hover_alpha != SK_AlphaTRANSPARENT) { | 522 if (hover_alpha != SK_AlphaTRANSPARENT) { |
| 522 paint.setColor(SkColorSetA(SK_ColorWHITE, hover_alpha)); | 523 paint.setColor(SkColorSetA(SK_ColorWHITE, hover_alpha)); |
| (...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2804 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2805 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
| 2805 if (view) | 2806 if (view) |
| 2806 return view; | 2807 return view; |
| 2807 } | 2808 } |
| 2808 Tab* tab = FindTabForEvent(point); | 2809 Tab* tab = FindTabForEvent(point); |
| 2809 if (tab) | 2810 if (tab) |
| 2810 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2811 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
| 2811 } | 2812 } |
| 2812 return this; | 2813 return this; |
| 2813 } | 2814 } |
| OLD | NEW |