| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/gfx/chrome_canvas.h" | 5 #include "chrome/common/gfx/chrome_canvas.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Set a stroke width of 0, which will put us down the stroke rect path. If | 76 // Set a stroke width of 0, which will put us down the stroke rect path. If |
| 77 // we set a stroke width of 1, for example, this will internally create a | 77 // we set a stroke width of 1, for example, this will internally create a |
| 78 // path and fill it, which causes problems near the edge of the canvas. | 78 // path and fill it, which causes problems near the edge of the canvas. |
| 79 paint.setStrokeWidth(SkIntToScalar(0)); | 79 paint.setStrokeWidth(SkIntToScalar(0)); |
| 80 paint.setPorterDuffXfermode(mode); | 80 paint.setPorterDuffXfermode(mode); |
| 81 | 81 |
| 82 SkIRect rc = {x, y, x + w, y + h}; | 82 SkIRect rc = {x, y, x + w, y + h}; |
| 83 drawIRect(rc, paint); | 83 drawIRect(rc, paint); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ChromeCanvas::DrawLineInt(const SkColor& color, |
| 87 int x1, int y1, int x2, int y2) { |
| 88 SkPaint paint; |
| 89 paint.setColor(color); |
| 90 paint.setStrokeWidth(SkIntToScalar(1)); |
| 91 drawLine(SkIntToScalar(x1), SkIntToScalar(y1), SkIntToScalar(x2), |
| 92 SkIntToScalar(y2), paint); |
| 93 } |
| 94 |
| 86 void ChromeCanvas::DrawFocusRect(int x, int y, int width, int height) { | 95 void ChromeCanvas::DrawFocusRect(int x, int y, int width, int height) { |
| 87 // Create a 2D bitmap containing alternating on/off pixels - we do this | 96 // Create a 2D bitmap containing alternating on/off pixels - we do this |
| 88 // so that you never get two pixels of the same color around the edges | 97 // so that you never get two pixels of the same color around the edges |
| 89 // of the focus rect (this may mean that opposing edges of the rect may | 98 // of the focus rect (this may mean that opposing edges of the rect may |
| 90 // have a dot pattern out of phase to each other). | 99 // have a dot pattern out of phase to each other). |
| 91 static SkBitmap* dots = NULL; | 100 static SkBitmap* dots = NULL; |
| 92 if (!dots) { | 101 if (!dots) { |
| 93 int col_pixels = 32; | 102 int col_pixels = 32; |
| 94 int row_pixels = 32; | 103 int row_pixels = 32; |
| 95 | 104 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 SkBitmap ChromeCanvas::ExtractBitmap() { | 256 SkBitmap ChromeCanvas::ExtractBitmap() { |
| 248 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); | 257 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); |
| 249 | 258 |
| 250 // Make a bitmap to return, and a canvas to draw into it. We don't just want | 259 // Make a bitmap to return, and a canvas to draw into it. We don't just want |
| 251 // to call extractSubset or the copy constuctor, since we want an actual copy | 260 // to call extractSubset or the copy constuctor, since we want an actual copy |
| 252 // of the bitmap. | 261 // of the bitmap. |
| 253 SkBitmap result; | 262 SkBitmap result; |
| 254 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); | 263 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); |
| 255 return result; | 264 return result; |
| 256 } | 265 } |
| OLD | NEW |