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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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
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.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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // stroke inner edge is (GetUnscaledEndcapWidth() * scale) + 1. 206 // stroke inner edge is (GetUnscaledEndcapWidth() * scale) + 1.
207 float GetUnscaledEndcapWidth() { 207 float GetUnscaledEndcapWidth() {
208 return GetLayoutInsets(TAB).left() - 0.5f; 208 return GetLayoutInsets(TAB).left() - 0.5f;
209 } 209 }
210 210
211 void DrawHighlight(gfx::Canvas* canvas, 211 void DrawHighlight(gfx::Canvas* canvas,
212 const SkPoint& p, 212 const SkPoint& p,
213 SkScalar radius, 213 SkScalar radius,
214 SkColor color) { 214 SkColor color) {
215 const SkColor colors[2] = { color, SkColorSetA(color, 0) }; 215 const SkColor colors[2] = { color, SkColorSetA(color, 0) };
216 SkPaint paint; 216 CdlPaint paint;
217 paint.setAntiAlias(true); 217 paint.setAntiAlias(true);
218 paint.setShader(SkGradientShader::MakeRadial(p, radius, colors, nullptr, 2, 218 paint.setShader(WrapSkShader(SkGradientShader::MakeRadial(
219 SkShader::kClamp_TileMode)); 219 p, radius, colors, nullptr, 2, SkShader::kClamp_TileMode)));
220 canvas->sk_canvas()->drawRect( 220 canvas->sk_canvas()->drawRect(
221 SkRect::MakeXYWH(p.x() - radius, p.y() - radius, radius * 2, radius * 2), 221 SkRect::MakeXYWH(p.x() - radius, p.y() - radius, radius * 2, radius * 2),
222 paint); 222 paint);
223 } 223 }
224 224
225 // Returns whether the favicon for the given URL should be colored according to 225 // Returns whether the favicon for the given URL should be colored according to
226 // the browser theme. 226 // the browser theme.
227 bool ShouldThemifyFaviconForUrl(const GURL& url) { 227 bool ShouldThemifyFaviconForUrl(const GURL& url) {
228 return url.SchemeIs(content::kChromeUIScheme) && 228 return url.SchemeIs(content::kChromeUIScheme) &&
229 url.host() != chrome::kChromeUIHelpHost && 229 url.host() != chrome::kChromeUIHelpHost &&
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1275 }
1276 canvas->DrawImageInt(it->stroke_image, 0, 0); 1276 canvas->DrawImageInt(it->stroke_image, 0, 0);
1277 } 1277 }
1278 1278
1279 void Tab::PaintTabBackgroundUsingFillId(gfx::Canvas* fill_canvas, 1279 void Tab::PaintTabBackgroundUsingFillId(gfx::Canvas* fill_canvas,
1280 gfx::Canvas* stroke_canvas, 1280 gfx::Canvas* stroke_canvas,
1281 bool is_active, 1281 bool is_active,
1282 int fill_id, 1282 int fill_id,
1283 int y_offset) { 1283 int y_offset) {
1284 gfx::Path fill; 1284 gfx::Path fill;
1285 SkPaint paint; 1285 CdlPaint paint;
1286 paint.setAntiAlias(true); 1286 paint.setAntiAlias(true);
1287 1287
1288 // Draw the fill. 1288 // Draw the fill.
1289 { 1289 {
1290 gfx::ScopedCanvas scoped_canvas(fill_canvas); 1290 gfx::ScopedCanvas scoped_canvas(fill_canvas);
1291 const float scale = fill_canvas->UndoDeviceScaleFactor(); 1291 const float scale = fill_canvas->UndoDeviceScaleFactor();
1292 const ui::ThemeProvider* tp = GetThemeProvider(); 1292 const ui::ThemeProvider* tp = GetThemeProvider();
1293 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); 1293 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR);
1294 1294
1295 fill = GetFillPath(scale, size()); 1295 fill = GetFillPath(scale, size());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 // The pinned tab title changed indicator consists of two parts: 1347 // The pinned tab title changed indicator consists of two parts:
1348 // . a clear (totally transparent) part over the bottom right (or left in rtl) 1348 // . a clear (totally transparent) part over the bottom right (or left in rtl)
1349 // of the favicon. This is done by drawing the favicon to a canvas, then 1349 // of the favicon. This is done by drawing the favicon to a canvas, then
1350 // drawing the clear part on top of the favicon. 1350 // drawing the clear part on top of the favicon.
1351 // . a circle in the bottom right (or left in rtl) of the favicon. 1351 // . a circle in the bottom right (or left in rtl) of the favicon.
1352 if (!favicon_.isNull()) { 1352 if (!favicon_.isNull()) {
1353 const float kIndicatorCropRadius = 4.5; 1353 const float kIndicatorCropRadius = 4.5;
1354 gfx::Canvas icon_canvas(gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize), 1354 gfx::Canvas icon_canvas(gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize),
1355 canvas->image_scale(), false); 1355 canvas->image_scale(), false);
1356 icon_canvas.DrawImageInt(favicon_, 0, 0); 1356 icon_canvas.DrawImageInt(favicon_, 0, 0);
1357 SkPaint clear_paint; 1357 CdlPaint clear_paint;
1358 clear_paint.setAntiAlias(true); 1358 clear_paint.setAntiAlias(true);
1359 clear_paint.setBlendMode(SkBlendMode::kClear); 1359 clear_paint.setBlendMode(SkBlendMode::kClear);
1360 const int circle_x = base::i18n::IsRTL() ? 0 : gfx::kFaviconSize; 1360 const int circle_x = base::i18n::IsRTL() ? 0 : gfx::kFaviconSize;
1361 icon_canvas.DrawCircle(gfx::PointF(circle_x, gfx::kFaviconSize), 1361 icon_canvas.DrawCircle(gfx::PointF(circle_x, gfx::kFaviconSize),
1362 kIndicatorCropRadius, clear_paint); 1362 kIndicatorCropRadius, clear_paint);
1363 canvas->DrawImageInt(gfx::ImageSkia(icon_canvas.ExtractImageRep()), 0, 0, 1363 canvas->DrawImageInt(gfx::ImageSkia(icon_canvas.ExtractImageRep()), 0, 0,
1364 favicon_draw_bounds.width(), 1364 favicon_draw_bounds.width(),
1365 favicon_draw_bounds.height(), favicon_draw_bounds.x(), 1365 favicon_draw_bounds.height(), favicon_draw_bounds.x(),
1366 favicon_draw_bounds.y(), favicon_draw_bounds.width(), 1366 favicon_draw_bounds.y(), favicon_draw_bounds.width(),
1367 favicon_draw_bounds.height(), false); 1367 favicon_draw_bounds.height(), false);
1368 } 1368 }
1369 1369
1370 // Draws the actual pinned tab title changed indicator. 1370 // Draws the actual pinned tab title changed indicator.
1371 const int kIndicatorRadius = 3; 1371 const int kIndicatorRadius = 3;
1372 SkPaint indicator_paint; 1372 CdlPaint indicator_paint;
1373 indicator_paint.setColor(GetNativeTheme()->GetSystemColor( 1373 indicator_paint.setColor(GetNativeTheme()->GetSystemColor(
1374 ui::NativeTheme::kColorId_ProminentButtonColor)); 1374 ui::NativeTheme::kColorId_ProminentButtonColor));
1375 indicator_paint.setAntiAlias(true); 1375 indicator_paint.setAntiAlias(true);
1376 const int indicator_x = GetMirroredXWithWidthInView( 1376 const int indicator_x = GetMirroredXWithWidthInView(
1377 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); 1377 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2);
1378 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; 1378 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius;
1379 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, 1379 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius,
1380 indicator_y + kIndicatorRadius), 1380 indicator_y + kIndicatorRadius),
1381 kIndicatorRadius, indicator_paint); 1381 kIndicatorRadius, indicator_paint);
1382 } 1382 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 SchedulePaintInRect(bounds); 1577 SchedulePaintInRect(bounds);
1578 } 1578 }
1579 1579
1580 gfx::Rect Tab::GetImmersiveBarRect() const { 1580 gfx::Rect Tab::GetImmersiveBarRect() const {
1581 // The main bar is as wide as the normal tab's horizontal top line. 1581 // The main bar is as wide as the normal tab's horizontal top line.
1582 gfx::Rect contents = GetContentsBounds(); 1582 gfx::Rect contents = GetContentsBounds();
1583 contents.set_y(0); 1583 contents.set_y(0);
1584 contents.set_height(kImmersiveBarHeight); 1584 contents.set_height(kImmersiveBarHeight);
1585 return contents; 1585 return contents;
1586 } 1586 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/status_bubble_views.cc ('k') | chrome/browser/ui/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698