summaryrefslogtreecommitdiffstats
path: root/ui/gfx/render_text.h
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 00:35:05 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 00:35:05 +0000
commit67b98156a64fcb8b70ad67006e4d8f53ec5df668 (patch)
tree3d2ac316c8215c6df36cd541b01b7f2ac94e1a6c /ui/gfx/render_text.h
parentde09a216e6dcb5b5cd84f422ed1287d6b4cb026f (diff)
downloadchromium_src-67b98156a64fcb8b70ad67006e4d8f53ec5df668.zip
chromium_src-67b98156a64fcb8b70ad67006e4d8f53ec5df668.tar.gz
chromium_src-67b98156a64fcb8b70ad67006e4d8f53ec5df668.tar.bz2
Draw text via Skia in RenderTextLinux.
Refactors some common Skia drawing code into RenderText internal class SkiaTextRenderer. Rewrite RenderTextLinux::DrawVisualText() to use SkiaTextRenderer and refactor RenderTextWin::DrawVisualText() to also use SkiaTextRenderer, to re-use code. BUG=103648 TEST=Run Linux views_examples_exe --use-pure-views. In the textfield example tab, the text field should draw its text correctly. Review URL: http://codereview.chromium.org/8725002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text.h')
-rw-r--r--ui/gfx/render_text.h39
1 files changed, 36 insertions, 3 deletions
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index a812210..681274a 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -13,14 +13,47 @@
#include "base/i18n/rtl.h"
#include "base/string16.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkPaint.h"
#include "ui/base/range/range.h"
#include "ui/gfx/font.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/selection_model.h"
+class SkCanvas;
+struct SkPoint;
+
namespace gfx {
+class Canvas;
+class RenderTextTest;
+
+namespace internal {
+
+// Internal helper class used by derived classes to draw text through Skia.
+class SkiaTextRenderer {
+ public:
+ explicit SkiaTextRenderer(Canvas* canvas);
+ ~SkiaTextRenderer();
+
+ void SetFont(const gfx::Font& font);
+ void SetForegroundColor(SkColor foreground);
+ void DrawSelection(const std::vector<Rect>& selection, SkColor color);
+ void DrawPosText(const SkPoint* pos,
+ const uint16* glyphs,
+ size_t glyph_count);
+ void DrawDecorations(int x, int y, int width, bool underline, bool strike);
+ void DrawCursor(const gfx::Rect& bounds);
+
+ private:
+ SkCanvas* canvas_skia_;
+ SkPaint paint_;
+
+ DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer);
+};
+
+} // namespace internal
+
// Color settings for text, backgrounds and cursor.
// These are tentative, and should be derived from theme, system
// settings and current settings.
@@ -31,9 +64,6 @@ const SkColor kFocusedSelectionColor = SkColorSetRGB(30, 144, 255);
const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY;
const SkColor kCursorColor = SK_ColorBLACK;
-class Canvas;
-class RenderTextTest;
-
// A visual style applicable to a range of text.
struct UI_EXPORT StyleRange {
StyleRange();
@@ -248,6 +278,9 @@ class UI_EXPORT RenderText {
Point ToTextPoint(const Point& point);
Point ToViewPoint(const Point& point);
+ // Returns the origin point for drawing text via Skia.
+ Point GetOriginForSkiaDrawing();
+
private:
friend class RenderTextTest;