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

Unified Diff: ui/views/controls/label.h

Issue 843503003: Cache DrawStringParams in views::Label (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/label.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.h
diff --git a/ui/views/controls/label.h b/ui/views/controls/label.h
index f3b6b634d29cf9d8e567e3271dfd9e0aa89da1ce..01bb10e1453a8b0158d3801549de87119e61a1d8 100644
--- a/ui/views/controls/label.h
+++ b/ui/views/controls/label.h
@@ -149,6 +149,14 @@ class VIEWS_EXPORT Label : public View {
void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
private:
+ struct DrawStringParams {
+ base::string16 text;
+ gfx::Rect bounds;
+ int flags;
+
+ DrawStringParams() : flags(0) {}
sky 2015/01/08 03:48:49 style guide says members after functions, even for
ckocagil 2015/01/08 14:16:32 Done.
+ };
+
// These tests call CalculateDrawStringParams in order to verify the
// calculations done for drawing text.
FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineString);
@@ -174,16 +182,14 @@ class VIEWS_EXPORT Label : public View {
gfx::Rect GetAvailableRect() const;
// Returns parameters to be used for the DrawString call.
- void CalculateDrawStringParams(base::string16* paint_text,
- gfx::Rect* text_bounds,
- int* flags) const;
+ const DrawStringParams* CalculateDrawStringParams() const;
sky 2015/01/08 03:48:49 Document ownership here.
ckocagil 2015/01/08 14:16:32 Done.
// Updates any colors that have not been explicitly set from the theme.
void UpdateColorsFromTheme(const ui::NativeTheme* theme);
- // Resets |cached_heights_| and |cached_heights_cursor_| and mark
- // |text_size_valid_| as false.
- void ResetCachedSize();
+ // Resets |cached_heights_|, |cached_heights_cursor_|, |cached_draw_params_|
+ // and mark |text_size_valid_| as false.
+ void ResetLayoutCache();
bool ShouldShowDefaultTooltip() const;
@@ -221,6 +227,9 @@ class VIEWS_EXPORT Label : public View {
mutable std::vector<gfx::Size> cached_heights_;
mutable int cached_heights_cursor_;
+ // The cached results of CalculateDrawStringParams().
+ mutable scoped_ptr<const DrawStringParams> cached_draw_params_;
sky 2015/01/08 03:48:49 Is there a reason to recreate this rather than mak
ckocagil 2015/01/08 14:16:32 Done, it's a member now.
+
// TODO(vadimt): Remove is_first_paint_text_ before crbug.com/431326 is
// closed.
bool is_first_paint_text_;
« no previous file with comments | « no previous file | ui/views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698