| 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 <algorithm> | 8 #include <algorithm> |
| 9 #include <cstring> | 9 #include <cstring> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 namespace gfx { | 39 namespace gfx { |
| 40 | 40 |
| 41 class Canvas; | 41 class Canvas; |
| 42 class Font; | 42 class Font; |
| 43 class RenderTextTest; | 43 class RenderTextTest; |
| 44 | 44 |
| 45 namespace internal { | 45 namespace internal { |
| 46 | 46 |
| 47 // Internal helper class used by derived classes to draw text through Skia. | 47 // Internal helper class used by derived classes to draw text through Skia. |
| 48 class SkiaTextRenderer { | 48 class GFX_EXPORT SkiaTextRenderer { |
| 49 public: | 49 public: |
| 50 explicit SkiaTextRenderer(Canvas* canvas); | 50 explicit SkiaTextRenderer(Canvas* canvas); |
| 51 ~SkiaTextRenderer(); | 51 virtual ~SkiaTextRenderer(); |
| 52 | 52 |
| 53 void SetDrawLooper(SkDrawLooper* draw_looper); | 53 void SetDrawLooper(SkDrawLooper* draw_looper); |
| 54 void SetFontRenderParams(const FontRenderParams& params, | 54 void SetFontRenderParams(const FontRenderParams& params, |
| 55 bool background_is_transparent); | 55 bool background_is_transparent); |
| 56 void SetTypeface(SkTypeface* typeface); | 56 void SetTypeface(SkTypeface* typeface); |
| 57 void SetTextSize(SkScalar size); | 57 void SetTextSize(SkScalar size); |
| 58 void SetFontFamilyWithStyle(const std::string& family, int font_style); | 58 void SetFontFamilyWithStyle(const std::string& family, int font_style); |
| 59 void SetForegroundColor(SkColor foreground); | 59 void SetForegroundColor(SkColor foreground); |
| 60 void SetShader(SkShader* shader); | 60 void SetShader(SkShader* shader); |
| 61 // Sets underline metrics to use if the text will be drawn with an underline. | 61 // Sets underline metrics to use if the text will be drawn with an underline. |
| 62 // If not set, default values based on the size of the text will be used. The | 62 // If not set, default values based on the size of the text will be used. The |
| 63 // two metrics must be set together. | 63 // two metrics must be set together. |
| 64 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); | 64 void SetUnderlineMetrics(SkScalar thickness, SkScalar position); |
| 65 void DrawSelection(const std::vector<Rect>& selection, SkColor color); | 65 void DrawSelection(const std::vector<Rect>& selection, SkColor color); |
| 66 void DrawPosText(const SkPoint* pos, | 66 virtual void DrawPosText(const SkPoint* pos, |
| 67 const uint16* glyphs, | 67 const uint16* glyphs, |
| 68 size_t glyph_count); | 68 size_t glyph_count); |
| 69 // Draw underline and strike-through text decorations. | 69 // Draw underline and strike-through text decorations. |
| 70 // Based on |SkCanvas::DrawTextDecorations()| and constants from: | 70 // Based on |SkCanvas::DrawTextDecorations()| and constants from: |
| 71 // third_party/skia/src/core/SkTextFormatParams.h | 71 // third_party/skia/src/core/SkTextFormatParams.h |
| 72 void DrawDecorations(int x, int y, int width, bool underline, bool strike, | 72 virtual void DrawDecorations(int x, int y, int width, bool underline, |
| 73 bool diagonal_strike); | 73 bool strike, bool diagonal_strike); |
| 74 // Finishes any ongoing diagonal strike run. | 74 // Finishes any ongoing diagonal strike run. |
| 75 void EndDiagonalStrike(); | 75 void EndDiagonalStrike(); |
| 76 void DrawUnderline(int x, int y, int width); | 76 void DrawUnderline(int x, int y, int width); |
| 77 void DrawStrike(int x, int y, int width) const; | 77 void DrawStrike(int x, int y, int width) const; |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // Helper class to draw a diagonal line with multiple pieces of different | 80 // Helper class to draw a diagonal line with multiple pieces of different |
| 81 // lengths and colors; to support text selection appearances. | 81 // lengths and colors; to support text selection appearances. |
| 82 class DiagonalStrike { | 82 class DiagonalStrike { |
| 83 public: | 83 public: |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 // Lines computed by EnsureLayout. These should be invalidated with | 741 // Lines computed by EnsureLayout. These should be invalidated with |
| 742 // ResetLayout and on |display_rect_| changes. | 742 // ResetLayout and on |display_rect_| changes. |
| 743 std::vector<internal::Line> lines_; | 743 std::vector<internal::Line> lines_; |
| 744 | 744 |
| 745 DISALLOW_COPY_AND_ASSIGN(RenderText); | 745 DISALLOW_COPY_AND_ASSIGN(RenderText); |
| 746 }; | 746 }; |
| 747 | 747 |
| 748 } // namespace gfx | 748 } // namespace gfx |
| 749 | 749 |
| 750 #endif // UI_GFX_RENDER_TEXT_H_ | 750 #endif // UI_GFX_RENDER_TEXT_H_ |
| OLD | NEW |