|
1 |
|
2 /* |
|
3 * Copyright 2011 Google Inc. |
|
4 * |
|
5 * Use of this source code is governed by a BSD-style license that can be |
|
6 * found in the LICENSE file. |
|
7 */ |
|
8 #ifndef SkTextLayout_DEFINED |
|
9 #define SkTextLayout_DEFINED |
|
10 |
|
11 #include "SkPaint.h" |
|
12 #include "SkRefCnt.h" |
|
13 |
|
14 class SkTextStyle : public SkRefCnt { |
|
15 public: |
|
16 SK_DECLARE_INST_COUNT(SkTextStyle) |
|
17 |
|
18 SkTextStyle(); |
|
19 SkTextStyle(const SkTextStyle&); |
|
20 explicit SkTextStyle(const SkPaint&); |
|
21 virtual ~SkTextStyle(); |
|
22 |
|
23 const SkPaint& paint() const { return fPaint; } |
|
24 SkPaint& paint() { return fPaint; } |
|
25 |
|
26 // todo: bidi-override, language |
|
27 |
|
28 private: |
|
29 SkPaint fPaint; |
|
30 |
|
31 typedef SkRefCnt INHERITED; |
|
32 }; |
|
33 |
|
34 class SkTextLayout { |
|
35 public: |
|
36 SkTextLayout(); |
|
37 ~SkTextLayout(); |
|
38 |
|
39 void setText(const char text[], size_t length); |
|
40 void setBounds(const SkRect& bounds); |
|
41 |
|
42 SkTextStyle* getDefaultStyle() const { return fDefaultStyle; } |
|
43 SkTextStyle* setDefaultStyle(SkTextStyle*); |
|
44 |
|
45 // SkTextStyle* setStyle(SkTextStyle*, size_t offset, size_t length); |
|
46 |
|
47 void draw(SkCanvas* canvas); |
|
48 |
|
49 private: |
|
50 SkTDArray<char> fText; |
|
51 SkTextStyle* fDefaultStyle; |
|
52 SkRect fBounds; |
|
53 |
|
54 // cache |
|
55 struct Line; |
|
56 struct GlyphRun; |
|
57 SkTDArray<Line*> fLines; |
|
58 }; |
|
59 |
|
60 #endif |