| 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 "app/gfx/canvas.h" | 5 #include "app/gfx/canvas.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/gfx/font.h" | 9 #include "app/gfx/font.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "base/i18n/rtl.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "gfx/rect.h" | 13 #include "gfx/rect.h" |
| 13 #include "third_party/skia/include/core/SkShader.h" | 14 #include "third_party/skia/include/core/SkShader.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 bool Canvas::GetClipRect(gfx::Rect* r) { | 18 bool Canvas::GetClipRect(gfx::Rect* r) { |
| 18 SkRect clip; | 19 SkRect clip; |
| 19 if (!getClipBounds(&clip)) { | 20 if (!getClipBounds(&clip)) { |
| 20 if (r) | 21 if (r) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 212 |
| 212 // The rect will be filled by the bitmap. | 213 // The rect will be filled by the bitmap. |
| 213 drawRect(dest_rect, p); | 214 drawRect(dest_rect, p); |
| 214 } | 215 } |
| 215 | 216 |
| 216 void Canvas::DrawStringInt(const std::wstring& text, | 217 void Canvas::DrawStringInt(const std::wstring& text, |
| 217 const gfx::Font& font, | 218 const gfx::Font& font, |
| 218 const SkColor& color, | 219 const SkColor& color, |
| 219 int x, int y, int w, int h) { | 220 int x, int y, int w, int h) { |
| 220 DrawStringInt(text, font, color, x, y, w, h, | 221 DrawStringInt(text, font, color, x, y, w, h, |
| 221 l10n_util::DefaultCanvasTextAlignment()); | 222 gfx::Canvas::DefaultCanvasTextAlignment()); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void Canvas::DrawStringInt(const std::wstring& text, | 225 void Canvas::DrawStringInt(const std::wstring& text, |
| 225 const gfx::Font& font, | 226 const gfx::Font& font, |
| 226 const SkColor& color, | 227 const SkColor& color, |
| 227 const gfx::Rect& display_rect) { | 228 const gfx::Rect& display_rect) { |
| 228 DrawStringInt(text, font, color, display_rect.x(), display_rect.y(), | 229 DrawStringInt(text, font, color, display_rect.x(), display_rect.y(), |
| 229 display_rect.width(), display_rect.height()); | 230 display_rect.width(), display_rect.height()); |
| 230 } | 231 } |
| 231 | 232 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 260 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); | 261 const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); |
| 261 | 262 |
| 262 // Make a bitmap to return, and a canvas to draw into it. We don't just want | 263 // Make a bitmap to return, and a canvas to draw into it. We don't just want |
| 263 // to call extractSubset or the copy constuctor, since we want an actual copy | 264 // to call extractSubset or the copy constuctor, since we want an actual copy |
| 264 // of the bitmap. | 265 // of the bitmap. |
| 265 SkBitmap result; | 266 SkBitmap result; |
| 266 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); | 267 device_bitmap.copyTo(&result, SkBitmap::kARGB_8888_Config); |
| 267 return result; | 268 return result; |
| 268 } | 269 } |
| 269 | 270 |
| 271 // static |
| 272 int Canvas::DefaultCanvasTextAlignment() { |
| 273 if (!base::i18n::IsRTL()) |
| 274 return gfx::Canvas::TEXT_ALIGN_LEFT; |
| 275 return gfx::Canvas::TEXT_ALIGN_RIGHT; |
| 276 } |
| 277 |
| 270 } // namespace gfx | 278 } // namespace gfx |
| OLD | NEW |