| OLD | NEW |
| 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" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 } | 325 } |
| 326 | 326 |
| 327 void Canvas::DrawPath(const SkPath& path, const SkPaint& paint) { | 327 void Canvas::DrawPath(const SkPath& path, const SkPaint& paint) { |
| 328 canvas_->drawPath(path, paint); | 328 canvas_->drawPath(path, paint); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void Canvas::DrawFocusRect(const Rect& rect) { | 331 void Canvas::DrawFocusRect(const Rect& rect) { |
| 332 DrawDashedRect(rect, SK_ColorGRAY); | 332 DrawDashedRect(rect, SK_ColorGRAY); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void Canvas::DrawSolidFocusRect(const Rect& rect, SkColor color) { |
| 336 SkPaint paint; |
| 337 paint.setColor(color); |
| 338 paint.setStrokeWidth(SkIntToScalar(1)); |
| 339 // Note: We cannot use DrawRect since it would create a path and fill it which |
| 340 // would cause problems near the edge of the canvas. |
| 341 int x1 = std::min(rect.x(), rect.right()); |
| 342 int x2 = std::max(rect.x(), rect.right()); |
| 343 int y1 = std::min(rect.y(), rect.bottom()); |
| 344 int y2 = std::max(rect.y(), rect.bottom()); |
| 345 DrawLine(Point(x1, y1), Point(x2, y1), paint); |
| 346 DrawLine(Point(x1, y2), Point(x2, y2), paint); |
| 347 DrawLine(Point(x1, y1), Point(x1, y2), paint); |
| 348 DrawLine(Point(x2, y1), Point(x2, y2 + 1), paint); |
| 349 } |
| 350 |
| 335 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { | 351 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { |
| 336 SkPaint paint; | 352 SkPaint paint; |
| 337 DrawImageInt(image, x, y, paint); | 353 DrawImageInt(image, x, y, paint); |
| 338 } | 354 } |
| 339 | 355 |
| 340 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8 a) { | 356 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8 a) { |
| 341 SkPaint paint; | 357 SkPaint paint; |
| 342 paint.setAlpha(a); | 358 paint.setAlpha(a); |
| 343 DrawImageInt(image, x, y, paint); | 359 DrawImageInt(image, x, y, paint); |
| 344 } | 360 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 | 650 |
| 635 float bitmap_scale = image_rep.scale(); | 651 float bitmap_scale = image_rep.scale(); |
| 636 if (scale_x < bitmap_scale || scale_y < bitmap_scale) | 652 if (scale_x < bitmap_scale || scale_y < bitmap_scale) |
| 637 const_cast<SkBitmap&>(image_rep.sk_bitmap()).buildMipMap(); | 653 const_cast<SkBitmap&>(image_rep.sk_bitmap()).buildMipMap(); |
| 638 } | 654 } |
| 639 | 655 |
| 640 return image_rep; | 656 return image_rep; |
| 641 } | 657 } |
| 642 | 658 |
| 643 } // namespace gfx | 659 } // namespace gfx |
| OLD | NEW |