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

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

Issue 9562038: ui/gfx: Make gfx::Canvas inherit from gfx::CanvasSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 9 months 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
OLDNEW
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 #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 "third_party/skia/include/core/SkPaint.h"
17 #include "ui/base/range/range.h" 17 #include "ui/base/range/range.h"
18 #include "ui/gfx/font_list.h" 18 #include "ui/gfx/font_list.h"
19 #include "ui/gfx/point.h" 19 #include "ui/gfx/point.h"
20 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
21 #include "ui/gfx/selection_model.h" 21 #include "ui/gfx/selection_model.h"
22 22
23 class SkCanvas; 23 class SkCanvas;
24 struct SkPoint; 24 struct SkPoint;
25 25
26 namespace gfx { 26 namespace gfx {
27 27
28 class Canvas; 28 class CanvasSkia;
29 class RenderTextTest; 29 class RenderTextTest;
30 struct StyleRange; 30 struct StyleRange;
31 31
32 namespace internal { 32 namespace internal {
33 33
34 // Internal helper class used by derived classes to draw text through Skia. 34 // Internal helper class used by derived classes to draw text through Skia.
35 class SkiaTextRenderer { 35 class SkiaTextRenderer {
36 public: 36 public:
37 explicit SkiaTextRenderer(Canvas* canvas); 37 explicit SkiaTextRenderer(CanvasSkia* canvas);
38 ~SkiaTextRenderer(); 38 ~SkiaTextRenderer();
39 39
40 void SetFontSmoothingSettings(bool enable_smoothing, bool enable_lcd_text); 40 void SetFontSmoothingSettings(bool enable_smoothing, bool enable_lcd_text);
41 void SetTypeface(SkTypeface* typeface); 41 void SetTypeface(SkTypeface* typeface);
42 void SetTextSize(int size); 42 void SetTextSize(int size);
43 void SetFont(const gfx::Font& font); 43 void SetFont(const gfx::Font& font);
44 void SetFontStyle(int font_style); 44 void SetFontStyle(int font_style);
45 void SetForegroundColor(SkColor foreground); 45 void SetForegroundColor(SkColor foreground);
46 void SetShader(SkShader* shader); 46 void SetShader(SkShader* shader);
47 void DrawSelection(const std::vector<Rect>& selection, SkColor color); 47 void DrawSelection(const std::vector<Rect>& selection, SkColor color);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 virtual base::i18n::TextDirection GetTextDirection() = 0; 241 virtual base::i18n::TextDirection GetTextDirection() = 0;
242 242
243 // Returns the visual movement direction corresponding to the logical end 243 // Returns the visual movement direction corresponding to the logical end
244 // of the text, considering only the dominant direction returned by 244 // of the text, considering only the dominant direction returned by
245 // |GetTextDirection()|, not the direction of a particular run. 245 // |GetTextDirection()|, not the direction of a particular run.
246 VisualCursorDirection GetVisualDirectionOfLogicalEnd(); 246 VisualCursorDirection GetVisualDirectionOfLogicalEnd();
247 247
248 // Get the width of the entire string. 248 // Get the width of the entire string.
249 virtual int GetStringWidth() = 0; 249 virtual int GetStringWidth() = 0;
250 250
251 void Draw(Canvas* canvas); 251 void Draw(CanvasSkia* canvas);
252 252
253 // Gets the SelectionModel from a visual point in local coordinates. 253 // Gets the SelectionModel from a visual point in local coordinates.
254 virtual SelectionModel FindCursorPosition(const Point& point) = 0; 254 virtual SelectionModel FindCursorPosition(const Point& point) = 0;
255 255
256 // Get the visual bounds of a cursor at |selection|. These bounds typically 256 // Get the visual bounds of a cursor at |selection|. These bounds typically
257 // represent a vertical line, but if |insert_mode| is true they contain the 257 // represent a vertical line, but if |insert_mode| is true they contain the
258 // bounds of the associated glyph. These bounds are in local coordinates, but 258 // bounds of the associated glyph. These bounds are in local coordinates, but
259 // may be outside the visible region if the text is longer than the textfield. 259 // may be outside the visible region if the text is longer than the textfield.
260 // Subsequent text, cursor, or bounds changes may invalidate returned values. 260 // Subsequent text, cursor, or bounds changes may invalidate returned values.
261 virtual Rect GetCursorBounds(const SelectionModel& selection, 261 virtual Rect GetCursorBounds(const SelectionModel& selection,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 virtual bool IsCursorablePosition(size_t position) = 0; 329 virtual bool IsCursorablePosition(size_t position) = 0;
330 330
331 // Update the layout so that the next draw request can correctly 331 // Update the layout so that the next draw request can correctly
332 // render the text and its attributes. 332 // render the text and its attributes.
333 virtual void UpdateLayout() = 0; 333 virtual void UpdateLayout() = 0;
334 334
335 // Ensure the text is laid out. 335 // Ensure the text is laid out.
336 virtual void EnsureLayout() = 0; 336 virtual void EnsureLayout() = 0;
337 337
338 // Draw the text. 338 // Draw the text.
339 virtual void DrawVisualText(Canvas* canvas) = 0; 339 virtual void DrawVisualText(CanvasSkia* canvas) = 0;
340 340
341 // Like text() except that it returns asterisks or bullets if this is an 341 // Like text() except that it returns asterisks or bullets if this is an
342 // obscured field. 342 // obscured field.
343 string16 GetDisplayText() const; 343 string16 GetDisplayText() const;
344 344
345 // Apply composition style (underline) to composition range and selection 345 // Apply composition style (underline) to composition range and selection
346 // style (foreground) to selection range. 346 // style (foreground) to selection range.
347 void ApplyCompositionAndSelectionStyles(StyleRanges* style_ranges); 347 void ApplyCompositionAndSelectionStyles(StyleRanges* style_ranges);
348 348
349 // Returns the text origin after applying text alignment and display offset. 349 // Returns the text origin after applying text alignment and display offset.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // If |select| is false, the selection start is moved to the same position. 384 // If |select| is false, the selection start is moved to the same position.
385 // If the |position| is not a cursorable position (not on grapheme boundary), 385 // If the |position| is not a cursorable position (not on grapheme boundary),
386 // it is a NO-OP. 386 // it is a NO-OP.
387 void MoveCursorTo(size_t position, bool select); 387 void MoveCursorTo(size_t position, bool select);
388 388
389 // Update the cached bounds and display offset to ensure that the current 389 // Update the cached bounds and display offset to ensure that the current
390 // cursor is within the visible display area. 390 // cursor is within the visible display area.
391 void UpdateCachedBoundsAndOffset(); 391 void UpdateCachedBoundsAndOffset();
392 392
393 // Draw the selection and cursor. 393 // Draw the selection and cursor.
394 void DrawSelection(Canvas* canvas); 394 void DrawSelection(CanvasSkia* canvas);
395 void DrawCursor(Canvas* canvas); 395 void DrawCursor(CanvasSkia* canvas);
396 396
397 // Logical UTF-16 string data to be drawn. 397 // Logical UTF-16 string data to be drawn.
398 string16 text_; 398 string16 text_;
399 399
400 // Horizontal alignment of the text with respect to |display_rect_|. 400 // Horizontal alignment of the text with respect to |display_rect_|.
401 HorizontalAlignment horizontal_alignment_; 401 HorizontalAlignment horizontal_alignment_;
402 402
403 // A list of fonts used to render |text_|. 403 // A list of fonts used to render |text_|.
404 FontList font_list_; 404 FontList font_list_;
405 405
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // The cached bounds and offset are invalidated by changes to the cursor, 451 // The cached bounds and offset are invalidated by changes to the cursor,
452 // selection, font, and other operations that adjust the visible text bounds. 452 // selection, font, and other operations that adjust the visible text bounds.
453 bool cached_bounds_and_offset_valid_; 453 bool cached_bounds_and_offset_valid_;
454 454
455 DISALLOW_COPY_AND_ASSIGN(RenderText); 455 DISALLOW_COPY_AND_ASSIGN(RenderText);
456 }; 456 };
457 457
458 } // namespace gfx 458 } // namespace gfx
459 459
460 #endif // UI_GFX_RENDER_TEXT_H_ 460 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698