| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // of the bitmap. | 124 // of the bitmap. |
| 125 const SkISize size = canvas_->getDeviceSize(); | 125 const SkISize size = canvas_->getDeviceSize(); |
| 126 SkBitmap result; | 126 SkBitmap result; |
| 127 result.allocN32Pixels(size.width(), size.height()); | 127 result.allocN32Pixels(size.width(), size.height()); |
| 128 | 128 |
| 129 canvas_->readPixels(&result, 0, 0); | 129 canvas_->readPixels(&result, 0, 0); |
| 130 return ImageSkiaRep(result, image_scale_); | 130 return ImageSkiaRep(result, image_scale_); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void Canvas::DrawDashedRect(const Rect& rect, SkColor color) { | 133 void Canvas::DrawDashedRect(const Rect& rect, SkColor color) { |
| 134 if (rect.IsEmpty()) |
| 135 return; |
| 134 // Create a 2D bitmap containing alternating on/off pixels - we do this | 136 // Create a 2D bitmap containing alternating on/off pixels - we do this |
| 135 // so that you never get two pixels of the same color around the edges | 137 // so that you never get two pixels of the same color around the edges |
| 136 // of the focus rect (this may mean that opposing edges of the rect may | 138 // of the focus rect (this may mean that opposing edges of the rect may |
| 137 // have a dot pattern out of phase to each other). | 139 // have a dot pattern out of phase to each other). |
| 138 static SkColor last_color; | 140 static SkColor last_color; |
| 139 static SkBitmap* dots = NULL; | 141 static SkBitmap* dots = NULL; |
| 140 if (!dots || last_color != color) { | 142 if (!dots || last_color != color) { |
| 141 int col_pixels = 32; | 143 int col_pixels = 32; |
| 142 int row_pixels = 32; | 144 int row_pixels = 32; |
| 143 | 145 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 SkPaint p(paint); | 631 SkPaint p(paint); |
| 630 p.setFilterLevel(filter ? SkPaint::kLow_FilterLevel | 632 p.setFilterLevel(filter ? SkPaint::kLow_FilterLevel |
| 631 : SkPaint::kNone_FilterLevel); | 633 : SkPaint::kNone_FilterLevel); |
| 632 p.setShader(shader.get()); | 634 p.setShader(shader.get()); |
| 633 | 635 |
| 634 // The rect will be filled by the bitmap. | 636 // The rect will be filled by the bitmap. |
| 635 canvas_->drawRect(dest_rect, p); | 637 canvas_->drawRect(dest_rect, p); |
| 636 } | 638 } |
| 637 | 639 |
| 638 } // namespace gfx | 640 } // namespace gfx |
| OLD | NEW |