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

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: sky's 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') | ui/views/controls/label.cc » ('J')
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..2f63b97aad1a5761d116e3ac2afbc3ab1efa51c4 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 {
+ DrawStringParams() : flags(0) {}
+
+ base::string16 text;
+ gfx::Rect bounds;
+ int flags;
+ };
+
// These tests call CalculateDrawStringParams in order to verify the
// calculations done for drawing text.
FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineString);
@@ -173,17 +181,16 @@ 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;
+ // Returns parameters to be used for the DrawString call. Returned value is a
+ // weak pointer, owned by and scoped to the label.
+ const DrawStringParams* CalculateDrawStringParams() const;
// 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 +228,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 DrawStringParams cached_draw_params_;
+
// 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') | ui/views/controls/label.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698