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

Side by Side Diff: chrome/browser/ui/gtk/browser_toolbar_gtk.cc

Issue 8806026: GTK: Remove UseSurface() calls in browser toolbar. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 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
« no previous file with comments | « no previous file | no next file » | 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/gtk/browser_toolbar_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
6 6
7 #include <X11/XF86keysym.h> 7 #include <X11/XF86keysym.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/browser/user_metrics.h" 45 #include "content/browser/user_metrics.h"
46 #include "content/public/browser/notification_details.h" 46 #include "content/public/browser/notification_details.h"
47 #include "content/public/browser/notification_service.h" 47 #include "content/public/browser/notification_service.h"
48 #include "grit/chromium_strings.h" 48 #include "grit/chromium_strings.h"
49 #include "grit/generated_resources.h" 49 #include "grit/generated_resources.h"
50 #include "grit/theme_resources.h" 50 #include "grit/theme_resources.h"
51 #include "grit/theme_resources_standard.h" 51 #include "grit/theme_resources_standard.h"
52 #include "ui/base/accelerators/accelerator_gtk.h" 52 #include "ui/base/accelerators/accelerator_gtk.h"
53 #include "ui/base/dragdrop/gtk_dnd_util.h" 53 #include "ui/base/dragdrop/gtk_dnd_util.h"
54 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
55 #include "ui/base/resource/resource_bundle.h"
55 #include "ui/gfx/canvas_skia_paint.h" 56 #include "ui/gfx/canvas_skia_paint.h"
56 #include "ui/gfx/gtk_util.h" 57 #include "ui/gfx/gtk_util.h"
57 #include "ui/gfx/image/cairo_cached_surface.h" 58 #include "ui/gfx/image/cairo_cached_surface.h"
58 #include "ui/gfx/skbitmap_operations.h" 59 #include "ui/gfx/skbitmap_operations.h"
59 60
60 namespace { 61 namespace {
61 62
62 // Padding on left and right of the left toolbar buttons (back, forward, reload, 63 // Padding on left and right of the left toolbar buttons (back, forward, reload,
63 // etc.). 64 // etc.).
64 const int kToolbarLeftAreaPadding = 4; 65 const int kToolbarLeftAreaPadding = 4;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 gfx::Rect left(allocation.x - kShadowThickness, 498 gfx::Rect left(allocation.x - kShadowThickness,
498 allocation.y - kShadowThickness, 499 allocation.y - kShadowThickness,
499 kCornerWidth, 500 kCornerWidth,
500 allocation.height + kShadowThickness); 501 allocation.height + kShadowThickness);
501 502
502 if (window_->ShouldDrawContentDropShadow()) { 503 if (window_->ShouldDrawContentDropShadow()) {
503 // Leave room to draw rounded corners. 504 // Leave room to draw rounded corners.
504 area = area.Subtract(right).Subtract(left); 505 area = area.Subtract(right).Subtract(left);
505 } 506 }
506 507
507 gfx::CairoCachedSurface* background = theme_service_->GetSurfaceNamed( 508 const gfx::Image* background =
508 IDR_THEME_TOOLBAR, widget); 509 theme_service_->GetImageNamed(IDR_THEME_TOOLBAR);
509 background->SetSource(cr, widget, tabstrip_origin.x(), tabstrip_origin.y()); 510 background->ToCairo()->SetSource(
511 cr, widget, tabstrip_origin.x(), tabstrip_origin.y());
510 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); 512 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
511 cairo_rectangle(cr, area.x(), area.y(), area.width(), area.height()); 513 cairo_rectangle(cr, area.x(), area.y(), area.width(), area.height());
512 cairo_fill(cr); 514 cairo_fill(cr);
513 515
514 if (!window_->ShouldDrawContentDropShadow()) { 516 if (!window_->ShouldDrawContentDropShadow()) {
515 // The rest of this function is for rounded corners. Our work is done here. 517 // The rest of this function is for rounded corners. Our work is done here.
516 cairo_destroy(cr); 518 cairo_destroy(cr);
517 return FALSE; 519 return FALSE;
518 } 520 }
519 521
520 bool draw_left_corner = left.Intersects(gfx::Rect(e->area)); 522 bool draw_left_corner = left.Intersects(gfx::Rect(e->area));
521 bool draw_right_corner = right.Intersects(gfx::Rect(e->area)); 523 bool draw_right_corner = right.Intersects(gfx::Rect(e->area));
522 524
523 if (draw_left_corner || draw_right_corner) { 525 if (draw_left_corner || draw_right_corner) {
524 // Create a mask which is composed of the left and/or right corners. 526 // Create a mask which is composed of the left and/or right corners.
525 cairo_surface_t* target = cairo_surface_create_similar( 527 cairo_surface_t* target = cairo_surface_create_similar(
526 cairo_get_target(cr), 528 cairo_get_target(cr),
527 CAIRO_CONTENT_COLOR_ALPHA, 529 CAIRO_CONTENT_COLOR_ALPHA,
528 allocation.x + allocation.width, 530 allocation.x + allocation.width,
529 allocation.y + allocation.height); 531 allocation.y + allocation.height);
530 cairo_t* copy_cr = cairo_create(target); 532 cairo_t* copy_cr = cairo_create(target);
531 533
534 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
535
532 cairo_set_operator(copy_cr, CAIRO_OPERATOR_SOURCE); 536 cairo_set_operator(copy_cr, CAIRO_OPERATOR_SOURCE);
533 if (draw_left_corner) { 537 if (draw_left_corner) {
534 gfx::CairoCachedSurface* left_corner = theme_service_->GetSurfaceNamed( 538 rb.GetNativeImageNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK).ToCairo()->
535 IDR_CONTENT_TOP_LEFT_CORNER_MASK, widget); 539 SetSource(copy_cr, widget, left.x(), left.y());
536 left_corner->SetSource(copy_cr, widget, left.x(), left.y());
537 cairo_paint(copy_cr); 540 cairo_paint(copy_cr);
538 } 541 }
539 if (draw_right_corner) { 542 if (draw_right_corner) {
540 gfx::CairoCachedSurface* right_corner = theme_service_->GetSurfaceNamed( 543 rb.GetNativeImageNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK).ToCairo()->
541 IDR_CONTENT_TOP_RIGHT_CORNER_MASK, widget); 544 SetSource(copy_cr, widget, right.x(), right.y());
542 right_corner->SetSource(copy_cr, widget, right.x(), right.y());
543 // We fill a path rather than just painting because we don't want to 545 // We fill a path rather than just painting because we don't want to
544 // overwrite the left corner. 546 // overwrite the left corner.
545 cairo_rectangle(copy_cr, right.x(), right.y(), 547 cairo_rectangle(copy_cr, right.x(), right.y(),
546 right.width(), right.height()); 548 right.width(), right.height());
547 cairo_fill(copy_cr); 549 cairo_fill(copy_cr);
548 } 550 }
549 551
550 // Draw the background. CAIRO_OPERATOR_IN uses the existing pixel data as 552 // Draw the background. CAIRO_OPERATOR_IN uses the existing pixel data as
551 // an alpha mask. 553 // an alpha mask.
552 background->SetSource(copy_cr, widget, 554 background->ToCairo()->SetSource(copy_cr, widget,
553 tabstrip_origin.x(), tabstrip_origin.y()); 555 tabstrip_origin.x(), tabstrip_origin.y());
554 cairo_set_operator(copy_cr, CAIRO_OPERATOR_IN); 556 cairo_set_operator(copy_cr, CAIRO_OPERATOR_IN);
555 cairo_pattern_set_extend(cairo_get_source(copy_cr), CAIRO_EXTEND_REPEAT); 557 cairo_pattern_set_extend(cairo_get_source(copy_cr), CAIRO_EXTEND_REPEAT);
556 cairo_paint(copy_cr); 558 cairo_paint(copy_cr);
557 cairo_destroy(copy_cr); 559 cairo_destroy(copy_cr);
558 560
559 // Copy the temporary surface to the screen. 561 // Copy the temporary surface to the screen.
560 cairo_set_source_surface(cr, target, 0, 0); 562 cairo_set_source_surface(cr, target, 0, 0);
561 cairo_paint(cr); 563 cairo_paint(cr);
562 cairo_surface_destroy(target); 564 cairo_surface_destroy(target);
563 } 565 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id); 672 const SkBitmap* badge = theme_service_->GetBitmapNamed(resource_id);
671 gfx::CanvasSkiaPaint canvas(expose, false); 673 gfx::CanvasSkiaPaint canvas(expose, false);
672 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width(); 674 int x_offset = base::i18n::IsRTL() ? 0 : allocation.width - badge->width();
673 int y_offset = 0; 675 int y_offset = 0;
674 canvas.DrawBitmapInt(*badge, 676 canvas.DrawBitmapInt(*badge,
675 allocation.x + x_offset, 677 allocation.x + x_offset,
676 allocation.y + y_offset); 678 allocation.y + y_offset);
677 679
678 return FALSE; 680 return FALSE;
679 } 681 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698