Chromium Code Reviews| 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.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 gfx::RectF(width() * scale, height() * scale - 1)); | 1268 gfx::RectF(width() * scale, height() * scale - 1)); |
| 1269 } | 1269 } |
| 1270 flags.setColor(controller_->GetToolbarTopSeparatorColor()); | 1270 flags.setColor(controller_->GetToolbarTopSeparatorColor()); |
| 1271 stroke_canvas->DrawPath(stroke, flags); | 1271 stroke_canvas->DrawPath(stroke, flags); |
| 1272 } | 1272 } |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 void Tab::PaintPinnedTabTitleChangedIndicatorAndIcon( | 1275 void Tab::PaintPinnedTabTitleChangedIndicatorAndIcon( |
| 1276 gfx::Canvas* canvas, | 1276 gfx::Canvas* canvas, |
| 1277 const gfx::Rect& favicon_draw_bounds) { | 1277 const gfx::Rect& favicon_draw_bounds) { |
| 1278 const float kIndicatorCropRadius = 4.5f; | |
|
sky
2017/04/04 22:02:41
Is there a reason to move these from where they we
danakj
2017/04/04 22:10:44
Oh, putting them together shows their relationship
| |
| 1279 const int kIndicatorRadius = 3; | |
| 1280 | |
| 1278 // The pinned tab title changed indicator consists of two parts: | 1281 // The pinned tab title changed indicator consists of two parts: |
| 1279 // . a clear (totally transparent) part over the bottom right (or left in rtl) | 1282 // . a clear (totally transparent) part over the bottom right (or left in rtl) |
| 1280 // of the favicon. This is done by drawing the favicon to a canvas, then | 1283 // of the favicon. This is done by drawing the favicon to a layer, then |
| 1281 // drawing the clear part on top of the favicon. | 1284 // drawing the clear part on top of the favicon. |
| 1282 // . a circle in the bottom right (or left in rtl) of the favicon. | 1285 // . a circle in the bottom right (or left in rtl) of the favicon. |
| 1283 if (!favicon_.isNull()) { | 1286 if (!favicon_.isNull()) { |
| 1284 const float kIndicatorCropRadius = 4.5; | 1287 canvas->SaveLayerAlpha(0xff); |
| 1285 gfx::Canvas icon_canvas(gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), | 1288 canvas->DrawImageInt(favicon_, 0, 0, favicon_draw_bounds.width(), |
| 1286 canvas->image_scale(), false); | 1289 favicon_draw_bounds.height(), favicon_draw_bounds.x(), |
| 1287 icon_canvas.DrawImageInt(favicon_, 0, 0); | 1290 favicon_draw_bounds.y(), favicon_draw_bounds.width(), |
| 1291 favicon_draw_bounds.height(), false); | |
| 1288 cc::PaintFlags clear_flags; | 1292 cc::PaintFlags clear_flags; |
| 1289 clear_flags.setAntiAlias(true); | 1293 clear_flags.setAntiAlias(true); |
| 1290 clear_flags.setBlendMode(SkBlendMode::kClear); | 1294 clear_flags.setBlendMode(SkBlendMode::kClear); |
| 1291 const int circle_x = base::i18n::IsRTL() ? 0 : gfx::kFaviconSize; | 1295 int circle_x = |
| 1292 icon_canvas.DrawCircle(gfx::PointF(circle_x, gfx::kFaviconSize), | 1296 favicon_draw_bounds.x() + (base::i18n::IsRTL() ? 0 : gfx::kFaviconSize); |
| 1293 kIndicatorCropRadius, clear_flags); | 1297 int circle_y = favicon_draw_bounds.y() + gfx::kFaviconSize; |
| 1294 canvas->DrawImageInt(gfx::ImageSkia(icon_canvas.ExtractImageRep()), 0, 0, | 1298 canvas->DrawCircle(gfx::Point(circle_x, circle_y), kIndicatorCropRadius, |
| 1295 favicon_draw_bounds.width(), | 1299 clear_flags); |
| 1296 favicon_draw_bounds.height(), favicon_draw_bounds.x(), | 1300 canvas->Restore(); |
| 1297 favicon_draw_bounds.y(), favicon_draw_bounds.width(), | |
| 1298 favicon_draw_bounds.height(), false); | |
| 1299 } | 1301 } |
| 1300 | 1302 |
| 1301 // Draws the actual pinned tab title changed indicator. | 1303 // Draws the actual pinned tab title changed indicator. |
| 1302 const int kIndicatorRadius = 3; | |
| 1303 cc::PaintFlags indicator_flags; | 1304 cc::PaintFlags indicator_flags; |
| 1304 indicator_flags.setColor(GetNativeTheme()->GetSystemColor( | 1305 indicator_flags.setColor(GetNativeTheme()->GetSystemColor( |
| 1305 ui::NativeTheme::kColorId_ProminentButtonColor)); | 1306 ui::NativeTheme::kColorId_ProminentButtonColor)); |
| 1306 indicator_flags.setAntiAlias(true); | 1307 indicator_flags.setAntiAlias(true); |
| 1307 const int indicator_x = GetMirroredXWithWidthInView( | 1308 const int indicator_x = GetMirroredXWithWidthInView( |
| 1308 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); | 1309 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); |
| 1309 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; | 1310 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; |
| 1310 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, | 1311 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, |
| 1311 indicator_y + kIndicatorRadius), | 1312 indicator_y + kIndicatorRadius), |
| 1312 kIndicatorRadius, indicator_flags); | 1313 kIndicatorRadius, indicator_flags); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1486 gfx::Rect bounds = favicon_bounds_; | 1487 gfx::Rect bounds = favicon_bounds_; |
| 1487 if (bounds.IsEmpty()) | 1488 if (bounds.IsEmpty()) |
| 1488 return; | 1489 return; |
| 1489 | 1490 |
| 1490 // Extends the area to the bottom when the crash animation is in progress. | 1491 // Extends the area to the bottom when the crash animation is in progress. |
| 1491 if (crash_icon_animation_->is_animating()) | 1492 if (crash_icon_animation_->is_animating()) |
| 1492 bounds.set_height(height() - bounds.y()); | 1493 bounds.set_height(height() - bounds.y()); |
| 1493 bounds.set_x(GetMirroredXForRect(bounds)); | 1494 bounds.set_x(GetMirroredXForRect(bounds)); |
| 1494 SchedulePaintInRect(bounds); | 1495 SchedulePaintInRect(bounds); |
| 1495 } | 1496 } |
| OLD | NEW |