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

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

Issue 2246213003: Fix pixelation of tab borders when device scale changes (alternate approach) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | no next file » | no next file with comments »
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 #include "chrome/browser/ui/views/tabs/tab.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 //////////////////////////////////////////////////////////////////////////////// 150 ////////////////////////////////////////////////////////////////////////////////
151 // ImageCacheEntryMetadata 151 // ImageCacheEntryMetadata
152 // 152 //
153 // All metadata necessary to uniquely identify a cached image. 153 // All metadata necessary to uniquely identify a cached image.
154 struct ImageCacheEntryMetadata { 154 struct ImageCacheEntryMetadata {
155 ImageCacheEntryMetadata(int resource_id, 155 ImageCacheEntryMetadata(int resource_id,
156 SkColor fill_color, 156 SkColor fill_color,
157 SkColor stroke_color, 157 SkColor stroke_color,
158 bool use_fill_and_stroke_images, 158 bool use_fill_and_stroke_images,
159 ui::ScaleFactor scale_factor, 159 float scale_factor,
160 const gfx::Size& size); 160 const gfx::Size& size);
161 161
162 ~ImageCacheEntryMetadata(); 162 ~ImageCacheEntryMetadata();
163 163
164 bool operator==(const ImageCacheEntryMetadata& rhs) const; 164 bool operator==(const ImageCacheEntryMetadata& rhs) const;
165 165
166 int resource_id; // Only needed by pre-MD 166 int resource_id; // Only needed by pre-MD
167 SkColor fill_color; // Both colors only needed by MD 167 SkColor fill_color; // Both colors only needed by MD
168 SkColor stroke_color; 168 SkColor stroke_color;
169 bool use_fill_and_stroke_images; 169 bool use_fill_and_stroke_images;
170 ui::ScaleFactor scale_factor; 170 float scale_factor;
171 gfx::Size size; 171 gfx::Size size;
172 }; 172 };
173 173
174 ImageCacheEntryMetadata::ImageCacheEntryMetadata( 174 ImageCacheEntryMetadata::ImageCacheEntryMetadata(
175 int resource_id, 175 int resource_id,
176 SkColor fill_color, 176 SkColor fill_color,
177 SkColor stroke_color, 177 SkColor stroke_color,
178 bool use_fill_and_stroke_images, 178 bool use_fill_and_stroke_images,
179 ui::ScaleFactor scale_factor, 179 float scale_factor,
180 const gfx::Size& size) 180 const gfx::Size& size)
181 : resource_id(resource_id), 181 : resource_id(resource_id),
182 fill_color(fill_color), 182 fill_color(fill_color),
183 stroke_color(stroke_color), 183 stroke_color(stroke_color),
184 use_fill_and_stroke_images(use_fill_and_stroke_images), 184 use_fill_and_stroke_images(use_fill_and_stroke_images),
185 scale_factor(scale_factor), 185 scale_factor(scale_factor),
186 size(size) { 186 size(size) {
187 DCHECK_NE(ui::SCALE_FACTOR_NONE, scale_factor); 187 DCHECK_NE(0.0, scale_factor);
Peter Kasting 2016/08/15 23:07:39 Nit: Technically 0.0 is a double. Honestly I'd ra
188 188
189 // Some fields are only relevant for pre-MD vs. MD. Erase the irrelevant ones 189 // Some fields are only relevant for pre-MD vs. MD. Erase the irrelevant ones
190 // so they don't cause incorrect cache misses. 190 // so they don't cause incorrect cache misses.
191 // TODO(pkasting): Remove |resource_id| field when non-MD code is deleted. 191 // TODO(pkasting): Remove |resource_id| field when non-MD code is deleted.
192 if (ui::MaterialDesignController::IsModeMaterial()) 192 if (ui::MaterialDesignController::IsModeMaterial())
193 resource_id = 0; 193 resource_id = 0;
194 else 194 else
195 fill_color = stroke_color = SK_ColorTRANSPARENT; 195 fill_color = stroke_color = SK_ColorTRANSPARENT;
196 } 196 }
197 197
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 // really need to clip the stroke and not the fill (for stacked tabs). This 1541 // really need to clip the stroke and not the fill (for stacked tabs). This
1542 // saves memory and avoids an extra image draw at the cost of recalculating 1542 // saves memory and avoids an extra image draw at the cost of recalculating
1543 // the images when MaySetClip() toggles. 1543 // the images when MaySetClip() toggles.
1544 const bool use_fill_and_stroke_images = 1544 const bool use_fill_and_stroke_images =
1545 controller_->MaySetClip() && 1545 controller_->MaySetClip() &&
1546 ui::MaterialDesignController::IsModeMaterial(); 1546 ui::MaterialDesignController::IsModeMaterial();
1547 1547
1548 const ImageCacheEntryMetadata metadata( 1548 const ImageCacheEntryMetadata metadata(
1549 fill_id, tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB), 1549 fill_id, tp->GetColor(ThemeProperties::COLOR_BACKGROUND_TAB),
1550 controller_->GetToolbarTopSeparatorColor(), use_fill_and_stroke_images, 1550 controller_->GetToolbarTopSeparatorColor(), use_fill_and_stroke_images,
1551 ui::GetSupportedScaleFactor(canvas->image_scale()), size()); 1551 canvas->image_scale(), size());
1552 auto it = std::find_if( 1552 auto it = std::find_if(
1553 g_image_cache->begin(), g_image_cache->end(), 1553 g_image_cache->begin(), g_image_cache->end(),
1554 [&metadata](const ImageCacheEntry& e) { return e.metadata == metadata; }); 1554 [&metadata](const ImageCacheEntry& e) { return e.metadata == metadata; });
1555 if (it == g_image_cache->end()) { 1555 if (it == g_image_cache->end()) {
1556 gfx::Canvas tmp_canvas(size(), canvas->image_scale(), false); 1556 gfx::Canvas tmp_canvas(size(), canvas->image_scale(), false);
1557 if (use_fill_and_stroke_images) { 1557 if (use_fill_and_stroke_images) {
1558 gfx::Canvas tmp_fill_canvas(size(), canvas->image_scale(), false); 1558 gfx::Canvas tmp_fill_canvas(size(), canvas->image_scale(), false);
1559 PaintTabBackgroundUsingFillId(&tmp_fill_canvas, &tmp_canvas, false, 1559 PaintTabBackgroundUsingFillId(&tmp_fill_canvas, &tmp_canvas, false,
1560 fill_id, false, y_offset); 1560 fill_id, false, y_offset);
1561 g_image_cache->emplace_front( 1561 g_image_cache->emplace_front(
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 gfx::Rect Tab::GetImmersiveBarRect() const { 1859 gfx::Rect Tab::GetImmersiveBarRect() const {
1860 // The main bar is as wide as the normal tab's horizontal top line. 1860 // The main bar is as wide as the normal tab's horizontal top line.
1861 // This top line of the tab extends a few pixels left and right of the 1861 // This top line of the tab extends a few pixels left and right of the
1862 // center image due to pixels in the rounded corner images. 1862 // center image due to pixels in the rounded corner images.
1863 const int kBarPadding = 1; 1863 const int kBarPadding = 1;
1864 int main_bar_left = g_active_images.l_width - kBarPadding; 1864 int main_bar_left = g_active_images.l_width - kBarPadding;
1865 int main_bar_right = width() - g_active_images.r_width + kBarPadding; 1865 int main_bar_right = width() - g_active_images.r_width + kBarPadding;
1866 return gfx::Rect( 1866 return gfx::Rect(
1867 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight); 1867 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight);
1868 } 1868 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698