| 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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // The pinned tab title changed indicator consists of two parts: | 1278 // The pinned tab title changed indicator consists of two parts: |
| 1279 // . a clear (totally transparent) part over the bottom right (or left in rtl) | 1279 // . 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 | 1280 // of the favicon. This is done by drawing the favicon to a layer, then |
| 1281 // drawing the clear part on top of the favicon. | 1281 // drawing the clear part on top of the favicon. |
| 1282 // . a circle in the bottom right (or left in rtl) of the favicon. | 1282 // . a circle in the bottom right (or left in rtl) of the favicon. |
| 1283 if (!favicon_.isNull()) { | 1283 if (!favicon_.isNull()) { |
| 1284 const float kIndicatorCropRadius = 4.5; | 1284 canvas->SaveLayerAlpha(0xff); |
| 1285 gfx::Canvas icon_canvas(gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), | 1285 canvas->DrawImageInt(favicon_, 0, 0, favicon_draw_bounds.width(), |
| 1286 canvas->image_scale(), false); | 1286 favicon_draw_bounds.height(), favicon_draw_bounds.x(), |
| 1287 icon_canvas.DrawImageInt(favicon_, 0, 0); | 1287 favicon_draw_bounds.y(), favicon_draw_bounds.width(), |
| 1288 favicon_draw_bounds.height(), false); |
| 1288 cc::PaintFlags clear_flags; | 1289 cc::PaintFlags clear_flags; |
| 1289 clear_flags.setAntiAlias(true); | 1290 clear_flags.setAntiAlias(true); |
| 1290 clear_flags.setBlendMode(SkBlendMode::kClear); | 1291 clear_flags.setBlendMode(SkBlendMode::kClear); |
| 1291 const int circle_x = base::i18n::IsRTL() ? 0 : gfx::kFaviconSize; | 1292 const float kIndicatorCropRadius = 4.5f; |
| 1292 icon_canvas.DrawCircle(gfx::PointF(circle_x, gfx::kFaviconSize), | 1293 int circle_x = |
| 1293 kIndicatorCropRadius, clear_flags); | 1294 favicon_draw_bounds.x() + (base::i18n::IsRTL() ? 0 : gfx::kFaviconSize); |
| 1294 canvas->DrawImageInt(gfx::ImageSkia(icon_canvas.ExtractImageRep()), 0, 0, | 1295 int circle_y = favicon_draw_bounds.y() + gfx::kFaviconSize; |
| 1295 favicon_draw_bounds.width(), | 1296 canvas->DrawCircle(gfx::Point(circle_x, circle_y), kIndicatorCropRadius, |
| 1296 favicon_draw_bounds.height(), favicon_draw_bounds.x(), | 1297 clear_flags); |
| 1297 favicon_draw_bounds.y(), favicon_draw_bounds.width(), | 1298 canvas->Restore(); |
| 1298 favicon_draw_bounds.height(), false); | |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 // Draws the actual pinned tab title changed indicator. | 1301 // Draws the actual pinned tab title changed indicator. |
| 1302 const int kIndicatorRadius = 3; | |
| 1303 cc::PaintFlags indicator_flags; | 1302 cc::PaintFlags indicator_flags; |
| 1304 indicator_flags.setColor(GetNativeTheme()->GetSystemColor( | 1303 indicator_flags.setColor(GetNativeTheme()->GetSystemColor( |
| 1305 ui::NativeTheme::kColorId_ProminentButtonColor)); | 1304 ui::NativeTheme::kColorId_ProminentButtonColor)); |
| 1306 indicator_flags.setAntiAlias(true); | 1305 indicator_flags.setAntiAlias(true); |
| 1306 const int kIndicatorRadius = 3; |
| 1307 const int indicator_x = GetMirroredXWithWidthInView( | 1307 const int indicator_x = GetMirroredXWithWidthInView( |
| 1308 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); | 1308 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); |
| 1309 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; | 1309 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; |
| 1310 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, | 1310 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, |
| 1311 indicator_y + kIndicatorRadius), | 1311 indicator_y + kIndicatorRadius), |
| 1312 kIndicatorRadius, indicator_flags); | 1312 kIndicatorRadius, indicator_flags); |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 void Tab::PaintIcon(gfx::Canvas* canvas) { | 1315 void Tab::PaintIcon(gfx::Canvas* canvas) { |
| 1316 gfx::Rect bounds = favicon_bounds_; | 1316 gfx::Rect bounds = favicon_bounds_; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 gfx::Rect bounds = favicon_bounds_; | 1486 gfx::Rect bounds = favicon_bounds_; |
| 1487 if (bounds.IsEmpty()) | 1487 if (bounds.IsEmpty()) |
| 1488 return; | 1488 return; |
| 1489 | 1489 |
| 1490 // Extends the area to the bottom when the crash animation is in progress. | 1490 // Extends the area to the bottom when the crash animation is in progress. |
| 1491 if (crash_icon_animation_->is_animating()) | 1491 if (crash_icon_animation_->is_animating()) |
| 1492 bounds.set_height(height() - bounds.y()); | 1492 bounds.set_height(height() - bounds.y()); |
| 1493 bounds.set_x(GetMirroredXForRect(bounds)); | 1493 bounds.set_x(GetMirroredXForRect(bounds)); |
| 1494 SchedulePaintInRect(bounds); | 1494 SchedulePaintInRect(bounds); |
| 1495 } | 1495 } |
| OLD | NEW |