| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "cc/paint/paint_record.h" |
| 15 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 16 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
| 16 #include "ui/base/layout.h" | 17 #include "ui/base/layout.h" |
| 17 #include "ui/gfx/animation/animation_delegate.h" | 18 #include "ui/gfx/animation/animation_delegate.h" |
| 18 #include "ui/gfx/geometry/point.h" | 19 #include "ui/gfx/geometry/point.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/gfx/paint_throbber.h" | 21 #include "ui/gfx/paint_throbber.h" |
| 21 #include "ui/views/context_menu_controller.h" | 22 #include "ui/views/context_menu_controller.h" |
| 22 #include "ui/views/controls/button/button.h" | 23 #include "ui/views/controls/button/button.h" |
| 23 #include "ui/views/controls/glow_hover_controller.h" | 24 #include "ui/views/controls/glow_hover_controller.h" |
| 24 #include "ui/views/masked_targeter_delegate.h" | 25 #include "ui/views/masked_targeter_delegate.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // Paints with the normal tab style. If |clip| is non-empty, the tab border | 229 // Paints with the normal tab style. If |clip| is non-empty, the tab border |
| 229 // should be clipped against it. | 230 // should be clipped against it. |
| 230 void PaintTab(gfx::Canvas* canvas, const gfx::Path& clip); | 231 void PaintTab(gfx::Canvas* canvas, const gfx::Path& clip); |
| 231 | 232 |
| 232 // Paints the background of an inactive tab. | 233 // Paints the background of an inactive tab. |
| 233 void PaintInactiveTabBackground(gfx::Canvas* canvas, const gfx::Path& clip); | 234 void PaintInactiveTabBackground(gfx::Canvas* canvas, const gfx::Path& clip); |
| 234 | 235 |
| 235 // Paints a tab background using the image defined by |fill_id| at the | 236 // Paints a tab background using the image defined by |fill_id| at the |
| 236 // provided offset. If |fill_id| is 0, it will fall back to using the solid | 237 // provided offset. If |fill_id| is 0, it will fall back to using the solid |
| 237 // color defined by the theme provider and ignore the offset. | 238 // color defined by the theme provider and ignore the offset. |
| 238 void PaintTabBackgroundUsingFillId(gfx::Canvas* fill_canvas, | 239 void PaintTabBackground(gfx::Canvas* canvas, |
| 239 gfx::Canvas* stroke_canvas, | 240 bool active, |
| 240 bool is_active, | 241 int fill_id, |
| 241 int fill_id, | 242 int y_offset, |
| 242 int y_offset); | 243 const gfx::Path* clip); |
| 244 |
| 245 // Helper methods for PaintTabBackground. |
| 246 void PaintTabBackgroundFill(gfx::Canvas* canvas, |
| 247 const gfx::Path& fill_path, |
| 248 bool active, |
| 249 bool hover, |
| 250 SkColor active_color, |
| 251 SkColor inactive_color, |
| 252 int fill_id, |
| 253 int y_offset); |
| 254 void PaintTabBackgroundStroke(gfx::Canvas* canvas, |
| 255 const gfx::Path& fill_path, |
| 256 const gfx::Path& stroke_path, |
| 257 bool active, |
| 258 SkColor color); |
| 243 | 259 |
| 244 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| | 260 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| |
| 245 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl | 261 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl |
| 246 // and clipped to the bounds of the tab. | 262 // and clipped to the bounds of the tab. |
| 247 void PaintPinnedTabTitleChangedIndicatorAndIcon( | 263 void PaintPinnedTabTitleChangedIndicatorAndIcon( |
| 248 gfx::Canvas* canvas, | 264 gfx::Canvas* canvas, |
| 249 const gfx::Rect& favicon_draw_bounds); | 265 const gfx::Rect& favicon_draw_bounds); |
| 250 | 266 |
| 251 // Paints the favicon, mirrored for RTL if needed. | 267 // Paints the favicon, mirrored for RTL if needed. |
| 252 void PaintIcon(gfx::Canvas* canvas); | 268 void PaintIcon(gfx::Canvas* canvas); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 bool showing_close_button_; | 364 bool showing_close_button_; |
| 349 | 365 |
| 350 // The current color of the alert indicator and close button icons. | 366 // The current color of the alert indicator and close button icons. |
| 351 SkColor button_color_; | 367 SkColor button_color_; |
| 352 | 368 |
| 353 // The favicon for the tab. This might be the sad tab icon or a copy of | 369 // The favicon for the tab. This might be the sad tab icon or a copy of |
| 354 // data().favicon and may be modified for theming. It is created on demand | 370 // data().favicon and may be modified for theming. It is created on demand |
| 355 // and thus may be null. | 371 // and thus may be null. |
| 356 gfx::ImageSkia favicon_; | 372 gfx::ImageSkia favicon_; |
| 357 | 373 |
| 374 class BackgroundCache { |
| 375 public: |
| 376 BackgroundCache(); |
| 377 ~BackgroundCache(); |
| 378 |
| 379 bool CacheKeyMatches(float scale, |
| 380 const gfx::Size& size, |
| 381 SkColor active_color, |
| 382 SkColor inactive_color, |
| 383 SkColor stroke_color) { |
| 384 return scale_ == scale && size_ == size && |
| 385 active_color_ == active_color && |
| 386 inactive_color_ == inactive_color && stroke_color_ == stroke_color; |
| 387 } |
| 388 |
| 389 void SetCacheKey(float scale, |
| 390 const gfx::Size& size, |
| 391 SkColor active_color, |
| 392 SkColor inactive_color, |
| 393 SkColor stroke_color) { |
| 394 scale_ = scale; |
| 395 size_ = size; |
| 396 active_color_ = active_color; |
| 397 inactive_color_ = inactive_color; |
| 398 stroke_color_ = stroke_color; |
| 399 } |
| 400 |
| 401 // The PaintRecords being cached based on the input parameters. |
| 402 sk_sp<cc::PaintRecord> fill_record; |
| 403 sk_sp<cc::PaintRecord> stroke_record; |
| 404 |
| 405 private: |
| 406 // Parameters used to construct the PaintRecords. |
| 407 float scale_ = 0.f; |
| 408 gfx::Size size_; |
| 409 SkColor active_color_ = 0; |
| 410 SkColor inactive_color_ = 0; |
| 411 SkColor stroke_color_ = 0; |
| 412 }; |
| 413 |
| 414 // Cache of the paint output for tab backgrounds. |
| 415 BackgroundCache background_active_cache_; |
| 416 BackgroundCache background_inactive_cache_; |
| 417 |
| 358 DISALLOW_COPY_AND_ASSIGN(Tab); | 418 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 359 }; | 419 }; |
| 360 | 420 |
| 361 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 421 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| OLD | NEW |