| 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 #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 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <cstring> | 12 #include <cstring> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/i18n/rtl.h" | 18 #include "base/i18n/rtl.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "skia/ext/cdl_common.h" |
| 22 #include "skia/ext/cdl_paint.h" |
| 21 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
| 22 #include "third_party/skia/include/core/SkPaint.h" | 24 #include "third_party/skia/include/core/SkPaint.h" |
| 23 #include "third_party/skia/include/core/SkRefCnt.h" | 25 #include "third_party/skia/include/core/SkRefCnt.h" |
| 24 #include "ui/gfx/break_list.h" | 26 #include "ui/gfx/break_list.h" |
| 25 #include "ui/gfx/font_list.h" | 27 #include "ui/gfx/font_list.h" |
| 26 #include "ui/gfx/font_render_params.h" | 28 #include "ui/gfx/font_render_params.h" |
| 27 #include "ui/gfx/geometry/point.h" | 29 #include "ui/gfx/geometry/point.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
| 29 #include "ui/gfx/geometry/size_f.h" | 31 #include "ui/gfx/geometry/size_f.h" |
| 30 #include "ui/gfx/geometry/vector2d.h" | 32 #include "ui/gfx/geometry/vector2d.h" |
| 31 #include "ui/gfx/range/range.h" | 33 #include "ui/gfx/range/range.h" |
| 32 #include "ui/gfx/range/range_f.h" | 34 #include "ui/gfx/range/range_f.h" |
| 33 #include "ui/gfx/selection_model.h" | 35 #include "ui/gfx/selection_model.h" |
| 34 #include "ui/gfx/shadow_value.h" | 36 #include "ui/gfx/shadow_value.h" |
| 35 #include "ui/gfx/text_constants.h" | 37 #include "ui/gfx/text_constants.h" |
| 36 | 38 |
| 37 class SkCanvas; | |
| 38 class SkDrawLooper; | 39 class SkDrawLooper; |
| 39 struct SkPoint; | 40 struct SkPoint; |
| 40 class SkShader; | 41 class SkShader; |
| 41 class SkTypeface; | 42 class SkTypeface; |
| 42 | 43 |
| 43 namespace gfx { | 44 namespace gfx { |
| 44 namespace test { | 45 namespace test { |
| 45 class RenderTextTestApi; | 46 class RenderTextTestApi; |
| 46 } | 47 } |
| 47 | 48 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void DrawUnderline(int x, int y, int width); | 84 void DrawUnderline(int x, int y, int width); |
| 84 void DrawStrike(int x, int y, int width) const; | 85 void DrawStrike(int x, int y, int width) const; |
| 85 | 86 |
| 86 private: | 87 private: |
| 87 friend class test::RenderTextTestApi; | 88 friend class test::RenderTextTestApi; |
| 88 | 89 |
| 89 // Helper class to draw a diagonal line with multiple pieces of different | 90 // Helper class to draw a diagonal line with multiple pieces of different |
| 90 // lengths and colors; to support text selection appearances. | 91 // lengths and colors; to support text selection appearances. |
| 91 class DiagonalStrike { | 92 class DiagonalStrike { |
| 92 public: | 93 public: |
| 93 DiagonalStrike(Canvas* canvas, Point start, const SkPaint& paint); | 94 DiagonalStrike(Canvas* canvas, Point start, const CdlPaint& paint); |
| 94 ~DiagonalStrike(); | 95 ~DiagonalStrike(); |
| 95 | 96 |
| 96 void AddPiece(int length, SkColor color); | 97 void AddPiece(int length, SkColor color); |
| 97 void Draw(); | 98 void Draw(); |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 typedef std::pair<int, SkColor> Piece; | 101 typedef std::pair<int, SkColor> Piece; |
| 101 | 102 |
| 102 Canvas* canvas_; | 103 Canvas* canvas_; |
| 103 const Point start_; | 104 const Point start_; |
| 104 SkPaint paint_; | 105 CdlPaint paint_; |
| 105 int total_length_; | 106 int total_length_; |
| 106 std::vector<Piece> pieces_; | 107 std::vector<Piece> pieces_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(DiagonalStrike); | 109 DISALLOW_COPY_AND_ASSIGN(DiagonalStrike); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 Canvas* canvas_; | 112 Canvas* canvas_; |
| 112 SkCanvas* canvas_skia_; | 113 CdlCanvas* canvas_skia_; |
| 113 SkPaint paint_; | 114 CdlPaint paint_; |
| 114 SkScalar underline_thickness_; | 115 SkScalar underline_thickness_; |
| 115 SkScalar underline_position_; | 116 SkScalar underline_position_; |
| 116 std::unique_ptr<DiagonalStrike> diagonal_; | 117 std::unique_ptr<DiagonalStrike> diagonal_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); | 119 DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 // Internal helper class used to iterate colors, baselines, and styles. | 122 // Internal helper class used to iterate colors, baselines, and styles. |
| 122 class StyleIterator { | 123 class StyleIterator { |
| 123 public: | 124 public: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 193 |
| 193 // Creates an SkTypeface from a font, |italic| and a desired |weight|. | 194 // Creates an SkTypeface from a font, |italic| and a desired |weight|. |
| 194 // May return null. | 195 // May return null. |
| 195 sk_sp<SkTypeface> CreateSkiaTypeface(const Font& font, | 196 sk_sp<SkTypeface> CreateSkiaTypeface(const Font& font, |
| 196 bool italic, | 197 bool italic, |
| 197 Font::Weight weight); | 198 Font::Weight weight); |
| 198 | 199 |
| 199 // Applies the given FontRenderParams to a Skia |paint|. | 200 // Applies the given FontRenderParams to a Skia |paint|. |
| 200 void ApplyRenderParams(const FontRenderParams& params, | 201 void ApplyRenderParams(const FontRenderParams& params, |
| 201 bool subpixel_rendering_suppressed, | 202 bool subpixel_rendering_suppressed, |
| 202 SkPaint* paint); | 203 CdlPaint* paint); |
| 203 | 204 |
| 204 } // namespace internal | 205 } // namespace internal |
| 205 | 206 |
| 206 // RenderText represents an abstract model of styled text and its corresponding | 207 // RenderText represents an abstract model of styled text and its corresponding |
| 207 // visual layout. Support is built in for a cursor, a selection, simple styling, | 208 // visual layout. Support is built in for a cursor, a selection, simple styling, |
| 208 // complex scripts, and bi-directional text. Implementations provide mechanisms | 209 // complex scripts, and bi-directional text. Implementations provide mechanisms |
| 209 // for rendering and translation between logical and visual data. | 210 // for rendering and translation between logical and visual data. |
| 210 class GFX_EXPORT RenderText { | 211 class GFX_EXPORT RenderText { |
| 211 public: | 212 public: |
| 212 // The character used for displaying obscured text. | 213 // The character used for displaying obscured text. |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // Lines computed by EnsureLayout. These should be invalidated upon | 862 // Lines computed by EnsureLayout. These should be invalidated upon |
| 862 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. | 863 // OnLayoutTextAttributeChanged and OnDisplayTextAttributeChanged calls. |
| 863 std::vector<internal::Line> lines_; | 864 std::vector<internal::Line> lines_; |
| 864 | 865 |
| 865 DISALLOW_COPY_AND_ASSIGN(RenderText); | 866 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 866 }; | 867 }; |
| 867 | 868 |
| 868 } // namespace gfx | 869 } // namespace gfx |
| 869 | 870 |
| 870 #endif // UI_GFX_RENDER_TEXT_H_ | 871 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |