Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: ui/gfx/render_text.h

Issue 8725002: Draw text via Skia in RenderTextLinux. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text_linux.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef UI_GFX_RENDER_TEXT_H_ 5 #ifndef UI_GFX_RENDER_TEXT_H_
6 #define UI_GFX_RENDER_TEXT_H_ 6 #define UI_GFX_RENDER_TEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "third_party/skia/include/core/SkCanvas.h"
15 #include "third_party/skia/include/core/SkColor.h" 16 #include "third_party/skia/include/core/SkColor.h"
17 #include "third_party/skia/include/core/SkPoint.h"
16 #include "ui/base/range/range.h" 18 #include "ui/base/range/range.h"
17 #include "ui/gfx/font.h" 19 #include "ui/gfx/font.h"
18 #include "ui/gfx/point.h" 20 #include "ui/gfx/point.h"
19 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
20 #include "ui/gfx/selection_model.h" 22 #include "ui/gfx/selection_model.h"
21 23
22 namespace gfx { 24 namespace gfx {
23 25
26 class Canvas;
27 class RenderTextTest;
28
29 namespace internal {
30
31 // Internal helper class used by derived classes to draw text through Skia.
32 class SkiaTextRenderer {
33 public:
34 explicit SkiaTextRenderer(Canvas* canvas);
35 ~SkiaTextRenderer();
36
37 void Init();
38 void SetFont(const gfx::Font& font);
39 void SetForegroundColor(SkColor foreground);
40 void DrawSelection(const std::vector<Rect>& selection, SkColor color);
41 void DrawPosText(const SkPoint* pos,
42 const uint16* glyphs,
43 size_t glyph_count);
44 void DrawDecorations(int x, int y, int width, bool underline, bool strike);
45 void DrawCursor(const gfx::Rect& bounds);
46
47 private:
48 SkCanvas* canvas_skia_;
49 SkPaint paint_;
50
51 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer);
52 };
53
54 } // namespace internal
55
24 // Color settings for text, backgrounds and cursor. 56 // Color settings for text, backgrounds and cursor.
25 // These are tentative, and should be derived from theme, system 57 // These are tentative, and should be derived from theme, system
26 // settings and current settings. 58 // settings and current settings.
27 // TODO(oshima): Change this to match the standard chrome 59 // TODO(oshima): Change this to match the standard chrome
28 // before dogfooding textfield views. 60 // before dogfooding textfield views.
29 const SkColor kSelectedTextColor = SK_ColorWHITE; 61 const SkColor kSelectedTextColor = SK_ColorWHITE;
30 const SkColor kFocusedSelectionColor = SkColorSetRGB(30, 144, 255); 62 const SkColor kFocusedSelectionColor = SkColorSetRGB(30, 144, 255);
31 const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY; 63 const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY;
32 const SkColor kCursorColor = SK_ColorBLACK; 64 const SkColor kCursorColor = SK_ColorBLACK;
33 65
34 class Canvas;
35 class RenderTextTest;
36
37 // A visual style applicable to a range of text. 66 // A visual style applicable to a range of text.
38 struct UI_EXPORT StyleRange { 67 struct UI_EXPORT StyleRange {
39 StyleRange(); 68 StyleRange();
40 69
41 Font font; 70 Font font;
42 SkColor foreground; 71 SkColor foreground;
43 bool strike; 72 bool strike;
44 bool underline; 73 bool underline;
45 ui::Range range; 74 ui::Range range;
46 }; 75 };
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // The cached bounds and offset are invalidated by changes to the cursor, 334 // The cached bounds and offset are invalidated by changes to the cursor,
306 // selection, font, and other operations that adjust the visible text bounds. 335 // selection, font, and other operations that adjust the visible text bounds.
307 bool cached_bounds_and_offset_valid_; 336 bool cached_bounds_and_offset_valid_;
308 337
309 DISALLOW_COPY_AND_ASSIGN(RenderText); 338 DISALLOW_COPY_AND_ASSIGN(RenderText);
310 }; 339 };
311 340
312 } // namespace gfx 341 } // namespace gfx
313 342
314 #endif // UI_GFX_RENDER_TEXT_H_ 343 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/render_text.cc » ('j') | ui/gfx/render_text_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698