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

Side by Side Diff: ui/gfx/canvas.cc

Issue 2527513002: Update ash shelf/tray focus rects. (Closed)
Patch Set: fixes Created 4 years 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
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 "ui/gfx/canvas.h" 5 #include "ui/gfx/canvas.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkPath.h" 13 #include "third_party/skia/include/core/SkPath.h"
14 #include "third_party/skia/include/core/SkRefCnt.h" 14 #include "third_party/skia/include/core/SkRefCnt.h"
15 #include "third_party/skia/include/effects/SkGradientShader.h" 15 #include "third_party/skia/include/effects/SkGradientShader.h"
16 #include "ui/gfx/font_list.h" 16 #include "ui/gfx/font_list.h"
17 #include "ui/gfx/geometry/insets_f.h"
17 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/rect_conversions.h" 19 #include "ui/gfx/geometry/rect_conversions.h"
19 #include "ui/gfx/geometry/rect_f.h" 20 #include "ui/gfx/geometry/rect_f.h"
20 #include "ui/gfx/geometry/safe_integer_conversions.h" 21 #include "ui/gfx/geometry/safe_integer_conversions.h"
21 #include "ui/gfx/geometry/size_conversions.h" 22 #include "ui/gfx/geometry/size_conversions.h"
22 #include "ui/gfx/scoped_canvas.h" 23 #include "ui/gfx/scoped_canvas.h"
23 #include "ui/gfx/skia_util.h" 24 #include "ui/gfx/skia_util.h"
24 #include "ui/gfx/transform.h" 25 #include "ui/gfx/transform.h"
25 26
26 namespace gfx { 27 namespace gfx {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 337
337 void Canvas::DrawFocusRect(const Rect& rect) { 338 void Canvas::DrawFocusRect(const Rect& rect) {
338 DrawFocusRect(RectF(rect)); 339 DrawFocusRect(RectF(rect));
339 } 340 }
340 341
341 void Canvas::DrawFocusRect(const RectF& rect) { 342 void Canvas::DrawFocusRect(const RectF& rect) {
342 DrawDashedRect(rect, SK_ColorGRAY); 343 DrawDashedRect(rect, SK_ColorGRAY);
343 } 344 }
344 345
345 void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) { 346 void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) {
346 DrawSolidFocusRect(RectF(rect), color); 347 DrawSolidFocusRect(RectF(rect), color, 1.f);
347 } 348 }
348 349
349 void Canvas::DrawSolidFocusRect(const RectF& rect, SkColor color) { 350 void Canvas::DrawSolidFocusRect(const RectF& rect,
351 SkColor color,
352 float thickness = 1.f) {
350 SkPaint paint; 353 SkPaint paint;
351 paint.setColor(color); 354 paint.setColor(color);
352 paint.setStrokeWidth(SK_Scalar1); 355 paint.setStrokeWidth(SkFloatToScalar(thickness));
353 // Note: We cannot use DrawRect since it would create a path and fill it which 356 paint.setStyle(SkPaint::kStroke_Style);
354 // would cause problems near the edge of the canvas. 357 gfx::RectF draw_rect = rect;
355 float x1 = std::min(rect.x(), rect.right()); 358 draw_rect.Inset(gfx::InsetsF(thickness / 2));
356 float x2 = std::max(rect.x(), rect.right()); 359 DrawRect(draw_rect, paint);
357 float y1 = std::min(rect.y(), rect.bottom());
358 float y2 = std::max(rect.y(), rect.bottom());
359 DrawLine(PointF(x1, y1), PointF(x2, y1), paint);
360 DrawLine(PointF(x1, y2), PointF(x2, y2), paint);
361 DrawLine(PointF(x1, y1), PointF(x1, y2), paint);
362 DrawLine(PointF(x2, y1), PointF(x2, y2 + 1.f), paint);
363 } 360 }
364 361
365 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { 362 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) {
366 SkPaint paint; 363 SkPaint paint;
367 DrawImageInt(image, x, y, paint); 364 DrawImageInt(image, x, y, paint);
368 } 365 }
369 366
370 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8_t a) { 367 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8_t a) {
371 SkPaint paint; 368 SkPaint paint;
372 paint.setAlpha(a); 369 paint.setAlpha(a);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); 592 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
596 p.setShader(CreateImageRepShaderForScale( 593 p.setShader(CreateImageRepShaderForScale(
597 image_rep, SkShader::kRepeat_TileMode, shader_scale, 594 image_rep, SkShader::kRepeat_TileMode, shader_scale,
598 remove_image_scale ? image_rep.scale() : 1.f)); 595 remove_image_scale ? image_rep.scale() : 1.f));
599 596
600 // The rect will be filled by the bitmap. 597 // The rect will be filled by the bitmap.
601 canvas_->drawRect(dest_rect, p); 598 canvas_->drawRect(dest_rect, p);
602 } 599 }
603 600
604 } // namespace gfx 601 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698