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

Side by Side Diff: ash/frame/default_header_painter.cc

Issue 1393013007: Add a Canvas::SaveAndUnscale() method for pixel-accurate drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/frame/browser_view.cc » ('j') | ui/gfx/canvas.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/frame/default_header_painter.h" 5 #include "ash/frame/default_header_painter.h"
6 6
7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
8 #include "ash/frame/header_painter_util.h" 8 #include "ash/frame/header_painter_util.h"
9 #include "base/debug/leak_annotations.h" 9 #include "base/debug/leak_annotations.h"
10 #include "base/logging.h" // DCHECK 10 #include "base/logging.h" // DCHECK
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 gfx::Rect title_bounds = GetTitleBounds(); 255 gfx::Rect title_bounds = GetTitleBounds();
256 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); 256 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds));
257 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(), 257 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(),
258 GetTitleFontList(), 258 GetTitleFontList(),
259 kTitleTextColor, 259 kTitleTextColor,
260 title_bounds, 260 title_bounds,
261 gfx::Canvas::NO_SUBPIXEL_RENDERING); 261 gfx::Canvas::NO_SUBPIXEL_RENDERING);
262 } 262 }
263 263
264 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { 264 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) {
265 SkColor color = (mode_ == MODE_ACTIVE) ? 265 const float scale = canvas->SaveAndUnscale();
266 kHeaderContentSeparatorColor : 266 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1);
267 kHeaderContentSeparatorInactiveColor;
268
269 SkPaint paint; 267 SkPaint paint;
270 paint.setColor(color); 268 paint.setColor((mode_ == MODE_ACTIVE) ?
271 // Draw the line as 1px thick regardless of scale factor. 269 kHeaderContentSeparatorColor : kHeaderContentSeparatorInactiveColor);
272 paint.setStrokeWidth(0); 270 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint);
273 271 canvas->Restore();
274 float thickness = 1 / canvas->image_scale();
275 SkScalar y = SkIntToScalar(painted_height_) - SkFloatToScalar(thickness);
276 canvas->sk_canvas()->drawLine(0, y, SkIntToScalar(view_->width()), y, paint);
277 } 272 }
278 273
279 void DefaultHeaderPainter::LayoutLeftHeaderView() { 274 void DefaultHeaderPainter::LayoutLeftHeaderView() {
280 if (left_header_view_) { 275 if (left_header_view_) {
281 // Vertically center the left header view with respect to the caption button 276 // Vertically center the left header view with respect to the caption button
282 // container. 277 // container.
283 // Floor when computing the center of |caption_button_container_|. 278 // Floor when computing the center of |caption_button_container_|.
284 gfx::Size size = left_header_view_->GetPreferredSize(); 279 gfx::Size size = left_header_view_->GetPreferredSize();
285 int icon_offset_y = caption_button_container_->height() / 2 - 280 int icon_offset_y = caption_button_container_->height() / 2 -
286 size.height() / 2; 281 size.height() / 2;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return HeaderPainterUtil::GetTitleBounds( 347 return HeaderPainterUtil::GetTitleBounds(
353 left_header_view_, caption_button_container_, GetTitleFontList()); 348 left_header_view_, caption_button_container_, GetTitleFontList());
354 } 349 }
355 350
356 bool DefaultHeaderPainter::UsesCustomFrameColors() const { 351 bool DefaultHeaderPainter::UsesCustomFrameColors() const {
357 return active_frame_color_ != kDefaultFrameColor || 352 return active_frame_color_ != kDefaultFrameColor ||
358 inactive_frame_color_ != kDefaultFrameColor; 353 inactive_frame_color_ != kDefaultFrameColor;
359 } 354 }
360 355
361 } // namespace ash 356 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_view.cc » ('j') | ui/gfx/canvas.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698