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

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/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
16 #include "third_party/skia/include/core/SkPaint.h"
16 #include "ui/base/range/range.h" 17 #include "ui/base/range/range.h"
17 #include "ui/gfx/font.h" 18 #include "ui/gfx/font.h"
18 #include "ui/gfx/point.h" 19 #include "ui/gfx/point.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 #include "ui/gfx/selection_model.h" 21 #include "ui/gfx/selection_model.h"
21 22
23 class SkCanvas;
24 class SkPoint;
25
22 namespace gfx { 26 namespace gfx {
23 27
28 class Canvas;
29 class RenderTextTest;
30
31 namespace internal {
32
33 // Internal helper class used by derived classes to draw text through Skia.
34 class SkiaTextRenderer {
35 public:
36 explicit SkiaTextRenderer(Canvas* canvas);
37 ~SkiaTextRenderer();
38
39 void SetFont(const gfx::Font& font);
40 void SetForegroundColor(SkColor foreground);
41 void DrawSelection(const std::vector<Rect>& selection, SkColor color);
42 void DrawPosText(const SkPoint* pos,
43 const uint16* glyphs,
44 size_t glyph_count);
45 void DrawDecorations(int x, int y, int width, bool underline, bool strike);
46 void DrawCursor(const gfx::Rect& bounds);
47
48 private:
49 SkCanvas* canvas_skia_;
50 SkPaint paint_;
51
52 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer);
53 };
54
55 } // namespace internal
56
24 // Color settings for text, backgrounds and cursor. 57 // Color settings for text, backgrounds and cursor.
25 // These are tentative, and should be derived from theme, system 58 // These are tentative, and should be derived from theme, system
26 // settings and current settings. 59 // settings and current settings.
27 // TODO(oshima): Change this to match the standard chrome 60 // TODO(oshima): Change this to match the standard chrome
28 // before dogfooding textfield views. 61 // before dogfooding textfield views.
29 const SkColor kSelectedTextColor = SK_ColorWHITE; 62 const SkColor kSelectedTextColor = SK_ColorWHITE;
30 const SkColor kFocusedSelectionColor = SkColorSetRGB(30, 144, 255); 63 const SkColor kFocusedSelectionColor = SkColorSetRGB(30, 144, 255);
31 const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY; 64 const SkColor kUnfocusedSelectionColor = SK_ColorLTGRAY;
32 const SkColor kCursorColor = SK_ColorBLACK; 65 const SkColor kCursorColor = SK_ColorBLACK;
33 66
34 class Canvas;
35 class RenderTextTest;
36
37 // A visual style applicable to a range of text. 67 // A visual style applicable to a range of text.
38 struct UI_EXPORT StyleRange { 68 struct UI_EXPORT StyleRange {
39 StyleRange(); 69 StyleRange();
40 70
41 Font font; 71 Font font;
42 SkColor foreground; 72 SkColor foreground;
43 bool strike; 73 bool strike;
44 bool underline; 74 bool underline;
45 ui::Range range; 75 ui::Range range;
46 }; 76 };
(...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, 335 // The cached bounds and offset are invalidated by changes to the cursor,
306 // selection, font, and other operations that adjust the visible text bounds. 336 // selection, font, and other operations that adjust the visible text bounds.
307 bool cached_bounds_and_offset_valid_; 337 bool cached_bounds_and_offset_valid_;
308 338
309 DISALLOW_COPY_AND_ASSIGN(RenderText); 339 DISALLOW_COPY_AND_ASSIGN(RenderText);
310 }; 340 };
311 341
312 } // namespace gfx 342 } // namespace gfx
313 343
314 #endif // UI_GFX_RENDER_TEXT_H_ 344 #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