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

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

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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/views/tabs/side_tab.cc ('k') | chrome/browser/views/tabs/tab_strip.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/tabs/tab.h" 5 #include "chrome/browser/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/multi_animation.h" 9 #include "app/multi_animation.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "app/slide_animation.h" 11 #include "app/slide_animation.h"
12 #include "app/throb_animation.h" 12 #include "app/throb_animation.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/browser_theme_provider.h" 14 #include "chrome/browser/browser_theme_provider.h"
15 #include "chrome/browser/defaults.h" 15 #include "chrome/browser/defaults.h"
16 #include "gfx/canvas.h"
16 #include "gfx/canvas_skia.h" 17 #include "gfx/canvas_skia.h"
17 #include "gfx/favicon_size.h" 18 #include "gfx/favicon_size.h"
18 #include "gfx/font.h" 19 #include "gfx/font.h"
19 #include "gfx/path.h" 20 #include "gfx/path.h"
20 #include "gfx/skbitmap_operations.h" 21 #include "gfx/skbitmap_operations.h"
21 #include "grit/app_resources.h" 22 #include "grit/app_resources.h"
22 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
23 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
24 #include "third_party/skia/include/effects/SkGradientShader.h" 25 #include "third_party/skia/include/effects/SkGradientShader.h"
25 #include "views/controls/button/image_button.h" 26 #include "views/controls/button/image_button.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } else { 375 } else {
375 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) 376 if (mini_title_animation_.get() && mini_title_animation_->is_animating())
376 PaintInactiveTabBackgroundWithTitleChange(canvas); 377 PaintInactiveTabBackgroundWithTitleChange(canvas);
377 else 378 else
378 PaintInactiveTabBackground(canvas); 379 PaintInactiveTabBackground(canvas);
379 380
380 double throb_value = GetThrobValue(); 381 double throb_value = GetThrobValue();
381 if (throb_value > 0) { 382 if (throb_value > 0) {
382 SkRect bounds; 383 SkRect bounds;
383 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); 384 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
384 canvas->AsCanvasSkia()->saveLayerAlpha( 385 canvas->saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff),
385 &bounds, static_cast<int>(throb_value * 0xff), 386 SkCanvas::kARGB_ClipLayer_SaveFlag);
386 SkCanvas::kARGB_ClipLayer_SaveFlag); 387 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
387 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255,
388 SkXfermode::kClear_Mode);
389 PaintActiveTabBackground(canvas); 388 PaintActiveTabBackground(canvas);
390 canvas->AsCanvasSkia()->restore(); 389 canvas->restore();
391 } 390 }
392 } 391 }
393 } 392 }
394 393
395 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { 394 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) {
396 // Render the inactive tab background. We'll use this for clipping. 395 // Render the inactive tab background. We'll use this for clipping.
397 gfx::CanvasSkia background_canvas(width(), height(), false); 396 gfx::Canvas background_canvas(width(), height(), false);
398 PaintInactiveTabBackground(&background_canvas); 397 PaintInactiveTabBackground(&background_canvas);
399 398
400 SkBitmap background_image = background_canvas.ExtractBitmap(); 399 SkBitmap background_image = background_canvas.ExtractBitmap();
401 400
402 // Draw a radial gradient to hover_canvas. 401 // Draw a radial gradient to hover_canvas.
403 gfx::CanvasSkia hover_canvas(width(), height(), false); 402 gfx::CanvasSkia hover_canvas(width(), height(), false);
404 int radius = kMiniTitleChangeGradientRadius; 403 int radius = kMiniTitleChangeGradientRadius;
405 int x0 = width() + radius - kMiniTitleChangeInitialXOffset; 404 int x0 = width() + radius - kMiniTitleChangeInitialXOffset;
406 int x1 = radius; 405 int x1 = radius;
407 int x2 = -radius; 406 int x2 = -radius;
(...skipping 23 matching lines...) Expand all
431 430
432 // Draw the radial gradient clipped to the background into hover_image. 431 // Draw the radial gradient clipped to the background into hover_image.
433 SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap( 432 SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap(
434 hover_canvas.ExtractBitmap(), background_image); 433 hover_canvas.ExtractBitmap(), background_image);
435 434
436 // Draw the tab background to the canvas. 435 // Draw the tab background to the canvas.
437 canvas->DrawBitmapInt(background_image, 0, 0); 436 canvas->DrawBitmapInt(background_image, 0, 0);
438 437
439 // And then the gradient on top of that. 438 // And then the gradient on top of that.
440 if (mini_title_animation_->current_part_index() == 2) { 439 if (mini_title_animation_->current_part_index() == 2) {
441 canvas->AsCanvasSkia()->saveLayerAlpha( 440 canvas->saveLayerAlpha(NULL,
442 NULL, mini_title_animation_->CurrentValueBetween(255, 0)); 441 mini_title_animation_->CurrentValueBetween(255, 0));
443 canvas->DrawBitmapInt(hover_image, 0, 0); 442 canvas->DrawBitmapInt(hover_image, 0, 0);
444 canvas->AsCanvasSkia()->restore(); 443 canvas->restore();
445 } else { 444 } else {
446 canvas->DrawBitmapInt(hover_image, 0, 0); 445 canvas->DrawBitmapInt(hover_image, 0, 0);
447 } 446 }
448 } 447 }
449 448
450 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { 449 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) {
451 bool is_otr = data().off_the_record; 450 bool is_otr = data().off_the_record;
452 451
453 // The tab image needs to be lined up with the background image 452 // The tab image needs to be lined up with the background image
454 // so that it feels partially transparent. These offsets represent the tab 453 // so that it feels partially transparent. These offsets represent the tab
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 tab_inactive.l_width = tab_inactive.image_l->width(); 636 tab_inactive.l_width = tab_inactive.image_l->width();
638 tab_inactive.r_width = tab_inactive.image_r->width(); 637 tab_inactive.r_width = tab_inactive.image_r->width();
639 638
640 tab_inactive_nano.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT); 639 tab_inactive_nano.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT);
641 tab_inactive_nano.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER); 640 tab_inactive_nano.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER);
642 tab_inactive_nano.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT); 641 tab_inactive_nano.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT);
643 tab_inactive_nano.l_width = tab_inactive_nano.image_l->width(); 642 tab_inactive_nano.l_width = tab_inactive_nano.image_l->width();
644 tab_inactive_nano.r_width = tab_inactive_nano.image_r->width(); 643 tab_inactive_nano.r_width = tab_inactive_nano.image_r->width();
645 tab_inactive_nano.y_offset = kNanoTabDiffHeight; 644 tab_inactive_nano.y_offset = kNanoTabDiffHeight;
646 } 645 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/side_tab.cc ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698