aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/text/SkTextLayout.cpp
blob: 4d87ffe2423a4e798dbfa463fec23feff397ff0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include "SkTextLayout.h"

SK_DEFINE_INST_COUNT(SkTextStyle)

SkTextStyle::SkTextStyle() {
    fPaint.setAntiAlias(true);
}

SkTextStyle::SkTextStyle(const SkTextStyle& src) : fPaint(src.fPaint) {}

SkTextStyle::SkTextStyle(const SkPaint& paint) : fPaint(paint) {}

SkTextStyle::~SkTextStyle() {}

///////////////////////////////////////////////////////////////////////////////

SkTextLayout::SkTextLayout() {
    fBounds.setEmpty();
    fDefaultStyle = new SkTextStyle;
}

SkTextLayout::~SkTextLayout() {
    fDefaultStyle->unref();
    fLines.deleteAll();
}

void SkTextLayout::setText(const char text[], size_t length) {
    fText.setCount(length);
    memcpy(fText.begin(), text, length);
}

void SkTextLayout::setBounds(const SkRect& bounds) {
    fBounds = bounds;
    // if width changed, inval cache
}

SkTextStyle* SkTextLayout::setDefaultStyle(SkTextStyle* style) {
    SkRefCnt_SafeAssign(fDefaultStyle, style);
    return style;
}

///////////////////////////////////////////////////////////////////////////////

struct SkTextLayout::GlyphRun {
    GlyphRun();
    ~GlyphRun();

    SkPoint*    fLocs;
    uint16_t*   fGlyphIDs;
    int         fCount;
};

SkTextLayout::GlyphRun::GlyphRun() : fLocs(NULL), fGlyphIDs(NULL), fCount(0) {}

SkTextLayout::GlyphRun::~GlyphRun() {
    delete[] fLocs;
    delete[] fGlyphIDs;
}

struct SkTextLayout::Line {
    Line() {}
    ~Line();

    SkScalar                fBaselineY;
    SkTDArray<GlyphRun*>    fRuns;
};

SkTextLayout::Line::~Line() {
    fRuns.deleteAll();
}

void SkTextLayout::draw(SkCanvas* canvas) {
}