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

Side by Side Diff: chrome/browser/ui/views/frame/glass_browser_frame_view.cc

Issue 10447053: Converts remainder of ui and chrome/browser/ui/views/frame to use ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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/frame/glass_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 ui::ThemeProvider* tp = GetThemeProvider(); 273 ui::ThemeProvider* tp = GetThemeProvider();
274 274
275 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); 275 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
276 gfx::Point toolbar_origin(toolbar_bounds.origin()); 276 gfx::Point toolbar_origin(toolbar_bounds.origin());
277 View::ConvertPointToView(browser_view(), this, &toolbar_origin); 277 View::ConvertPointToView(browser_view(), this, &toolbar_origin);
278 toolbar_bounds.set_origin(toolbar_origin); 278 toolbar_bounds.set_origin(toolbar_origin);
279 int x = toolbar_bounds.x(); 279 int x = toolbar_bounds.x();
280 int w = toolbar_bounds.width(); 280 int w = toolbar_bounds.width();
281 int left_x = x - kContentEdgeShadowThickness; 281 int left_x = x - kContentEdgeShadowThickness;
282 282
283 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); 283 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR);
284 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); 284 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed(
285 SkBitmap* toolbar_center = tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); 285 IDR_CONTENT_TOP_LEFT_CORNER);
286 gfx::ImageSkia* toolbar_center = tp->GetImageSkiaNamed(
287 IDR_CONTENT_TOP_CENTER);
286 288
287 // Tile the toolbar image starting at the frame edge on the left and where 289 // Tile the toolbar image starting at the frame edge on the left and where
288 // the tabstrip is on the top. 290 // the tabstrip is on the top.
289 int y = toolbar_bounds.y(); 291 int y = toolbar_bounds.y();
290 int dest_y = y + (kFrameShadowThickness * 2); 292 int dest_y = y + (kFrameShadowThickness * 2);
291 canvas->TileImageInt(*theme_toolbar, x, 293 canvas->TileImageInt(*theme_toolbar, x,
292 dest_y - GetHorizontalTabStripVerticalOffset(false), x, 294 dest_y - GetHorizontalTabStripVerticalOffset(false), x,
293 dest_y, w, theme_toolbar->height()); 295 dest_y, w, theme_toolbar->height());
294 296
295 // Draw rounded corners for the tab. 297 // Draw rounded corners for the tab.
296 SkBitmap* toolbar_left_mask = 298 gfx::ImageSkia* toolbar_left_mask =
297 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); 299 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK);
298 SkBitmap* toolbar_right_mask = 300 gfx::ImageSkia* toolbar_right_mask =
299 tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); 301 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK);
300 302
301 // We mask out the corners by using the DestinationIn transfer mode, 303 // We mask out the corners by using the DestinationIn transfer mode,
302 // which keeps the RGB pixels from the destination and the alpha from 304 // which keeps the RGB pixels from the destination and the alpha from
303 // the source. 305 // the source.
304 SkPaint paint; 306 SkPaint paint;
305 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); 307 paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
306 308
307 // Mask out the top left corner. 309 // Mask out the top left corner.
308 canvas->DrawBitmapInt(*toolbar_left_mask, left_x, y, paint); 310 canvas->DrawBitmapInt(*toolbar_left_mask, left_x, y, paint);
309 311
310 // Mask out the top right corner. 312 // Mask out the top right corner.
311 int right_x = 313 int right_x =
312 x + w + kContentEdgeShadowThickness - toolbar_right_mask->width(); 314 x + w + kContentEdgeShadowThickness - toolbar_right_mask->width();
313 canvas->DrawBitmapInt(*toolbar_right_mask, right_x, y, paint); 315 canvas->DrawBitmapInt(*toolbar_right_mask, right_x, y, paint);
314 316
315 // Draw left edge. 317 // Draw left edge.
316 canvas->DrawBitmapInt(*toolbar_left, left_x, y); 318 canvas->DrawBitmapInt(*toolbar_left, left_x, y);
317 319
318 // Draw center edge. 320 // Draw center edge.
319 canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y, 321 canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y,
320 right_x - (left_x + toolbar_left->width()), toolbar_center->height()); 322 right_x - (left_x + toolbar_left->width()), toolbar_center->height());
321 323
322 // Right edge. 324 // Right edge.
323 canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER), 325 canvas->DrawBitmapInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
324 right_x, y); 326 right_x, y);
325 327
326 // Draw the content/toolbar separator. 328 // Draw the content/toolbar separator.
327 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, 329 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness,
328 toolbar_bounds.bottom() - kClientEdgeThickness, 330 toolbar_bounds.bottom() - kClientEdgeThickness,
329 w - (2 * kClientEdgeThickness), 331 w - (2 * kClientEdgeThickness),
330 kClientEdgeThickness), 332 kClientEdgeThickness),
331 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); 333 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
332 } 334 }
333 335
334 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 336 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
335 ui::ThemeProvider* tp = GetThemeProvider(); 337 ui::ThemeProvider* tp = GetThemeProvider();
336 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); 338 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
337 339
338 // The client edges start below the toolbar upper corner images regardless 340 // The client edges start below the toolbar upper corner images regardless
339 // of how tall the toolbar itself is. 341 // of how tall the toolbar itself is.
340 int client_area_top = frame()->client_view()->y() + 342 int client_area_top = frame()->client_view()->y() +
341 browser_view()->GetToolbarBounds().y() + 343 browser_view()->GetToolbarBounds().y() +
342 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); 344 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
343 int client_area_bottom = 345 int client_area_bottom =
344 std::max(client_area_top, height() - NonClientBorderThickness()); 346 std::max(client_area_top, height() - NonClientBorderThickness());
345 int client_area_height = client_area_bottom - client_area_top; 347 int client_area_height = client_area_bottom - client_area_top;
346 348
347 // Draw the client edge images. 349 // Draw the client edge images.
348 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); 350 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
349 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, 351 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
350 right->width(), client_area_height); 352 right->width(), client_area_height);
351 canvas->DrawBitmapInt( 353 canvas->DrawBitmapInt(
352 *tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), 354 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
353 client_area_bounds.right(), client_area_bottom); 355 client_area_bounds.right(), client_area_bottom);
354 SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); 356 gfx::ImageSkia* bottom = tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
355 canvas->TileImageInt(*bottom, client_area_bounds.x(), 357 canvas->TileImageInt(*bottom, client_area_bounds.x(),
356 client_area_bottom, client_area_bounds.width(), 358 client_area_bottom, client_area_bounds.width(),
357 bottom->height()); 359 bottom->height());
358 SkBitmap* bottom_left = 360 gfx::ImageSkia* bottom_left =
359 tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); 361 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
360 canvas->DrawBitmapInt(*bottom_left, 362 canvas->DrawBitmapInt(*bottom_left,
361 client_area_bounds.x() - bottom_left->width(), client_area_bottom); 363 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
362 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); 364 gfx::ImageSkia* left = tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE);
363 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), 365 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
364 client_area_top, left->width(), client_area_height); 366 client_area_top, left->width(), client_area_height);
365 367
366 // Draw the toolbar color so that the client edges show the right color even 368 // Draw the toolbar color so that the client edges show the right color even
367 // where not covered by the toolbar image. NOTE: We do this after drawing the 369 // where not covered by the toolbar image. NOTE: We do this after drawing the
368 // images because the images are meant to alpha-blend atop the frame whereas 370 // images because the images are meant to alpha-blend atop the frame whereas
369 // these rects are meant to be fully opaque, without anything overlaid. 371 // these rects are meant to be fully opaque, without anything overlaid.
370 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR); 372 SkColor toolbar_color = tp->GetColor(ThemeService::COLOR_TOOLBAR);
371 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness, 373 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness,
372 client_area_top, kClientEdgeThickness, 374 client_area_top, kClientEdgeThickness,
373 client_area_bottom + kClientEdgeThickness - client_area_top), 375 client_area_bottom + kClientEdgeThickness - client_area_top),
374 toolbar_color); 376 toolbar_color);
375 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom, 377 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom,
376 client_area_bounds.width(), kClientEdgeThickness), 378 client_area_bounds.width(), kClientEdgeThickness),
377 toolbar_color); 379 toolbar_color);
378 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top, 380 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top,
379 kClientEdgeThickness, 381 kClientEdgeThickness,
380 client_area_bottom + kClientEdgeThickness - client_area_top), 382 client_area_bottom + kClientEdgeThickness - client_area_top),
381 toolbar_color); 383 toolbar_color);
382 } 384 }
383 385
384 void GlassBrowserFrameView::LayoutAvatar() { 386 void GlassBrowserFrameView::LayoutAvatar() {
385 // Even though the avatar is used for both incognito and profiles we always 387 // Even though the avatar is used for both incognito and profiles we always
386 // use the incognito icon to layout the avatar button. The profile icon 388 // use the incognito icon to layout the avatar button. The profile icon
387 // can be customized so we can't depend on its size to perform layout. 389 // can be customized so we can't depend on its size to perform layout.
388 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); 390 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
389 391
390 int avatar_x = NonClientBorderThickness() + kAvatarLeftSpacing; 392 int avatar_x = NonClientBorderThickness() + kAvatarLeftSpacing;
391 // Move this avatar icon by the size of window controls to prevent it from 393 // Move this avatar icon by the size of window controls to prevent it from
392 // being rendered over them in RTL languages. This code also needs to adjust 394 // being rendered over them in RTL languages. This code also needs to adjust
393 // the width of a tab strip to avoid decreasing this size twice. (See the 395 // the width of a tab strip to avoid decreasing this size twice. (See the
394 // comment in GetBoundsForTabStrip().) 396 // comment in GetBoundsForTabStrip().)
395 if (base::i18n::IsRTL()) 397 if (base::i18n::IsRTL())
396 avatar_x += width() - frame()->GetMinimizeButtonOffset(); 398 avatar_x += width() - frame()->GetMinimizeButtonOffset();
397 399
398 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + 400 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) +
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 445 }
444 446
445 void GlassBrowserFrameView::StopThrobber() { 447 void GlassBrowserFrameView::StopThrobber() {
446 if (throbber_running_) { 448 if (throbber_running_) {
447 throbber_running_ = false; 449 throbber_running_ = false;
448 450
449 HICON frame_icon = NULL; 451 HICON frame_icon = NULL;
450 452
451 // Check if hosted BrowserView has a window icon to use. 453 // Check if hosted BrowserView has a window icon to use.
452 if (browser_view()->ShouldShowWindowIcon()) { 454 if (browser_view()->ShouldShowWindowIcon()) {
453 SkBitmap icon = browser_view()->GetWindowIcon(); 455 gfx::ImageSkia icon = browser_view()->GetWindowIcon();
454 if (!icon.isNull()) 456 if (!icon.isNull())
455 frame_icon = IconUtil::CreateHICONFromSkBitmap(icon); 457 frame_icon = IconUtil::CreateHICONFromSkBitmap(icon);
456 } 458 }
457 459
458 // Fallback to class icon. 460 // Fallback to class icon.
459 if (!frame_icon) { 461 if (!frame_icon) {
460 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr( 462 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr(
461 frame()->GetNativeWindow(), GCLP_HICONSM)); 463 frame()->GetNativeWindow(), GCLP_HICONSM));
462 } 464 }
463 465
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 static bool initialized = false; 498 static bool initialized = false;
497 if (!initialized) { 499 if (!initialized) {
498 for (int i = 0; i < kThrobberIconCount; ++i) { 500 for (int i = 0; i < kThrobberIconCount; ++i) {
499 throbber_icons_[i] = 501 throbber_icons_[i] =
500 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 502 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
501 DCHECK(throbber_icons_[i]); 503 DCHECK(throbber_icons_[i]);
502 } 504 }
503 initialized = true; 505 initialized = true;
504 } 506 }
505 } 507 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698