blob: 4e531cf21d1de4cb4fa89e028f7d28395145857c [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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 */
reed@android.comed8dbf72010-02-11 13:56:04 +00008#include "SkTextLayout.h"
9
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000010SK_DEFINE_INST_COUNT(SkTextStyle)
11
reed@android.comed8dbf72010-02-11 13:56:04 +000012SkTextStyle::SkTextStyle() {
13 fPaint.setAntiAlias(true);
14}
15
16SkTextStyle::SkTextStyle(const SkTextStyle& src) : fPaint(src.fPaint) {}
17
18SkTextStyle::SkTextStyle(const SkPaint& paint) : fPaint(paint) {}
19
20SkTextStyle::~SkTextStyle() {}
21
22///////////////////////////////////////////////////////////////////////////////
23
24SkTextLayout::SkTextLayout() {
25 fBounds.setEmpty();
26 fDefaultStyle = new SkTextStyle;
27}
28
29SkTextLayout::~SkTextLayout() {
30 fDefaultStyle->unref();
31 fLines.deleteAll();
32}
33
34void SkTextLayout::setText(const char text[], size_t length) {
35 fText.setCount(length);
36 memcpy(fText.begin(), text, length);
37}
38
39void SkTextLayout::setBounds(const SkRect& bounds) {
40 fBounds = bounds;
41 // if width changed, inval cache
42}
43
44SkTextStyle* SkTextLayout::setDefaultStyle(SkTextStyle* style) {
45 SkRefCnt_SafeAssign(fDefaultStyle, style);
46 return style;
47}
48
49///////////////////////////////////////////////////////////////////////////////
50
51struct SkTextLayout::GlyphRun {
52 GlyphRun();
53 ~GlyphRun();
54
55 SkPoint* fLocs;
56 uint16_t* fGlyphIDs;
57 int fCount;
58};
59
60SkTextLayout::GlyphRun::GlyphRun() : fLocs(NULL), fGlyphIDs(NULL), fCount(0) {}
61
62SkTextLayout::GlyphRun::~GlyphRun() {
63 delete[] fLocs;
64 delete[] fGlyphIDs;
65}
66
67struct SkTextLayout::Line {
68 Line() {}
69 ~Line();
70
71 SkScalar fBaselineY;
72 SkTDArray<GlyphRun*> fRuns;
73};
74
75SkTextLayout::Line::~Line() {
76 fRuns.deleteAll();
77}
78
79void SkTextLayout::draw(SkCanvas* canvas) {
80}