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

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

Issue 2661313005: Add extra DCHECKing to try to catch subpixel rendering on a non-opaque (Closed)
Patch Set: checkpoint Created 3 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 | « chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 2086222e63f3c879d426a3d4509f7f2ec612a0d8..6b71eb17965db42ae7cebd9cbd080d241b663408 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -450,8 +450,27 @@ std::unique_ptr<gfx::RenderText> Label::CreateRenderText(
void Label::PaintText(gfx::Canvas* canvas) {
MaybeBuildRenderTextLines();
- for (size_t i = 0; i < lines_.size(); ++i)
+
+ for (size_t i = 0; i < lines_.size(); ++i) {
lines_[i]->Draw(canvas);
+#if DCHECK_IS_ON()
+ // Attempt to ensure that if we're using subpixel rendering, we're painting
+ // to an opaque background. What we don't want to find is an ancestor in the
+ // hierarchy that paints to a non-opaque layer.
+ if (!lines_[i]->subpixel_rendering_suppressed()) {
Daniel Erat 2017/02/06 22:35:49 as a minor optimization, you can skip the stuff in
Evan Stade 2017/02/07 23:55:19 yea, we can just do this for the first line since
+ for (View* view = this; view; view = view->parent()) {
+ if (view->background())
+ break;
sadrul 2017/02/07 03:36:39 The background could be non-opaque (e.g. solid-col
Evan Stade 2017/02/07 23:51:23 Correct, that's the situation I was referring to i
+ if (view->layer()) {
+ DCHECK(view->layer()->fills_bounds_opaquely())
+ << " Ancestor view has a non-opaque layer: "
+ << view->GetClassName() << " with ID " << view->id();
+ break;
+ }
+ }
+ }
+#endif
+ }
}
void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) {
@@ -964,7 +983,8 @@ void Label::RecalculateColors() {
void Label::ApplyTextColors() const {
SkColor color = enabled() ? actual_enabled_color_ : actual_disabled_color_;
bool subpixel_rendering_suppressed =
- SkColorGetA(background_color_) != 0xFF || !subpixel_rendering_enabled_;
+ SkColorGetA(background_color_) != SK_AlphaOPAQUE ||
+ !subpixel_rendering_enabled_;
for (size_t i = 0; i < lines_.size(); ++i) {
lines_[i]->SetColor(color);
lines_[i]->set_selection_color(actual_selection_text_color_);
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698