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

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

Issue 6879013: skia::PlatformCanvas is being deprecated. Going forward we will use gfx::Canvas wherever we need ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/tabs/side_tab.cc ('k') | chrome/browser/ui/views/theme_helpers.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <limits> 7 #include <limits>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/defaults.h" 10 #include "chrome/browser/defaults.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } else { 372 } else {
373 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) 373 if (mini_title_animation_.get() && mini_title_animation_->is_animating())
374 PaintInactiveTabBackgroundWithTitleChange(canvas); 374 PaintInactiveTabBackgroundWithTitleChange(canvas);
375 else 375 else
376 PaintInactiveTabBackground(canvas); 376 PaintInactiveTabBackground(canvas);
377 377
378 double throb_value = GetThrobValue(); 378 double throb_value = GetThrobValue();
379 if (throb_value > 0) { 379 if (throb_value > 0) {
380 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff), 380 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff),
381 gfx::Rect(width(), height())); 381 gfx::Rect(width(), height()));
382 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, 382 canvas->AsCanvasSkia()->skia_canvas()->drawARGB(
383 SkXfermode::kClear_Mode); 383 0, 255, 255, 255, SkXfermode::kClear_Mode);
384 PaintActiveTabBackground(canvas); 384 PaintActiveTabBackground(canvas);
385 canvas->Restore(); 385 canvas->Restore();
386 } 386 }
387 } 387 }
388 } 388 }
389 389
390 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { 390 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) {
391 // Render the inactive tab background. We'll use this for clipping. 391 // Render the inactive tab background. We'll use this for clipping.
392 gfx::CanvasSkia background_canvas(width(), height(), false); 392 gfx::CanvasSkia background_canvas;
393 background_canvas.Init(width(), height(), false);
393 PaintInactiveTabBackground(&background_canvas); 394 PaintInactiveTabBackground(&background_canvas);
394 395
395 SkBitmap background_image = background_canvas.ExtractBitmap(); 396 SkBitmap background_image = background_canvas.ExtractBitmap();
396 397
397 // Draw a radial gradient to hover_canvas. 398 // Draw a radial gradient to hover_canvas.
398 gfx::CanvasSkia hover_canvas(width(), height(), false); 399 gfx::CanvasSkia hover_canvas;
400 hover_canvas.Init(width(), height(), false);
399 int radius = kMiniTitleChangeGradientRadius; 401 int radius = kMiniTitleChangeGradientRadius;
400 int x0 = width() + radius - kMiniTitleChangeInitialXOffset; 402 int x0 = width() + radius - kMiniTitleChangeInitialXOffset;
401 int x1 = radius; 403 int x1 = radius;
402 int x2 = -radius; 404 int x2 = -radius;
403 int x; 405 int x;
404 if (mini_title_animation_->current_part_index() == 0) { 406 if (mini_title_animation_->current_part_index() == 0) {
405 x = mini_title_animation_->CurrentValueBetween(x0, x1); 407 x = mini_title_animation_->CurrentValueBetween(x0, x1);
406 } else if (mini_title_animation_->current_part_index() == 1) { 408 } else if (mini_title_animation_->current_part_index() == 1) {
407 x = x1; 409 x = x1;
408 } else { 410 } else {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 466
465 // If the theme is providing a custom background image, then its top edge 467 // If the theme is providing a custom background image, then its top edge
466 // should be at the top of the tab. Otherwise, we assume that the background 468 // should be at the top of the tab. Otherwise, we assume that the background
467 // image is a composited foreground + frame image. 469 // image is a composited foreground + frame image.
468 int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ? 470 int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ?
469 0 : background_offset_.y(); 471 0 : background_offset_.y();
470 472
471 // We need a CanvasSkia object to be able to extract the bitmap from. 473 // We need a CanvasSkia object to be able to extract the bitmap from.
472 // We draw everything to this canvas and then output it to the canvas 474 // We draw everything to this canvas and then output it to the canvas
473 // parameter in addition to using it to mask the hover glow if needed. 475 // parameter in addition to using it to mask the hover glow if needed.
474 gfx::CanvasSkia background_canvas(width(), height(), false); 476 gfx::CanvasSkia background_canvas;
477 background_canvas.Init(width(), height(), false);
475 478
476 // Draw left edge. Don't draw over the toolbar, as we're not the foreground 479 // Draw left edge. Don't draw over the toolbar, as we're not the foreground
477 // tab. 480 // tab.
478 SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap( 481 SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
479 *tab_bg, offset, bg_offset_y, tab_image->l_width, height()); 482 *tab_bg, offset, bg_offset_y, tab_image->l_width, height());
480 SkBitmap theme_l = 483 SkBitmap theme_l =
481 SkBitmapOperations::CreateMaskedBitmap(tab_l, *alpha->image_l); 484 SkBitmapOperations::CreateMaskedBitmap(tab_l, *alpha->image_l);
482 background_canvas.DrawBitmapInt(theme_l, 485 background_canvas.DrawBitmapInt(theme_l,
483 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, 486 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
484 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, 487 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 568
566 // Now draw the highlights/shadows around the tab edge. 569 // Now draw the highlights/shadows around the tab edge.
567 canvas->DrawBitmapInt(*tab_image->image_l, 0, 0); 570 canvas->DrawBitmapInt(*tab_image->image_l, 0, 0);
568 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0, 571 canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0,
569 width() - tab_image->l_width - tab_image->r_width, height()); 572 width() - tab_image->l_width - tab_image->r_width, height());
570 canvas->DrawBitmapInt(*tab_image->image_r, width() - tab_image->r_width, 0); 573 canvas->DrawBitmapInt(*tab_image->image_r, width() - tab_image->r_width, 0);
571 } 574 }
572 575
573 SkBitmap Tab::DrawHoverGlowBitmap(int width_input, int height_input) { 576 SkBitmap Tab::DrawHoverGlowBitmap(int width_input, int height_input) {
574 // Draw a radial gradient to hover_canvas so we can export the bitmap. 577 // Draw a radial gradient to hover_canvas so we can export the bitmap.
575 gfx::CanvasSkia hover_canvas(width_input, height_input, false); 578 gfx::CanvasSkia hover_canvas;
579 hover_canvas.Init(width_input, height_input, false);
576 580
577 // Draw a radial gradient to hover_canvas. 581 // Draw a radial gradient to hover_canvas.
578 int radius = width() / 3; 582 int radius = width() / 3;
579 583
580 SkPaint paint; 584 SkPaint paint;
581 paint.setStyle(SkPaint::kFill_Style); 585 paint.setStyle(SkPaint::kFill_Style);
582 paint.setFlags(SkPaint::kAntiAlias_Flag); 586 paint.setFlags(SkPaint::kAntiAlias_Flag);
583 SkPoint loc = { SkIntToScalar(hover_point_.x()), 587 SkPoint loc = { SkIntToScalar(hover_point_.x()),
584 SkIntToScalar(hover_point_.y()) }; 588 SkIntToScalar(hover_point_.y()) };
585 SkColor colors[2]; 589 SkColor colors[2];
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); 680 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
677 tab_active_.l_width = tab_active_.image_l->width(); 681 tab_active_.l_width = tab_active_.image_l->width();
678 tab_active_.r_width = tab_active_.image_r->width(); 682 tab_active_.r_width = tab_active_.image_r->width();
679 683
680 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); 684 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
681 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); 685 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
682 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); 686 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
683 tab_inactive_.l_width = tab_inactive_.image_l->width(); 687 tab_inactive_.l_width = tab_inactive_.image_l->width();
684 tab_inactive_.r_width = tab_inactive_.image_r->width(); 688 tab_inactive_.r_width = tab_inactive_.image_r->width();
685 } 689 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/side_tab.cc ('k') | chrome/browser/ui/views/theme_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698