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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 1785613004: Dynamically compute tab/frame separator color. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exclude test on Mac Created 4 years, 9 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
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 canvas->ClipPath(stroke, true); 411 canvas->ClipPath(stroke, true);
412 Op(stroke, fill, kDifference_SkPathOp, &stroke); 412 Op(stroke, fill, kDifference_SkPathOp, &stroke);
413 if (!pressed) 413 if (!pressed)
414 canvas->sk_canvas()->clipPath(fill, SkRegion::kDifference_Op, true); 414 canvas->sk_canvas()->clipPath(fill, SkRegion::kDifference_Op, true);
415 // Now draw the stroke and shadow; the stroke will always be visible, while 415 // Now draw the stroke and shadow; the stroke will always be visible, while
416 // the shadow will be affected by the clip we set above. 416 // the shadow will be affected by the clip we set above.
417 SkPaint paint; 417 SkPaint paint;
418 paint.setAntiAlias(true); 418 paint.setAntiAlias(true);
419 const SkColor stroke_color = 419 const SkColor stroke_color =
420 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR); 420 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR);
421 const float alpha = SkColorGetA(stroke_color);
422 const SkAlpha shadow_alpha =
423 base::saturated_cast<SkAlpha>(std::round(2.1875f * alpha));
421 skia::RefPtr<SkDrawLooper> stroke_looper = 424 skia::RefPtr<SkDrawLooper> stroke_looper =
422 CreateShadowDrawLooper(SkColorSetA(stroke_color, 0x8C)); 425 CreateShadowDrawLooper(SkColorSetA(stroke_color, shadow_alpha));
423 paint.setLooper(stroke_looper.get()); 426 paint.setLooper(stroke_looper.get());
424 paint.setColor(SkColorSetA(stroke_color, pressed ? 0x38 : 0x27)); 427 const SkAlpha path_alpha = static_cast<SkAlpha>(
428 std::round((pressed ? 0.875f : 0.609375f) * alpha));
429 paint.setColor(SkColorSetA(stroke_color, path_alpha));
425 canvas->DrawPath(stroke, paint); 430 canvas->DrawPath(stroke, paint);
426 } else { 431 } else {
427 // Fill. 432 // Fill.
428 gfx::ImageSkia* mask = tp->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK); 433 gfx::ImageSkia* mask = tp->GetImageSkiaNamed(IDR_NEWTAB_BUTTON_MASK);
429 // The canvas and mask have to use the same scale factor. 434 // The canvas and mask have to use the same scale factor.
430 const float fill_canvas_scale = mask->HasRepresentation(scale) ? 435 const float fill_canvas_scale = mask->HasRepresentation(scale) ?
431 scale : ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_100P); 436 scale : ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_100P);
432 gfx::Canvas fill_canvas(GetLayoutSize(NEW_TAB_BUTTON), fill_canvas_scale, 437 gfx::Canvas fill_canvas(GetLayoutSize(NEW_TAB_BUTTON), fill_canvas_scale,
433 false); 438 false);
434 PaintFill(pressed, fill_canvas_scale, fill, &fill_canvas); 439 PaintFill(pressed, fill_canvas_scale, fill, &fill_canvas);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 if (custom_image) { 565 if (custom_image) {
561 const bool succeeded = canvas->InitSkPaintForTiling( 566 const bool succeeded = canvas->InitSkPaintForTiling(
562 *tp->GetImageSkiaNamed(bg_id), x, y, x_scale * scale, scale, 0, 0, 567 *tp->GetImageSkiaNamed(bg_id), x, y, x_scale * scale, scale, 0, 0,
563 &paint); 568 &paint);
564 DCHECK(succeeded); 569 DCHECK(succeeded);
565 } else { 570 } else {
566 paint.setColor(tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB)); 571 paint.setColor(tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB));
567 } 572 }
568 const SkColor stroke_color = GetThemeProvider()->GetColor( 573 const SkColor stroke_color = GetThemeProvider()->GetColor(
569 ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR); 574 ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR);
575 const SkAlpha alpha = static_cast<SkAlpha>(
576 std::round(SkColorGetA(stroke_color) * 0.59375f));
570 skia::RefPtr<SkDrawLooper> looper = 577 skia::RefPtr<SkDrawLooper> looper =
571 CreateShadowDrawLooper(SkColorSetA(stroke_color, 0x26)); 578 CreateShadowDrawLooper(SkColorSetA(stroke_color, alpha));
572 paint.setLooper(looper.get()); 579 paint.setLooper(looper.get());
573 canvas->DrawPath(fill, paint); 580 canvas->DrawPath(fill, paint);
574 } 581 }
575 582
576 // Draw a white highlight on hover. 583 // Draw a white highlight on hover.
577 SkPaint paint; 584 SkPaint paint;
578 paint.setAntiAlias(true); 585 paint.setAntiAlias(true);
579 const SkAlpha hover_alpha = static_cast<SkAlpha>( 586 const SkAlpha hover_alpha = static_cast<SkAlpha>(
580 hover_animation().CurrentValueBetween(0x00, 0x4D)); 587 hover_animation().CurrentValueBetween(0x00, 0x4D));
581 if (hover_alpha != SK_AlphaTRANSPARENT) { 588 if (hover_alpha != SK_AlphaTRANSPARENT) {
(...skipping 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); 2884 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
2878 if (view) 2885 if (view)
2879 return view; 2886 return view;
2880 } 2887 }
2881 Tab* tab = FindTabForEvent(point); 2888 Tab* tab = FindTabForEvent(point);
2882 if (tab) 2889 if (tab)
2883 return ConvertPointToViewAndGetEventHandler(this, tab, point); 2890 return ConvertPointToViewAndGetEventHandler(this, tab, point);
2884 } 2891 }
2885 return this; 2892 return this;
2886 } 2893 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/opaque_browser_frame_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698