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

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

Issue 2803583003: ui: Remove use of bitmaps when painting tab backgrounds. (Closed)
Patch Set: tabbackground: with-cache Created 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab.cc » ('j') | chrome/browser/ui/views/tabs/tab.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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 bool active);
243 257
244 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_| 258 // Paints the pinned tab title changed indicator and |favicon_|. |favicon_|
245 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl 259 // may be null. |favicon_draw_bounds| is |favicon_bounds_| adjusted for rtl
246 // and clipped to the bounds of the tab. 260 // and clipped to the bounds of the tab.
247 void PaintPinnedTabTitleChangedIndicatorAndIcon( 261 void PaintPinnedTabTitleChangedIndicatorAndIcon(
248 gfx::Canvas* canvas, 262 gfx::Canvas* canvas,
249 const gfx::Rect& favicon_draw_bounds); 263 const gfx::Rect& favicon_draw_bounds);
250 264
251 // Paints the favicon, mirrored for RTL if needed. 265 // Paints the favicon, mirrored for RTL if needed.
252 void PaintIcon(gfx::Canvas* canvas); 266 void PaintIcon(gfx::Canvas* canvas);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 bool showing_close_button_; 362 bool showing_close_button_;
349 363
350 // The current color of the alert indicator and close button icons. 364 // The current color of the alert indicator and close button icons.
351 SkColor button_color_; 365 SkColor button_color_;
352 366
353 // The favicon for the tab. This might be the sad tab icon or a copy of 367 // 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 368 // data().favicon and may be modified for theming. It is created on demand
355 // and thus may be null. 369 // and thus may be null.
356 gfx::ImageSkia favicon_; 370 gfx::ImageSkia favicon_;
357 371
372 struct BackgroundCache {
Peter Kasting 2017/04/07 00:59:20 Nit: I think the Google style guide requests that
danakj 2017/04/07 19:10:49 yeh.. that seems unfortunate here. The guide says
Peter Kasting 2017/04/07 23:34:03 It's OK to keep it here. It'd be even better to m
373 BackgroundCache();
374 ~BackgroundCache();
375
376 // Parameters used to construct the PaintRecords.
377 float scale = 0.f;
378 gfx::Size size;
379 SkColor active_color;
Peter Kasting 2017/04/07 00:59:20 Nit: If you're going to init |scale| in the declar
danakj 2017/04/07 19:10:49 Right, don't want to compare uninit things, even t
380 SkColor inactive_color;
381
382 // The PaintRecords being cached based on the above parameters.
383 sk_sp<cc::PaintRecord> fill_record;
384 sk_sp<cc::PaintRecord> stroke_record;
385 };
386
387 BackgroundCache background_active_cache_;
388 BackgroundCache background_inactive_cache_;
389
358 DISALLOW_COPY_AND_ASSIGN(Tab); 390 DISALLOW_COPY_AND_ASSIGN(Tab);
359 }; 391 };
360 392
361 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ 393 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/tabs/tab.cc » ('j') | chrome/browser/ui/views/tabs/tab.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698