| 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_skia.h" | 5 #include "ui/gfx/canvas_skia.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 CanvasSkia::CanvasSkia(SkCanvas* canvas) | 70 CanvasSkia::CanvasSkia(SkCanvas* canvas) |
| 71 : owned_canvas_(), | 71 : owned_canvas_(), |
| 72 canvas_(canvas) { | 72 canvas_(canvas) { |
| 73 DCHECK(canvas); | 73 DCHECK(canvas); |
| 74 } | 74 } |
| 75 | 75 |
| 76 CanvasSkia::~CanvasSkia() { | 76 CanvasSkia::~CanvasSkia() { |
| 77 } | 77 } |
| 78 | 78 |
| 79 // static | 79 // static |
| 80 int CanvasSkia::GetStringWidth(const string16& text, const gfx::Font& font) { |
| 81 int width = 0, height = 0; |
| 82 CanvasSkia::SizeStringInt(text, font, &width, &height, Canvas::NO_ELLIPSIS); |
| 83 return width; |
| 84 } |
| 85 |
| 86 // static |
| 80 int CanvasSkia::DefaultCanvasTextAlignment() { | 87 int CanvasSkia::DefaultCanvasTextAlignment() { |
| 81 if (!base::i18n::IsRTL()) | 88 if (!base::i18n::IsRTL()) |
| 82 return gfx::Canvas::TEXT_ALIGN_LEFT; | 89 return gfx::Canvas::TEXT_ALIGN_LEFT; |
| 83 return gfx::Canvas::TEXT_ALIGN_RIGHT; | 90 return gfx::Canvas::TEXT_ALIGN_RIGHT; |
| 84 } | 91 } |
| 85 | 92 |
| 86 SkBitmap CanvasSkia::ExtractBitmap() const { | 93 SkBitmap CanvasSkia::ExtractBitmap() const { |
| 87 const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false); | 94 const SkBitmap& device_bitmap = canvas_->getDevice()->accessBitmap(false); |
| 88 | 95 |
| 89 // Make a bitmap to return, and a canvas to draw into it. We don't just want | 96 // Make a bitmap to return, and a canvas to draw into it. We don't just want |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 427 |
| 421 CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) { | 428 CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) { |
| 422 #if defined(OS_WIN) && !defined(USE_AURA) | 429 #if defined(OS_WIN) && !defined(USE_AURA) |
| 423 return new CanvasPaintWin(view); | 430 return new CanvasPaintWin(view); |
| 424 #else | 431 #else |
| 425 return NULL; | 432 return NULL; |
| 426 #endif | 433 #endif |
| 427 } | 434 } |
| 428 | 435 |
| 429 } // namespace gfx | 436 } // namespace gfx |
| OLD | NEW |